From 87d98d3bb21949ea44130d8ec6fd4629e00e4e72 Mon Sep 17 00:00:00 2001 From: Intege-rs Date: Sat, 24 Jan 2026 12:58:43 -0500 Subject: [PATCH] 2026.01.24-6e2d4fc36 --- .gitignore | 35 +- .idea/.gitignore | 8 - .idea/.name | 1 - .idea/AndroidProjectSystem.xml | 6 - .idea/gradle.xml | 16 - .idea/misc.xml | 10 - _decomp/decomp.ps1 | 23 + build.gradle.kts | 13 +- gradle/wrapper/gradle-wrapper.jar | Bin 60756 -> 0 bytes gradle/wrapper/gradle-wrapper.properties | 6 - gradlew | 234 ------ gradlew.bat | 89 --- .../hypixel/fastutil/util/SneakyThrow.java | 3 - src/com/hypixel/fastutil/util/TLRUtil.java | 3 - src/com/hypixel/hytale/LateMain.java | 3 - src/com/hypixel/hytale/Main.java | 3 - .../hytale/assetstore/AssetConstants.java | 3 - .../hypixel/hytale/assetstore/AssetMap.java | 3 - .../hytale/assetstore/AssetRegistry.java | 3 - .../assetstore/AssetValidationResults.java | 5 +- .../assetstore/codec/ContainedAssetCodec.java | 3 - .../hytale/assetstore/event/AssetsEvent.java | 2 - .../assetstore/map/AssetMapWithIndexes.java | 3 - .../map/CaseInsensitiveHashStrategy.java | 3 - .../camera/asset/CameraShakeConfig.java | 9 - .../adventure/camera/asset/EasingConfig.java | 3 - .../adventure/camera/asset/NoiseConfig.java | 6 - .../asset/cameraeffect/CameraShakeEffect.java | 3 - .../asset/cameraeffect/ShakeIntensity.java | 6 - .../CameraShakePacketGenerator.java | 3 - .../camera/asset/viewbobbing/ViewBobbing.java | 3 - .../ViewBobbingPacketGenerator.java | 3 - .../camera/command/CameraEffectCommand.java | 27 +- .../interaction/CameraShakeInteraction.java | 3 - .../camera/system/CameraEffectSystem.java | 3 - .../adventure/farming/FarmingSystems.java | 134 ++-- .../adventure/farming/FarmingUtil.java | 29 +- .../component/CoopResidentComponent.java | 7 +- .../FertilizerGrowthModifierAsset.java | 3 - .../LightLevelGrowthModifierAsset.java | 6 - .../modifiers/WaterGrowthModifierAsset.java | 3 - .../stages/BlockStateFarmingStageData.java | 3 - .../stages/BlockTypeFarmingStageData.java | 3 - .../config/stages/PrefabFarmingStageData.java | 6 - .../spread/DirectionalGrowthBehaviour.java | 6 - .../stages/spread/SpreadFarmingStageData.java | 3 - .../stages/spread/SpreadGrowthBehaviour.java | 3 - .../ChangeFarmingStageInteraction.java | 3 - .../FertilizeSoilInteraction.java | 3 - .../interactions/HarvestCropInteraction.java | 3 - .../UseCaptureCrateInteraction.java | 207 +++--- .../interactions/UseCoopInteraction.java | 27 +- .../UseWateringCanInteraction.java | 3 - .../adventure/farming/states/CoopBlock.java | 16 +- .../farming/states/FarmingBlockState.java | 6 - .../memories/MemoriesGameplayConfig.java | 30 +- .../adventure/memories/MemoriesPlugin.java | 87 ++- .../memories/commands/MemoriesCommand.java | 1 + .../commands/MemoriesSetCountCommand.java | 34 + .../memories/component/PlayerMemories.java | 3 - .../MemoriesConditionInteraction.java | 8 +- .../SetMemoriesCapacityInteraction.java | 3 - .../adventure/memories/memories/Memory.java | 3 - .../memories/memories/npc/NPCMemory.java | 46 +- .../memories/npc/NPCMemoryProvider.java | 3 +- .../adventure/memories/page/MemoriesPage.java | 16 +- .../memories/page/MemoriesPageSupplier.java | 7 +- .../memories/page/MemoriesUnlockedPage.java | 71 ++ .../page/MemoriesUnlockedPageSuplier.java | 18 + .../temple/ForgottenTempleConfig.java | 3 - .../temple/TempleRespawnPlayersSystem.java | 23 +- .../memories/window/MemoriesWindow.java | 15 +- .../KillSpawnBeaconObjectiveTaskAsset.java | 3 - .../builders/BuilderActionCompleteTask.java | 3 - .../builders/BuilderActionStartObjective.java | 3 - .../npc/builders/BuilderSensorHasTask.java | 3 - .../resources/KillTrackerResource.java | 3 - .../systems/KillTrackerSystem.java | 3 - .../SpawnBeaconCheckRemovalSystem.java | 3 - .../ReputationAttitudeSystem.java | 3 - .../builders/BuilderActionOpenBarterShop.java | 3 - .../npc/builders/BuilderActionOpenShop.java | 3 - .../adventure/objectives/DialogPage.java | 3 - .../adventure/objectives/ObjectivePlugin.java | 3 - .../blockstates/TreasureChestState.java | 3 - .../ObjectiveLocationMarkerCommand.java | 21 +- .../ObjectiveReachLocationMarkerCommand.java | 19 +- .../commands/ObjectiveStartCommand.java | 32 +- .../ClearObjectiveItemsCompletion.java | 6 +- .../components/ObjectiveHistoryComponent.java | 3 - .../config/ObjectiveLocationMarkerAsset.java | 3 - .../ObjectiveGameplayConfig.java | 3 - .../ObjectiveLocationMarkerArea.java | 3 - .../objectivesetup/ObjectiveTypeSetup.java | 3 - .../config/objectivesetup/SetupObjective.java | 3 - .../objectivesetup/SetupObjectiveLine.java | 3 - .../config/task/ObjectiveTaskAsset.java | 3 - .../config/task/ReachLocationTaskAsset.java | 3 - .../task/TreasureMapObjectiveTaskAsset.java | 3 - .../taskcondition/SoloInventoryCondition.java | 3 - .../HourRangeTriggerCondition.java | 3 - .../ObjectiveLocationTriggerCondition.java | 3 - .../WeatherTriggerCondition.java | 3 - .../LocationRadiusProvider.java | 3 - .../WorldLocationProvider.java | 3 - .../ObjectiveRewardHistoryData.java | 3 - .../CanBreakRespawnPointInteraction.java | 3 - .../StartObjectiveInteraction.java | 3 - .../markers/ObjectiveMarkerProvider.java | 7 +- .../ObjectiveLocationMarkerSystems.java | 6 - .../ReachLocationMarkerAsset.java | 3 - .../ReachLocationMarkerSystems.java | 6 - .../ObjectiveItemEntityRemovalSystem.java | 3 - .../objectives/task/GatherObjectiveTask.java | 27 +- .../transaction/TransactionRecord.java | 3 - .../transaction/TransactionStatus.java | 3 - .../transaction/TransactionUtil.java | 3 - .../transaction/WorldTransactionRecord.java | 3 - .../reputation/ReputationGameplayConfig.java | 6 - .../store/ReputationDataResource.java | 3 - .../builtin/adventure/shop/ShopElement.java | 3 - .../adventure/shop/ShopPageSupplier.java | 3 - .../adventure/shop/barter/BarterPage.java | 3 - .../shop/barter/BarterShopState.java | 3 - .../adventure/stash/StashGameplayConfig.java | 3 - .../teleporter/TeleporterPlugin.java | 6 - .../teleporter/component/Teleporter.java | 11 +- .../server/TeleporterInteraction.java | 37 +- .../page/TeleporterSettingsPage.java | 6 - .../page/TeleporterSettingsPageSupplier.java | 3 - .../CreateWarpWhenTeleporterPlacedSystem.java | 36 +- .../NeighbourBlockTagsLocationCondition.java | 6 - .../builtin/ambience/AmbiencePlugin.java | 3 - .../ambience/components/AmbienceTracker.java | 3 - .../components/AmbientEmitterComponent.java | 3 - .../ambience/resources/AmbienceResource.java | 3 - .../systems/AmbientEmitterSystems.java | 12 - .../ambience/systems/ForcedMusicSystems.java | 25 +- .../asseteditor/AssetEditorPlugin.java | 9 +- .../AssetSpecificFunctionality.java | 6 - .../asseteditor/AssetTypeRegistry.java | 3 - .../hytale/builtin/asseteditor/Messages.java | 3 - .../builtin/asseteditor/UndoRedoManager.java | 3 - .../assettypehandler/AssetTypeHandler.java | 3 - .../builtin/asseteditor/data/AssetState.java | 3 - .../asseteditor/data/AssetUndoRedoInfo.java | 3 - .../asseteditor/data/ModifiedAsset.java | 3 - .../asseteditor/util/AssetPathUtil.java | 3 - .../asseteditor/util/AssetStoreUtil.java | 3 - .../util/BsonTransformationUtil.java | 3 - .../beds/interactions/BedInteraction.java | 50 +- .../beds/respawn/RespawnPointPage.java | 3 - .../beds/sleep/components/PlayerSleep.java | 3 - .../sleep/components/PlayerSomnolence.java | 4 +- .../beds/sleep/components/SleepTracker.java | 6 +- .../beds/sleep/resources/WorldSleep.java | 3 - .../beds/sleep/resources/WorldSomnolence.java | 10 +- .../sleep/systems/player/EnterBedSystem.java | 34 +- .../systems/player/RegisterTrackerSystem.java | 13 +- .../player/UpdateSleepPacketSystem.java | 34 +- .../player/WakeUpOnDismountSystem.java | 27 +- .../sleep/systems/world/CanSleepInWorld.java | 6 - .../systems/world/StartSlumberSystem.java | 12 +- .../world/UpdateWorldSlumberSystem.java | 24 +- .../blockphysics/BlockPhysicsSystems.java | 6 - .../blockphysics/BlockPhysicsUtil.java | 6 - .../blockphysics/PrefabBufferValidator.java | 19 +- .../blockphysics/WorldValidationUtil.java | 13 +- .../blockspawner/BlockSpawnerEntry.java | 6 - .../blockspawner/BlockSpawnerPlugin.java | 46 +- .../system/ChunkBlockTickSystem.java | 9 - .../system/MergeWaitingBlocksSystem.java | 3 - .../builtin/buildertools/BlockColorIndex.java | 3 - .../BuilderToolsPacketHandler.java | 42 +- .../buildertools/BuilderToolsPlugin.java | 172 +++-- .../buildertools/BuilderToolsSystems.java | 6 - .../buildertools/BuilderToolsUserData.java | 3 - .../BuilderToolsUserDataSystem.java | 3 - .../builtin/buildertools/CopyCutSettings.java | 3 - .../commands/ClearBlocksCommand.java | 4 + .../commands/ClearEntitiesCommand.java | 4 +- .../buildertools/commands/CopyCommand.java | 63 +- .../buildertools/commands/PasteCommand.java | 12 +- .../buildertools/commands/PrefabCommand.java | 59 +- .../buildertools/commands/ReplaceCommand.java | 72 +- .../imageimport/ImageImportPage.java | 240 ++---- .../buildertools/objimport/ObjImportPage.java | 251 +++---- .../PrefabEditSessionManager.java | 9 +- .../prefabeditor/PrefabLoadingState.java | 3 - .../prefabeditor/PrefabMarkerProvider.java | 10 +- .../PrefabSelectionInteraction.java | 3 - .../PrefabSetAnchorInteraction.java | 3 - .../enums/PrefabStackingAxis.java | 3 - .../prefabeditor/saving/PrefabSaver.java | 360 +++++---- .../saving/PrefabSaverSettings.java | 3 - .../ui/PrefabEditorExitConfirmPage.java | 5 +- .../ui/PrefabEditorLoadSettingsPage.java | 20 +- .../ui/PrefabEditorSaveSettingsPage.java | 32 +- .../prefabeditor/ui/PrefabTeleportPage.java | 5 +- .../prefablist/AssetPrefabFileProvider.java | 16 +- .../buildertools/prefablist/PrefabPage.java | 76 +- .../prefablist/PrefabSavePage.java | 32 +- .../scriptedbrushes/BrushConfig.java | 6 - .../BrushConfigCommandExecutor.java | 3 - .../scriptedbrushes/ScriptedBrushAsset.java | 3 - .../commands/BrushConfigLoadCommand.java | 4 +- .../sequential/HeightmapLayerOperation.java | 4 + .../operations/sequential/LayerOperation.java | 4 + .../flowcontrol/JumpIfBlockTypeOperation.java | 49 +- .../flowcontrol/JumpIfClickType.java | 3 - .../flowcontrol/JumpIfToolArgOperation.java | 3 - .../scriptedbrushes/ui/ScriptedBrushPage.java | 16 +- .../tooloperations/LayersOperation.java | 25 +- .../tooloperations/TintOperation.java | 7 +- .../buildertools/utils/PasteToolUtil.java | 71 ++ .../utils/RecursivePrefabLoader.java | 3 - .../commandmacro/MacroCommandBuilder.java | 3 - .../commandmacro/MacroCommandParameter.java | 6 - .../builtin/crafting/CraftingPlugin.java | 8 +- .../crafting/component/CraftingManager.java | 312 +++++--- .../interaction/LearnRecipeInteraction.java | 3 - .../interaction/OpenBenchPageInteraction.java | 23 +- .../OpenProcessingBenchInteraction.java | 6 +- .../builtin/crafting/state/BenchState.java | 15 +- .../crafting/state/ProcessingBenchState.java | 28 +- .../system/PlayerCraftingSystems.java | 79 +- .../builtin/crafting/window/BenchWindow.java | 64 +- .../crafting/window/CraftingWindow.java | 46 +- .../window/DiagramCraftingWindow.java | 135 ++-- .../crafting/window/FieldCraftingWindow.java | 9 +- .../window/ProcessingBenchWindow.java | 20 +- .../crafting/window/SimpleCraftingWindow.java | 4 +- .../window/StructuralCraftingWindow.java | 40 +- .../config/CreativeHubEntityConfig.java | 3 - .../config/CreativeHubWorldConfig.java | 3 - .../interactions/HubPortalInteraction.java | 9 +- .../builtin/deployables/DeployablesUtils.java | 3 - .../component/DeployableComponent.java | 6 - .../component/DeployableOwnerComponent.java | 3 - .../DeployableProjectileShooterComponent.java | 3 - .../config/DeployableAoeConfig.java | 3 - .../config/DeployableTrapSpawnerConfig.java | 3 - .../config/DeployableTurretConfig.java | 3 - ...awnDeployableAtHitLocationInteraction.java | 6 +- ...SpawnDeployableFromRaycastInteraction.java | 8 +- .../deployables/system/DeployablesSystem.java | 12 - .../hytale/builtin/fluid/FluidSystems.java | 21 - .../builtin/hytalegenerator/ArrayUtil.java | 3 - .../builtin/hytalegenerator/BlockMask.java | 3 - .../builtin/hytalegenerator/FutureUtils.java | 3 - .../builtin/hytalegenerator/Indexer.java | 3 - .../builtin/hytalegenerator/LoggerUtil.java | 3 - .../builtin/hytalegenerator/VectorUtil.java | 3 - .../hytalegenerator/assets/AssetManager.java | 8 +- .../hytalegenerator/assets/ValidatorUtil.java | 3 - .../assets/blockmask/BlockMaskAsset.java | 6 - .../assets/blockset/MaterialSetAsset.java | 3 - .../assets/curves/CeilingCurveAsset.java | 3 - .../assets/curves/ClampCurveAsset.java | 3 - .../curves/DistanceExponentialCurveAsset.java | 3 - .../assets/curves/DistanceSCurveAsset.java | 3 - .../assets/curves/FloorCurveAsset.java | 3 - .../assets/curves/ImportedCurveAsset.java | 3 - .../assets/curves/InverterCurveAsset.java | 3 - .../assets/curves/MaxCurveAsset.java | 3 - .../assets/curves/MinCurveAsset.java | 3 - .../assets/curves/MultiplierCurveAsset.java | 3 - .../assets/curves/NotCurveAsset.java | 3 - .../curves/SmoothCeilingCurveAsset.java | 3 - .../assets/curves/SmoothClampCurveAsset.java | 3 - .../assets/curves/SmoothFloorCurveAsset.java | 3 - .../assets/curves/SmoothMaxCurveAsset.java | 3 - .../assets/curves/SmoothMinCurveAsset.java | 3 - .../assets/curves/SumCurveAsset.java | 3 - .../curves/legacy/NodeFunctionYOutAsset.java | 3 - .../assets/delimiters/RangeDoubleAsset.java | 3 - .../assets/delimiters/RangeIntAsset.java | 3 - .../assets/density/AbsDensityAsset.java | 3 - .../density/AmplitudeConstantAsset.java | 3 - .../assets/density/AmplitudeDensityAsset.java | 3 - .../assets/density/AnchorDensityAsset.java | 3 - .../assets/density/AngleDensityAsset.java | 3 - .../assets/density/AxisDensityAsset.java | 3 - .../density/BaseHeightDensityAsset.java | 3 - .../Cache2dDensityAsset_Deprecated.java | 3 - .../assets/density/CacheDensityAsset.java | 3 - .../assets/density/CeilingDensityAsset.java | 3 - .../density/CellNoise2DDensityAsset.java | 3 - .../density/CellNoise3DDensityAsset.java | 3 - .../density/CellWallDistanceDensityAsset.java | 3 - .../assets/density/ClampDensityAsset.java | 3 - .../assets/density/ConstantDensityAsset.java | 3 - .../assets/density/CubeDensityAsset.java | 3 - .../assets/density/CuboidDensityAsset.java | 3 - .../density/CurveMapperDensityAsset.java | 3 - .../assets/density/CylinderDensityAsset.java | 3 - .../assets/density/DensityAsset.java | 3 - .../assets/density/DistanceDensityAsset.java | 3 - .../DistanceToBiomeEdgeDensityAsset.java | 3 - .../assets/density/EllipsoidDensityAsset.java | 3 - .../assets/density/ExportedDensityAsset.java | 3 - .../density/FastGradientWarpDensityAsset.java | 3 - .../assets/density/FloorDensityAsset.java | 3 - .../assets/density/GradientDensityAsset.java | 3 - .../density/GradientWarpDensityAsset.java | 6 - .../assets/density/ImportedDensityAsset.java | 3 - .../assets/density/InverterDensityAsset.java | 3 - .../assets/density/MaxDensityAsset.java | 3 - .../assets/density/MinDensityAsset.java | 3 - .../assets/density/MixDensityAsset.java | 3 - .../assets/density/MultiMixDensityAsset.java | 6 - .../density/MultiplierDensityAsset.java | 3 - .../density/NormalizerDensityAsset.java | 3 - .../assets/density/OffsetConstantAsset.java | 3 - .../assets/density/OffsetDensityAsset.java | 3 - .../assets/density/PipelineDensityAsset.java | 3 - .../assets/density/PlaneDensityAsset.java | 3 - .../density/PositionsPinchDensityAsset.java | 3 - .../density/PositionsTwistDensityAsset.java | 3 - .../assets/density/PowDensityAsset.java | 3 - .../assets/density/RotatorDensityAsset.java | 3 - .../assets/density/ScaleDensityAsset.java | 3 - .../assets/density/SelectorDensityAsset.java | 3 - .../assets/density/ShellDensityAsset.java | 3 - .../density/SimplexNoise2dDensityAsset.java | 3 - .../density/SimplexNoise3DDensityAsset.java | 3 - .../assets/density/SliderDensityAsset.java | 3 - .../density/SmoothCeilingDensityAsset.java | 3 - .../density/SmoothClampDensityAsset.java | 3 - .../density/SmoothFloorDensityAsset.java | 3 - .../assets/density/SmoothMaxDensityAsset.java | 3 - .../assets/density/SmoothMinDensityAsset.java | 3 - .../assets/density/SqrtDensityAsset.java | 3 - .../assets/density/SumDensityAsset.java | 3 - .../assets/density/SwitchDensityAsset.java | 6 - .../density/SwitchStateDensityAsset.java | 3 - .../assets/density/TerrainDensityAsset.java | 3 - .../density/VectorWarpDensityAsset.java | 3 - .../assets/density/XOverrideDensityAsset.java | 3 - .../assets/density/XValueDensityAsset.java | 3 - .../assets/density/YOverrideDensityAsset.java | 3 - .../assets/density/YValueDensityAsset.java | 3 - .../assets/density/ZOverrideDensityAsset.java | 3 - .../assets/density/ZValueDensityAsset.java | 3 - .../positions/Positions3DDensityAsset.java | 3 - .../PositionsCellNoiseDensityAsset.java | 3 - .../EuclideanDistanceFunctionAsset.java | 3 - .../ManhattanDistanceFunctionAsset.java | 3 - .../returntypes/CellValueReturnTypeAsset.java | 3 - .../returntypes/CurveReturnTypeAsset.java | 3 - .../returntypes/DensityReturnTypeAsset.java | 6 - .../Distance2AddReturnTypeAsset.java | 3 - .../Distance2DivReturnTypeAsset.java | 3 - .../Distance2MulReturnTypeAsset.java | 3 - .../returntypes/Distance2ReturnTypeAsset.java | 3 - .../Distance2SubReturnTypeAsset.java | 3 - .../returntypes/DistanceReturnTypeAsset.java | 3 - .../returntypes/ImportedReturnTypeAsset.java | 3 - .../ConstantEnvironmentProviderAsset.java | 3 - ...sityDelimitedEnvironmentProviderAsset.java | 6 - .../ConstantMaterialProviderAsset.java | 3 - .../DownwardDepthMaterialProviderAsset.java | 3 - .../DownwardSpaceMaterialProviderAsset.java | 3 - .../FieldFunctionMaterialProviderAsset.java | 6 - .../ImportedMaterialProviderAsset.java | 3 - .../QueueMaterialProviderAsset.java | 3 - ...SimpleHorizontalMaterialProviderAsset.java | 3 - .../SolidityMaterialProviderAsset.java | 3 - .../StripedMaterialProviderAsset.java | 6 - .../TerrainDensityMaterialProviderAsset.java | 6 - .../UpwardDepthMaterialProviderAsset.java | 3 - .../UpwardSpaceMaterialProviderAsset.java | 3 - .../WeightedMaterialProviderAsset.java | 6 - .../SpaceAndDepthMaterialProviderAsset.java | 3 - .../AlwaysTrueConditionAsset.java | 3 - .../conditionassets/AndConditionAsset.java | 3 - .../conditionassets/EqualsConditionAsset.java | 3 - .../GreaterThanConditionAsset.java | 3 - .../conditionassets/NotConditionAsset.java | 3 - .../conditionassets/OrConditionAsset.java | 3 - .../SmallerThanConditionAsset.java | 3 - .../ConstantThicknessLayerAsset.java | 3 - .../layerassets/NoiseThicknessAsset.java | 3 - .../layerassets/RangeThicknessAsset.java | 3 - .../WeightedThicknessLayerAsset.java | 6 - .../noisegenerators/CellNoiseAsset.java | 3 - .../noisegenerators/SimplexNoiseAsset.java | 3 - .../assets/patterns/AndPatternAsset.java | 3 - .../assets/patterns/BlockSetPatternAsset.java | 3 - .../assets/patterns/CeilingPatternAsset.java | 3 - .../assets/patterns/ConstantPatternAsset.java | 3 - .../assets/patterns/CuboidPatternAsset.java | 3 - .../assets/patterns/DensityPatternAsset.java | 6 - .../assets/patterns/FloorPatternAsset.java | 3 - .../assets/patterns/GapPatternAsset.java | 3 - .../assets/patterns/ImportedPatternAsset.java | 3 - .../assets/patterns/MaterialPatternAsset.java | 3 - .../assets/patterns/NotPatternAsset.java | 3 - .../assets/patterns/OffsetPatternAsset.java | 3 - .../assets/patterns/OrPatternAsset.java | 3 - .../assets/patterns/SurfacePatternAsset.java | 3 - .../assets/patterns/WallPatternAsset.java | 3 - .../MeshPointGeneratorAsset.java | 3 - .../NoPointGeneratorAsset.java | 3 - .../AnchorPositionProviderAsset.java | 3 - .../BaseHeightPositionProviderAsset.java | 3 - .../CachedPositionProviderAsset.java | 3 - ...nctionOccurrencePositionProviderAsset.java | 3 - .../FieldFunctionPositionProviderAsset.java | 6 - .../ImportedPositionProviderAsset.java | 3 - .../ListPositionProviderAsset.java | 6 - .../Mesh2DPositionProviderAsset.java | 3 - .../Mesh3DPositionProviderAsset.java | 3 - .../OffsetPositionProviderAsset.java | 3 - ...impleHorizontalPositionProviderAsset.java} | 22 +- .../SpherePositionProviderAsset.java | 3 - .../UnionPositionProviderAsset.java | 3 - .../ConstantAssignmentsAsset.java | 3 - .../FieldFunctionAssignmentsAsset.java | 6 - .../ImportedAssignmentsAsset.java | 3 - .../SandwichAssignmentsAsset.java | 6 - .../WeightedAssignmentsAsset.java | 6 - .../assets/props/BoxPropAsset.java | 3 - .../assets/props/ClusterPropAsset.java | 20 +- .../assets/props/ColumnPropAsset.java | 6 - .../assets/props/DensityPropAsset.java | 3 - .../assets/props/ImportedPropAsset.java | 3 - .../assets/props/NoPropAsset.java | 16 +- .../assets/props/OffsetPropAsset.java | 30 + .../assets/props/PondFillerPropAsset.java | 3 - .../assets/props/QueuePropAsset.java | 3 - .../assets/props/UnionPropAsset.java | 3 - .../assets/props/WeightedPropAsset.java | 87 +++ .../assets/props/prefabprop/PrefabLoader.java | 3 - .../props/prefabprop/PrefabPropAsset.java | 6 - .../ImportedDirectionalityAsset.java | 3 - .../PatternDirectionalityAsset.java | 3 - .../RandomDirectionalityAsset.java | 3 - .../StaticDirectionalityAsset.java | 3 - .../assets/scanners/AreaScannerAsset.java | 3 - .../scanners/ColumnLinearScannerAsset.java | 3 - .../scanners/ColumnRandomScannerAsset.java | 3 - .../assets/scanners/ImportedScannerAsset.java | 3 - .../assets/scanners/OriginScannerAsset.java | 3 - .../assets/terrains/DensityTerrainAsset.java | 3 - .../ConstantTintProviderAsset.java | 3 - .../DensityDelimitedTintProviderAsset.java | 6 - .../DensityGradientVectorProviderAsset.java | 3 - .../ExportedVectorProviderAsset.java | 3 - .../ImportedVectorProviderAsset.java | 3 - .../vectorproviders/VectorProviderAsset.java | 3 - .../basic/BasicWorldStructureAsset.java | 3 - .../hytalegenerator/biomemap/BiomeMap.java | 2 - .../hytalegenerator/bounds/SpaceSize.java | 5 + .../chunkgenerator/ChunkRequest.java | 19 +- .../chunkgenerator/FallbackGenerator.java | 3 - .../stagedconveyor/ContextDependency.java | 20 +- .../datastructures/CollectionFactory.java | 3 - .../HashedBiCoordinateCache.java | 3 - .../compression/Compressor.java | 3 - .../voxelspace/VoxelSpaceUtil.java | 3 - .../hytalegenerator/density/Density.java | 3 - .../density/nodes/CacheDensity.java | 3 - .../nodes/CellWallDistanceDensity.java | 3 - .../nodes/DistanceToBiomeEdgeDensity.java | 3 - .../density/nodes/MultiMixDensity.java | 3 - .../PositionsHorizontalPinchDensity.java | 3 - .../density/nodes/RotatorDensity.java | 3 - .../density/nodes/TerrainDensity.java | 3 - .../density/nodes/XValueDensity.java | 3 - .../density/nodes/YValueDensity.java | 3 - .../density/nodes/ZValueDensity.java | 3 - .../distancefunctions/DistanceFunction.java | 3 - .../EuclideanDistanceFunction.java | 3 - .../ManhattanDistanceFunction.java | 3 - .../returntypes/DensityReturnType.java | 3 - .../returntypes/Distance2AddReturnType.java | 3 - .../returntypes/Distance2DivReturnType.java | 3 - .../returntypes/Distance2MulReturnType.java | 3 - .../returntypes/Distance2ReturnType.java | 3 - .../returntypes/Distance2SubReturnType.java | 3 - .../returntypes/DistanceReturnType.java | 3 - .../positions/returntypes/ReturnType.java | 3 - .../EnvironmentProvider.java | 3 - .../hytalegenerator/fields/FastNoiseLite.java | 21 - .../fields/noise/NoiseField.java | 3 - .../hytalegenerator/fields/noise/Simplex.java | 3 - .../fields/points/PointField.java | 3 - .../framework/cartas/ImageCarta.java | 3 - .../interfaces/functions/BiCarta.java | 3 - .../interfaces/functions/TriCarta.java | 3 - .../framework/math/BitConverter.java | 3 - .../framework/math/Calculator.java | 3 - .../framework/math/CoPrimeGenerator.java | 3 - .../framework/math/Combiner.java | 3 - .../framework/math/Interpolation.java | 3 - .../framework/math/MultipliedIteration.java | 3 - .../framework/math/NodeFunction.java | 3 - .../framework/math/Normalizer.java | 3 - .../framework/math/Probability.java | 3 - .../framework/math/Splitter.java | 3 - .../iterators/IntIterators.java | 3 - .../hytalegenerator/material/Material.java | 3 - .../material/MaterialCache.java | 3 - .../materialproviders/MaterialProvider.java | 3 - .../SpaceAndDepthMaterialProvider.java | 6 - .../conditions/ConditionParameter.java | 3 - .../hytalegenerator/newsystem/GridUtils.java | 3 - .../newsystem/NStagedChunkGenerator.java | 3 - .../newsystem/bufferbundle/NBufferBundle.java | 9 - .../bufferbundle/buffers/NBuffer.java | 2 - .../buffers/NCountedPixelBuffer.java | 6 - .../bufferbundle/buffers/NEntityBuffer.java | 3 - .../bufferbundle/buffers/NPixelBuffer.java | 3 - .../buffers/NSimplePixelBuffer.java | 6 - .../bufferbundle/buffers/NVoxelBuffer.java | 6 - .../TimeInstrument.java | 3 - .../newsystem/stages/NBiomeDistanceStage.java | 3 - .../newsystem/stages/NPropStage.java | 2 +- .../newsystem/stages/NTerrainStage.java | 3 - .../patterns/FieldFunctionPattern.java | 3 - .../hytalegenerator/patterns/Pattern.java | 3 - .../patterns/SurfacePattern.java | 3 - .../hytalegenerator/patterns/WallPattern.java | 3 - .../hytalegenerator/plugin/Handle.java | 2 +- .../plugin/HandleProvider.java | 19 +- .../plugin/HytaleGenerator.java | 9 +- .../FieldFunctionPositionProvider.java | 3 - .../positionproviders/PositionProvider.java | 3 - ... => SimpleHorizontalPositionProvider.java} | 13 +- .../propdistributions/Assignments.java | 3 - .../hytalegenerator/props/BoxProp.java | 13 +- .../hytalegenerator/props/ClusterProp.java | 13 +- .../hytalegenerator/props/ColumnProp.java | 15 +- .../hytalegenerator/props/DensityProp.java | 13 +- .../hytalegenerator/props/OffsetProp.java | 54 ++ .../builtin/hytalegenerator/props/Prop.java | 21 +- .../hytalegenerator/props/QueueProp.java | 19 +- .../hytalegenerator/props/UnionProp.java | 19 +- .../hytalegenerator/props/WeightedProp.java | 107 +++ .../props/directionality/Directionality.java | 3 - .../directionality/OrthogonalDirection.java | 3 - .../props/filler/PondFillerProp.java | 13 +- .../props/prefab/MoldingDirection.java | 3 - .../props/prefab/PrefabProp.java | 15 +- .../props/prefab/PropPrefabUtil.java | 3 - .../rangemaps/DoubleRangeMap.java | 3 - .../referencebundle/Reference.java | 2 - .../referencebundle/ReferenceBundle.java | 3 - .../hytalegenerator/scanners/AreaScanner.java | 6 - .../scanners/ColumnRandomScanner.java | 3 - .../hytalegenerator/scanners/Scanner.java | 3 - .../threadindexer/WorkerIndexer.java | 3 - .../tintproviders/NoTintProvider.java | 3 - .../tintproviders/TintProvider.java | 3 - .../vectorproviders/CacheVectorProvider.java | 3 - .../vectorproviders/VectorProvider.java | 3 - .../builtin/instances/InstanceValidator.java | 3 - .../builtin/instances/InstancesPlugin.java | 14 +- .../blocks/ConfigurableInstanceBlock.java | 3 - .../instances/blocks/InstanceBlock.java | 3 - .../command/InstanceEditLoadCommand.java | 5 +- .../instances/config/ExitInstance.java | 13 +- .../config/InstanceDiscoveryConfig.java | 3 - .../config/InstanceEntityConfig.java | 3 - .../instances/config/InstanceWorldConfig.java | 3 - .../interactions/ExitInstanceInteraction.java | 3 - .../TeleportConfigInstanceInteraction.java | 3 - .../TeleportInstanceInteraction.java | 6 - .../page/ConfigureInstanceBlockPage.java | 6 - .../instances/page/InstanceListPage.java | 219 ++++-- .../removal/IdleTimeoutCondition.java | 3 - .../removal/InstanceDataResource.java | 3 - .../instances/removal/RemovalSystem.java | 3 - .../builtin/model/pages/ChangeModelPage.java | 3 - .../hytale/builtin/mounts/BlockMountAPI.java | 3 - .../hytale/builtin/mounts/MountSystems.java | 39 - .../builtin/mounts/MountedByComponent.java | 3 - .../builtin/mounts/NPCMountComponent.java | 3 - .../builtin/mounts/NPCMountSystems.java | 9 - .../mounts/interactions/MountInteraction.java | 3 - .../interactions/SeatingInteraction.java | 5 +- .../SpawnMinecartInteraction.java | 3 - .../npc/builders/BuilderActionMount.java | 3 - .../CombatActionEvaluatorSystems.java | 6 - .../npccombatactionevaluator/Positioning.java | 3 - .../RecentSustainedDamageCondition.java | 3 - .../TargetMemoryCountCondition.java | 6 - .../TotalSustainedDamageCondition.java | 3 - .../config/CombatBalanceAsset.java | 5 +- .../corecomponents/CombatTargetCollector.java | 3 - .../BuilderActionAddToTargetMemory.java | 3 - .../builders/BuilderActionCombatAbility.java | 3 - .../BuilderCombatTargetCollector.java | 3 - .../BuilderSensorCombatActionEvaluator.java | 3 - .../BuilderSensorHasHostileTargetMemory.java | 3 - .../CombatActionEvaluatorConfig.java | 3 - .../combatactions/AbilityCombatAction.java | 3 - .../BasicAttackTargetCombatAction.java | 3 - .../combatactions/CombatActionOption.java | 3 - .../combatactions/StateCombatAction.java | 3 - .../memory/DamageMemory.java | 3 - .../memory/DamageMemorySystems.java | 3 - .../memory/TargetMemorySystems.java | 3 - .../parkour/ParkourCheckpointSystems.java | 6 - .../builtin/path/PrefabPathCollection.java | 3 - .../builtin/path/PrefabPathSystems.java | 44 +- .../hytale/builtin/path/WorldPathBuilder.java | 3 - .../hytale/builtin/path/WorldPathData.java | 3 - .../commands/WorldPathBuilderCommand.java | 9 +- .../builtin/path/path/TransientPath.java | 3 - .../components/PortalDeviceConfig.java | 3 - .../components/voidevent/VoidEvent.java | 3 - .../components/voidevent/VoidSpawner.java | 3 - .../config/InvasionPortalConfig.java | 3 - .../voidevent/config/VoidEventConfig.java | 3 - .../voidevent/config/VoidEventStage.java | 3 - .../integrations/PortalGameplayConfig.java | 3 - .../integrations/PortalMarkerProvider.java | 12 +- .../interactions/EnterPortalInteraction.java | 6 - .../interactions/ReturnPortalInteraction.java | 3 - .../portals/resources/PortalWorld.java | 3 - .../CloseWorldWhenBreakingDeviceSystems.java | 45 +- .../PortalInvalidDestinationSystem.java | 3 - .../portals/systems/PortalTrackerSystems.java | 3 - .../systems/curse/CurseItemDropsSystem.java | 3 - .../curse/DeleteCursedItemsOnSpawnSystem.java | 3 - .../systems/curse/DiedInPortalSystem.java | 3 - .../systems/voidevent/VoidEventRefSystem.java | 3 - .../systems/voidevent/VoidSpawnerSystems.java | 6 - .../portals/ui/PortalDeviceActivePage.java | 6 - .../portals/ui/PortalDevicePageSupplier.java | 3 - .../portals/ui/PortalDeviceSummonPage.java | 20 +- .../builtin/portals/ui/PortalSpawnFinder.java | 6 - .../utils/posqueries/SpatialQueryDebug.java | 4 +- .../posqueries/generators/SearchCone.java | 2 +- .../posqueries/predicates/FitsAPortal.java | 3 - .../hytale/builtin/tagset/TagSetPlugin.java | 3 - .../builtin/teleport/TeleportPlugin.java | 15 +- .../hypixel/hytale/builtin/teleport/Warp.java | 6 +- .../hytale/builtin/teleport/WarpListPage.java | 3 - .../commands/teleport/SpawnCommand.java | 18 +- .../commands/teleport/SpawnSetCommand.java | 4 +- .../commands/teleport/TeleportAllCommand.java | 40 +- .../teleport/TeleportHistoryCommand.java | 4 +- .../teleport/TeleportHomeCommand.java | 15 +- .../commands/teleport/TeleportTopCommand.java | 4 +- .../teleport/TeleportWorldCommand.java | 14 +- .../variant/TeleportOtherToPlayerCommand.java | 19 +- .../TeleportPlayerToCoordinatesCommand.java | 16 +- .../variant/TeleportToCoordinatesCommand.java | 15 +- .../variant/TeleportToPlayerCommand.java | 13 +- .../teleport/commands/warp/WarpCommand.java | 21 +- .../commands/warp/WarpListCommand.java | 14 +- .../commands/warp/WarpReloadCommand.java | 3 +- .../commands/warp/WarpRemoveCommand.java | 6 +- .../commands/warp/WarpSetCommand.java | 16 +- .../teleport/components/TeleportHistory.java | 48 +- .../weather/commands/WeatherGetCommand.java | 5 +- .../weather/commands/WeatherResetCommand.java | 5 +- .../weather/commands/WeatherSetCommand.java | 4 +- .../weather/systems/WeatherSystem.java | 52 +- .../hytale/codec/builder/BuilderCodec.java | 3 - .../codec/codecs/BsonDocumentCodec.java | 3 - .../hytale/codec/codecs/EnumCodec.java | 3 - .../codec/codecs/StringIntegerCodec.java | 3 - .../hytale/codec/codecs/UUIDBinaryCodec.java | 3 - .../codec/codecs/array/DoubleArrayCodec.java | 3 - .../codec/codecs/array/FloatArrayCodec.java | 3 - .../codec/codecs/array/IntArrayCodec.java | 3 - .../codec/codecs/array/LongArrayCodec.java | 3 - .../codec/codecs/simple/BooleanCodec.java | 3 - .../hytale/codec/codecs/simple/ByteCodec.java | 3 - .../codec/codecs/simple/DoubleCodec.java | 3 - .../codec/codecs/simple/FloatCodec.java | 3 - .../codec/codecs/simple/IntegerCodec.java | 3 - .../hytale/codec/codecs/simple/LongCodec.java | 3 - .../codec/codecs/simple/ShortCodec.java | 3 - .../codec/codecs/simple/StringCodec.java | 3 - .../hytale/codec/schema/SchemaContext.java | 3 - .../codec/schema/config/ArraySchema.java | 3 - .../codec/schema/config/BooleanSchema.java | 3 - .../codec/schema/config/IntegerSchema.java | 6 - .../codec/schema/config/NullSchema.java | 3 - .../codec/schema/config/NumberSchema.java | 6 - .../codec/schema/config/ObjectSchema.java | 3 - .../hytale/codec/schema/config/Schema.java | 15 +- .../codec/schema/config/StringSchema.java | 3 - .../schema/metadata/ui/UIDisplayMode.java | 3 - .../codec/schema/metadata/ui/UIEditor.java | 9 - .../schema/metadata/ui/UIEditorFeatures.java | 3 - .../schema/metadata/ui/UIEditorPreview.java | 3 - .../schema/metadata/ui/UIRebuildCaches.java | 3 - .../hytale/codec/util/Documentation.java | 51 +- .../codec/validation/ValidationResults.java | 3 - .../hytale/codec/validation/Validators.java | 3 - .../benchmark/ContinuousValueRecorder.java | 3 - .../hytale/common/benchmark/TimeRecorder.java | 3 - .../hytale/common/collection/BucketItem.java | 3 - .../common/collection/BucketItemPool.java | 3 - .../hytale/common/collection/BucketList.java | 3 - .../common/fastutil/HLongOpenHashSet.java | 3 - .../common/fastutil/HObjectOpenHashSet.java | 3 - .../hytale/common/plugin/AuthorInfo.java | 3 - .../thread/HytaleForkJoinThreadFactory.java | 3 - .../hypixel/hytale/common/util/ArrayUtil.java | 3 - .../hypixel/hytale/common/util/AudioUtil.java | 3 - .../hytale/common/util/BitSetUtil.java | 3 - .../hypixel/hytale/common/util/BitUtil.java | 3 - .../common/util/CompletableFutureUtil.java | 3 - .../hytale/common/util/ExceptionUtil.java | 3 - .../hytale/common/util/FormatUtil.java | 3 - .../hypixel/hytale/common/util/GCUtil.java | 3 - .../hytale/common/util/HardwareUtil.java | 3 - .../hypixel/hytale/common/util/ListUtil.java | 3 - .../hypixel/hytale/common/util/MapUtil.java | 3 - .../hytale/common/util/NetworkUtil.java | 3 - .../hypixel/hytale/common/util/PathUtil.java | 3 - .../hytale/common/util/PatternUtil.java | 3 - .../hytale/common/util/RandomUtil.java | 3 - .../hytale/common/util/StringCompareUtil.java | 3 - .../hytale/common/util/StringUtil.java | 8 +- .../hytale/common/util/SystemUtil.java | 11 +- .../hypixel/hytale/common/util/TimeUtil.java | 3 - .../hytale/common/util/java/ManifestUtil.java | 3 - .../hypixel/hytale/component/AddReason.java | 3 - .../hypixel/hytale/component/Archetype.java | 3 +- .../hytale/component/ComponentRegistry.java | 3 +- .../hytale/component/ComponentType.java | 5 +- .../component/EmptyResourceStorage.java | 3 - src/com/hypixel/hytale/component/Holder.java | 31 + .../hytale/component/NonSerialized.java | 8 +- .../hypixel/hytale/component/NonTicking.java | 8 +- .../hytale/component/ReadWriteQuery.java | 8 +- .../hytale/component/RemoveReason.java | 3 - .../hytale/component/ResourceType.java | 3 - src/com/hypixel/hytale/component/Store.java | 5 +- .../component/data/ForEachTaskData.java | 3 - .../component/data/change/ChangeType.java | 3 - .../data/unknown/TempUnknownComponent.java | 7 +- .../data/unknown/UnknownComponents.java | 15 +- .../component/dependency/Dependency.java | 2 +- .../component/dependency/DependencyGraph.java | 14 +- .../hytale/component/dependency/Order.java | 3 - .../component/dependency/OrderPriority.java | 2 +- .../hytale/component/query/AndQuery.java | 13 +- .../hytale/component/query/AnyQuery.java | 9 +- .../component/query/ExactArchetypeQuery.java | 7 +- .../hytale/component/query/NotQuery.java | 8 +- .../hytale/component/query/OrQuery.java | 15 +- .../hypixel/hytale/component/query/Query.java | 8 +- .../query/ReadWriteArchetypeQuery.java | 2 +- .../hytale/component/spatial/KDTree.java | 2 +- .../hytale/component/spatial/MortonCode.java | 3 - .../hytale/component/spatial/SpatialData.java | 3 - .../system/ArchetypeChunkSystem.java | 3 - .../component/system/CancellableEcsEvent.java | 3 - .../component/system/DelayedSystem.java | 3 - .../hytale/component/system/EcsEvent.java | 2 - .../hytale/component/system/HolderSystem.java | 3 - .../component/system/RefChangeSystem.java | 3 - .../hytale/component/system/RefSystem.java | 3 - .../hytale/component/system/StoreSystem.java | 3 - .../hytale/component/system/System.java | 3 - .../system/data/ArchetypeDataSystem.java | 3 - .../system/data/EntityDataSystem.java | 6 - .../system/tick/ArchetypeTickingSystem.java | 3 - .../system/tick/DelayedEntitySystem.java | 3 - .../system/tick/EntityTickingSystem.java | 6 - .../component/system/tick/TickingSystem.java | 3 - .../hytale/event/EventBusRegistry.java | 3 - .../function/supplier/SupplierUtil.java | 3 - .../hypixel/hytale/logger/HytaleLogger.java | 2 - .../HytaleUncaughtExceptionHandler.java | 3 - .../logger/sentry/HytaleSentryHandler.java | 3 - .../hytale/logger/util/GithubMessageUtil.java | 3 - .../hytale/math/block/BlockConeUtil.java | 3 - .../hytale/math/block/BlockCubeUtil.java | 3 - .../hytale/math/block/BlockCylinderUtil.java | 3 - .../hytale/math/block/BlockDiamondUtil.java | 3 - .../hytale/math/block/BlockDomeUtil.java | 3 - .../math/block/BlockInvertedDomeUtil.java | 3 - .../hytale/math/block/BlockPyramidUtil.java | 3 - .../hytale/math/block/BlockSphereUtil.java | 3 - .../hytale/math/block/BlockTorusUtil.java | 3 - .../hypixel/hytale/math/block/BlockUtil.java | 20 +- .../math/codec/FloatRangeArrayCodec.java | 3 - .../hytale/math/codec/IntRangeArrayCodec.java | 3 - .../hytale/math/codec/Vector2dArrayCodec.java | 3 - .../hytale/math/codec/Vector3dArrayCodec.java | 3 - .../hytale/math/codec/Vector3iArrayCodec.java | 3 - .../hitdetection/HitDetectionExecutor.java | 3 - .../hytale/math/iterator/BlockIterator.java | 3 - .../math/iterator/BoxBlockIterator.java | 3 - .../math/iterator/CircleSpiralIterator.java | 3 - .../hytale/math/raycast/RaycastAABB.java | 3 - .../hypixel/hytale/math/util/NumberUtil.java | 3 - .../hytale/math/util/TrigMathUtil.java | 6 - .../hytale/math/vector/VectorBoxUtil.java | 3 - .../hytale/math/vector/VectorSphereUtil.java | 3 - .../metrics/ExecutorMetricsRegistry.java | 3 - .../hypixel/hytale/metrics/JVMMetrics.java | 3 - .../hypixel/hytale/metrics/MetricResults.java | 3 - .../metrics/metric/AverageCollector.java | 3 - .../metric/SynchronizedAverageCollector.java | 3 - .../hytale/procedurallib/NoiseType.java | 3 - .../condition/DoubleThreshold.java | 3 - .../hytale/procedurallib/json/JsonLoader.java | 20 +- .../procedurallib/logic/DoubleArray.java | 3 - .../procedurallib/logic/ResultBuffer.java | 12 - .../procedurallib/logic/cell/CellType.java | 3 - .../logic/cell/GridCellDistanceFunction.java | 3 - .../logic/cell/HexCellDistanceFunction.java | 6 - .../logic/cell/MeasurementMode.java | 3 - .../cell/evaluator/BorderPointEvaluator.java | 3 - .../logic/cell/evaluator/BranchEvaluator.java | 3 - .../evaluator/SkipCellPointEvaluator.java | 6 +- .../logic/cell/jitter/DefaultCellJitter.java | 3 - .../property/GradientNoiseProperty.java | 3 - .../property/NoisePropertyType.java | 3 - .../random/CoordinateRandomizer.java | 3 - .../procedurallib/supplier/DoubleRange.java | 3 - .../procedurallib/supplier/FloatRange.java | 3 - .../hypixel/hytale/protocol/AmbienceFX.java | 44 +- .../hytale/protocol/AmbienceFXConditions.java | 56 +- .../hypixel/hytale/protocol/AnimationSet.java | 20 +- .../hytale/protocol/ApplicationEffects.java | 44 +- .../protocol/ApplyForceInteraction.java | 56 +- .../hytale/protocol/BlockParticleSet.java | 20 +- .../hytale/protocol/BlockSoundSet.java | 20 +- .../hypixel/hytale/protocol/BlockType.java | 164 ++--- .../hytale/protocol/ChargingInteraction.java | 60 +- .../hytale/protocol/ComponentUpdate.java | 112 +-- .../hytale/protocol/ConditionInteraction.java | 64 +- .../hytale/protocol/EntityStatUpdate.java | 20 +- src/com/hypixel/hytale/protocol/Fluid.java | 40 +- src/com/hypixel/hytale/protocol/FluidFX.java | 32 +- .../hytale/protocol/FluidParticle.java | 12 +- .../hypixel/hytale/protocol/Interaction.java | 14 +- .../hytale/protocol/InteractionChainData.java | 16 +- .../hytale/protocol/InteractionEffects.java | 48 +- .../hytale/protocol/InteractionSyncData.java | 36 +- .../protocol/ItemAppearanceCondition.java | 44 +- src/com/hypixel/hytale/protocol/ItemBase.java | 228 +++--- .../hytale/protocol/ItemEntityConfig.java | 12 +- .../hytale/protocol/ItemPlayerAnimations.java | 32 +- .../hypixel/hytale/protocol/ItemQuality.java | 52 +- src/com/hypixel/hytale/protocol/Model.java | 88 +-- .../hypixel/hytale/protocol/ModelDisplay.java | 28 +- .../hytale/protocol/ModelParticle.java | 28 +- .../hypixel/hytale/protocol/ModelTrail.java | 24 +- src/com/hypixel/hytale/protocol/ModelVFX.java | 28 +- .../protocol/ModifyInventoryInteraction.java | 44 +- .../hytale/protocol/MouseMotionEvent.java | 12 +- .../hytale/protocol/PacketRegistry.java | 4 +- .../hypixel/hytale/protocol/ParamValue.java | 3 - src/com/hypixel/hytale/protocol/Particle.java | 20 +- .../hytale/protocol/ParticleSpawner.java | 64 +- .../hytale/protocol/ParticleSpawnerGroup.java | 36 +- src/com/hypixel/hytale/protocol/Phobia.java | 3 +- .../hytale/protocol/ProjectileConfig.java | 16 +- .../hytale/protocol/ProtocolSettings.java | 11 +- .../protocol/RefillContainerInteraction.java | 605 ---------------- src/com/hypixel/hytale/protocol/Selector.java | 3 - src/com/hypixel/hytale/protocol/Trail.java | 36 +- src/com/hypixel/hytale/protocol/Weather.java | 200 ++--- .../hytale/protocol/WeatherParticle.java | 12 +- .../hytale/protocol/WieldingInteraction.java | 72 +- .../hytale/protocol/WorldEnvironment.java | 12 +- .../hytale/protocol/WorldParticle.java | 20 +- .../protocol/io/NoopPacketStatsRecorder.java | 3 - .../protocol/io/netty/PacketDecoder.java | 58 +- .../protocol/io/netty/PacketEncoder.java | 3 - .../protocol/io/netty/ProtocolUtil.java | 22 + .../asseteditor/AssetEditorCreateAsset.java | 20 +- .../AssetEditorExportAssetFinalize.java | 3 - .../AssetEditorFetchLastModifiedAssets.java | 3 - .../asseteditor/AssetEditorInitialize.java | 3 - .../AssetEditorUpdateModelPreview.java | 28 +- .../asseteditor/JsonUpdateCommand.java | 36 +- .../packets/asseteditor/SchemaFile.java | 12 +- .../packets/auth/PasswordAccepted.java | 3 - .../packets/buildertools/BuilderToolArg.java | 40 +- .../buildertools/BuilderToolBrushData.java | 80 +- .../buildertools/BuilderToolHideAnchors.java | 3 - ...ilderToolSelectionToolAskForClipboard.java | 3 - .../BuilderToolSelectionTransform.java | 24 +- .../buildertools/PrefabUnselectPrefab.java | 3 - .../protocol/packets/connection/Connect.java | 459 ++++++------ .../packets/interaction/DismountNPC.java | 3 - .../interface_/ResetUserInterfaceState.java | 3 - .../interface_/ServerPlayerListPlayer.java | 12 +- .../packets/player/ClearDebugShapes.java | 3 - .../protocol/packets/player/DisplayDebug.java | 12 +- .../packets/player/MouseInteraction.java | 28 +- .../packets/player/SyncPlayerPreferences.java | 54 +- .../protocol/packets/setup/AssetFinalize.java | 3 - .../protocol/packets/setup/ClientFeature.java | 6 +- .../setup/RequestCommonAssetsRebuild.java | 3 - .../packets/setup/WorldLoadFinished.java | 3 - .../packets/window/CancelCraftingAction.java | 3 - .../packets/window/CraftItemAction.java | 3 - .../packets/window/TierUpgradeAction.java | 3 - .../protocol/packets/window/WindowAction.java | 3 - .../world/ClearEditorTimeOverride.java | 3 - .../packets/world/SpawnParticleSystem.java | 20 +- .../packets/worldmap/ClearWorldMap.java | 3 - .../protocol/packets/worldmap/MapMarker.java | 28 +- .../hypixel/hytale/server/core/Constants.java | 5 +- .../hytale/server/core/HytaleServer.java | 62 +- .../server/core/HytaleServerConfig.java | 448 +++++++++--- .../hypixel/hytale/server/core/Message.java | 12 +- .../hypixel/hytale/server/core/Options.java | 24 - .../hytale/server/core/ShutdownReason.java | 2 + .../hytale/server/core/asset/AssetModule.java | 87 +-- .../server/core/asset/AssetNotifications.java | 3 - .../core/asset/AssetRegistryLoader.java | 3 - .../asset/common/BlockyAnimationCache.java | 6 - .../asset/common/CommonAssetRegistry.java | 6 - .../core/asset/common/HytaleFileTypes.java | 3 - .../core/asset/common/OggVorbisInfoCache.java | 3 - .../asset/common/SoundFileValidators.java | 3 - .../server/core/asset/monitor/EventKind.java | 3 - .../asset/packet/AssetPacketGenerator.java | 3 - .../packet/DefaultAssetPacketGenerator.java | 3 - .../packet/SimpleAssetPacketGenerator.java | 3 - .../ambiencefx/AmbienceFXPacketGenerator.java | 3 - .../AudioCategoryPacketGenerator.java | 3 - .../BlockBreakingDecalPacketGenerator.java | 3 - .../BlockBoundingBoxesPacketGenerator.java | 3 - .../BlockParticleSetPacketGenerator.java | 3 - .../blockset/BlockSetPacketGenerator.java | 3 - .../BlockSoundSetPacketGenerator.java | 3 - .../type/blocktick/BlockTickStrategy.java | 3 - .../type/blocktick/config/TickProcedure.java | 3 - .../blocktype/BlockGroupPacketGenerator.java | 3 - .../blocktype/BlockTypePacketGenerator.java | 3 - .../type/blocktype/config/BlockFace.java | 3 - .../type/blocktype/config/BlockFlipType.java | 3 - .../type/blocktype/config/BlockGathering.java | 3 - .../config/BlockPlacementSettings.java | 6 - .../config/BlockSupportsRequiredForType.java | 3 - .../type/blocktype/config/BlockType.java | 2 +- .../config/RequiredBlockFaceSupport.java | 3 - .../RequiredBlockFaceSupportValidator.java | 3 - .../blocktype/config/SupportDropType.java | 3 - .../type/blocktype/config/bench/Bench.java | 3 - .../blocktype/config/bench/CraftingBench.java | 3 - .../config/bench/DiagramCraftingBench.java | 3 - .../config/bench/ProcessingBench.java | 9 - .../config/bench/StructuralCraftingBench.java | 3 - .../blocktype/config/farming/FarmingData.java | 6 - .../config/farming/FarmingStageData.java | 3 - .../config/BlockTypeListAsset.java | 3 - .../type/buildertool/config/BuilderTool.java | 3 - .../buildertool/config/PrefabListAsset.java | 6 - .../type/buildertool/config/args/ToolArg.java | 3 - .../core/asset/type/camera/CameraEffect.java | 3 - .../EntityEffectPacketGenerator.java | 3 - .../entityeffect/config/OverlapBehavior.java | 3 - .../entityeffect/config/RemovalBehavior.java | 3 - .../EnvironmentPacketGenerator.java | 3 - .../EqualizerEffectPacketGenerator.java | 3 - .../asset/type/fluid/DefaultFluidTicker.java | 42 +- .../asset/type/fluid/FiniteFluidTicker.java | 6 - .../server/core/asset/type/fluid/Fluid.java | 14 + .../core/asset/type/fluid/FluidTicker.java | 68 +- .../type/fluid/FluidTypePacketGenerator.java | 3 - .../type/fluidfx/FluidFXPacketGenerator.java | 3 - .../asset/type/gameplay/BrokenPenalties.java | 3 - .../type/gameplay/CameraEffectsConfig.java | 3 - .../asset/type/gameplay/CraftingConfig.java | 11 +- .../core/asset/type/gameplay/DeathConfig.java | 6 - .../asset/type/gameplay/GameplayConfig.java | 3 - .../asset/type/gameplay/GatheringConfig.java | 3 - .../type/gameplay/GatheringEffectsConfig.java | 3 - .../type/gameplay/ItemDurabilityConfig.java | 3 - .../asset/type/gameplay/PlayerConfig.java | 50 +- .../asset/type/gameplay/RespawnConfig.java | 3 - .../core/asset/type/gameplay/SleepConfig.java | 3 - .../core/asset/type/gameplay/SpawnConfig.java | 3 - .../core/asset/type/gameplay/WorldConfig.java | 3 - .../asset/type/gameplay/WorldMapConfig.java | 3 - .../gameplay/respawn/HomeOrSpawnPoint.java | 19 +- .../gameplay/respawn/RespawnController.java | 5 +- .../gameplay/respawn/WorldSpawnPoint.java | 20 +- .../core/asset/type/item/DroplistCommand.java | 3 +- .../FieldcraftCategoryPacketGenerator.java | 3 - .../item/ItemCategoryPacketGenerator.java | 3 - .../item/ResourceTypePacketGenerator.java | 3 - .../asset/type/item/config/BlockGroup.java | 3 - .../config/BuilderToolItemReferenceAsset.java | 3 - .../core/asset/type/item/config/Item.java | 2 +- .../item/config/ItemAppearanceCondition.java | 3 - .../asset/type/item/config/ItemArmor.java | 3 - .../asset/type/item/config/ItemGlider.java | 3 - .../item/config/ItemStackContainerConfig.java | 3 - .../asset/type/item/config/ItemUtility.java | 3 - .../asset/type/item/config/ItemWeapon.java | 3 - .../asset/type/item/config/PortalKey.java | 3 - .../container/DroplistItemDropContainer.java | 3 - .../container/EmptyItemDropContainer.java | 3 - .../config/metadata/AdventureMetadata.java | 3 - .../ItemPlayerAnimationsPacketGenerator.java | 3 - .../ItemSoundSetPacketGenerator.java | 3 - .../asset/type/model/config/ModelAsset.java | 3 - .../modelvfx/ModelVFXPacketGenerator.java | 3 - .../ParticleSpawnerPacketGenerator.java | 3 - .../ParticleSystemPacketGenerator.java | 3 - .../particle/pages/ParticleSpawnPage.java | 3 - .../core/asset/type/portalworld/PillTag.java | 3 - .../type/portalworld/PortalDescription.java | 3 - .../asset/type/portalworld/PortalSpawn.java | 3 - .../asset/type/portalworld/PortalType.java | 3 - .../ReverbEffectPacketGenerator.java | 3 - .../soundevent/SoundEventPacketGenerator.java | 3 - .../soundevent/config/SoundEventLayer.java | 3 - .../validator/SoundEventValidators.java | 3 - .../soundset/SoundSetPacketGenerator.java | 3 - .../tagpattern/TagPatternPacketGenerator.java | 3 - .../type/tagpattern/config/AndPatternOp.java | 3 - .../tagpattern/config/MultiplePatternOp.java | 3 - .../type/tagpattern/config/NotPatternOp.java | 3 - .../type/tagpattern/config/OrPatternOp.java | 3 - .../type/tagpattern/config/TagPattern.java | 3 - .../type/trail/TrailPacketGenerator.java | 3 - .../asset/type/trail/config/Animation.java | 3 - .../core/asset/type/trail/config/Edge.java | 3 - .../type/weather/WeatherPacketGenerator.java | 3 - .../asset/type/weather/config/FogOptions.java | 3 - .../core/asset/util/ColorParseUtil.java | 3 - .../hytale/server/core/auth/AuthConfig.java | 2 +- .../server/core/auth/CertificateUtil.java | 3 - .../core/auth/DefaultAuthCredentialStore.java | 3 - .../auth/EncryptedAuthCredentialStore.java | 3 - .../EncryptedAuthCredentialStoreProvider.java | 3 - .../hytale/server/core/auth/JWTValidator.java | 133 +++- .../MemoryAuthCredentialStoreProvider.java | 3 - .../core/auth/ProfileServiceClient.java | 161 +++++ .../server/core/auth/ServerAuthManager.java | 684 ++++++++++-------- .../core/auth/SessionServiceClient.java | 21 - .../core/auth/oauth/OAuthBrowserFlow.java | 3 - .../server/core/auth/oauth/OAuthClient.java | 5 +- .../core/auth/oauth/OAuthDeviceFlow.java | 3 - .../server/core/auth/oauth/OAuthFlow.java | 3 - .../server/core/auth/oauth/OAuthResult.java | 3 - .../core/blocktype/BlockTypeModule.java | 6 - .../blocktype/component/BlockPhysics.java | 3 - .../core/client/ClientFeatureHandler.java | 3 - .../core/codec/BoolDoublePairCodec.java | 3 - .../server/core/codec/LayerEntryCodec.java | 7 + .../hytale/server/core/codec/PairCodec.java | 3 - .../server/core/codec/ProtocolCodecs.java | 3 - .../hytale/server/core/codec/ShapeCodecs.java | 3 - .../core/codec/protocol/ColorAlphaCodec.java | 3 - .../core/codec/protocol/ColorCodec.java | 3 - .../commands/debug/AssetTagsCommand.java | 4 +- .../debug/DebugPlayerPositionCommand.java | 26 +- .../commands/debug/VersionCommand.java | 12 +- .../debug/server/ServerStatsCpuCommand.java | 10 +- .../debug/server/ServerStatsGcCommand.java | 6 +- .../server/ServerStatsMemoryCommand.java | 10 +- .../commands/debug/stresstest/Bot.java | 4 +- .../stresstest/StressTestStartCommand.java | 6 - .../commands/player/PlayerRespawnCommand.java | 4 +- .../command/commands/player/ReferCommand.java | 8 +- .../commands/player/camera/CameraDemo.java | 3 - .../effect/PlayerEffectApplyCommand.java | 7 +- .../effect/PlayerEffectClearCommand.java | 29 +- .../player/inventory/GiveCommand.java | 53 +- .../inventory/InventoryBackpackCommand.java | 10 +- .../command/commands/server/KickCommand.java | 4 +- .../command/commands/server/WhoCommand.java | 7 +- .../server/auth/AuthLoginBrowserCommand.java | 11 +- .../server/auth/AuthLoginDeviceCommand.java | 3 - .../server/auth/AuthLogoutCommand.java | 4 +- .../server/auth/AuthPersistenceCommand.java | 16 +- .../server/auth/AuthStatusCommand.java | 5 +- .../commands/utility/StashCommand.java | 6 +- .../{UpdateCommand.java => GitCommand.java} | 6 +- .../utility/git/UpdateAssetsCommand.java | 18 +- .../utility/git/UpdatePrefabsCommand.java | 36 +- .../lighting/LightingCalculationCommand.java | 3 - .../world/chunk/ChunkFixHeightMapCommand.java | 22 +- .../world/chunk/ChunkForceTickCommand.java | 17 +- .../world/chunk/ChunkInfoCommand.java | 8 +- .../world/chunk/ChunkLightingCommand.java | 13 +- .../world/chunk/ChunkLoadCommand.java | 40 +- .../world/chunk/ChunkMarkSaveCommand.java | 38 +- .../world/chunk/ChunkMaxSendRateCommand.java | 13 +- .../world/chunk/ChunkRegenerateCommand.java | 5 +- .../world/chunk/ChunkTintCommand.java | 19 +- .../world/chunk/ChunkTrackerCommand.java | 6 +- .../world/chunk/ChunkUnloadCommand.java | 16 +- .../worldgen/WorldGenBenchmarkCommand.java | 94 +-- .../core/command/system/AbbreviationMap.java | 3 - .../core/command/system/CommandManager.java | 4 +- .../core/command/system/CommandUtil.java | 3 - .../core/command/system/ParserContext.java | 3 - .../server/core/command/system/Tokenizer.java | 3 - .../system/arguments/types/ArgTypes.java | 101 ++- .../arguments/types/MultiArgumentContext.java | 3 - .../arguments/types/RelativeDirection.java | 3 - .../system/exceptions/CommandException.java | 3 - .../command/system/pages/CommandListPage.java | 3 - .../system/suggestion/SuggestionResult.java | 3 - .../server/core/cosmetics/BodyType.java | 3 - .../server/core/cosmetics/CosmeticType.java | 3 - .../core/cosmetics/CosmeticsModule.java | 64 +- .../server/core/cosmetics/PlayerSkinPart.java | 6 - .../core/cosmetics/PlayerSkinPartType.java | 3 - .../server/core/entity/AnimationUtils.java | 3 - .../hytale/server/core/entity/Entity.java | 3 - .../server/core/entity/EntityUtils.java | 3 - .../server/core/entity/ExplosionConfig.java | 3 - .../server/core/entity/ExplosionUtils.java | 3 - .../hytale/server/core/entity/Frozen.java | 2 + .../server/core/entity/InteractionChain.java | 22 +- .../core/entity/InteractionContext.java | 8 + .../server/core/entity/InteractionEntry.java | 2 +- .../core/entity/InteractionManager.java | 145 +++- .../hytale/server/core/entity/ItemUtils.java | 3 - .../core/entity/StatModifiersManager.java | 11 +- .../entity/damage/DamageDataComponent.java | 3 - .../server/core/entity/entities/Player.java | 126 +++- .../entities/player/HiddenPlayersManager.java | 3 - .../entity/entities/player/HotbarManager.java | 3 - .../player/data/PlayerConfigData.java | 3 - .../data/UniqueItemUsagesComponent.java | 9 +- .../entities/player/pages/PageManager.java | 7 +- .../entities/player/pages/RespawnPage.java | 35 +- .../player/pages/audio/PlaySoundPage.java | 3 - .../player/pages/choices/ChoiceBasePage.java | 3 - .../entities/player/windows/BlockWindow.java | 44 +- .../player/windows/ContainerBlockWindow.java | 5 +- .../player/windows/ContainerWindow.java | 8 +- .../windows/ItemStackContainerWindow.java | 10 +- .../MaterialExtraResourcesSection.java | 3 - .../player/windows/ValidatedWindow.java | 7 +- .../entities/player/windows/Window.java | 23 +- .../player/windows/WindowManager.java | 84 ++- .../server/core/entity/group/EntityGroup.java | 3 - .../entity/knockback/KnockbackComponent.java | 3 - .../entity/knockback/KnockbackSystems.java | 9 - .../movement/MovementStatesSystems.java | 3 - .../entity/nameplate/NameplateSystems.java | 3 - .../reference/InvalidatablePersistentRef.java | 3 - .../core/entity/reference/PersistentRef.java | 3 - .../entity/reference/PersistentRefCount.java | 3 - .../server/core/event/events/BootEvent.java | 3 - .../core/event/events/ShutdownEvent.java | 3 - .../core/event/events/ecs/DropItemEvent.java | 3 - .../server/core/inventory/Inventory.java | 27 +- .../server/core/inventory/ItemStack.java | 3 - .../InternalContainerUtilItemStack.java | 3 - .../InternalContainerUtilMaterial.java | 3 - .../InternalContainerUtilResource.java | 3 - .../container/InternalContainerUtilTag.java | 3 - .../inventory/container/ItemContainer.java | 3 - .../container/ItemContainerUtil.java | 3 - .../core/inventory/container/SortType.java | 6 - .../container/filter/FilterActionType.java | 3 - .../core/inventory/transaction/MoveType.java | 3 - .../hytale/server/core/io/PacketHandler.java | 54 +- .../server/core/io/ProtocolVersion.java | 16 +- .../core/io/adapter/PacketAdapters.java | 3 - .../io/handlers/InitialPacketHandler.java | 252 ++++--- .../core/io/handlers/SetupPacketHandler.java | 62 +- .../io/handlers/game/GamePacketHandler.java | 94 +-- .../io/handlers/login/HandshakeHandler.java | 32 +- .../handlers/login/PasswordPacketHandler.java | 13 +- .../io/netty/HytaleChannelInitializer.java | 84 ++- .../server/core/io/netty/NettyUtil.java | 33 +- .../core/io/netty/PacketArrayEncoder.java | 3 - .../core/io/transport/QUICTransport.java | 29 +- .../core/io/transport/TransportType.java | 3 - .../hytale/server/core/meta/MetaRegistry.java | 3 - .../server/core/modules/LegacyModule.java | 3 - .../accesscontrol/commands/BanCommand.java | 53 +- .../accesscontrol/commands/UnbanCommand.java | 27 +- .../commands/WhitelistAddCommand.java | 27 +- .../commands/WhitelistRemoveCommand.java | 27 +- .../commands/WhitelistStatusCommand.java | 4 +- .../provider/ClientDelegatingProvider.java | 3 - .../provider/HytaleWhitelistProvider.java | 4 + .../core/modules/block/BlockModule.java | 5 - .../modules/blockhealth/BlockHealthChunk.java | 3 - .../modules/collision/BasicCollisionData.java | 3 - .../modules/collision/BlockCollisionData.java | 3 - .../collision/BlockCollisionProvider.java | 3 - .../modules/collision/BlockContactData.java | 3 - .../core/modules/collision/BlockData.java | 3 - .../modules/collision/BlockDataProvider.java | 3 - .../modules/collision/BoxCollisionData.java | 3 - .../collision/CharacterCollisionData.java | 3 - .../modules/collision/CollisionConfig.java | 3 - .../modules/collision/CollisionMaterial.java | 3 - .../collision/CollisionModuleConfig.java | 3 - .../modules/collision/CollisionResult.java | 3 +- .../modules/collision/EntityContactData.java | 3 - .../collision/IBlockCollisionConsumer.java | 3 - .../MovingBoxBoxCollisionEvaluator.java | 3 - .../core/modules/collision/WorldUtil.java | 5 +- .../server/core/modules/debug/DebugUtils.java | 3 - .../entity/AllLegacyEntityTypesQuery.java | 6 +- .../AllLegacyLivingEntityTypesQuery.java | 5 +- .../modules/entity/BlockEntitySystems.java | 3 - .../core/modules/entity/EntityModule.java | 27 +- .../entity/LegacyProjectileSystems.java | 20 +- .../component/DisplayNameComponent.java | 3 +- .../component/MovementAudioComponent.java | 6 - .../entity/component/PropComponent.java | 3 - .../entity/component/SnapshotBuffer.java | 3 - .../damage/DamageCalculatorSystems.java | 14 +- .../modules/entity/damage/DamageModule.java | 4 - .../modules/entity/damage/DamageSystems.java | 404 +++++------ .../modules/entity/damage/DeathComponent.java | 36 +- .../modules/entity/damage/DeathSystems.java | 64 +- .../modules/entity/damage/RespawnSystems.java | 42 -- .../entity/damage/event/KillFeedEvent.java | 3 - .../dynamiclight/DynamicLightSystems.java | 6 - .../HitboxCollisionConfigPacketGenerator.java | 3 - .../HitboxCollisionSystems.java | 3 - .../modules/entity/item/ItemMergeSystem.java | 7 +- .../entity/item/ItemPhysicsSystem.java | 15 +- .../core/modules/entity/item/ItemSystems.java | 6 - .../entity/item/PickupItemComponent.java | 8 +- .../modules/entity/item/PickupItemSystem.java | 27 +- .../LivingEntityEffectClearChangesSystem.java | 3 - .../LivingEntityEffectSystem.java | 104 +-- .../ApplyRandomSkinPersistedComponent.java | 3 - .../modules/entity/player/ChunkTracker.java | 150 ++-- .../player/KnockbackPredictionSystems.java | 25 +- .../entity/player/KnockbackSimulation.java | 3 - .../entity/player/PlayerCameraAddSystem.java | 3 - .../player/PlayerChunkTrackerSystems.java | 36 +- .../player/PlayerHudManagerSystems.java | 6 - .../modules/entity/player/PlayerInput.java | 3 - .../player/PlayerItemEntityPickupSystem.java | 1 + .../player/PlayerMovementManagerSystems.java | 9 - .../entity/player/PlayerPingSystem.java | 3 - .../player/PlayerProcessMovementSystem.java | 135 ++-- .../entity/player/PlayerSavingSystems.java | 6 - .../modules/entity/player/PlayerSettings.java | 24 +- .../modules/entity/player/PlayerSystems.java | 262 +++++-- .../RepulsionConfigPacketGenerator.java | 3 - .../entity/repulsion/RepulsionSystems.java | 51 +- .../entity/stamina/StaminaGameplayConfig.java | 6 - .../entity/stamina/StaminaSystems.java | 6 - .../modules/entity/system/AudioSystems.java | 9 - .../system/EntityInteractableSystems.java | 6 - .../modules/entity/system/EntitySystems.java | 12 - .../entity/system/HideEntitySystems.java | 6 - .../entity/system/IntangibleSystems.java | 6 - .../entity/system/InvulnerableSystems.java | 6 - .../modules/entity/system/ModelSystems.java | 39 +- .../entity/system/RespondToHitSystems.java | 35 +- .../entity/system/RotateObjectSystem.java | 10 +- .../entity/system/SnapshotSystems.java | 12 - .../entity/system/TransformSystems.java | 9 - .../entity/system/UpdateLocationSystems.java | 21 +- .../entity/teleport/PendingTeleport.java | 6 - .../modules/entity/teleport/Teleport.java | 55 +- .../entity/teleport/TeleportRecord.java | 51 ++ .../entity/teleport/TeleportSystems.java | 26 +- .../entity/tracker/EntityTrackerSystems.java | 6 - .../tracker/LegacyEntityTrackerSystems.java | 197 ++--- .../modules/entitystats/EntityStatMap.java | 6 - .../modules/entitystats/EntityStatValue.java | 2 +- .../entitystats/EntityStatsSystems.java | 8 +- .../entitystats/asset/EntityStatType.java | 3 - .../asset/EntityStatTypePacketGenerator.java | 3 - .../asset/condition/LogicCondition.java | 3 - .../asset/condition/SuffocatingCondition.java | 4 +- .../entitystats/modifier/Modifier.java | 3 - .../entitystats/modifier/StaticModifier.java | 3 - .../modules/entityui/UIComponentSystems.java | 3 - .../entityui/asset/CombatTextUIComponent.java | 3 - .../CombatTextUIComponentAnimationEvent.java | 3 - ...tTextUIComponentOpacityAnimationEvent.java | 3 - ...TextUIComponentPositionAnimationEvent.java | 3 - ...batTextUIComponentScaleAnimationEvent.java | 3 - .../entityui/asset/EntityStatUIComponent.java | 3 - .../EntityUIComponentPacketGenerator.java | 3 - .../server/core/modules/i18n/I18nModule.java | 14 - .../modules/i18n/parser/LangFileParser.java | 3 - .../interaction/BlockHarvestUtils.java | 11 +- .../interaction/BlockInteractionUtils.java | 3 - .../modules/interaction/BlockPlaceUtils.java | 3 - .../interaction/InteractionModule.java | 2 + .../InteractionSimulationHandler.java | 3 - .../modules/interaction/Interactions.java | 7 + .../blocktrack/TrackedPlacement.java | 3 - .../interaction/CooldownHandler.java | 3 - .../InteractionPacketGenerator.java | 3 - .../RootInteractionPacketGenerator.java | 3 - .../interaction/UnarmedInteractions.java | 3 - .../UnarmedInteractionsPacketGenerator.java | 3 - .../config/InteractionCameraSettings.java | 6 - .../config/InteractionConfiguration.java | 4 + .../config/InteractionPriorityCodec.java | 3 - .../interaction/config/InteractionRules.java | 3 - .../config/InteractionTypeUtils.java | 3 - .../config/SimpleInstantInteraction.java | 5 +- .../interaction/config/SimpleInteraction.java | 7 +- .../config/client/AddItemInteraction.java | 3 - .../config/client/ApplyForceInteraction.java | 11 +- .../client/BlockConditionInteraction.java | 9 - .../config/client/BreakBlockInteraction.java | 3 - .../config/client/ChainingInteraction.java | 11 +- .../config/client/ChangeBlockInteraction.java | 3 - .../config/client/ChangeStateInteraction.java | 3 - .../config/client/ChargingInteraction.java | 8 +- .../client/CooldownConditionInteraction.java | 3 - .../client/CycleBlockGroupInteraction.java | 3 - .../client/DestroyBlockInteraction.java | 3 - .../config/client/ExplodeInteraction.java | 3 - .../config/client/FirstClickInteraction.java | 8 +- .../client/IncrementCooldownInteraction.java | 3 - .../client/MovementConditionInteraction.java | 8 +- .../config/client/PickBlockInteraction.java | 26 +- .../config/client/PlaceBlockInteraction.java | 8 +- .../config/client/PlaceFluidInteraction.java | 3 - .../client/ResetCooldownInteraction.java | 3 - .../config/client/SimpleBlockInteraction.java | 9 +- .../client/ToggleGliderInteraction.java | 3 - .../client/TriggerCooldownInteraction.java | 3 - .../config/client/UseBlockInteraction.java | 3 - .../config/client/UseEntityInteraction.java | 3 - .../config/client/WieldingInteraction.java | 17 +- .../config/none/BuilderToolInteraction.java | 6 +- .../config/none/CameraInteraction.java | 6 +- .../config/none/CancelChainInteraction.java | 3 - .../config/none/ChainFlagInteraction.java | 3 - .../none/ChangeActiveSlotInteraction.java | 5 +- .../config/none/ConditionInteraction.java | 6 +- .../none/EffectConditionInteraction.java | 5 +- .../config/none/ParallelInteraction.java | 8 +- .../config/none/RepeatInteraction.java | 8 +- .../config/none/ReplaceInteraction.java | 8 +- .../config/none/RunRootInteraction.java | 3 - .../config/none/SelectInteraction.java | 52 +- .../config/none/SerialInteraction.java | 8 +- .../none/StatsConditionBaseInteraction.java | 3 - .../none/StatsConditionInteraction.java | 3 - ...StatsConditionWithModifierInteraction.java | 3 - .../none/simple/ApplyEffectInteraction.java | 3 - .../none/simple/RemoveEntityInteraction.java | 3 - .../config/selector/AOECircleSelector.java | 6 - .../config/selector/AOECylinderSelector.java | 6 - .../config/selector/HorizontalSelector.java | 135 ++-- .../config/selector/PlayerMatcher.java | 8 +- .../config/selector/RaycastSelector.java | 9 - .../config/selector/SelectorType.java | 7 +- .../config/selector/StabSelector.java | 137 ++-- .../config/selector/VulnerableMatcher.java | 8 +- .../server/ChangeStatBaseInteraction.java | 3 - .../config/server/ChangeStatInteraction.java | 3 - .../ChangeStatWithModifierInteraction.java | 6 +- .../CheckUniqueItemUsageInteraction.java | 6 +- .../server/ClearEntityEffectInteraction.java | 3 - .../server/DamageEntityInteraction.java | 17 +- .../server/DestroyConditionInteraction.java | 3 - .../config/server/DoorInteraction.java | 6 - .../config/server/EquipItemInteraction.java | 6 +- .../IncreaseBackpackCapacityInteraction.java | 6 +- .../config/server/InterruptInteraction.java | 3 - .../config/server/LaunchPadInteraction.java | 3 - .../server/LaunchProjectileInteraction.java | 74 +- .../server/ModifyInventoryInteraction.java | 7 +- .../server/OpenContainerInteraction.java | 3 - .../server/OpenCustomUIInteraction.java | 3 - .../OpenItemStackContainerInteraction.java | 3 - .../config/server/OpenPageInteraction.java | 3 - .../PlacementCountConditionInteraction.java | 3 - .../server/RefillContainerInteraction.java | 278 ++++--- .../server/RunOnBlockTypesInteraction.java | 376 ++++++++++ .../config/server/SpawnPrefabInteraction.java | 6 - .../server/combat/DamageCalculator.java | 3 - .../config/server/combat/DamageClass.java | 3 - .../server/combat/DirectionalKnockback.java | 3 - .../config/server/combat/ForceKnockback.java | 3 - .../config/server/combat/PointKnockback.java | 3 - .../operation/OperationsBuilder.java | 3 - .../interaction/util/InteractionTarget.java | 15 +- .../suppliers/ItemRepairPageSupplier.java | 3 - .../system/InteractionSystems.java | 19 +- .../item/CraftingRecipePacketGenerator.java | 3 - .../modules/item/ItemPacketGenerator.java | 3 - .../item/ItemQualityPacketGenerator.java | 3 - .../ItemReticleConfigPacketGenerator.java | 3 - .../modules/item/RecipePacketGenerator.java | 3 - .../ChunkColumnMigrationSystem.java | 2 - .../ChunkSectionMigrationSystem.java | 2 - .../core/modules/physics/RestingSupport.java | 3 - .../physics/SimplePhysicsProvider.java | 11 +- .../GenericVelocityInstructionSystem.java | 3 - .../physics/systems/VelocitySystems.java | 3 - .../physics/util/ForceAccumulator.java | 3 - .../physics/util/ForceProviderStandard.java | 3 - .../physics/util/PhysicsBodyState.java | 3 - .../physics/util/PhysicsBodyStateUpdater.java | 3 - .../util/PhysicsBodyStateUpdaterMidpoint.java | 3 - .../util/PhysicsBodyStateUpdaterRK4.java | 3 - ...hysicsBodyStateUpdaterSymplecticEuler.java | 3 - .../physics/util/PhysicsConstants.java | 3 - .../modules/physics/util/PhysicsFlags.java | 3 - .../modules/physics/util/PhysicsMath.java | 3 - .../prefabspawner/PrefabSpawnerState.java | 6 - .../projectile/config/ProjectileConfig.java | 3 - .../ProjectileConfigPacketGenerator.java | 3 - .../config/StandardPhysicsConfig.java | 3 - .../config/StandardPhysicsProvider.java | 3 - .../interaction/ProjectileInteraction.java | 3 - .../system/PredictedProjectileSystems.java | 6 - .../system/StandardPhysicsTickSystem.java | 3 - .../modules/splitvelocity/VelocityConfig.java | 3 - .../core/modules/time/WorldTimeResource.java | 3 - .../core/modules/time/WorldTimeSystems.java | 3 - .../core/permissions/HytalePermissions.java | 6 +- .../permissions/commands/op/OpAddCommand.java | 18 +- .../commands/op/OpRemoveCommand.java | 18 +- .../commands/op/OpSelfCommand.java | 18 +- .../server/core/plugin/PluginState.java | 3 - .../core/plugin/pages/PluginListPage.java | 3 - .../core/prefab/PrefabCopyableComponent.java | 5 +- .../core/prefab/PrefabLoadException.java | 3 - .../server/core/prefab/PrefabRotation.java | 12 - .../core/prefab/PrefabSaveException.java | 3 - .../server/core/prefab/PrefabStore.java | 2 +- .../server/core/prefab/PrefabWeights.java | 3 - .../config/SelectionPrefabSerializer.java | 10 +- .../buffer/BinaryPrefabBufferCodec.java | 3 - .../buffer/BsonPrefabBufferDeserializer.java | 3 - .../selection/buffer/PrefabBufferUtil.java | 6 - .../prefab/selection/mask/BlockPattern.java | 4 + .../selection/standard/BlockSelection.java | 47 +- .../hypixel/hytale/server/core/ui/Anchor.java | 3 - .../hypixel/hytale/server/core/ui/Area.java | 3 - .../server/core/ui/LocalizableString.java | 6 - .../core/ui/browser/FileBrowserConfig.java | 32 +- .../core/ui/browser/FileBrowserEventData.java | 3 - .../core/ui/browser/FileListProvider.java | 10 +- .../core/ui/browser/ServerFileBrowser.java | 293 +++++++- .../core/ui/builder/UICommandBuilder.java | 3 - .../core/ui/builder/UIEventBuilder.java | 3 - .../hytale/server/core/universe/Universe.java | 19 +- .../universe/WorldLoadCancelledException.java | 2 - .../DefaultPlayerStorageProvider.java | 3 - .../playerdata/DiskPlayerStorageProvider.java | 3 - .../PlayerVelocityInstructionSystem.java | 21 +- .../world/ClientEffectWorldSettings.java | 3 - .../core/universe/world/ParticleUtil.java | 3 - .../universe/world/PlaceBlockSettings.java | 3 - .../core/universe/world/PlayerUtil.java | 3 - .../core/universe/world/SetBlockSettings.java | 3 - .../server/core/universe/world/SoundUtil.java | 3 - .../server/core/universe/world/SpawnUtil.java | 3 - .../core/universe/world/ValidationOption.java | 3 - .../server/core/universe/world/World.java | 15 +- .../core/universe/world/WorldConfig.java | 3 - .../universe/world/WorldConfigProvider.java | 2 - .../core/universe/world/WorldMapTracker.java | 176 +---- .../world/accessor/BlockAccessor.java | 16 +- .../world/accessor/EmptyBlockAccessor.java | 3 - .../world/accessor/IChunkAccessorSync.java | 4 + .../world/chunk/BlockComponentChunk.java | 19 +- .../world/chunk/BlockRotationUtil.java | 3 - .../core/universe/world/chunk/ChunkFlag.java | 3 - .../universe/world/chunk/EntityChunk.java | 54 +- .../core/universe/world/chunk/WorldChunk.java | 30 +- .../world/chunk/section/BlockSection.java | 12 +- .../world/chunk/section/FluidSection.java | 3 - .../section/palette/ISectionPalette.java | 3 - .../world/chunk/systems/ChunkSystems.java | 21 - .../world/perf/WorldPerfResetCommand.java | 3 +- .../commands/world/tps/WorldTpsCommand.java | 11 +- .../ConnectedBlockFaceTags.java | 3 - .../ConnectedBlockPatternRule.java | 6 - .../ConnectedBlockRuleSet.java | 3 - .../connectedblocks/ConnectedBlockShape.java | 3 - .../connectedblocks/ConnectedBlocksUtil.java | 3 - .../CustomConnectedBlockPattern.java | 3 - .../CustomConnectedBlockTemplateAsset.java | 3 - .../CustomTemplateConnectedBlockPattern.java | 3 - .../CustomTemplateConnectedBlockRuleSet.java | 3 - .../PatternRotationDefinition.java | 6 - .../builtin/RoofConnectedBlockRuleSet.java | 38 +- .../builtin/StairConnectedBlockRuleSet.java | 9 - .../world/events/AllWorldsLoadedEvent.java | 3 - .../world/events/RemoveWorldEvent.java | 3 - .../world/lighting/CalculationResult.java | 3 - .../core/universe/world/meta/BlockState.java | 9 +- .../universe/world/meta/BlockStateModule.java | 7 +- .../world/meta/state/BlockMapMarker.java | 11 +- .../world/meta/state/ItemContainerState.java | 3 - .../universe/world/meta/state/LaunchPad.java | 3 - .../world/meta/state/RespawnBlock.java | 74 +- .../world/path/SimplePathWaypoint.java | 3 +- .../universe/world/path/WorldPathConfig.java | 3 - .../spawn/FitToHeightMapSpawnProvider.java | 2 +- .../world/spawn/GlobalSpawnProvider.java | 4 +- .../world/spawn/IndividualSpawnProvider.java | 6 +- .../universe/world/storage/ChunkStore.java | 82 ++- .../universe/world/storage/EntityStore.java | 6 - .../universe/world/storage/GetChunkFlags.java | 3 - .../storage/component/ChunkSavingSystems.java | 18 +- .../component/ChunkUnloadingSystem.java | 3 - .../provider/DefaultChunkStorageProvider.java | 10 +- .../provider/EmptyChunkStorageProvider.java | 16 +- .../IndexedStorageChunkStorageProvider.java | 63 +- .../MigrationChunkStorageProvider.java | 5 +- .../DefaultResourceStorageProvider.java | 3 - .../DiskResourceStorageProvider.java | 3 - .../EmptyResourceStorageProvider.java | 3 - .../world/system/WorldPregenerateSystem.java | 3 - .../worldgen/GeneratedBlockStateChunk.java | 3 - .../world/worldgen/GeneratedChunkSection.java | 3 - .../provider/DummyWorldGenProvider.java | 3 - .../WorldLocationCondition.java | 3 - .../world/worldmap/WorldMapManager.java | 19 +- .../worldmap/markers/MapMarkerTracker.java | 179 +++++ .../markers/PlayerIconMarkerProvider.java | 63 -- .../{ => providers}/DeathMarkerProvider.java | 13 +- .../{ => providers}/POIMarkerProvider.java | 9 +- .../PerWorldDataMarkerProvider.java} | 15 +- .../providers/PlayerIconMarkerProvider.java | 56 ++ .../RespawnMarkerProvider.java | 13 +- .../{ => providers}/SpawnMarkerProvider.java | 11 +- .../provider/DisabledWorldMapProvider.java | 6 - .../provider/chunk/ChunkWorldMap.java | 3 - .../worldmap/provider/chunk/ImageBuilder.java | 44 +- .../chunk/WorldGenWorldMapProvider.java | 3 - .../server/core/update/UpdateModule.java | 415 +++++++++++ .../server/core/update/UpdateService.java | 382 ++++++++++ .../update/command/UpdateApplyCommand.java | 122 ++++ .../update/command/UpdateCancelCommand.java | 41 ++ .../update/command/UpdateCheckCommand.java | 58 ++ .../core/update/command/UpdateCommand.java | 36 + .../update/command/UpdateDownloadCommand.java | 115 +++ .../command/UpdatePatchlineCommand.java | 41 ++ .../update/command/UpdateStatusCommand.java | 68 ++ .../hytale/server/core/util/AssetUtil.java | 3 - .../hytale/server/core/util/AuthUtil.java | 23 - .../hytale/server/core/util/BsonUtil.java | 3 - .../server/core/util/ConsoleColorUtil.java | 3 - .../hytale/server/core/util/DumpUtil.java | 3 - .../server/core/util/EventTitleUtil.java | 3 - .../server/core/util/FillerBlockUtil.java | 6 - .../hytale/server/core/util/HashUtil.java | 3 - .../hytale/server/core/util/MessageUtil.java | 212 +++++- .../server/core/util/NotificationUtil.java | 3 - .../hytale/server/core/util/PositionUtil.java | 3 - .../hytale/server/core/util/PrefabUtil.java | 16 +- .../hytale/server/core/util/ProcessUtil.java | 3 - .../hytale/server/core/util/TargetUtil.java | 3 - .../server/core/util/TempAssetIdUtil.java | 3 - .../hytale/server/core/util/UUIDUtil.java | 3 - .../hytale/server/core/util/ValidateUtil.java | 3 - .../server/core/util/backup/BackupUtil.java | 3 - .../core/util/concurrent/ThreadUtil.java | 3 - .../server/core/util/io/ByteBufUtil.java | 3 - .../hytale/server/core/util/io/FileUtil.java | 28 +- .../core/util/message/MessageFormat.java | 3 - .../hypixel/hytale/server/flock/Flock.java | 3 - .../server/flock/FlockDeathSystems.java | 17 +- .../hytale/server/flock/FlockMembership.java | 3 - .../server/flock/FlockMembershipSystems.java | 12 - .../hytale/server/flock/FlockSystems.java | 3 - .../hytale/server/flock/StoredFlock.java | 3 - .../builders/BuilderActionFlockBeacon.java | 3 - .../builders/BuilderActionFlockJoin.java | 3 - .../builders/BuilderActionFlockLeave.java | 3 - .../builders/BuilderActionFlockSetTarget.java | 3 - .../builders/BuilderActionFlockState.java | 3 - .../builders/BuilderBodyMotionFlock.java | 3 - .../builders/BuilderEntityFilterFlock.java | 3 - .../BuilderSensorFlockCombatDamage.java | 3 - .../builders/BuilderSensorFlockLeader.java | 3 - .../BuilderSensorInflictedDamage.java | 3 - .../hypixel/hytale/server/npc/NPCPlugin.java | 9 +- .../builder/BuilderAttributeDescriptor.java | 3 - .../server/npc/asset/builder/BuilderBase.java | 3 - .../asset/builder/BuilderBaseWithType.java | 3 - .../asset/builder/BuilderDescriptorState.java | 3 - .../server/npc/asset/builder/BuilderInfo.java | 3 - .../npc/asset/builder/BuilderManager.java | 9 +- .../npc/asset/builder/BuilderModifier.java | 16 +- .../builder/SpawnableWithModelBuilder.java | 3 - .../npc/asset/builder/StateMappingHelper.java | 3 - .../builder/expression/BuilderExpression.java | 6 - .../BuilderExpressionStaticEmptyArray.java | 3 - .../builder/holder/AssetArrayHolder.java | 3 - .../npc/asset/builder/holder/AssetHolder.java | 3 - .../holder/DeferEvaluateAssetHolder.java | 3 - .../asset/builder/holder/DoubleHolder.java | 3 - .../npc/asset/builder/holder/EnumHolder.java | 3 - .../npc/asset/builder/holder/FloatHolder.java | 3 - .../asset/builder/holder/StringHolder.java | 3 - .../builder/holder/TemporalArrayHolder.java | 3 - .../ProviderEvaluatorTypeRegistry.java | 3 - .../builder/validators/ArrayValidator.java | 3 - .../builder/validators/AssetValidator.java | 3 - .../validators/BooleanArrayValidator.java | 3 - .../validators/DoubleArrayValidator.java | 3 - .../builder/validators/DoubleValidator.java | 3 - .../validators/EnumArrayValidator.java | 3 - .../builder/validators/IntArrayValidator.java | 3 - .../builder/validators/IntValidator.java | 3 - .../validators/RequiredFeatureValidator.java | 3 - .../validators/StringArrayValidator.java | 3 - .../builder/validators/StringValidator.java | 3 - .../validators/TemporalArrayValidator.java | 3 - .../asset/builder/validators/Validator.java | 2 - .../validators/ValidatorTypeRegistry.java | 3 - .../server/npc/blackboard/Blackboard.java | 3 - .../npc/blackboard/view/BlockRegionView.java | 3 - .../view/BlockRegionViewManager.java | 3 - .../view/PrioritisedProviderView.java | 3 - .../blackboard/view/attitude/AttitudeMap.java | 3 - .../view/attitude/ItemAttitudeMap.java | 3 - .../BlockPositionEntryGenerator.java | 6 - .../view/blocktype/BlockTypeViewManager.java | 3 - .../view/combat/CombatViewSystems.java | 30 +- .../view/combat/InterpretedCombatData.java | 3 - .../view/event/EntityEventNotification.java | 3 - .../view/event/EventNotification.java | 3 - .../view/interaction/ReservationStatus.java | 3 - .../view/resource/ResourceViewManager.java | 3 - .../server/npc/commands/NPCCommandUtils.java | 3 - .../npc/commands/NPCRunTestsCommand.java | 3 - .../npc/components/FailedSpawnComponent.java | 3 - .../SortBufferProviderResource.java | 3 - .../npc/components/SpawnBeaconReference.java | 3 - .../npc/components/SpawnMarkerReference.java | 3 - .../server/npc/components/SpawnReference.java | 3 - .../components/messaging/BeaconSupport.java | 3 - .../messaging/EntityEventSupport.java | 3 - .../components/messaging/EventSupport.java | 3 - .../components/messaging/MessageSupport.java | 3 - .../messaging/NPCBlockEventSupport.java | 3 - .../messaging/NPCEntityEventSupport.java | 3 - .../npc/components/messaging/NPCMessage.java | 3 - .../messaging/PlayerBlockEventSupport.java | 3 - .../messaging/PlayerEntityEventSupport.java | 3 - .../AnnotatedComponentBase.java | 3 - .../npc/corecomponents/BlockTarget.java | 3 - .../npc/corecomponents/EntityFilterBase.java | 2 - .../server/npc/corecomponents/MotionBase.java | 2 - .../audiovisual/ActionSpawnParticles.java | 4 +- .../builders/BuilderActionAppearance.java | 3 - .../builders/BuilderActionDisplayName.java | 3 - .../BuilderActionModelAttachment.java | 3 - .../builders/BuilderActionPlayAnimation.java | 3 - .../builders/BuilderActionPlaySound.java | 3 - .../builders/BuilderActionSpawnParticles.java | 25 +- .../builders/BuilderSensorAnimation.java | 3 - .../builders/BuilderActionBase.java | 3 - .../builders/BuilderActionWithDelay.java | 3 - .../builders/BuilderBodyMotionBase.java | 3 - .../builders/BuilderEntityFilterBase.java | 3 - .../BuilderEntityFilterWithToggle.java | 3 - .../builders/BuilderHeadMotionBase.java | 3 - .../builders/BuilderMotionBase.java | 3 - .../builders/BuilderSensorBase.java | 3 - .../BuilderSensorWithEntityFilters.java | 3 - .../builders/BuilderWeightedAction.java | 3 - .../corecomponents/combat/HeadMotionAim.java | 6 +- .../BuilderActionApplyEntityEffect.java | 3 - .../combat/builders/BuilderActionAttack.java | 3 - .../builders/BuilderBodyMotionAimCharge.java | 3 - .../combat/builders/BuilderHeadMotionAim.java | 28 +- .../combat/builders/BuilderSensorDamage.java | 3 - .../builders/BuilderSensorIsBackingAway.java | 3 - .../debug/builders/BuilderActionLog.java | 3 - .../debug/builders/BuilderActionTest.java | 3 - .../builders/BuilderBodyMotionTestProbe.java | 3 - .../entity/builders/BuilderActionBeacon.java | 3 - .../BuilderActionIgnoreForAvoidance.java | 3 - .../entity/builders/BuilderActionNotify.java | 3 - .../BuilderActionOverrideAttitude.java | 3 - .../builders/BuilderActionReleaseTarget.java | 3 - .../BuilderActionSetMarkedTarget.java | 3 - .../entity/builders/BuilderActionSetStat.java | 3 - .../builders/BuilderHeadMotionWatch.java | 3 - .../entity/builders/BuilderSensorBeacon.java | 3 - .../entity/builders/BuilderSensorCount.java | 3 - .../entity/builders/BuilderSensorEntity.java | 3 - .../builders/BuilderSensorEntityBase.java | 3 - .../entity/builders/BuilderSensorKill.java | 3 - .../entity/builders/BuilderSensorPlayer.java | 3 - .../entity/builders/BuilderSensorSelf.java | 3 - .../entity/builders/BuilderSensorTarget.java | 3 - .../entity/filters/EntityFilterCombat.java | 2 +- .../filters/EntityFilterLineOfSight.java | 3 - .../builders/BuilderEntityFilterAltitude.java | 3 - .../builders/BuilderEntityFilterAnd.java | 3 - .../builders/BuilderEntityFilterAttitude.java | 3 - .../builders/BuilderEntityFilterCombat.java | 3 - .../BuilderEntityFilterHeightDifference.java | 3 - .../BuilderEntityFilterInsideBlock.java | 3 - .../BuilderEntityFilterInventory.java | 3 - .../BuilderEntityFilterItemInHand.java | 3 - .../BuilderEntityFilterLineOfSight.java | 3 - .../builders/BuilderEntityFilterMany.java | 3 - .../BuilderEntityFilterMovementState.java | 3 - .../builders/BuilderEntityFilterNPCGroup.java | 3 - .../builders/BuilderEntityFilterNot.java | 3 - .../builders/BuilderEntityFilterOr.java | 3 - .../builders/BuilderEntityFilterSpotsMe.java | 3 - .../BuilderEntityFilterStandingOnBlock.java | 3 - .../builders/BuilderEntityFilterStat.java | 3 - .../BuilderEntityFilterViewSector.java | 3 - .../SensorEntityPrioritiserDefault.java | 3 - .../BuilderActionLockOnInteractionTarget.java | 3 - .../BuilderActionSetInteractable.java | 3 - .../builders/BuilderSensorCanInteract.java | 3 - .../builders/BuilderSensorHasInteracted.java | 3 - .../BuilderSensorInteractionContext.java | 3 - .../corecomponents/items/ActionInventory.java | 2 +- .../items/builders/BuilderActionDropItem.java | 3 - .../builders/BuilderActionInventory.java | 3 - .../builders/BuilderActionPickUpItem.java | 3 - .../builders/BuilderSensorDroppedItem.java | 3 - .../builders/BuilderActionDelayDespawn.java | 3 - .../builders/BuilderActionDespawn.java | 3 - .../lifecycle/builders/BuilderActionDie.java | 3 - .../builders/BuilderActionRemove.java | 3 - .../lifecycle/builders/BuilderActionRole.java | 3 - .../builders/BuilderActionSpawn.java | 3 - .../lifecycle/builders/BuilderSensorAge.java | 3 - .../movement/BodyMotionTeleport.java | 6 +- .../movement/BodyMotionWanderBase.java | 3 - .../builders/BuilderActionCrouch.java | 3 - .../BuilderActionOverrideAltitude.java | 3 - .../builders/BuilderActionRecomputePath.java | 3 - .../builders/BuilderBodyMotionFind.java | 3 - .../builders/BuilderBodyMotionLand.java | 3 - .../BuilderBodyMotionMaintainDistance.java | 3 - .../builders/BuilderBodyMotionMatchLook.java | 3 - .../builders/BuilderBodyMotionMoveAway.java | 3 - .../builders/BuilderBodyMotionTakeOff.java | 3 - .../builders/BuilderBodyMotionTeleport.java | 3 - .../builders/BuilderBodyMotionWander.java | 3 - .../builders/BuilderBodyMotionWanderBase.java | 3 - .../BuilderBodyMotionWanderInCircle.java | 3 - .../BuilderBodyMotionWanderInRect.java | 3 - .../movement/builders/BuilderSensorInAir.java | 3 - .../BuilderSensorMotionController.java | 3 - .../movement/builders/BuilderSensorNav.java | 3 - .../builders/BuilderSensorOnGround.java | 3 - .../builders/BuilderActionParentState.java | 3 - .../builders/BuilderActionState.java | 3 - .../BuilderActionToggleStateEvaluator.java | 3 - .../builders/BuilderSensorIsBusy.java | 3 - .../builders/BuilderSensorState.java | 3 - .../timer/builders/BuilderActionSetAlarm.java | 3 - .../timer/builders/BuilderActionTimer.java | 3 - .../builders/BuilderActionTimerContinue.java | 3 - .../builders/BuilderActionTimerModify.java | 3 - .../builders/BuilderActionTimerPause.java | 3 - .../builders/BuilderActionTimerRestart.java | 3 - .../builders/BuilderActionTimerStart.java | 3 - .../builders/BuilderActionTimerStop.java | 3 - .../timer/builders/BuilderMotionTimer.java | 3 - .../timer/builders/BuilderSensorAlarm.java | 3 - .../timer/builders/BuilderSensorTimer.java | 3 - .../builders/BuilderActionNothing.java | 3 - .../utility/builders/BuilderActionRandom.java | 3 - .../BuilderActionResetInstructions.java | 3 - .../builders/BuilderActionSequence.java | 3 - .../builders/BuilderActionSetFlag.java | 3 - .../builders/BuilderActionTimeout.java | 3 - .../builders/BuilderBodyMotionNothing.java | 3 - .../builders/BuilderHeadMotionNothing.java | 3 - .../builders/BuilderMotionSequence.java | 3 - .../builders/BuilderSensorAdjustPosition.java | 3 - .../utility/builders/BuilderSensorAnd.java | 3 - .../utility/builders/BuilderSensorAny.java | 3 - .../utility/builders/BuilderSensorEval.java | 3 - .../utility/builders/BuilderSensorFlag.java | 3 - .../utility/builders/BuilderSensorMany.java | 3 - .../utility/builders/BuilderSensorNot.java | 3 - .../utility/builders/BuilderSensorOr.java | 3 - .../utility/builders/BuilderSensorRandom.java | 3 - .../utility/builders/BuilderSensorSwitch.java | 3 - .../BuilderSensorValueProviderWrapper.java | 3 - .../BuilderValueToParameterMapping.java | 3 - .../npc/corecomponents/world/SensorPath.java | 3 - .../world/builders/BuilderActionMakePath.java | 3 - .../builders/BuilderActionPlaceBlock.java | 3 - .../BuilderActionResetBlockSensors.java | 3 - .../builders/BuilderActionResetPath.java | 3 - .../BuilderActionResetSearchRays.java | 3 - .../BuilderActionSetBlockToPlace.java | 3 - .../BuilderActionSetLeashPosition.java | 3 - .../builders/BuilderActionStorePosition.java | 3 - .../BuilderActionTriggerSpawners.java | 3 - .../world/builders/BuilderBodyMotionPath.java | 3 - .../builders/BuilderHeadMotionObserve.java | 3 - .../world/builders/BuilderSensorBlock.java | 3 - .../builders/BuilderSensorBlockChange.java | 3 - .../builders/BuilderSensorBlockType.java | 3 - .../world/builders/BuilderSensorCanPlace.java | 3 - .../builders/BuilderSensorEntityEvent.java | 3 - .../world/builders/BuilderSensorEvent.java | 3 - .../world/builders/BuilderSensorInWater.java | 3 - .../world/builders/BuilderSensorLeash.java | 3 - .../world/builders/BuilderSensorLight.java | 3 - .../world/builders/BuilderSensorPath.java | 3 - .../builders/BuilderSensorReadPosition.java | 3 - .../builders/BuilderSensorSearchRay.java | 3 - .../world/builders/BuilderSensorTime.java | 3 - .../world/builders/BuilderSensorWeather.java | 3 - .../decisionmaker/core/EvaluationContext.java | 3 - .../npc/decisionmaker/core/Evaluator.java | 3 - .../core/conditions/LineOfSightCondition.java | 3 - .../core/conditions/RandomiserCondition.java | 3 - .../conditions/TargetDistanceCondition.java | 3 - .../TargetMovementStateCondition.java | 3 - .../server/npc/entities/PathManager.java | 3 - .../server/npc/instructions/NullSensor.java | 3 - .../builders/BuilderActionList.java | 3 - .../builders/BuilderInstruction.java | 3 - .../BuilderInstructionRandomized.java | 3 - .../builders/BuilderInstructionReference.java | 3 - .../NPCInteractionSimulationHandler.java | 3 - .../npc/interactions/SpawnNPCInteraction.java | 3 - .../npc/metadata/CapturedNPCMetadata.java | 3 - .../movement/GroupSteeringAccumulator.java | 3 - .../server/npc/movement/MotionKind.java | 3 - .../hytale/server/npc/movement/Steering.java | 3 - .../BuilderMotionControllerMapUtil.java | 3 - .../controllers/MotionController.java | 5 +- .../controllers/MotionControllerBase.java | 20 +- .../controllers/MotionControllerWalk.java | 10 +- .../movement/controllers/ProbeMoveData.java | 3 - .../builders/BuilderMotionControllerBase.java | 3 - .../builders/BuilderMotionControllerDive.java | 3 - .../builders/BuilderMotionControllerFly.java | 3 - .../builders/BuilderMotionControllerMap.java | 3 - .../builders/BuilderMotionControllerWalk.java | 44 +- .../SteeringForceAvoidCollision.java | 3 - .../steeringforces/SteeringForceRotate.java | 3 - .../SteeringForceWithGroup.java | 3 - .../SteeringForceWithTarget.java | 3 - .../server/npc/navigation/AStarBase.java | 6 - .../server/npc/navigation/AStarDebugBase.java | 26 +- .../npc/navigation/AStarDebugWithTarget.java | 2 +- .../AStarNodePoolProviderSimple.java | 3 - .../npc/navigation/AStarWithTarget.java | 3 - .../server/npc/navigation/PathFollower.java | 6 - .../server/npc/pages/EntitySpawnPage.java | 3 - .../BuilderRelativeWaypointDefinition.java | 3 - .../BuilderTransientPathDefinition.java | 3 - .../hypixel/hytale/server/npc/role/Role.java | 11 +- .../hytale/server/npc/role/RoleUtils.java | 3 - .../server/npc/role/builders/BuilderRole.java | 50 +- .../role/builders/BuilderRoleAbstract.java | 3 - .../npc/role/builders/BuilderRoleVariant.java | 3 - .../npc/role/support/PositionCache.java | 6 - .../server/npc/role/support/RoleStats.java | 6 - .../server/npc/role/support/StateSupport.java | 2 +- .../sensorinfo/CachedPositionProvider.java | 3 - .../server/npc/sensorinfo/PathProvider.java | 3 - .../MultipleParameterProvider.java | 3 - .../builders/BuilderStateTransition.java | 3 - .../BuilderStateTransitionController.java | 3 - .../builders/BuilderStateTransitionEdges.java | 3 - .../hytale/server/npc/storage/AlarmStore.java | 3 - .../BalancingInitialisationSystem.java | 3 - .../server/npc/systems/BlackboardSystems.java | 3 - .../server/npc/systems/FailedSpawnSystem.java | 3 - .../server/npc/systems/NPCDamageSystems.java | 103 ++- .../server/npc/systems/NPCDeathSystems.java | 42 +- .../npc/systems/NPCInteractionSystems.java | 3 - .../hytale/server/npc/systems/NPCSystems.java | 41 +- .../systems/NPCVelocityInstructionSystem.java | 67 +- .../systems/NewSpawnStartTickingSystem.java | 3 - .../npc/systems/PositionCacheSystems.java | 3 - .../server/npc/systems/RoleChangeSystem.java | 3 - .../server/npc/systems/RoleSystems.java | 3 - .../npc/systems/SpawnReferenceSystems.java | 3 - .../npc/systems/StateEvaluatorSystem.java | 64 +- .../server/npc/systems/SteeringSystem.java | 80 +- .../npc/systems/SteppableTickingSystem.java | 3 - .../hytale/server/npc/util/AimingData.java | 3 - .../hytale/server/npc/util/AimingHelper.java | 3 - .../hypixel/hytale/server/npc/util/Alarm.java | 3 - .../server/npc/util/BlockPlacementHelper.java | 3 - .../server/npc/util/InventoryHelper.java | 4 +- .../server/npc/util/NPCPhysicsMath.java | 3 - .../server/npc/util/PositionProbeAir.java | 3 - .../server/npc/util/PositionProbeBase.java | 3 - .../server/npc/util/PositionProbeWater.java | 3 - .../server/npc/util/RayBlockHitTest.java | 3 - .../hytale/server/npc/util/RootSolver.java | 3 - .../npc/util/SensorSupportBenchmark.java | 3 - .../hypixel/hytale/server/npc/util/Timer.java | 3 - .../npc/util/expression/ExecutionContext.java | 3 - .../server/npc/util/expression/ValueType.java | 3 - .../util/expression/compile/LexerContext.java | 3 - .../util/expression/compile/TokenFlags.java | 3 - .../npc/validators/NPCRoleValidator.java | 3 - .../server/npc/valuestore/ValueStore.java | 3 - .../npc/valuestore/ValueStoreValidator.java | 3 - .../server/spawning/SpawnRejection.java | 3 - .../server/spawning/SpawnTestResult.java | 3 - .../server/spawning/SpawningContext.java | 3 - .../server/spawning/SpawningPlugin.java | 6 - .../spawning/assets/spawns/LightType.java | 3 - .../spawning/beacons/InitialBeaconDelay.java | 3 - .../server/spawning/beacons/SpawnBeacon.java | 82 ++- .../spawning/beacons/SpawnBeaconSystems.java | 5 +- .../blockstates/SpawnMarkerBlockState.java | 3 - .../SpawnMarkerBlockStateSystems.java | 3 - .../controllers/BeaconSpawnController.java | 40 +- .../controllers/SpawnControllerSystem.java | 3 - .../spawning/controllers/SpawnJobSystem.java | 6 - .../BuilderActionTriggerSpawnBeacon.java | 3 - .../TriggerSpawnMarkersInteraction.java | 3 - .../spawning/jobs/NPCBeaconSpawnJob.java | 3 - .../spawning/local/LocalSpawnBeacon.java | 3 - .../spawning/local/LocalSpawnController.java | 3 - .../local/LocalSpawnControllerSystem.java | 2 +- .../spawning/local/LocalSpawnState.java | 3 - .../spawning/managers/BeaconSpawnManager.java | 3 - .../spawning/managers/SpawnManager.java | 3 - .../spawnmarkers/SpawnMarkerEntity.java | 277 +++---- .../spawnmarkers/SpawnMarkerSystems.java | 249 ++++--- .../suppression/SuppressionSpanHelper.java | 6 - .../component/ChunkSuppressionQueue.java | 3 - .../component/SpawnSuppressionController.java | 3 - .../system/ChunkSuppressionSystems.java | 3 - .../system/SpawnSuppressionSystems.java | 6 - .../server/spawning/util/ChunkColumnMask.java | 3 - .../FloodFillEntryPoolProviderSimple.java | 3 - .../util/FloodFillEntryPoolSimple.java | 3 - .../util/FloodFillPositionSelector.java | 6 - .../spawning/util/LightRangePredicate.java | 3 - .../world/ChunkEnvironmentSpawnData.java | 3 - .../world/component/ChunkSpawnData.java | 3 - .../world/component/ChunkSpawnedNPCData.java | 3 - .../world/component/WorldSpawnData.java | 3 - .../world/system/ChunkSpawningSystems.java | 3 - .../world/system/WorldSpawnJobSystems.java | 6 - .../worldgen/HytaleWorldGenProvider.java | 3 - .../server/worldgen/SeedStringResource.java | 11 + .../benchmark/ChunkWorldgenBenchmark.java | 3 - .../worldgen/biome/BiomeInterpolation.java | 3 - .../cache/InterpolatedBiomeCountList.java | 3 - .../worldgen/cave/CaveBiomeMaskFlags.java | 6 - .../cave/CaveBlockPriorityModifier.java | 3 - .../server/worldgen/cave/CaveYawMode.java | 3 - .../cave/shape/AbstractCaveNodeShape.java | 5 +- .../cave/shape/CaveNodeShapeEnum.java | 3 - .../cave/shape/CaveNodeShapeUtils.java | 3 - .../cave/shape/DistortedCaveNodeShape.java | 2 +- .../cave/shape/TetrahedronCaveNodeShape.java | 3 - .../distorted/AbstractDistortedBody.java | 3 - .../distorted/DistortedCylinderShape.java | 3 - .../distorted/DistortedEllipsoidShape.java | 3 - .../shape/distorted/DistortedPipeShape.java | 3 - .../worldgen/chunk/BlockPriorityChunk.java | 3 - .../server/worldgen/chunk/ValidationUtil.java | 3 - .../chunk/populator/BlockPopulator.java | 6 - .../chunk/populator/CavePopulator.java | 3 - .../chunk/populator/PrefabPopulator.java | 3 - .../chunk/populator/WaterPopulator.java | 3 - .../server/worldgen/climate/ClimateGraph.java | 3 - .../server/worldgen/climate/ClimateNoise.java | 3 - .../worldgen/climate/ClimateSearch.java | 3 - .../server/worldgen/climate/DirectGrid.java | 3 - .../climate/util/DistanceTransform.java | 3 - .../cave/CaveNodeChildEntryJsonLoader.java | 22 +- .../loader/cave/CaveNodeTypeJsonLoader.java | 5 +- .../loader/cave/CaveNodeTypeStorage.java | 7 +- .../cave/CavePrefabConfigJsonLoader.java | 3 +- .../loader/cave/CaveTypeJsonLoader.java | 17 +- .../loader/cave/CaveTypesJsonLoader.java | 11 +- ...refabCaveNodeShapeGeneratorJsonLoader.java | 3 +- .../prefab/BlockPlacementMaskJsonLoader.java | 33 +- .../prefab/BlockPlacementMaskRegistry.java | 31 +- .../PrefabPatternGeneratorJsonLoader.java | 3 +- .../UniquePrefabConfigurationJsonLoader.java | 3 +- .../worldgen/loader/util/ColorUtil.java | 3 - .../worldgen/loader/util/FileMaskCache.java | 3 - .../worldgen/prefab/BlockPlacementMask.java | 225 ------ .../worldgen/prefab/PrefabLoadingCache.java | 3 - .../worldgen/prefab/PrefabPasteUtil.java | 13 +- .../worldgen/prefab/PrefabStoreRoot.java | 3 - .../server/worldgen/util/ArrayUtli.java | 3 - .../hytale/server/worldgen/util/LogUtil.java | 3 - .../cache/ConcurrentSizedTimeoutCache.java | 11 +- .../util/cache/SizedTimeoutCache.java | 3 - .../util/condition/BlockMaskCondition.java | 160 +++- .../condition/DefaultBlockMaskCondition.java | 25 - .../util/condition/FilteredIntCondition.java | 30 - .../util/condition/flag/FlagOperator.java | 3 - .../worldgen/zone/ZoneColorMapping.java | 3 - .../hytale/sneakythrow/SneakyThrow.java | 3 - .../hytale/storage/IndexedStorageFile.java | 3 - .../hytale/storage/IndexedStorageFile_v0.java | 3 - src/com/hypixel/hytale/unsafe/UnsafeUtil.java | 3 - src/manifests.json | 540 ++++++++++++++ 2005 files changed, 13041 insertions(+), 14378 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/.name delete mode 100644 .idea/AndroidProjectSystem.xml delete mode 100644 .idea/gradle.xml delete mode 100644 .idea/misc.xml delete mode 100644 gradle/wrapper/gradle-wrapper.jar delete mode 100644 gradle/wrapper/gradle-wrapper.properties delete mode 100644 gradlew delete mode 100644 gradlew.bat create mode 100644 src/com/hypixel/hytale/builtin/adventure/memories/commands/MemoriesSetCountCommand.java create mode 100644 src/com/hypixel/hytale/builtin/adventure/memories/page/MemoriesUnlockedPage.java create mode 100644 src/com/hypixel/hytale/builtin/adventure/memories/page/MemoriesUnlockedPageSuplier.java create mode 100644 src/com/hypixel/hytale/builtin/buildertools/utils/PasteToolUtil.java rename src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/{VerticalEliminatorPositionProviderAsset.java => SimpleHorizontalPositionProviderAsset.java} (55%) create mode 100644 src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/OffsetPropAsset.java create mode 100644 src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/WeightedPropAsset.java rename src/com/hypixel/hytale/builtin/hytalegenerator/positionproviders/{VerticalEliminatorPositionProvider.java => SimpleHorizontalPositionProvider.java} (59%) create mode 100644 src/com/hypixel/hytale/builtin/hytalegenerator/props/OffsetProp.java create mode 100644 src/com/hypixel/hytale/builtin/hytalegenerator/props/WeightedProp.java delete mode 100644 src/com/hypixel/hytale/protocol/RefillContainerInteraction.java create mode 100644 src/com/hypixel/hytale/server/core/auth/ProfileServiceClient.java rename src/com/hypixel/hytale/server/core/command/commands/utility/git/{UpdateCommand.java => GitCommand.java} (65%) create mode 100644 src/com/hypixel/hytale/server/core/modules/entity/teleport/TeleportRecord.java create mode 100644 src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/RunOnBlockTypesInteraction.java create mode 100644 src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/MapMarkerTracker.java delete mode 100644 src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/PlayerIconMarkerProvider.java rename src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/{ => providers}/DeathMarkerProvider.java (76%) rename src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/{ => providers}/POIMarkerProvider.java (71%) rename src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/{PlayerMarkersProvider.java => providers/PerWorldDataMarkerProvider.java} (62%) create mode 100644 src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/providers/PlayerIconMarkerProvider.java rename src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/{ => providers}/RespawnMarkerProvider.java (76%) rename src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/{ => providers}/SpawnMarkerProvider.java (78%) create mode 100644 src/com/hypixel/hytale/server/core/update/UpdateModule.java create mode 100644 src/com/hypixel/hytale/server/core/update/UpdateService.java create mode 100644 src/com/hypixel/hytale/server/core/update/command/UpdateApplyCommand.java create mode 100644 src/com/hypixel/hytale/server/core/update/command/UpdateCancelCommand.java create mode 100644 src/com/hypixel/hytale/server/core/update/command/UpdateCheckCommand.java create mode 100644 src/com/hypixel/hytale/server/core/update/command/UpdateCommand.java create mode 100644 src/com/hypixel/hytale/server/core/update/command/UpdateDownloadCommand.java create mode 100644 src/com/hypixel/hytale/server/core/update/command/UpdatePatchlineCommand.java create mode 100644 src/com/hypixel/hytale/server/core/update/command/UpdateStatusCommand.java delete mode 100644 src/com/hypixel/hytale/server/core/util/AuthUtil.java delete mode 100644 src/com/hypixel/hytale/server/worldgen/prefab/BlockPlacementMask.java delete mode 100644 src/com/hypixel/hytale/server/worldgen/util/condition/DefaultBlockMaskCondition.java delete mode 100644 src/com/hypixel/hytale/server/worldgen/util/condition/FilteredIntCondition.java create mode 100644 src/manifests.json diff --git a/.gitignore b/.gitignore index 1fac4d5..625ddc5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,7 @@ -.gradle build/ -!gradle/wrapper/gradle-wrapper.jar -!**/src/main/**/build/ -!**/src/test/**/build/ +bin/ .kotlin +.idea ### IntelliJ IDEA ### .idea/modules.xml @@ -17,27 +15,8 @@ out/ !**/src/main/**/out/ !**/src/test/**/out/ -### Eclipse ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache -bin/ -!**/src/main/**/bin/ -!**/src/test/**/bin/ - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ - -### VS Code ### -.vscode/ - -### Mac OS ### -.DS_Store \ No newline at end of file +# Gradle Wrapper +gradlew +gradlew.bat +.gradle +gradle \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index 4b3d693..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -Hytale-Server \ No newline at end of file diff --git a/.idea/AndroidProjectSystem.xml b/.idea/AndroidProjectSystem.xml deleted file mode 100644 index 4a53bee..0000000 --- a/.idea/AndroidProjectSystem.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml deleted file mode 100644 index 14746e7..0000000 --- a/.idea/gradle.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 32cf4db..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/_decomp/decomp.ps1 b/_decomp/decomp.ps1 index e69de29..439a98f 100644 --- a/_decomp/decomp.ps1 +++ b/_decomp/decomp.ps1 @@ -0,0 +1,23 @@ +$ErrorActionPreference = "Stop" + +# Move to the git root if we arn't already there +git rev-parse --show-toplevel | Set-Location + +# get the server jar from the install directory ( in future support pre-release ) +$server_jar = resolve-path "$env:APPDATA/Hytale/install/release/package/game/latest/Server/HytaleServer.jar" + +# clear the source directory +Get-ChildItem -Path "src" | Remove-Item -Recurse -Force -Confirm:$false + +# Decompile hytale +java -jar "_decomp/vineflower-1.11.2-slim.jar" --only="com/hypixel" $server_jar "./src" + +# Extract the version before deleting the meta inf file +$version = (Get-Content "src/META-INF/MANIFEST.MF" | Select-String "^Implementation-Version:\s*(.+)$").Matches.Groups[1].Value + +# delete anything not in com hypixel +Get-ChildItem "src/" -Exclude @("com", "manifests.json") | Remove-Item -Recurse -Force -Confirm:$false +Get-ChildItem "src/com/" -Exclude @("hypixel") | Remove-Item -Recurse -Force -Confirm:$false + +git add "./src" +git commit -am "$version" diff --git a/build.gradle.kts b/build.gradle.kts index 94004fc..b38a154 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,5 @@ +import org.apache.tools.ant.taskdefs.condition.Os + plugins { id("java") } @@ -10,9 +12,14 @@ repositories { } dependencies { - testImplementation(platform("org.junit:junit-bom:5.10.0")) - testImplementation("org.junit.jupiter:junit-jupiter") - testRuntimeOnly("org.junit.platform:junit-platform-launcher") + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + implementation(files("${System.getenv("APPDATA")}/Hytale/install/release/package/game/latest/Server/HytaleServer.jar")) + } +} + +tasks.wrapper { + gradleVersion = "8.14" + distributionType = Wrapper.DistributionType.ALL } sourceSets { diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 249e5832f090a2944b7473328c07c9755baa3196..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 60756 zcmb5WV{~QRw(p$^Dz@00IL3?^hro$gg*4VI_WAaTyVM5Foj~O|-84 z$;06hMwt*rV;^8iB z1~&0XWpYJmG?Ts^K9PC62H*`G}xom%S%yq|xvG~FIfP=9*f zZoDRJBm*Y0aId=qJ?7dyb)6)JGWGwe)MHeNSzhi)Ko6J<-m@v=a%NsP537lHe0R* z`If4$aaBA#S=w!2z&m>{lpTy^Lm^mg*3?M&7HFv}7K6x*cukLIGX;bQG|QWdn{%_6 zHnwBKr84#B7Z+AnBXa16a?or^R?+>$4`}{*a_>IhbjvyTtWkHw)|ay)ahWUd-qq$~ zMbh6roVsj;_qnC-R{G+Cy6bApVOinSU-;(DxUEl!i2)1EeQ9`hrfqj(nKI7?Z>Xur zoJz-a`PxkYit1HEbv|jy%~DO^13J-ut986EEG=66S}D3!L}Efp;Bez~7tNq{QsUMm zh9~(HYg1pA*=37C0}n4g&bFbQ+?-h-W}onYeE{q;cIy%eZK9wZjSwGvT+&Cgv z?~{9p(;bY_1+k|wkt_|N!@J~aoY@|U_RGoWX<;p{Nu*D*&_phw`8jYkMNpRTWx1H* z>J-Mi_!`M468#5Aix$$u1M@rJEIOc?k^QBc?T(#=n&*5eS#u*Y)?L8Ha$9wRWdH^3D4|Ps)Y?m0q~SiKiSfEkJ!=^`lJ(%W3o|CZ zSrZL-Xxc{OrmsQD&s~zPfNJOpSZUl%V8tdG%ei}lQkM+z@-4etFPR>GOH9+Y_F<3=~SXln9Kb-o~f>2a6Xz@AS3cn^;c_>lUwlK(n>z?A>NbC z`Ud8^aQy>wy=$)w;JZzA)_*Y$Z5hU=KAG&htLw1Uh00yE!|Nu{EZkch zY9O6x7Y??>!7pUNME*d!=R#s)ghr|R#41l!c?~=3CS8&zr6*aA7n9*)*PWBV2w+&I zpW1-9fr3j{VTcls1>ua}F*bbju_Xq%^v;-W~paSqlf zolj*dt`BBjHI)H9{zrkBo=B%>8}4jeBO~kWqO!~Thi!I1H(in=n^fS%nuL=X2+s!p}HfTU#NBGiwEBF^^tKU zbhhv+0dE-sbK$>J#t-J!B$TMgN@Wh5wTtK2BG}4BGfsZOoRUS#G8Cxv|6EI*n&Xxq zt{&OxCC+BNqz$9b0WM7_PyBJEVObHFh%%`~!@MNZlo*oXDCwDcFwT~Rls!aApL<)^ zbBftGKKBRhB!{?fX@l2_y~%ygNFfF(XJzHh#?`WlSL{1lKT*gJM zs>bd^H9NCxqxn(IOky5k-wALFowQr(gw%|`0991u#9jXQh?4l|l>pd6a&rx|v=fPJ z1mutj{YzpJ_gsClbWFk(G}bSlFi-6@mwoQh-XeD*j@~huW4(8ub%^I|azA)h2t#yG z7e_V_<4jlM3D(I+qX}yEtqj)cpzN*oCdYHa!nm%0t^wHm)EmFP*|FMw!tb@&`G-u~ zK)=Sf6z+BiTAI}}i{*_Ac$ffr*Wrv$F7_0gJkjx;@)XjYSh`RjAgrCck`x!zP>Ifu z&%he4P|S)H*(9oB4uvH67^0}I-_ye_!w)u3v2+EY>eD3#8QR24<;7?*hj8k~rS)~7 zSXs5ww)T(0eHSp$hEIBnW|Iun<_i`}VE0Nc$|-R}wlSIs5pV{g_Dar(Zz<4X3`W?K z6&CAIl4U(Qk-tTcK{|zYF6QG5ArrEB!;5s?tW7 zrE3hcFY&k)+)e{+YOJ0X2uDE_hd2{|m_dC}kgEKqiE9Q^A-+>2UonB+L@v3$9?AYw zVQv?X*pK;X4Ovc6Ev5Gbg{{Eu*7{N3#0@9oMI~}KnObQE#Y{&3mM4`w%wN+xrKYgD zB-ay0Q}m{QI;iY`s1Z^NqIkjrTlf`B)B#MajZ#9u41oRBC1oM1vq0i|F59> z#StM@bHt|#`2)cpl_rWB($DNJ3Lap}QM-+A$3pe}NyP(@+i1>o^fe-oxX#Bt`mcQc zb?pD4W%#ep|3%CHAYnr*^M6Czg>~L4?l16H1OozM{P*en298b+`i4$|w$|4AHbzqB zHpYUsHZET$Z0ztC;U+0*+amF!@PI%^oUIZy{`L{%O^i{Xk}X0&nl)n~tVEpcAJSJ} zverw15zP1P-O8h9nd!&hj$zuwjg?DoxYIw{jWM zW5_pj+wFy8Tsa9g<7Qa21WaV&;ejoYflRKcz?#fSH_)@*QVlN2l4(QNk| z4aPnv&mrS&0|6NHq05XQw$J^RR9T{3SOcMKCXIR1iSf+xJ0E_Wv?jEc*I#ZPzyJN2 zUG0UOXHl+PikM*&g$U@g+KbG-RY>uaIl&DEtw_Q=FYq?etc!;hEC_}UX{eyh%dw2V zTTSlap&5>PY{6I#(6`j-9`D&I#|YPP8a;(sOzgeKDWsLa!i-$frD>zr-oid!Hf&yS z!i^cr&7tN}OOGmX2)`8k?Tn!!4=tz~3hCTq_9CdiV!NIblUDxHh(FJ$zs)B2(t5@u z-`^RA1ShrLCkg0)OhfoM;4Z{&oZmAec$qV@ zGQ(7(!CBk<5;Ar%DLJ0p0!ResC#U<+3i<|vib1?{5gCebG7$F7URKZXuX-2WgF>YJ^i zMhHDBsh9PDU8dlZ$yJKtc6JA#y!y$57%sE>4Nt+wF1lfNIWyA`=hF=9Gj%sRwi@vd z%2eVV3y&dvAgyuJ=eNJR+*080dbO_t@BFJO<@&#yqTK&+xc|FRR;p;KVk@J3$S{p` zGaMj6isho#%m)?pOG^G0mzOAw0z?!AEMsv=0T>WWcE>??WS=fII$t$(^PDPMU(P>o z_*0s^W#|x)%tx8jIgZY~A2yG;US0m2ZOQt6yJqW@XNY_>_R7(Nxb8Ged6BdYW6{prd!|zuX$@Q2o6Ona8zzYC1u!+2!Y$Jc9a;wy+pXt}o6~Bu1oF1c zp7Y|SBTNi@=I(K%A60PMjM#sfH$y*c{xUgeSpi#HB`?|`!Tb&-qJ3;vxS!TIzuTZs-&%#bAkAyw9m4PJgvey zM5?up*b}eDEY+#@tKec)-c(#QF0P?MRlD1+7%Yk*jW;)`f;0a-ZJ6CQA?E%>i2Dt7T9?s|9ZF|KP4;CNWvaVKZ+Qeut;Jith_y{v*Ny6Co6!8MZx;Wgo z=qAi%&S;8J{iyD&>3CLCQdTX*$+Rx1AwA*D_J^0>suTgBMBb=*hefV+Ars#mmr+YsI3#!F@Xc1t4F-gB@6aoyT+5O(qMz*zG<9Qq*f0w^V!03rpr*-WLH}; zfM{xSPJeu6D(%8HU%0GEa%waFHE$G?FH^kMS-&I3)ycx|iv{T6Wx}9$$D&6{%1N_8 z_CLw)_9+O4&u94##vI9b-HHm_95m)fa??q07`DniVjAy`t7;)4NpeyAY(aAk(+T_O z1om+b5K2g_B&b2DCTK<>SE$Ode1DopAi)xaJjU>**AJK3hZrnhEQ9E`2=|HHe<^tv z63e(bn#fMWuz>4erc47}!J>U58%<&N<6AOAewyzNTqi7hJc|X{782&cM zHZYclNbBwU6673=!ClmxMfkC$(CykGR@10F!zN1Se83LR&a~$Ht&>~43OX22mt7tcZUpa;9@q}KDX3O&Ugp6< zLZLfIMO5;pTee1vNyVC$FGxzK2f>0Z-6hM82zKg44nWo|n}$Zk6&;5ry3`(JFEX$q zK&KivAe${e^5ZGc3a9hOt|!UOE&OocpVryE$Y4sPcs4rJ>>Kbi2_subQ9($2VN(3o zb~tEzMsHaBmBtaHAyES+d3A(qURgiskSSwUc9CfJ@99&MKp2sooSYZu+-0t0+L*!I zYagjOlPgx|lep9tiU%ts&McF6b0VE57%E0Ho%2oi?=Ks+5%aj#au^OBwNwhec zta6QAeQI^V!dF1C)>RHAmB`HnxyqWx?td@4sd15zPd*Fc9hpDXP23kbBenBxGeD$k z;%0VBQEJ-C)&dTAw_yW@k0u?IUk*NrkJ)(XEeI z9Y>6Vel>#s_v@=@0<{4A{pl=9cQ&Iah0iD0H`q)7NeCIRz8zx;! z^OO;1+IqoQNak&pV`qKW+K0^Hqp!~gSohcyS)?^P`JNZXw@gc6{A3OLZ?@1Uc^I2v z+X!^R*HCm3{7JPq{8*Tn>5;B|X7n4QQ0Bs79uTU%nbqOJh`nX(BVj!#f;#J+WZxx4 z_yM&1Y`2XzhfqkIMO7tB3raJKQS+H5F%o83bM+hxbQ zeeJm=Dvix$2j|b4?mDacb67v-1^lTp${z=jc1=j~QD>7c*@+1?py>%Kj%Ejp7Y-!? z8iYRUlGVrQPandAaxFfks53@2EC#0)%mrnmGRn&>=$H$S8q|kE_iWko4`^vCS2aWg z#!`RHUGyOt*k?bBYu3*j3u0gB#v(3tsije zgIuNNWNtrOkx@Pzs;A9un+2LX!zw+p3_NX^Sh09HZAf>m8l@O*rXy_82aWT$Q>iyy zqO7Of)D=wcSn!0+467&!Hl))eff=$aneB?R!YykdKW@k^_uR!+Q1tR)+IJb`-6=jj zymzA>Sv4>Z&g&WWu#|~GcP7qP&m*w-S$)7Xr;(duqCTe7p8H3k5>Y-n8438+%^9~K z3r^LIT_K{i7DgEJjIocw_6d0!<;wKT`X;&vv+&msmhAAnIe!OTdybPctzcEzBy88_ zWO{6i4YT%e4^WQZB)KHCvA(0tS zHu_Bg+6Ko%a9~$EjRB90`P(2~6uI@SFibxct{H#o&y40MdiXblu@VFXbhz>Nko;7R z70Ntmm-FePqhb%9gL+7U8@(ch|JfH5Fm)5${8|`Lef>LttM_iww6LW2X61ldBmG0z zax3y)njFe>j*T{i0s8D4=L>X^j0)({R5lMGVS#7(2C9@AxL&C-lZQx~czI7Iv+{%1 z2hEG>RzX4S8x3v#9sgGAnPzptM)g&LB}@%E>fy0vGSa(&q0ch|=ncKjNrK z`jA~jObJhrJ^ri|-)J^HUyeZXz~XkBp$VhcTEcTdc#a2EUOGVX?@mYx#Vy*!qO$Jv zQ4rgOJ~M*o-_Wptam=~krnmG*p^j!JAqoQ%+YsDFW7Cc9M%YPiBOrVcD^RY>m9Pd< zu}#9M?K{+;UIO!D9qOpq9yxUquQRmQNMo0pT`@$pVt=rMvyX)ph(-CCJLvUJy71DI zBk7oc7)-%ngdj~s@76Yse3L^gV0 z2==qfp&Q~L(+%RHP0n}+xH#k(hPRx(!AdBM$JCfJ5*C=K3ts>P?@@SZ_+{U2qFZb>4kZ{Go37{# zSQc+-dq*a-Vy4?taS&{Ht|MLRiS)Sn14JOONyXqPNnpq&2y~)6wEG0oNy>qvod$FF z`9o&?&6uZjhZ4_*5qWVrEfu(>_n2Xi2{@Gz9MZ8!YmjYvIMasE9yVQL10NBrTCczq zcTY1q^PF2l!Eraguf{+PtHV3=2A?Cu&NN&a8V(y;q(^_mFc6)%Yfn&X&~Pq zU1?qCj^LF(EQB1F`8NxNjyV%fde}dEa(Hx=r7$~ts2dzDwyi6ByBAIx$NllB4%K=O z$AHz1<2bTUb>(MCVPpK(E9wlLElo(aSd(Os)^Raum`d(g9Vd_+Bf&V;l=@mM=cC>) z)9b0enb)u_7V!!E_bl>u5nf&Rl|2r=2F3rHMdb7y9E}}F82^$Rf+P8%dKnOeKh1vs zhH^P*4Ydr^$)$h@4KVzxrHyy#cKmWEa9P5DJ|- zG;!Qi35Tp7XNj60=$!S6U#!(${6hyh7d4q=pF{`0t|N^|L^d8pD{O9@tF~W;#Je*P z&ah%W!KOIN;SyAEhAeTafJ4uEL`(RtnovM+cb(O#>xQnk?dzAjG^~4$dFn^<@-Na3 z395;wBnS{t*H;Jef2eE!2}u5Ns{AHj>WYZDgQJt8v%x?9{MXqJsGP|l%OiZqQ1aB! z%E=*Ig`(!tHh>}4_z5IMpg{49UvD*Pp9!pxt_gdAW%sIf3k6CTycOT1McPl=_#0?8 zVjz8Hj*Vy9c5-krd-{BQ{6Xy|P$6LJvMuX$* zA+@I_66_ET5l2&gk9n4$1M3LN8(yEViRx&mtd#LD}AqEs?RW=xKC(OCWH;~>(X6h!uDxXIPH06xh z*`F4cVlbDP`A)-fzf>MuScYsmq&1LUMGaQ3bRm6i7OsJ|%uhTDT zlvZA1M}nz*SalJWNT|`dBm1$xlaA>CCiQ zK`xD-RuEn>-`Z?M{1%@wewf#8?F|(@1e0+T4>nmlSRrNK5f)BJ2H*$q(H>zGD0>eL zQ!tl_Wk)k*e6v^m*{~A;@6+JGeWU-q9>?+L_#UNT%G?4&BnOgvm9@o7l?ov~XL+et zbGT)|G7)KAeqb=wHSPk+J1bdg7N3$vp(ekjI1D9V$G5Cj!=R2w=3*4!z*J-r-cyeb zd(i2KmX!|Lhey!snRw z?#$Gu%S^SQEKt&kep)up#j&9}e+3=JJBS(s>MH+|=R(`8xK{mmndWo_r`-w1#SeRD&YtAJ#GiVI*TkQZ}&aq<+bU2+coU3!jCI6E+Ad_xFW*ghnZ$q zAoF*i&3n1j#?B8x;kjSJD${1jdRB;)R*)Ao!9bd|C7{;iqDo|T&>KSh6*hCD!rwv= zyK#F@2+cv3=|S1Kef(E6Niv8kyLVLX&e=U;{0x{$tDfShqkjUME>f8d(5nzSkY6@! z^-0>DM)wa&%m#UF1F?zR`8Y3X#tA!*7Q$P3lZJ%*KNlrk_uaPkxw~ zxZ1qlE;Zo;nb@!SMazSjM>;34ROOoygo%SF);LL>rRonWwR>bmSd1XD^~sGSu$Gg# zFZ`|yKU0%!v07dz^v(tY%;So(e`o{ZYTX`hm;@b0%8|H>VW`*cr8R%3n|ehw2`(9B+V72`>SY}9^8oh$En80mZK9T4abVG*to;E z1_S6bgDOW?!Oy1LwYy=w3q~KKdbNtyH#d24PFjX)KYMY93{3-mPP-H>@M-_>N~DDu zENh~reh?JBAK=TFN-SfDfT^=+{w4ea2KNWXq2Y<;?(gf(FgVp8Zp-oEjKzB%2Iqj;48GmY3h=bcdYJ}~&4tS`Q1sb=^emaW$IC$|R+r-8V- zf0$gGE(CS_n4s>oicVk)MfvVg#I>iDvf~Ov8bk}sSxluG!6#^Z_zhB&U^`eIi1@j( z^CK$z^stBHtaDDHxn+R;3u+>Lil^}fj?7eaGB z&5nl^STqcaBxI@v>%zG|j))G(rVa4aY=B@^2{TFkW~YP!8!9TG#(-nOf^^X-%m9{Z zCC?iC`G-^RcBSCuk=Z`(FaUUe?hf3{0C>>$?Vs z`2Uud9M+T&KB6o4o9kvdi^Q=Bw!asPdxbe#W-Oaa#_NP(qpyF@bVxv5D5))srkU#m zj_KA+#7sqDn*Ipf!F5Byco4HOSd!Ui$l94|IbW%Ny(s1>f4|Mv^#NfB31N~kya9!k zWCGL-$0ZQztBate^fd>R!hXY_N9ZjYp3V~4_V z#eB)Kjr8yW=+oG)BuNdZG?jaZlw+l_ma8aET(s+-x+=F-t#Qoiuu1i`^x8Sj>b^U} zs^z<()YMFP7CmjUC@M=&lA5W7t&cxTlzJAts*%PBDAPuqcV5o7HEnqjif_7xGt)F% zGx2b4w{@!tE)$p=l3&?Bf#`+!-RLOleeRk3 z7#pF|w@6_sBmn1nECqdunmG^}pr5(ZJQVvAt$6p3H(16~;vO>?sTE`Y+mq5YP&PBo zvq!7#W$Gewy`;%6o^!Dtjz~x)T}Bdk*BS#=EY=ODD&B=V6TD2z^hj1m5^d6s)D*wk zu$z~D7QuZ2b?5`p)E8e2_L38v3WE{V`bVk;6fl#o2`) z99JsWhh?$oVRn@$S#)uK&8DL8>An0&S<%V8hnGD7Z^;Y(%6;^9!7kDQ5bjR_V+~wp zfx4m3z6CWmmZ<8gDGUyg3>t8wgJ5NkkiEm^(sedCicP^&3D%}6LtIUq>mXCAt{9eF zNXL$kGcoUTf_Lhm`t;hD-SE)m=iBnxRU(NyL}f6~1uH)`K!hmYZjLI%H}AmEF5RZt z06$wn63GHnApHXZZJ}s^s)j9(BM6e*7IBK6Bq(!)d~zR#rbxK9NVIlgquoMq z=eGZ9NR!SEqP6=9UQg#@!rtbbSBUM#ynF);zKX+|!Zm}*{H z+j=d?aZ2!?@EL7C~%B?6ouCKLnO$uWn;Y6Xz zX8dSwj732u(o*U3F$F=7xwxm>E-B+SVZH;O-4XPuPkLSt_?S0)lb7EEg)Mglk0#eS z9@jl(OnH4juMxY+*r03VDfPx_IM!Lmc(5hOI;`?d37f>jPP$?9jQQIQU@i4vuG6MagEoJrQ=RD7xt@8E;c zeGV*+Pt+t$@pt!|McETOE$9k=_C!70uhwRS9X#b%ZK z%q(TIUXSS^F0`4Cx?Rk07C6wI4!UVPeI~-fxY6`YH$kABdOuiRtl73MqG|~AzZ@iL&^s?24iS;RK_pdlWkhcF z@Wv-Om(Aealfg)D^adlXh9Nvf~Uf@y;g3Y)i(YP zEXDnb1V}1pJT5ZWyw=1i+0fni9yINurD=EqH^ciOwLUGi)C%Da)tyt=zq2P7pV5-G zR7!oq28-Fgn5pW|nlu^b!S1Z#r7!Wtr{5J5PQ>pd+2P7RSD?>(U7-|Y z7ZQ5lhYIl_IF<9?T9^IPK<(Hp;l5bl5tF9>X-zG14_7PfsA>6<$~A338iYRT{a@r_ zuXBaT=`T5x3=s&3=RYx6NgG>No4?5KFBVjE(swfcivcIpPQFx5l+O;fiGsOrl5teR z_Cm+;PW}O0Dwe_(4Z@XZ)O0W-v2X><&L*<~*q3dg;bQW3g7)a#3KiQP>+qj|qo*Hk z?57>f2?f@`=Fj^nkDKeRkN2d$Z@2eNKpHo}ksj-$`QKb6n?*$^*%Fb3_Kbf1(*W9K>{L$mud2WHJ=j0^=g30Xhg8$#g^?36`p1fm;;1@0Lrx+8t`?vN0ZorM zSW?rhjCE8$C|@p^sXdx z|NOHHg+fL;HIlqyLp~SSdIF`TnSHehNCU9t89yr@)FY<~hu+X`tjg(aSVae$wDG*C zq$nY(Y494R)hD!i1|IIyP*&PD_c2FPgeY)&mX1qujB1VHPG9`yFQpLFVQ0>EKS@Bp zAfP5`C(sWGLI?AC{XEjLKR4FVNw(4+9b?kba95ukgR1H?w<8F7)G+6&(zUhIE5Ef% z=fFkL3QKA~M@h{nzjRq!Y_t!%U66#L8!(2-GgFxkD1=JRRqk=n%G(yHKn%^&$dW>; zSjAcjETMz1%205se$iH_)ZCpfg_LwvnsZQAUCS#^FExp8O4CrJb6>JquNV@qPq~3A zZ<6dOU#6|8+fcgiA#~MDmcpIEaUO02L5#T$HV0$EMD94HT_eXLZ2Zi&(! z&5E>%&|FZ`)CN10tM%tLSPD*~r#--K(H-CZqIOb99_;m|D5wdgJ<1iOJz@h2Zkq?} z%8_KXb&hf=2Wza(Wgc;3v3TN*;HTU*q2?#z&tLn_U0Nt!y>Oo>+2T)He6%XuP;fgn z-G!#h$Y2`9>Jtf}hbVrm6D70|ERzLAU>3zoWhJmjWfgM^))T+2u$~5>HF9jQDkrXR z=IzX36)V75PrFjkQ%TO+iqKGCQ-DDXbaE;C#}!-CoWQx&v*vHfyI>$HNRbpvm<`O( zlx9NBWD6_e&J%Ous4yp~s6)Ghni!I6)0W;9(9$y1wWu`$gs<$9Mcf$L*piP zPR0Av*2%ul`W;?-1_-5Zy0~}?`e@Y5A&0H!^ApyVTT}BiOm4GeFo$_oPlDEyeGBbh z1h3q&Dx~GmUS|3@4V36&$2uO8!Yp&^pD7J5&TN{?xphf*-js1fP?B|`>p_K>lh{ij zP(?H%e}AIP?_i^f&Li=FDSQ`2_NWxL+BB=nQr=$ zHojMlXNGauvvwPU>ZLq!`bX-5F4jBJ&So{kE5+ms9UEYD{66!|k~3vsP+mE}x!>%P za98bAU0!h0&ka4EoiDvBM#CP#dRNdXJcb*(%=<(g+M@<)DZ!@v1V>;54En?igcHR2 zhubQMq}VSOK)onqHfczM7YA@s=9*ow;k;8)&?J3@0JiGcP! zP#00KZ1t)GyZeRJ=f0^gc+58lc4Qh*S7RqPIC6GugG1gXe$LIQMRCo8cHf^qXgAa2 z`}t>u2Cq1CbSEpLr~E=c7~=Qkc9-vLE%(v9N*&HF`(d~(0`iukl5aQ9u4rUvc8%m) zr2GwZN4!s;{SB87lJB;veebPmqE}tSpT>+`t?<457Q9iV$th%i__Z1kOMAswFldD6 ztbOvO337S5o#ZZgN2G99_AVqPv!?Gmt3pzgD+Hp3QPQ`9qJ(g=kjvD+fUSS3upJn! zqoG7acIKEFRX~S}3|{EWT$kdz#zrDlJU(rPkxjws_iyLKU8+v|*oS_W*-guAb&Pj1 z35Z`3z<&Jb@2Mwz=KXucNYdY#SNO$tcVFr9KdKm|%^e-TXzs6M`PBper%ajkrIyUe zp$vVxVs9*>Vp4_1NC~Zg)WOCPmOxI1V34QlG4!aSFOH{QqSVq1^1)- z0P!Z?tT&E-ll(pwf0?=F=yOzik=@nh1Clxr9}Vij89z)ePDSCYAqw?lVI?v?+&*zH z)p$CScFI8rrwId~`}9YWPFu0cW1Sf@vRELs&cbntRU6QfPK-SO*mqu|u~}8AJ!Q$z znzu}50O=YbjwKCuSVBs6&CZR#0FTu)3{}qJJYX(>QPr4$RqWiwX3NT~;>cLn*_&1H zaKpIW)JVJ>b{uo2oq>oQt3y=zJjb%fU@wLqM{SyaC6x2snMx-}ivfU<1- znu1Lh;i$3Tf$Kh5Uk))G!D1UhE8pvx&nO~w^fG)BC&L!_hQk%^p`Kp@F{cz>80W&T ziOK=Sq3fdRu*V0=S53rcIfWFazI}Twj63CG(jOB;$*b`*#B9uEnBM`hDk*EwSRdwP8?5T?xGUKs=5N83XsR*)a4|ijz|c{4tIU+4j^A5C<#5 z*$c_d=5ml~%pGxw#?*q9N7aRwPux5EyqHVkdJO=5J>84!X6P>DS8PTTz>7C#FO?k#edkntG+fJk8ZMn?pmJSO@`x-QHq;7^h6GEXLXo1TCNhH z8ZDH{*NLAjo3WM`xeb=X{((uv3H(8&r8fJJg_uSs_%hOH%JDD?hu*2NvWGYD+j)&` zz#_1%O1wF^o5ryt?O0n;`lHbzp0wQ?rcbW(F1+h7_EZZ9{>rePvLAPVZ_R|n@;b$;UchU=0j<6k8G9QuQf@76oiE*4 zXOLQ&n3$NR#p4<5NJMVC*S);5x2)eRbaAM%VxWu9ohlT;pGEk7;002enCbQ>2r-us z3#bpXP9g|mE`65VrN`+3mC)M(eMj~~eOf)do<@l+fMiTR)XO}422*1SL{wyY(%oMpBgJagtiDf zz>O6(m;};>Hi=t8o{DVC@YigqS(Qh+ix3Rwa9aliH}a}IlOCW1@?%h_bRbq-W{KHF z%Vo?-j@{Xi@=~Lz5uZP27==UGE15|g^0gzD|3x)SCEXrx`*MP^FDLl%pOi~~Il;dc z^hrwp9sYeT7iZ)-ajKy@{a`kr0-5*_!XfBpXwEcFGJ;%kV$0Nx;apKrur zJN2J~CAv{Zjj%FolyurtW8RaFmpn&zKJWL>(0;;+q(%(Hx!GMW4AcfP0YJ*Vz!F4g z!ZhMyj$BdXL@MlF%KeInmPCt~9&A!;cRw)W!Hi@0DY(GD_f?jeV{=s=cJ6e}JktJw zQORnxxj3mBxfrH=x{`_^Z1ddDh}L#V7i}$njUFRVwOX?qOTKjfPMBO4y(WiU<)epb zvB9L=%jW#*SL|Nd_G?E*_h1^M-$PG6Pc_&QqF0O-FIOpa4)PAEPsyvB)GKasmBoEt z?_Q2~QCYGH+hW31x-B=@5_AN870vY#KB~3a*&{I=f);3Kv7q4Q7s)0)gVYx2#Iz9g(F2;=+Iy4 z6KI^8GJ6D@%tpS^8boU}zpi=+(5GfIR)35PzrbuXeL1Y1N%JK7PG|^2k3qIqHfX;G zQ}~JZ-UWx|60P5?d1e;AHx!_;#PG%d=^X(AR%i`l0jSpYOpXoKFW~7ip7|xvN;2^? zsYC9fanpO7rO=V7+KXqVc;Q5z%Bj})xHVrgoR04sA2 zl~DAwv=!(()DvH*=lyhIlU^hBkA0$e*7&fJpB0|oB7)rqGK#5##2T`@_I^|O2x4GO z;xh6ROcV<9>?e0)MI(y++$-ksV;G;Xe`lh76T#Htuia+(UrIXrf9?

L(tZ$0BqX1>24?V$S+&kLZ`AodQ4_)P#Q3*4xg8}lMV-FLwC*cN$< zt65Rf%7z41u^i=P*qO8>JqXPrinQFapR7qHAtp~&RZ85$>ob|Js;GS^y;S{XnGiBc zGa4IGvDl?x%gY`vNhv8wgZnP#UYI-w*^4YCZnxkF85@ldepk$&$#3EAhrJY0U)lR{F6sM3SONV^+$;Zx8BD&Eku3K zKNLZyBni3)pGzU0;n(X@1fX8wYGKYMpLmCu{N5-}epPDxClPFK#A@02WM3!myN%bkF z|GJ4GZ}3sL{3{qXemy+#Uk{4>Kf8v11;f8I&c76+B&AQ8udd<8gU7+BeWC`akUU~U zgXoxie>MS@rBoyY8O8Tc&8id!w+_ooxcr!1?#rc$-|SBBtH6S?)1e#P#S?jFZ8u-Bs&k`yLqW|{j+%c#A4AQ>+tj$Y z^CZajspu$F%73E68Lw5q7IVREED9r1Ijsg#@DzH>wKseye>hjsk^{n0g?3+gs@7`i zHx+-!sjLx^fS;fY!ERBU+Q zVJ!e0hJH%P)z!y%1^ZyG0>PN@5W~SV%f>}c?$H8r;Sy-ui>aruVTY=bHe}$e zi&Q4&XK!qT7-XjCrDaufT@>ieQ&4G(SShUob0Q>Gznep9fR783jGuUynAqc6$pYX; z7*O@@JW>O6lKIk0G00xsm|=*UVTQBB`u1f=6wGAj%nHK_;Aqmfa!eAykDmi-@u%6~ z;*c!pS1@V8r@IX9j&rW&d*}wpNs96O2Ute>%yt{yv>k!6zfT6pru{F1M3P z2WN1JDYqoTB#(`kE{H676QOoX`cnqHl1Yaru)>8Ky~VU{)r#{&s86Vz5X)v15ULHA zAZDb{99+s~qI6;-dQ5DBjHJP@GYTwn;Dv&9kE<0R!d z8tf1oq$kO`_sV(NHOSbMwr=To4r^X$`sBW4$gWUov|WY?xccQJN}1DOL|GEaD_!@& z15p?Pj+>7d`@LvNIu9*^hPN)pwcv|akvYYq)ks%`G>!+!pW{-iXPZsRp8 z35LR;DhseQKWYSD`%gO&k$Dj6_6q#vjWA}rZcWtQr=Xn*)kJ9kacA=esi*I<)1>w^ zO_+E>QvjP)qiSZg9M|GNeLtO2D7xT6vsj`88sd!94j^AqxFLi}@w9!Y*?nwWARE0P znuI_7A-saQ+%?MFA$gttMV-NAR^#tjl_e{R$N8t2NbOlX373>e7Ox=l=;y#;M7asp zRCz*CLnrm$esvSb5{T<$6CjY zmZ(i{Rs_<#pWW>(HPaaYj`%YqBra=Ey3R21O7vUbzOkJJO?V`4-D*u4$Me0Bx$K(lYo`JO}gnC zx`V}a7m-hLU9Xvb@K2ymioF)vj12<*^oAqRuG_4u%(ah?+go%$kOpfb`T96P+L$4> zQ#S+sA%VbH&mD1k5Ak7^^dZoC>`1L%i>ZXmooA!%GI)b+$D&ziKrb)a=-ds9xk#~& z7)3iem6I|r5+ZrTRe_W861x8JpD`DDIYZNm{$baw+$)X^Jtjnl0xlBgdnNY}x%5za zkQ8E6T<^$sKBPtL4(1zi_Rd(tVth*3Xs!ulflX+70?gb&jRTnI8l+*Aj9{|d%qLZ+ z>~V9Z;)`8-lds*Zgs~z1?Fg?Po7|FDl(Ce<*c^2=lFQ~ahwh6rqSjtM5+$GT>3WZW zj;u~w9xwAhOc<kF}~`CJ68 z?(S5vNJa;kriPlim33{N5`C{9?NWhzsna_~^|K2k4xz1`xcui*LXL-1#Y}Hi9`Oo!zQ>x-kgAX4LrPz63uZ+?uG*84@PKq-KgQlMNRwz=6Yes) zY}>YN+qP}nwr$(CZQFjUOI=-6J$2^XGvC~EZ+vrqWaOXB$k?%Suf5k=4>AveC1aJ! ziaW4IS%F$_Babi)kA8Y&u4F7E%99OPtm=vzw$$ zEz#9rvn`Iot_z-r3MtV>k)YvErZ<^Oa${`2>MYYODSr6?QZu+be-~MBjwPGdMvGd!b!elsdi4% z`37W*8+OGulab8YM?`KjJ8e+jM(tqLKSS@=jimq3)Ea2EB%88L8CaM+aG7;27b?5` z4zuUWBr)f)k2o&xg{iZ$IQkJ+SK>lpq4GEacu~eOW4yNFLU!Kgc{w4&D$4ecm0f}~ zTTzquRW@`f0}|IILl`!1P+;69g^upiPA6F{)U8)muWHzexRenBU$E^9X-uIY2%&1w z_=#5*(nmxJ9zF%styBwivi)?#KMG96-H@hD-H_&EZiRNsfk7mjBq{L%!E;Sqn!mVX*}kXhwH6eh;b42eD!*~upVG@ z#smUqz$ICm!Y8wY53gJeS|Iuard0=;k5i5Z_hSIs6tr)R4n*r*rE`>38Pw&lkv{_r!jNN=;#?WbMj|l>cU(9trCq; z%nN~r^y7!kH^GPOf3R}?dDhO=v^3BeP5hF|%4GNQYBSwz;x({21i4OQY->1G=KFyu z&6d`f2tT9Yl_Z8YACZaJ#v#-(gcyeqXMhYGXb=t>)M@fFa8tHp2x;ODX=Ap@a5I=U z0G80^$N0G4=U(>W%mrrThl0DjyQ-_I>+1Tdd_AuB3qpYAqY54upwa3}owa|x5iQ^1 zEf|iTZxKNGRpI>34EwkIQ2zHDEZ=(J@lRaOH>F|2Z%V_t56Km$PUYu^xA5#5Uj4I4RGqHD56xT%H{+P8Ag>e_3pN$4m8n>i%OyJFPNWaEnJ4McUZPa1QmOh?t8~n& z&RulPCors8wUaqMHECG=IhB(-tU2XvHP6#NrLVyKG%Ee*mQ5Ps%wW?mcnriTVRc4J`2YVM>$ixSF2Xi+Wn(RUZnV?mJ?GRdw%lhZ+t&3s7g!~g{%m&i<6 z5{ib-<==DYG93I(yhyv4jp*y3#*WNuDUf6`vTM%c&hiayf(%=x@4$kJ!W4MtYcE#1 zHM?3xw63;L%x3drtd?jot!8u3qeqctceX3m;tWetK+>~q7Be$h>n6riK(5@ujLgRS zvOym)k+VAtyV^mF)$29Y`nw&ijdg~jYpkx%*^ z8dz`C*g=I?;clyi5|!27e2AuSa$&%UyR(J3W!A=ZgHF9OuKA34I-1U~pyD!KuRkjA zbkN!?MfQOeN>DUPBxoy5IX}@vw`EEB->q!)8fRl_mqUVuRu|C@KD-;yl=yKc=ZT0% zB$fMwcC|HE*0f8+PVlWHi>M`zfsA(NQFET?LrM^pPcw`cK+Mo0%8*x8@65=CS_^$cG{GZQ#xv($7J z??R$P)nPLodI;P!IC3eEYEHh7TV@opr#*)6A-;EU2XuogHvC;;k1aI8asq7ovoP!* z?x%UoPrZjj<&&aWpsbr>J$Er-7!E(BmOyEv!-mbGQGeJm-U2J>74>o5x`1l;)+P&~ z>}f^=Rx(ZQ2bm+YE0u=ZYrAV@apyt=v1wb?R@`i_g64YyAwcOUl=C!i>=Lzb$`tjv zOO-P#A+)t-JbbotGMT}arNhJmmGl-lyUpMn=2UacVZxmiG!s!6H39@~&uVokS zG=5qWhfW-WOI9g4!R$n7!|ViL!|v3G?GN6HR0Pt_L5*>D#FEj5wM1DScz4Jv@Sxnl zB@MPPmdI{(2D?;*wd>3#tjAirmUnQoZrVv`xM3hARuJksF(Q)wd4P$88fGYOT1p6U z`AHSN!`St}}UMBT9o7i|G`r$ zrB=s$qV3d6$W9@?L!pl0lf%)xs%1ko^=QY$ty-57=55PvP(^6E7cc zGJ*>m2=;fOj?F~yBf@K@9qwX0hA803Xw+b0m}+#a(>RyR8}*Y<4b+kpp|OS+!whP( zH`v{%s>jsQI9rd$*vm)EkwOm#W_-rLTHcZRek)>AtF+~<(did)*oR1|&~1|e36d-d zgtm5cv1O0oqgWC%Et@P4Vhm}Ndl(Y#C^MD03g#PH-TFy+7!Osv1z^UWS9@%JhswEq~6kSr2DITo59+; ze=ZC}i2Q?CJ~Iyu?vn|=9iKV>4j8KbxhE4&!@SQ^dVa-gK@YfS9xT(0kpW*EDjYUkoj! zE49{7H&E}k%5(>sM4uGY)Q*&3>{aitqdNnRJkbOmD5Mp5rv-hxzOn80QsG=HJ_atI-EaP69cacR)Uvh{G5dTpYG7d zbtmRMq@Sexey)||UpnZ?;g_KMZq4IDCy5}@u!5&B^-=6yyY{}e4Hh3ee!ZWtL*s?G zxG(A!<9o!CL+q?u_utltPMk+hn?N2@?}xU0KlYg?Jco{Yf@|mSGC<(Zj^yHCvhmyx z?OxOYoxbptDK()tsJ42VzXdINAMWL$0Gcw?G(g8TMB)Khw_|v9`_ql#pRd2i*?CZl z7k1b!jQB=9-V@h%;Cnl7EKi;Y^&NhU0mWEcj8B|3L30Ku#-9389Q+(Yet0r$F=+3p z6AKOMAIi|OHyzlHZtOm73}|ntKtFaXF2Fy|M!gOh^L4^62kGUoWS1i{9gsds_GWBc zLw|TaLP64z3z9?=R2|T6Xh2W4_F*$cq>MtXMOy&=IPIJ`;!Tw?PqvI2b*U1)25^<2 zU_ZPoxg_V0tngA0J+mm?3;OYw{i2Zb4x}NedZug!>EoN3DC{1i)Z{Z4m*(y{ov2%- zk(w>+scOO}MN!exSc`TN)!B=NUX`zThWO~M*ohqq;J2hx9h9}|s#?@eR!=F{QTrq~ zTcY|>azkCe$|Q0XFUdpFT=lTcyW##i;-e{}ORB4D?t@SfqGo_cS z->?^rh$<&n9DL!CF+h?LMZRi)qju!meugvxX*&jfD!^1XB3?E?HnwHP8$;uX{Rvp# zh|)hM>XDv$ZGg=$1{+_bA~u-vXqlw6NH=nkpyWE0u}LQjF-3NhATL@9rRxMnpO%f7 z)EhZf{PF|mKIMFxnC?*78(}{Y)}iztV12}_OXffJ;ta!fcFIVjdchyHxH=t%ci`Xd zX2AUB?%?poD6Zv*&BA!6c5S#|xn~DK01#XvjT!w!;&`lDXSJT4_j$}!qSPrb37vc{ z9^NfC%QvPu@vlxaZ;mIbn-VHA6miwi8qJ~V;pTZkKqqOii<1Cs}0i?uUIss;hM4dKq^1O35y?Yp=l4i zf{M!@QHH~rJ&X~8uATV><23zZUbs-J^3}$IvV_ANLS08>k`Td7aU_S1sLsfi*C-m1 z-e#S%UGs4E!;CeBT@9}aaI)qR-6NU@kvS#0r`g&UWg?fC7|b^_HyCE!8}nyh^~o@< zpm7PDFs9yxp+byMS(JWm$NeL?DNrMCNE!I^ko-*csB+dsf4GAq{=6sfyf4wb>?v1v zmb`F*bN1KUx-`ra1+TJ37bXNP%`-Fd`vVQFTwWpX@;s(%nDQa#oWhgk#mYlY*!d>( zE&!|ySF!mIyfING+#%RDY3IBH_fW$}6~1%!G`suHub1kP@&DoAd5~7J55;5_noPI6eLf{t;@9Kf<{aO0`1WNKd?<)C-|?C?)3s z>wEq@8=I$Wc~Mt$o;g++5qR+(6wt9GI~pyrDJ%c?gPZe)owvy^J2S=+M^ z&WhIE`g;;J^xQLVeCtf7b%Dg#Z2gq9hp_%g)-%_`y*zb; zn9`f`mUPN-Ts&fFo(aNTsXPA|J!TJ{0hZp0^;MYHLOcD=r_~~^ymS8KLCSeU3;^QzJNqS z5{5rEAv#l(X?bvwxpU;2%pQftF`YFgrD1jt2^~Mt^~G>T*}A$yZc@(k9orlCGv&|1 zWWvVgiJsCAtamuAYT~nzs?TQFt<1LSEx!@e0~@yd6$b5!Zm(FpBl;(Cn>2vF?k zOm#TTjFwd2D-CyA!mqR^?#Uwm{NBemP>(pHmM}9;;8`c&+_o3#E5m)JzfwN?(f-a4 zyd%xZc^oQx3XT?vcCqCX&Qrk~nu;fxs@JUoyVoi5fqpi&bUhQ2y!Ok2pzsFR(M(|U zw3E+kH_zmTRQ9dUMZWRE%Zakiwc+lgv7Z%|YO9YxAy`y28`Aw;WU6HXBgU7fl@dnt z-fFBV)}H-gqP!1;V@Je$WcbYre|dRdp{xt!7sL3Eoa%IA`5CAA%;Wq8PktwPdULo! z8!sB}Qt8#jH9Sh}QiUtEPZ6H0b*7qEKGJ%ITZ|vH)5Q^2m<7o3#Z>AKc%z7_u`rXA zqrCy{-{8;9>dfllLu$^M5L z-hXs))h*qz%~ActwkIA(qOVBZl2v4lwbM>9l70Y`+T*elINFqt#>OaVWoja8RMsep z6Or3f=oBnA3vDbn*+HNZP?8LsH2MY)x%c13@(XfuGR}R?Nu<|07{$+Lc3$Uv^I!MQ z>6qWgd-=aG2Y^24g4{Bw9ueOR)(9h`scImD=86dD+MnSN4$6 z^U*o_mE-6Rk~Dp!ANp#5RE9n*LG(Vg`1)g6!(XtDzsov$Dvz|Gv1WU68J$CkshQhS zCrc|cdkW~UK}5NeaWj^F4MSgFM+@fJd{|LLM)}_O<{rj z+?*Lm?owq?IzC%U%9EBga~h-cJbIu=#C}XuWN>OLrc%M@Gu~kFEYUi4EC6l#PR2JS zQUkGKrrS#6H7}2l0F@S11DP`@pih0WRkRJl#F;u{c&ZC{^$Z+_*lB)r)-bPgRFE;* zl)@hK4`tEP=P=il02x7-C7p%l=B`vkYjw?YhdJU9!P!jcmY$OtC^12w?vy3<<=tlY zUwHJ_0lgWN9vf>1%WACBD{UT)1qHQSE2%z|JHvP{#INr13jM}oYv_5#xsnv9`)UAO zuwgyV4YZ;O)eSc3(mka6=aRohi!HH@I#xq7kng?Acdg7S4vDJb6cI5fw?2z%3yR+| zU5v@Hm}vy;${cBp&@D=HQ9j7NcFaOYL zj-wV=eYF{|XTkFNM2uz&T8uH~;)^Zo!=KP)EVyH6s9l1~4m}N%XzPpduPg|h-&lL` zAXspR0YMOKd2yO)eMFFJ4?sQ&!`dF&!|niH*!^*Ml##o0M(0*uK9&yzekFi$+mP9s z>W9d%Jb)PtVi&-Ha!o~Iyh@KRuKpQ@)I~L*d`{O8!kRObjO7=n+Gp36fe!66neh+7 zW*l^0tTKjLLzr`x4`_8&on?mjW-PzheTNox8Hg7Nt@*SbE-%kP2hWYmHu#Fn@Q^J(SsPUz*|EgOoZ6byg3ew88UGdZ>9B2Tq=jF72ZaR=4u%1A6Vm{O#?@dD!(#tmR;eP(Fu z{$0O%=Vmua7=Gjr8nY%>ul?w=FJ76O2js&17W_iq2*tb!i{pt#`qZB#im9Rl>?t?0c zicIC}et_4d+CpVPx)i4~$u6N-QX3H77ez z?ZdvXifFk|*F8~L(W$OWM~r`pSk5}#F?j_5u$Obu9lDWIknO^AGu+Blk7!9Sb;NjS zncZA?qtASdNtzQ>z7N871IsPAk^CC?iIL}+{K|F@BuG2>qQ;_RUYV#>hHO(HUPpk@ z(bn~4|F_jiZi}Sad;_7`#4}EmD<1EiIxa48QjUuR?rC}^HRocq`OQPM@aHVKP9E#q zy%6bmHygCpIddPjE}q_DPC`VH_2m;Eey&ZH)E6xGeStOK7H)#+9y!%-Hm|QF6w#A( zIC0Yw%9j$s-#odxG~C*^MZ?M<+&WJ+@?B_QPUyTg9DJGtQN#NIC&-XddRsf3n^AL6 zT@P|H;PvN;ZpL0iv$bRb7|J{0o!Hq+S>_NrH4@coZtBJu#g8#CbR7|#?6uxi8d+$g z87apN>EciJZ`%Zv2**_uiET9Vk{pny&My;+WfGDw4EVL#B!Wiw&M|A8f1A@ z(yFQS6jfbH{b8Z-S7D2?Ixl`j0{+ZnpT=;KzVMLW{B$`N?Gw^Fl0H6lT61%T2AU**!sX0u?|I(yoy&Xveg7XBL&+>n6jd1##6d>TxE*Vj=8lWiG$4=u{1UbAa5QD>5_ z;Te^42v7K6Mmu4IWT6Rnm>oxrl~b<~^e3vbj-GCdHLIB_>59}Ya+~OF68NiH=?}2o zP(X7EN=quQn&)fK>M&kqF|<_*H`}c zk=+x)GU>{Af#vx&s?`UKUsz})g^Pc&?Ka@t5$n$bqf6{r1>#mWx6Ep>9|A}VmWRnowVo`OyCr^fHsf# zQjQ3Ttp7y#iQY8l`zEUW)(@gGQdt(~rkxlkefskT(t%@i8=|p1Y9Dc5bc+z#n$s13 zGJk|V0+&Ekh(F};PJzQKKo+FG@KV8a<$gmNSD;7rd_nRdc%?9)p!|B-@P~kxQG}~B zi|{0}@}zKC(rlFUYp*dO1RuvPC^DQOkX4<+EwvBAC{IZQdYxoq1Za!MW7%p7gGr=j zzWnAq%)^O2$eItftC#TTSArUyL$U54-O7e|)4_7%Q^2tZ^0-d&3J1}qCzR4dWX!)4 zzIEKjgnYgMus^>6uw4Jm8ga6>GBtMjpNRJ6CP~W=37~||gMo_p@GA@#-3)+cVYnU> zE5=Y4kzl+EbEh%dhQokB{gqNDqx%5*qBusWV%!iprn$S!;oN_6E3?0+umADVs4ako z?P+t?m?};gev9JXQ#Q&KBpzkHPde_CGu-y z<{}RRAx=xlv#mVi+Ibrgx~ujW$h{?zPfhz)Kp7kmYS&_|97b&H&1;J-mzrBWAvY} zh8-I8hl_RK2+nnf&}!W0P+>5?#?7>npshe<1~&l_xqKd0_>dl_^RMRq@-Myz&|TKZBj1=Q()) zF{dBjv5)h=&Z)Aevx}+i|7=R9rG^Di!sa)sZCl&ctX4&LScQ-kMncgO(9o6W6)yd< z@Rk!vkja*X_N3H=BavGoR0@u0<}m-7|2v!0+2h~S2Q&a=lTH91OJsvms2MT~ zY=c@LO5i`mLpBd(vh|)I&^A3TQLtr>w=zoyzTd=^f@TPu&+*2MtqE$Avf>l>}V|3-8Fp2hzo3y<)hr_|NO(&oSD z!vEjTWBxbKTiShVl-U{n*B3#)3a8$`{~Pk}J@elZ=>Pqp|MQ}jrGv7KrNcjW%TN_< zZz8kG{#}XoeWf7qY?D)L)8?Q-b@Na&>i=)(@uNo zr;cH98T3$Iau8Hn*@vXi{A@YehxDE2zX~o+RY`)6-X{8~hMpc#C`|8y> zU8Mnv5A0dNCf{Ims*|l-^ z(MRp{qoGohB34|ggDI*p!Aw|MFyJ|v+<+E3brfrI)|+l3W~CQLPbnF@G0)P~Ly!1TJLp}xh8uW`Q+RB-v`MRYZ9Gam3cM%{ zb4Cb*f)0deR~wtNb*8w-LlIF>kc7DAv>T0D(a3@l`k4TFnrO+g9XH7;nYOHxjc4lq zMmaW6qpgAgy)MckYMhl?>sq;-1E)-1llUneeA!ya9KM$)DaNGu57Z5aE>=VST$#vb zFo=uRHr$0M{-ha>h(D_boS4zId;3B|Tpqo|?B?Z@I?G(?&Iei+-{9L_A9=h=Qfn-U z1wIUnQe9!z%_j$F_{rf&`ZFSott09gY~qrf@g3O=Y>vzAnXCyL!@(BqWa)Zqt!#_k zfZHuwS52|&&)aK;CHq9V-t9qt0au{$#6c*R#e5n3rje0hic7c7m{kW$p(_`wB=Gw7 z4k`1Hi;Mc@yA7dp@r~?@rfw)TkjAW++|pkfOG}0N|2guek}j8Zen(!+@7?qt_7ndX zB=BG6WJ31#F3#Vk3=aQr8T)3`{=p9nBHlKzE0I@v`{vJ}h8pd6vby&VgFhzH|q;=aonunAXL6G2y(X^CtAhWr*jI zGjpY@raZDQkg*aMq}Ni6cRF z{oWv}5`nhSAv>usX}m^GHt`f(t8@zHc?K|y5Zi=4G*UG1Sza{$Dpj%X8 zzEXaKT5N6F5j4J|w#qlZP!zS7BT)9b+!ZSJdToqJts1c!)fwih4d31vfb{}W)EgcA zH2pZ^8_k$9+WD2n`6q5XbOy8>3pcYH9 z07eUB+p}YD@AH!}p!iKv><2QF-Y^&xx^PAc1F13A{nUeCDg&{hnix#FiO!fe(^&%Qcux!h znu*S!s$&nnkeotYsDthh1dq(iQrE|#f_=xVgfiiL&-5eAcC-> z5L0l|DVEM$#ulf{bj+Y~7iD)j<~O8CYM8GW)dQGq)!mck)FqoL^X zwNdZb3->hFrbHFm?hLvut-*uK?zXn3q1z|UX{RZ;-WiLoOjnle!xs+W0-8D)kjU#R z+S|A^HkRg$Ij%N4v~k`jyHffKaC~=wg=9)V5h=|kLQ@;^W!o2^K+xG&2n`XCd>OY5Ydi= zgHH=lgy++erK8&+YeTl7VNyVm9-GfONlSlVb3)V9NW5tT!cJ8d7X)!b-$fb!s76{t z@d=Vg-5K_sqHA@Zx-L_}wVnc@L@GL9_K~Zl(h5@AR#FAiKad8~KeWCo@mgXIQ#~u{ zgYFwNz}2b6Vu@CP0XoqJ+dm8px(5W5-Jpis97F`+KM)TuP*X8H@zwiVKDKGVp59pI zifNHZr|B+PG|7|Y<*tqap0CvG7tbR1R>jn70t1X`XJixiMVcHf%Ez*=xm1(CrTSDt z0cle!+{8*Ja&EOZ4@$qhBuKQ$U95Q%rc7tg$VRhk?3=pE&n+T3upZg^ZJc9~c2es% zh7>+|mrmA-p&v}|OtxqmHIBgUxL~^0+cpfkSK2mhh+4b=^F1Xgd2)}U*Yp+H?ls#z zrLxWg_hm}AfK2XYWr!rzW4g;+^^&bW%LmbtRai9f3PjU${r@n`JThy-cphbcwn)rq9{A$Ht`lmYKxOacy z6v2R(?gHhD5@&kB-Eg?4!hAoD7~(h>(R!s1c1Hx#s9vGPePUR|of32bS`J5U5w{F) z>0<^ktO2UHg<0{oxkdOQ;}coZDQph8p6ruj*_?uqURCMTac;>T#v+l1Tc~%^k-Vd@ zkc5y35jVNc49vZpZx;gG$h{%yslDI%Lqga1&&;mN{Ush1c7p>7e-(zp}6E7f-XmJb4nhk zb8zS+{IVbL$QVF8pf8}~kQ|dHJAEATmmnrb_wLG}-yHe>W|A&Y|;muy-d^t^<&)g5SJfaTH@P1%euONny=mxo+C z4N&w#biWY41r8k~468tvuYVh&XN&d#%QtIf9;iVXfWY)#j=l`&B~lqDT@28+Y!0E+MkfC}}H*#(WKKdJJq=O$vNYCb(ZG@p{fJgu;h z21oHQ(14?LeT>n5)s;uD@5&ohU!@wX8w*lB6i@GEH0pM>YTG+RAIWZD;4#F1&F%Jp zXZUml2sH0!lYJT?&sA!qwez6cXzJEd(1ZC~kT5kZSp7(@=H2$Azb_*W&6aA|9iwCL zdX7Q=42;@dspHDwYE?miGX#L^3xD&%BI&fN9^;`v4OjQXPBaBmOF1;#C)8XA(WFlH zycro;DS2?(G&6wkr6rqC>rqDv3nfGw3hmN_9Al>TgvmGsL8_hXx09};l9Ow@)F5@y z#VH5WigLDwZE4nh^7&@g{1FV^UZ%_LJ-s<{HN*2R$OPg@R~Z`c-ET*2}XB@9xvAjrK&hS=f|R8Gr9 zr|0TGOsI7RD+4+2{ZiwdVD@2zmg~g@^D--YL;6UYGSM8i$NbQr4!c7T9rg!8;TM0E zT#@?&S=t>GQm)*ua|?TLT2ktj#`|R<_*FAkOu2Pz$wEc%-=Y9V*$&dg+wIei3b*O8 z2|m$!jJG!J!ZGbbIa!(Af~oSyZV+~M1qGvelMzPNE_%5?c2>;MeeG2^N?JDKjFYCy z7SbPWH-$cWF9~fX%9~v99L!G(wi!PFp>rB!9xj7=Cv|F+7CsGNwY0Q_J%FID%C^CBZQfJ9K(HK%k31j~e#&?hQ zNuD6gRkVckU)v+53-fc} z7ZCzYN-5RG4H7;>>Hg?LU9&5_aua?A0)0dpew1#MMlu)LHe(M;OHjHIUl7|%%)YPo z0cBk;AOY00%Fe6heoN*$(b<)Cd#^8Iu;-2v@>cE-OB$icUF9EEoaC&q8z9}jMTT2I z8`9;jT%z0;dy4!8U;GW{i`)3!c6&oWY`J3669C!tM<5nQFFrFRglU8f)5Op$GtR-3 zn!+SPCw|04sv?%YZ(a7#L?vsdr7ss@WKAw&A*}-1S|9~cL%uA+E~>N6QklFE>8W|% zyX-qAUGTY1hQ-+um`2|&ji0cY*(qN!zp{YpDO-r>jPk*yuVSay<)cUt`t@&FPF_&$ zcHwu1(SQ`I-l8~vYyUxm@D1UEdFJ$f5Sw^HPH7b!9 zzYT3gKMF((N(v0#4f_jPfVZ=ApN^jQJe-X$`A?X+vWjLn_%31KXE*}5_}d8 zw_B1+a#6T1?>M{ronLbHIlEsMf93muJ7AH5h%;i99<~JX^;EAgEB1uHralD*!aJ@F zV2ruuFe9i2Q1C?^^kmVy921eb=tLDD43@-AgL^rQ3IO9%+vi_&R2^dpr}x{bCVPej z7G0-0o64uyWNtr*loIvslyo0%)KSDDKjfThe0hcqs)(C-MH1>bNGBDRTW~scy_{w} zp^aq8Qb!h9Lwielq%C1b8=?Z=&U)ST&PHbS)8Xzjh2DF?d{iAv)Eh)wsUnf>UtXN( zL7=$%YrZ#|^c{MYmhn!zV#t*(jdmYdCpwqpZ{v&L8KIuKn`@IIZfp!uo}c;7J57N` zAxyZ-uA4=Gzl~Ovycz%MW9ZL7N+nRo&1cfNn9(1H5eM;V_4Z_qVann7F>5f>%{rf= zPBZFaV@_Sobl?Fy&KXyzFDV*FIdhS5`Uc~S^Gjo)aiTHgn#<0C=9o-a-}@}xDor;D zZyZ|fvf;+=3MZd>SR1F^F`RJEZo+|MdyJYQAEauKu%WDol~ayrGU3zzbHKsnHKZ*z zFiwUkL@DZ>!*x05ql&EBq@_Vqv83&?@~q5?lVmffQZ+V-=qL+!u4Xs2Z2zdCQ3U7B&QR9_Iggy} z(om{Y9eU;IPe`+p1ifLx-XWh?wI)xU9ik+m#g&pGdB5Bi<`PR*?92lE0+TkRuXI)z z5LP!N2+tTc%cB6B1F-!fj#}>S!vnpgVU~3!*U1ej^)vjUH4s-bd^%B=ItQqDCGbrEzNQi(dJ`J}-U=2{7-d zK8k^Rlq2N#0G?9&1?HSle2vlkj^KWSBYTwx`2?9TU_DX#J+f+qLiZCqY1TXHFxXZqYMuD@RU$TgcnCC{_(vwZ-*uX)~go#%PK z@}2Km_5aQ~(<3cXeJN6|F8X_1@L%@xTzs}$_*E|a^_URF_qcF;Pfhoe?FTFwvjm1o z8onf@OY@jC2tVcMaZS;|T!Ks(wOgPpRzRnFS-^RZ4E!9dsnj9sFt609a|jJbb1Dt@ z<=Gal2jDEupxUSwWu6zp<<&RnAA;d&4gKVG0iu6g(DsST(4)z6R)zDpfaQ}v{5ARt zyhwvMtF%b-YazR5XLz+oh=mn;y-Mf2a8>7?2v8qX;19y?b>Z5laGHvzH;Nu9S`B8} zI)qN$GbXIQ1VL3lnof^6TS~rvPVg4V?Dl2Bb*K2z4E{5vy<(@@K_cN@U>R!>aUIRnb zL*)=787*cs#zb31zBC49x$`=fkQbMAef)L2$dR{)6BAz!t5U_B#1zZG`^neKSS22oJ#5B=gl%U=WeqL9REF2g zZnfCb0?quf?Ztj$VXvDSWoK`0L=Zxem2q}!XWLoT-kYMOx)!7fcgT35uC~0pySEme z`{wGWTkGr7>+Kb^n;W?BZH6ZP(9tQX%-7zF>vc2}LuWDI(9kh1G#7B99r4x6;_-V+k&c{nPUrR zAXJGRiMe~aup{0qzmLNjS_BC4cB#sXjckx{%_c&^xy{M61xEb>KW_AG5VFXUOjAG4 z^>Qlm9A#1N{4snY=(AmWzatb!ngqiqPbBZ7>Uhb3)dTkSGcL#&SH>iMO-IJBPua`u zo)LWZ>=NZLr758j{%(|uQuZ)pXq_4c!!>s|aDM9#`~1bzK3J1^^D#<2bNCccH7~-X}Ggi!pIIF>uFx%aPARGQsnC8ZQc8lrQ5o~smqOg>Ti^GNme94*w z)JZy{_{#$jxGQ&`M z!OMvZMHR>8*^>eS%o*6hJwn!l8VOOjZQJvh)@tnHVW&*GYPuxqXw}%M!(f-SQf`=L z5;=5w2;%82VMH6Xi&-K3W)o&K^+vJCepWZ-rW%+Dc6X3(){z$@4zjYxQ|}8UIojeC zYZpQ1dU{fy=oTr<4VX?$q)LP}IUmpiez^O&N3E_qPpchGTi5ZM6-2ScWlQq%V&R2Euz zO|Q0Hx>lY1Q1cW5xHv5!0OGU~PVEqSuy#fD72d#O`N!C;o=m+YioGu-wH2k6!t<~K zSr`E=W9)!g==~x9VV~-8{4ZN9{~-A9zJpRe%NGg$+MDuI-dH|b@BD)~>pPCGUNNzY zMDg||0@XGQgw`YCt5C&A{_+J}mvV9Wg{6V%2n#YSRN{AP#PY?1FF1#|vO_%e+#`|2*~wGAJaeRX6=IzFNeWhz6gJc8+(03Ph4y6ELAm=AkN7TOgMUEw*N{= z_)EIDQx5q22oUR+_b*tazu9+pX|n1c*IB-}{DqIj z-?E|ks{o3AGRNb;+iKcHkZvYJvFsW&83RAPs1Oh@IWy%l#5x2oUP6ZCtv+b|q>jsf zZ_9XO;V!>n`UxH1LvH8)L4?8raIvasEhkpQoJ`%!5rBs!0Tu(s_D{`4opB;57)pkX z4$A^8CsD3U5*!|bHIEqsn~{q+Ddj$ME@Gq4JXtgVz&7l{Ok!@?EA{B3P~NAqb9)4? zkQo30A^EbHfQ@87G5&EQTd`frrwL)&Yw?%-W@uy^Gn23%j?Y!Iea2xw<-f;esq zf%w5WN@E1}zyXtYv}}`U^B>W`>XPmdLj%4{P298|SisrE;7HvXX;A}Ffi8B#3Lr;1 zHt6zVb`8{#+e$*k?w8|O{Uh|&AG}|DG1PFo1i?Y*cQm$ZwtGcVgMwtBUDa{~L1KT-{jET4w60>{KZ27vXrHJ;fW{6| z=|Y4!&UX020wU1>1iRgB@Q#m~1^Z^9CG1LqDhYBrnx%IEdIty z!46iOoKlKs)c}newDG)rWUikD%j`)p z_w9Ph&e40=(2eBy;T!}*1p1f1SAUDP9iWy^u^Ubdj21Kn{46;GR+hwLO=4D11@c~V zI8x&(D({K~Df2E)Nx_yQvYfh4;MbMJ@Z}=Dt3_>iim~QZ*hZIlEs0mEb z_54+&*?wMD`2#vsQRN3KvoT>hWofI_Vf(^C1ff-Ike@h@saEf7g}<9T`W;HAne-Nd z>RR+&SP35w)xKn8^U$7))PsM!jKwYZ*RzEcG-OlTrX3}9a{q%#Un5E5W{{hp>w~;` zGky+3(vJvQyGwBo`tCpmo0mo((?nM8vf9aXrrY1Ve}~TuVkB(zeds^jEfI}xGBCM2 zL1|#tycSaWCurP+0MiActG3LCas@_@tao@(R1ANlwB$4K53egNE_;!&(%@Qo$>h`^1S_!hN6 z)vZtG$8fN!|BXBJ=SI>e(LAU(y(i*PHvgQ2llulxS8>qsimv7yL}0q_E5WiAz7)(f zC(ahFvG8&HN9+6^jGyLHM~$)7auppeWh_^zKk&C_MQ~8;N??OlyH~azgz5fe^>~7F zl3HnPN3z-kN)I$4@`CLCMQx3sG~V8hPS^}XDXZrQA>}mQPw%7&!sd(Pp^P=tgp-s^ zjl}1-KRPNWXgV_K^HkP__SR`S-|OF0bR-N5>I%ODj&1JUeAQ3$9i;B~$S6}*^tK?= z**%aCiH7y?xdY?{LgVP}S0HOh%0%LI$wRx;$T|~Y8R)Vdwa}kGWv8?SJVm^>r6+%I z#lj1aR94{@MP;t-scEYQWc#xFA30^}?|BeX*W#9OL;Q9#WqaaM546j5j29((^_8Nu z4uq}ESLr~r*O7E7$D{!k9W>`!SLoyA53i9QwRB{!pHe8um|aDE`Cg0O*{jmor)^t)3`>V>SWN-2VJcFmj^1?~tT=JrP`fVh*t zXHarp=8HEcR#vFe+1a%XXuK+)oFs`GDD}#Z+TJ}Ri`FvKO@ek2ayn}yaOi%(8p%2$ zpEu)v0Jym@f}U|-;}CbR=9{#<^z28PzkkTNvyKvJDZe+^VS2bES3N@Jq!-*}{oQlz z@8bgC_KnDnT4}d#&Cpr!%Yb?E!brx0!eVOw~;lLwUoz#Np%d$o%9scc3&zPm`%G((Le|6o1 zM(VhOw)!f84zG^)tZ1?Egv)d8cdNi+T${=5kV+j;Wf%2{3g@FHp^Gf*qO0q!u$=m9 zCaY`4mRqJ;FTH5`a$affE5dJrk~k`HTP_7nGTY@B9o9vvnbytaID;^b=Tzp7Q#DmD zC(XEN)Ktn39z5|G!wsVNnHi) z%^q94!lL|hF`IijA^9NR0F$@h7k5R^ljOW(;Td9grRN0Mb)l_l7##{2nPQ@?;VjXv zaLZG}yuf$r$<79rVPpXg?6iiieX|r#&`p#Con2i%S8*8F}(E) zI5E6c3tG*<;m~6>!&H!GJ6zEuhH7mkAzovdhLy;)q z{H2*8I^Pb}xC4s^6Y}6bJvMu=8>g&I)7!N!5QG$xseeU#CC?ZM-TbjsHwHgDGrsD= z{%f;@Sod+Ch66Ko2WF~;Ty)v>&x^aovCbCbD7>qF*!?BXmOV3(s|nxsb*Lx_2lpB7 zokUnzrk;P=T-&kUHO}td+Zdj!3n&NR?K~cRU zAXU!DCp?51{J4w^`cV#ye}(`SQhGQkkMu}O3M*BWt4UsC^jCFUy;wTINYmhD$AT;4 z?Xd{HaJjP`raZ39qAm;%beDbrLpbRf(mkKbANan7XsL>_pE2oo^$TgdidjRP!5-`% zv0d!|iKN$c0(T|L0C~XD0aS8t{*&#LnhE;1Kb<9&=c2B+9JeLvJr*AyyRh%@jHej=AetOMSlz^=!kxX>>B{2B1uIrQyfd8KjJ+DBy!h)~*(!|&L4^Q_07SQ~E zcemVP`{9CwFvPFu7pyVGCLhH?LhEVb2{7U+Z_>o25#+3<|8%1T^5dh}*4(kfJGry} zm%r#hU+__Z;;*4fMrX=Bkc@7|v^*B;HAl0((IBPPii%X9+u3DDF6%bI&6?Eu$8&aWVqHIM7mK6?Uvq$1|(-T|)IV<>e?!(rY zqkmO1MRaLeTR=)io(0GVtQT@s6rN%C6;nS3@eu;P#ry4q;^O@1ZKCJyp_Jo)Ty^QW z+vweTx_DLm{P-XSBj~Sl<%_b^$=}odJ!S2wAcxenmzFGX1t&Qp8Vxz2VT`uQsQYtdn&_0xVivIcxZ_hnrRtwq4cZSj1c-SG9 z7vHBCA=fd0O1<4*=lu$6pn~_pVKyL@ztw1swbZi0B?spLo56ZKu5;7ZeUml1Ws1?u zqMf1p{5myAzeX$lAi{jIUqo1g4!zWLMm9cfWcnw`k6*BR^?$2(&yW?>w;G$EmTA@a z6?y#K$C~ZT8+v{87n5Dm&H6Pb_EQ@V0IWmG9cG=O;(;5aMWWrIPzz4Q`mhK;qQp~a z+BbQrEQ+w{SeiuG-~Po5f=^EvlouB@_|4xQXH@A~KgpFHrwu%dwuCR)=B&C(y6J4J zvoGk9;lLs9%iA-IJGU#RgnZZR+@{5lYl8(e1h6&>Vc_mvg0d@);X zji4T|n#lB!>pfL|8tQYkw?U2bD`W{na&;*|znjmalA&f;*U++_aBYerq;&C8Kw7mI z7tsG*?7*5j&dU)Lje;^{D_h`%(dK|pB*A*1(Jj)w^mZ9HB|vGLkF1GEFhu&rH=r=8 zMxO42e{Si6$m+Zj`_mXb&w5Q(i|Yxyg?juUrY}78uo@~3v84|8dfgbPd0iQJRdMj< zncCNGdMEcsxu#o#B5+XD{tsg*;j-eF8`mp~K8O1J!Z0+>0=7O=4M}E?)H)ENE;P*F z$Ox?ril_^p0g7xhDUf(q652l|562VFlC8^r8?lQv;TMvn+*8I}&+hIQYh2 z1}uQQaag&!-+DZ@|C+C$bN6W;S-Z@)d1|en+XGvjbOxCa-qAF*LA=6s(Jg+g;82f$ z(Vb)8I)AH@cdjGFAR5Rqd0wiNCu!xtqWbcTx&5kslzTb^7A78~Xzw1($UV6S^VWiP zFd{Rimd-0CZC_Bu(WxBFW7+k{cOW7DxBBkJdJ;VsJ4Z@lERQr%3eVv&$%)b%<~ zCl^Y4NgO}js@u{|o~KTgH}>!* z_iDNqX2(As7T0xivMH|3SC1ivm8Q}6Ffcd7owUKN5lHAtzMM4<0v+ykUT!QiowO;`@%JGv+K$bBx@*S7C8GJVqQ_K>12}M`f_Ys=S zKFh}HM9#6Izb$Y{wYzItTy+l5U2oL%boCJn?R3?jP@n$zSIwlmyGq30Cw4QBO|14` zW5c);AN*J3&eMFAk$SR~2k|&+&Bc$e>s%c{`?d~85S-UWjA>DS5+;UKZ}5oVa5O(N zqqc@>)nee)+4MUjH?FGv%hm2{IlIF-QX}ym-7ok4Z9{V+ZHVZQl$A*x!(q%<2~iVv znUa+BX35&lCb#9VE-~Y^W_f;Xhl%vgjwdjzMy$FsSIj&ok}L+X`4>J=9BkN&nu^E*gbhj3(+D>C4E z@Fwq_=N)^bKFSHTzZk?-gNU$@l}r}dwGyh_fNi=9b|n}J>&;G!lzilbWF4B}BBq4f zYIOl?b)PSh#XTPp4IS5ZR_2C!E)Z`zH0OW%4;&~z7UAyA-X|sh9@~>cQW^COA9hV4 zXcA6qUo9P{bW1_2`eo6%hgbN%(G-F1xTvq!sc?4wN6Q4`e9Hku zFwvlAcRY?6h^Fj$R8zCNEDq8`=uZB8D-xn)tA<^bFFy}4$vA}Xq0jAsv1&5!h!yRA zU()KLJya5MQ`q&LKdH#fwq&(bNFS{sKlEh_{N%{XCGO+po#(+WCLmKW6&5iOHny>g z3*VFN?mx!16V5{zyuMWDVP8U*|BGT$(%IO|)?EF|OI*sq&RovH!N%=>i_c?K*A>>k zyg1+~++zY4Q)J;VWN0axhoIKx;l&G$gvj(#go^pZskEVj8^}is3Jw26LzYYVos0HX zRPvmK$dVxM8(Tc?pHFe0Z3uq){{#OK3i-ra#@+;*=ui8)y6hsRv z4Fxx1c1+fr!VI{L3DFMwXKrfl#Q8hfP@ajgEau&QMCxd{g#!T^;ATXW)nUg&$-n25 zruy3V!!;{?OTobo|0GAxe`Acn3GV@W=&n;~&9 zQM>NWW~R@OYORkJAo+eq1!4vzmf9K%plR4(tB@TR&FSbDoRgJ8qVcH#;7lQub*nq&?Z>7WM=oeEVjkaG zT#f)=o!M2DO5hLR+op>t0CixJCIeXH*+z{-XS|%jx)y(j&}Wo|3!l7{o)HU3m7LYyhv*xF&tq z%IN7N;D4raue&&hm0xM=`qv`+TK@;_xAcGKuK(2|75~ar2Yw)geNLSmVxV@x89bQu zpViVKKnlkwjS&&c|-X6`~xdnh}Ps)Hs z4VbUL^{XNLf7_|Oi>tA%?SG5zax}esF*FH3d(JH^Gvr7Rp*n=t7frH!U;!y1gJB^i zY_M$KL_}mW&XKaDEi9K-wZR|q*L32&m+2n_8lq$xRznJ7p8}V>w+d@?uB!eS3#u<} zIaqi!b!w}a2;_BfUUhGMy#4dPx>)_>yZ`ai?Rk`}d0>~ce-PfY-b?Csd(28yX22L% zI7XI>OjIHYTk_@Xk;Gu^F52^Gn6E1&+?4MxDS2G_#PQ&yXPXP^<-p|2nLTb@AAQEY zI*UQ9Pmm{Kat}wuazpjSyXCdnrD&|C1c5DIb1TnzF}f4KIV6D)CJ!?&l&{T)e4U%3HTSYqsQ zo@zWB1o}ceQSV)<4G<)jM|@@YpL+XHuWsr5AYh^Q{K=wSV99D~4RRU52FufmMBMmd z_H}L#qe(}|I9ZyPRD6kT>Ivj&2Y?qVZq<4bG_co_DP`sE*_Xw8D;+7QR$Uq(rr+u> z8bHUWbV19i#)@@G4bCco@Xb<8u~wVDz9S`#k@ciJtlu@uP1U0X?yov8v9U3VOig2t zL9?n$P3=1U_Emi$#slR>N5wH-=J&T=EdUHA}_Z zZIl3nvMP*AZS9{cDqFanrA~S5BqxtNm9tlu;^`)3X&V4tMAkJ4gEIPl= zoV!Gyx0N{3DpD@)pv^iS*dl2FwANu;1;%EDl}JQ7MbxLMAp>)UwNwe{=V}O-5C*>F zu?Ny+F64jZn<+fKjF01}8h5H_3pey|;%bI;SFg$w8;IC<8l|3#Lz2;mNNik6sVTG3 z+Su^rIE#40C4a-587$U~%KedEEw1%r6wdvoMwpmlXH$xPnNQN#f%Z7|p)nC>WsuO= z4zyqapLS<8(UJ~Qi9d|dQijb_xhA2)v>la)<1md5s^R1N&PiuA$^k|A<+2C?OiHbj z>Bn$~t)>Y(Zb`8hW7q9xQ=s>Rv81V+UiuZJc<23HplI88isqRCId89fb`Kt|CxVIg znWcwprwXnotO>3s&Oypkte^9yJjlUVVxSe%_xlzmje|mYOVPH^vjA=?6xd0vaj0Oz zwJ4OJNiFdnHJX3rw&inskjryukl`*fRQ#SMod5J|KroJRsVXa5_$q7whSQ{gOi*s0 z1LeCy|JBWRsDPn7jCb4s(p|JZiZ8+*ExC@Vj)MF|*Vp{B(ziccSn`G1Br9bV(v!C2 z6#?eqpJBc9o@lJ#^p-`-=`4i&wFe>2)nlPK1p9yPFzJCzBQbpkcR>={YtamIw)3nt z(QEF;+)4`>8^_LU)_Q3 zC5_7lgi_6y>U%m)m@}Ku4C}=l^J=<<7c;99ec3p{aR+v=diuJR7uZi%aQv$oP?dn?@6Yu_+*^>T0ptf(oobdL;6)N-I!TO`zg^Xbv3#L0I~sn@WGk-^SmPh5>W+LB<+1PU}AKa?FCWF|qMNELOgdxR{ zbqE7@jVe+FklzdcD$!(A$&}}H*HQFTJ+AOrJYnhh}Yvta(B zQ_bW4Rr;R~&6PAKwgLWXS{Bnln(vUI+~g#kl{r+_zbngT`Y3`^Qf=!PxN4IYX#iW4 zucW7@LLJA9Zh3(rj~&SyN_pjO8H&)|(v%!BnMWySBJV=eSkB3YSTCyIeJ{i;(oc%_hk{$_l;v>nWSB)oVeg+blh=HB5JSlG_r7@P z3q;aFoZjD_qS@zygYqCn=;Zxjo!?NK!%J$ z52lOP`8G3feEj+HTp@Tnn9X~nG=;tS+z}u{mQX_J0kxtr)O30YD%oo)L@wy`jpQYM z@M>Me=95k1p*FW~rHiV1CIfVc{K8r|#Kt(ApkXKsDG$_>76UGNhHExFCw#Ky9*B-z zNq2ga*xax!HMf_|Vp-86r{;~YgQKqu7%szk8$hpvi_2I`OVbG1doP(`gn}=W<8%Gn z%81#&WjkH4GV;4u43EtSW>K_Ta3Zj!XF?;SO3V#q=<=>Tc^@?A`i;&`-cYj|;^ zEo#Jl5zSr~_V-4}y8pnufXLa80vZY4z2ko7fj>DR)#z=wWuS1$$W!L?(y}YC+yQ|G z@L&`2upy3f>~*IquAjkVNU>}c10(fq#HdbK$~Q3l6|=@-eBbo>B9(6xV`*)sae58*f zym~RRVx;xoCG3`JV`xo z!lFw)=t2Hy)e!IFs?0~7osWk(d%^wxq&>_XD4+U#y&-VF%4z?XH^i4w`TxpF{`XhZ z%G}iEzf!T(l>g;W9<~K+)$g!{UvhW{E0Lis(S^%I8OF&%kr!gJ&fMOpM=&=Aj@wuL zBX?*6i51Qb$uhkwkFYkaD_UDE+)rh1c;(&Y=B$3)J&iJfQSx!1NGgPtK!$c9OtJuu zX(pV$bfuJpRR|K(dp@^j}i&HeJOh@|7lWo8^$*o~Xqo z5Sb+!EtJ&e@6F+h&+_1ETbg7LfP5GZjvIUIN3ibCOldAv z)>YdO|NH$x7AC8dr=<2ekiY1%fN*r~e5h6Yaw<{XIErujKV~tiyrvV_DV0AzEknC- zR^xKM3i<1UkvqBj3C{wDvytOd+YtDSGu!gEMg+!&|8BQrT*|p)(dwQLEy+ zMtMzij3zo40)CA!BKZF~yWg?#lWhqD3@qR)gh~D{uZaJO;{OWV8XZ_)J@r3=)T|kt zUS1pXr6-`!Z}w2QR7nP%d?ecf90;K_7C3d!UZ`N(TZoWNN^Q~RjVhQG{Y<%E1PpV^4 z-m-K+$A~-+VDABs^Q@U*)YvhY4Znn2^w>732H?NRK(5QSS$V@D7yz2BVX4)f5A04~$WbxGOam22>t&uD)JB8-~yiQW6ik;FGblY_I>SvB_z2?PS z*Qm&qbKI{H1V@YGWzpx`!v)WeLT02};JJo*#f$a*FH?IIad-^(;9XC#YTWN6;Z6+S zm4O1KH=#V@FJw7Pha0!9Vb%ZIM$)a`VRMoiN&C|$YA3~ZC*8ayZRY^fyuP6$n%2IU z$#XceYZeqLTXw(m$_z|33I$B4k~NZO>pP6)H_}R{E$i%USGy{l{-jOE;%CloYPEU+ zRFxOn4;7lIOh!7abb23YKD+_-?O z0FP9otcAh+oSj;=f#$&*ExUHpd&e#bSF%#8*&ItcL2H$Sa)?pt0Xtf+t)z$_u^wZi z44oE}r4kIZGy3!Mc8q$B&6JqtnHZ>Znn!Zh@6rgIu|yU+zG8q`q9%B18|T|oN3zMq z`l&D;U!OL~%>vo&q0>Y==~zLiCZk4v%s_7!9DxQ~id1LLE93gf*gg&2$|hB#j8;?3 z5v4S;oM6rT{Y;I+#FdmNw z){d%tNM<<#GN%n9ox7B=3#;u7unZ~tLB_vRZ52a&2=IM)2VkXm=L+Iqq~uk#Dug|x z>S84e+A7EiOY5lj*!q?6HDkNh~0g;0Jy(al!ZHHDtur9T$y-~)94HelX1NHjXWIM7UAe}$?jiz z9?P4`I0JM=G5K{3_%2jPLC^_Mlw?-kYYgb7`qGa3@dn|^1fRMwiyM@Ch z;CB&o7&&?c5e>h`IM;Wnha0QKnEp=$hA8TJgR-07N~U5(>9vJzeoFsSRBkDq=x(YgEMpb=l4TDD`2 zwVJpWGTA_u7}?ecW7s6%rUs&NXD3+n;jB86`X?8(l3MBo6)PdakI6V6a}22{)8ilT zM~T*mU}__xSy|6XSrJ^%lDAR3Lft%+yxC|ZUvSO_nqMX!_ul3;R#*{~4DA=h$bP)%8Yv9X zyp><|e8=_ttI}ZAwOd#dlnSjck#6%273{E$kJuCGu=I@O)&6ID{nWF5@gLb16sj|&Sb~+du4e4O_%_o`Ix4NRrAsyr1_}MuP94s>de8cH-OUkVPk3+K z&jW)It9QiU-ti~AuJkL`XMca8Oh4$SyJ=`-5WU<{cIh+XVH#e4d&zive_UHC!pN>W z3TB;Mn5i)9Qn)#6@lo4QpI3jFYc0~+jS)4AFz8fVC;lD^+idw^S~Qhq>Tg(!3$yLD zzktzoFrU@6s4wwCMz}edpF5i5Q1IMmEJQHzp(LAt)pgN3&O!&d?3W@6U4)I^2V{;- z6A(?zd93hS*uQmnh4T)nHnE{wVhh(=MMD(h(P4+^p83Om6t<*cUW>l(qJzr%5vp@K zN27ka(L{JX=1~e2^)F^i=TYj&;<7jyUUR2Bek^A8+3Up*&Xwc{)1nRR5CT8vG>ExV zHnF3UqXJOAno_?bnhCX-&kwI~Ti8t4`n0%Up>!U`ZvK^w2+0Cs-b9%w%4`$+To|k= zKtgc&l}P`*8IS>8DOe?EB84^kx4BQp3<7P{Pq}&p%xF_81pg!l2|u=&I{AuUgmF5n zJQCTLv}%}xbFGYtKfbba{CBo)lWW%Z>i(_NvLhoQZ*5-@2l&x>e+I~0Nld3UI9tdL zRzu8}i;X!h8LHVvN?C+|M81e>Jr38%&*9LYQec9Ax>?NN+9(_>XSRv&6hlCYB`>Qm z1&ygi{Y()OU4@D_jd_-7vDILR{>o|7-k)Sjdxkjgvi{@S>6GqiF|o`*Otr;P)kLHN zZkpts;0zw_6;?f(@4S1FN=m!4^mv~W+lJA`&7RH%2$)49z0A+8@0BCHtj|yH--AEL z0tW6G%X-+J+5a{5*WKaM0QDznf;V?L5&uQw+yegDNDP`hA;0XPYc6e0;Xv6|i|^F2WB)Z$LR|HR4 zTQsRAby9(^Z@yATyOgcfQw7cKyr^3Tz7lc7+JEwwzA7)|2x+PtEb>nD(tpxJQm)Kn zW9K_*r!L%~N*vS8<5T=iv|o!zTe9k_2jC_j*7ik^M_ zaf%k{WX{-;0*`t`G!&`eW;gChVXnJ-Rn)To8vW-?>>a%QU1v`ZC=U)f8iA@%JG0mZ zDqH;~mgBnrCP~1II<=V9;EBL)J+xzCoiRBaeH&J6rL!{4zIY8tZka?_FBeQeNO3q6 zyG_alW54Ba&wQf{&F1v-r1R6ID)PTsqjIBc+5MHkcW5Fnvi~{-FjKe)t1bl}Y;z@< z=!%zvpRua>>t_x}^}z0<7MI!H2v6|XAyR9!t50q-A)xk0nflgF4*OQlCGK==4S|wc zRMsSscNhRzHMBU8TdcHN!q^I}x0iXJ%uehac|Zs_B$p@CnF)HeXPpB_Za}F{<@6-4 zl%kml@}kHQ(ypD8FsPJ2=14xXJE|b20RUIgs!2|R3>LUMGF6X*B_I|$`Qg=;zm7C z{mEDy9dTmPbued7mlO@phdmAmJ7p@GR1bjCkMw6*G7#4+`k>fk1czdJUB!e@Q(~6# zwo%@p@V5RL0ABU2LH7Asq^quDUho@H>eTZH9f*no9fY0T zD_-9px3e}A!>>kv5wk91%C9R1J_Nh!*&Kk$J3KNxC}c_@zlgpJZ+5L)Nw|^p=2ue}CJtm;uj*Iqr)K})kA$xtNUEvX;4!Px*^&9T_`IN{D z{6~QY=Nau6EzpvufB^hflc#XIsSq0Y9(nf$d~6ZwK}fal92)fr%T3=q{0mP-EyP_G z)UR5h@IX}3Qll2b0oCAcBF>b*@Etu*aTLPU<%C>KoOrk=x?pN!#f_Og-w+;xbFgjQ zXp`et%lDBBh~OcFnMKMUoox0YwBNy`N0q~bSPh@+enQ=4RUw1) zpovN`QoV>vZ#5LvC;cl|6jPr}O5tu!Ipoyib8iXqy}TeJ;4+_7r<1kV0v5?Kv>fYp zg>9L`;XwXa&W7-jf|9~uP2iyF5`5AJ`Q~p4eBU$MCC00`rcSF>`&0fbd^_eqR+}mK z4n*PMMa&FOcc)vTUR zlDUAn-mh`ahi_`f`=39JYTNVjsTa_Y3b1GOIi)6dY)D}xeshB0T8Eov5%UhWd1)u}kjEQ|LDo{tqKKrYIfVz~@dp!! zMOnah@vp)%_-jDTUG09l+;{CkDCH|Q{NqX*uHa1YxFShy*1+;J`gywKaz|2Q{lG8x zP?KBur`}r`!WLKXY_K;C8$EWG>jY3UIh{+BLv0=2)KH%P}6xE2kg)%(-uA6lC?u8}{K(#P*c zE9C8t*u%j2r_{;Rpe1A{9nNXU;b_N0vNgyK!EZVut~}+R2rcbsHilqsOviYh-pYX= zHw@53nlmwYI5W5KP>&`dBZe0Jn?nAdC^HY1wlR6$u^PbpB#AS&5L6zqrXN&7*N2Q` z+Rae1EwS)H=aVSIkr8Ek^1jy2iS2o7mqm~Mr&g5=jjt7VxwglQ^`h#Mx+x2v|9ZAwE$i_9918MjJxTMr?n!bZ6n$}y11u8I9COTU`Z$Fi z!AeAQLMw^gp_{+0QTEJrhL424pVDp%wpku~XRlD3iv{vQ!lAf!_jyqd_h}+Tr1XG| z`*FT*NbPqvHCUsYAkFnM`@l4u_QH&bszpUK#M~XLJt{%?00GXY?u_{gj3Hvs!=N(I z(=AuWPijyoU!r?aFTsa8pLB&cx}$*%;K$e*XqF{~*rA-qn)h^!(-;e}O#B$|S~c+U zN4vyOK0vmtx$5K!?g*+J@G1NmlEI=pyZXZ69tAv=@`t%ag_Hk{LP~OH9iE)I= zaJ69b4kuCkV0V zo(M0#>phpQ_)@j;h%m{-a*LGi(72TP)ws2w*@4|C-3+;=5DmC4s7Lp95%n%@Ko zfdr3-a7m*dys9iIci$A=4NPJ`HfJ;hujLgU)ZRuJI`n;Pw|yksu!#LQnJ#dJysgNb z@@qwR^wrk(jbq4H?d!lNyy72~Dnn87KxsgQ!)|*m(DRM+eC$wh7KnS-mho3|KE)7h zK3k;qZ;K1Lj6uEXLYUYi)1FN}F@-xJ z@@3Hb84sl|j{4$3J}aTY@cbX@pzB_qM~APljrjju6P0tY{C@ zpUCOz_NFmALMv1*blCcwUD3?U6tYs+N%cmJ98D%3)%)Xu^uvzF zS5O!sc#X6?EwsYkvPo6A%O8&y8sCCQH<%f2togVwW&{M;PR!a(ZT_A+jVAbf{@5kL zB@Z(hb$3U{T_}SKA_CoQVU-;j>2J=L#lZ~aQCFg-d<9rzs$_gO&d5N6eFSc z1ml8)P*FSi+k@!^M9nDWR5e@ATD8oxtDu=36Iv2!;dZzidIS(PCtEuXAtlBb1;H%Z zwnC^Ek*D)EX4#Q>R$$WA2sxC_t(!!6Tr?C#@{3}n{<^o;9id1RA&-Pig1e-2B1XpG zliNjgmd3c&%A}s>qf{_j#!Z`fu0xIwm4L0)OF=u(OEmp;bLCIaZX$&J_^Z%4Sq4GZ zPn6sV_#+6pJmDN_lx@1;Zw6Md_p0w9h6mHtzpuIEwNn>OnuRSC2=>fP^Hqgc)xu^4 z<3!s`cORHJh#?!nKI`Et7{3C27+EuH)Gw1f)aoP|B3y?fuVfvpYYmmukx0ya-)TQX zR{ggy5cNf4X|g)nl#jC9p>7|09_S7>1D2GTRBUTW zAkQ=JMRogZqG#v;^=11O6@rPPwvJkr{bW-Qg8`q8GoD#K`&Y+S#%&B>SGRL>;ZunM@49!}Uy zN|bBCJ%sO;@3wl0>0gbl3L@1^O60ONObz8ZI7nder>(udj-jt`;yj^nTQ$L9`OU9W zX4alF#$|GiR47%x@s&LV>2Sz2R6?;2R~5k6V>)nz!o_*1Y!$p>BC5&?hJg_MiE6UBy>RkVZj`9UWbRkN-Hk!S`=BS3t3uyX6)7SF#)71*}`~Ogz z1rap5H6~dhBJ83;q-Y<5V35C2&F^JI-it(=5D#v!fAi9p#UwV~2tZQI+W(Dv?1t9? zfh*xpxxO{-(VGB>!Q&0%^YW_F!@aZS#ucP|YaD#>wd1Fv&Z*SR&mc;asi}1G) z_H>`!akh-Zxq9#io(7%;a$)w+{QH)Y$?UK1Dt^4)up!Szcxnu}kn$0afcfJL#IL+S z5gF_Y30j;{lNrG6m~$Ay?)*V9fZuU@3=kd40=LhazjFrau>(Y>SJNtOz>8x_X-BlA zIpl{i>OarVGj1v(4?^1`R}aQB&WCRQzS~;7R{tDZG=HhgrW@B`W|#cdyj%YBky)P= zpxuOZkW>S6%q7U{VsB#G(^FMsH5QuGXhb(sY+!-R8Bmv6Sx3WzSW<1MPPN1!&PurYky(@`bP9tz z52}LH9Q?+FF5jR6-;|+GVdRA!qtd;}*-h&iIw3Tq3qF9sDIb1FFxGbo&fbG5n8$3F zyY&PWL{ys^dTO}oZ#@sIX^BKW*bon=;te9j5k+T%wJ zNJtoN1~YVj4~YRrlZl)b&kJqp+Z`DqT!la$x&&IxgOQw#yZd-nBP3!7FijBXD|IsU8Zl^ zc6?MKpJQ+7ka|tZQLfchD$PD|;K(9FiLE|eUZX#EZxhG!S-63C$jWX1Yd!6-Yxi-u zjULIr|0-Q%D9jz}IF~S%>0(jOqZ(Ln<$9PxiySr&2Oic7vb<8q=46)Ln%Z|<*z5&> z3f~Zw@m;vR(bESB<=Jqkxn(=#hQw42l(7)h`vMQQTttz9XW6^|^8EK7qhju4r_c*b zJIi`)MB$w@9epwdIfnEBR+?~);yd6C(LeMC& zn&&N*?-g&BBJcV;8&UoZi4Lmxcj16ojlxR~zMrf=O_^i1wGb9X-0@6_rpjPYemIin zmJb+;lHe;Yp=8G)Q(L1bzH*}I>}uAqhj4;g)PlvD9_e_ScR{Ipq|$8NvAvLD8MYr}xl=bU~)f%B3E>r3Bu9_t|ThF3C5~BdOve zEbk^r&r#PT&?^V1cb{72yEWH}TXEE}w>t!cY~rA+hNOTK8FAtIEoszp!qqptS&;r$ zaYV-NX96-h$6aR@1xz6_E0^N49mU)-v#bwtGJm)ibygzJ8!7|WIrcb`$XH~^!a#s& z{Db-0IOTFq#9!^j!n_F}#Z_nX{YzBK8XLPVmc&X`fT7!@$U-@2KM9soGbmOSAmqV z{nr$L^MBo_u^Joyf0E^=eo{Rt0{{e$IFA(#*kP@SQd6lWT2-#>` zP1)7_@IO!9lk>Zt?#CU?cuhiLF&)+XEM9B)cS(gvQT!X3`wL*{fArTS;Ak`J<84du zALKPz4}3nlG8Fo^MH0L|oK2-4xIY!~Oux~1sw!+It)&D3p;+N8AgqKI`ld6v71wy8I!eP0o~=RVcFQR2Gr(eP_JbSytoQ$Yt}l*4r@A8Me94y z8cTDWhqlq^qoAhbOzGBXv^Wa4vUz$(7B!mX`T=x_ueKRRDfg&Uc-e1+z4x$jyW_Pm zp?U;-R#xt^Z8Ev~`m`iL4*c#65Nn)q#=Y0l1AuD&+{|8-Gsij3LUZXpM0Bx0u7WWm zH|%yE@-#XEph2}-$-thl+S;__ciBxSSzHveP%~v}5I%u!z_l_KoW{KRx2=eB33umE zIYFtu^5=wGU`Jab8#}cnYry@9p5UE#U|VVvx_4l49JQ;jQdp(uw=$^A$EA$LM%vmE zvdEOaIcp5qX8wX{mYf0;#51~imYYPn4=k&#DsKTxo{_Mg*;S495?OBY?#gv=edYC* z^O@-sd-qa+U24xvcbL0@C7_6o!$`)sVr-jSJE4XQUQ$?L7}2(}Eixqv;L8AdJAVqc zq}RPgpnDb@E_;?6K58r3h4-!4rT4Ab#rLHLX?eMOfluJk=3i1@Gt1i#iA=O`M0@x! z(HtJP9BMHXEzuD93m|B&woj0g6T?f#^)>J>|I4C5?Gam>n9!8CT%~aT;=oco5d6U8 zMXl(=W;$ND_8+DD*?|5bJ!;8ebESXMUKBAf7YBwNVJibGaJ*(2G`F%wx)grqVPjudiaq^Kl&g$8A2 zWMxMr@_$c}d+;_B`#kUX-t|4VKH&_f^^EP0&=DPLW)H)UzBG%%Tra*5 z%$kyZe3I&S#gfie^z5)!twG={3Cuh)FdeA!Kj<-9** zvT*5%Tb`|QbE!iW-XcOuy39>D3oe6x{>&<#E$o8Ac|j)wq#kQzz|ATd=Z0K!p2$QE zPu?jL8Lb^y3_CQE{*}sTDe!2!dtlFjq&YLY@2#4>XS`}v#PLrpvc4*@q^O{mmnr5D zmyJq~t?8>FWU5vZdE(%4cuZuao0GNjp3~Dt*SLaxI#g_u>hu@k&9Ho*#CZP~lFJHj z(e!SYlLigyc?&5-YxlE{uuk$9b&l6d`uIlpg_z15dPo*iU&|Khx2*A5Fp;8iK_bdP z?T6|^7@lcx2j0T@x>X7|kuuBSB7<^zeY~R~4McconTxA2flHC0_jFxmSTv-~?zVT| zG_|yDqa9lkF*B6_{j=T>=M8r<0s;@z#h)3BQ4NLl@`Xr__o7;~M&dL3J8fP&zLfDfy z);ckcTev{@OUlZ`bCo(-3? z1u1xD`PKgSg?RqeVVsF<1SLF;XYA@Bsa&cY!I48ZJn1V<3d!?s=St?TLo zC0cNr`qD*M#s6f~X>SCNVkva^9A2ZP>CoJ9bvgXe_c}WdX-)pHM5m7O zrHt#g$F0AO+nGA;7dSJ?)|Mo~cf{z2L)Rz!`fpi73Zv)H=a5K)*$5sf_IZypi($P5 zsPwUc4~P-J1@^3C6-r9{V-u0Z&Sl7vNfmuMY4yy*cL>_)BmQF!8Om9Dej%cHxbIzA zhtV0d{=%cr?;bpBPjt@4w=#<>k5ee=TiWAXM2~tUGfm z$s&!Dm0R^V$}fOR*B^kGaipi~rx~A2cS0;t&khV1a4u38*XRUP~f za!rZMtay8bsLt6yFYl@>-y^31(*P!L^^s@mslZy(SMsv9bVoX`O#yBgEcjCmGpyc* zeH$Dw6vB5P*;jor+JOX@;6K#+xc)Z9B8M=x2a@Wx-{snPGpRmOC$zpsqW*JCh@M2Y z#K+M(>=#d^>Of9C`))h<=Bsy)6zaMJ&x-t%&+UcpLjV`jo4R2025 zXaG8EA!0lQa)|dx-@{O)qP6`$rhCkoQqZ`^SW8g-kOwrwsK8 z3ms*AIcyj}-1x&A&vSq{r=QMyp3CHdWH35!sad#!Sm>^|-|afB+Q;|Iq@LFgqIp#Z zD1%H+3I?6RGnk&IFo|u+E0dCxXz4yI^1i!QTu7uvIEH>i3rR{srcST`LIRwdV1P;W z+%AN1NIf@xxvVLiSX`8ILA8MzNqE&7>%jMzGt9wm78bo9<;h*W84i29^w!>V>{N+S zd`5Zmz^G;f=icvoOZfK5#1ctx*~UwD=ab4DGQXehQ!XYnak*dee%YN$_ZPL%KZuz$ zD;$PpT;HM^$KwtQm@7uvT`i6>Hae1CoRVM2)NL<2-k2PiX=eAx+-6j#JI?M}(tuBW zkF%jjLR)O`gI2fcPBxF^HeI|DWwQWHVR!;;{BXXHskxh8F@BMDn`oEi-NHt;CLymW z=KSv5)3dyzec0T5B*`g-MQ<;gz=nIWKUi9ko<|4I(-E0k$QncH>E4l z**1w&#={&zv4Tvhgz#c29`m|;lU-jmaXFMC11 z*dlXDMEOG>VoLMc>!rApwOu2prKSi*!w%`yzGmS+k(zm*CsLK*wv{S_0WX^8A-rKy zbk^Gf_92^7iB_uUF)EE+ET4d|X|>d&mdN?x@vxKAQk`O+r4Qdu>XGy(a(19g;=jU} zFX{O*_NG>!$@jh!U369Lnc+D~qch3uT+_Amyi}*k#LAAwh}k8IPK5a-WZ81ufD>l> z$4cF}GSz>ce`3FAic}6W4Z7m9KGO?(eWqi@L|5Hq0@L|&2flN1PVl}XgQ2q*_n2s3 zt5KtowNkTYB5b;SVuoXA@i5irXO)A&%7?V`1@HGCB&)Wgk+l|^XXChq;u(nyPB}b3 zY>m5jkxpZgi)zfbgv&ec4Zqdvm+D<?Im*mXweS9H+V>)zF#Zp3)bhl$PbISY{5=_z!8&*Jv~NYtI-g!>fDs zmvL5O^U%!^VaKA9gvKw|5?-jk>~%CVGvctKmP$kpnpfN{D8@X*Aazi$txfa%vd-|E z>kYmV66W!lNekJPom29LdZ%(I+ZLZYTXzTg*to~m?7vp%{V<~>H+2}PQ?PPAq`36R z<%wR8v6UkS>Wt#hzGk#44W<%9S=nBfB);6clKwnxY}T*w21Qc3_?IJ@4gYzC7s;WP zVQNI(M=S=JT#xsZy7G`cR(BP9*je0bfeN8JN5~zY(DDs0t{LpHOIbN);?T-69Pf3R zSNe*&p2%AwXHL>__g+xd4Hlc_vu<25H?(`nafS%)3UPP7_4;gk-9ckt8SJRTv5v0M z_Hww`qPudL?ajIR&X*;$y-`<)6dxx1U~5eGS13CB!lX;3w7n&lDDiArbAhSycd}+b zya_3p@A`$kQy;|NJZ~s44Hqo7Hwt}X86NK=(ey>lgWTtGL6k@Gy;PbO!M%1~Wcn2k zUFP|*5d>t-X*RU8g%>|(wwj*~#l4z^Aatf^DWd1Wj#Q*AY0D^V@sC`M zjJc6qXu0I7Y*2;;gGu!plAFzG=J;1%eIOdn zQA>J&e05UN*7I5@yRhK|lbBSfJ+5Uq;!&HV@xfPZrgD}kE*1DSq^=%{o%|LChhl#0 zlMb<^a6ixzpd{kNZr|3jTGeEzuo}-eLT-)Q$#b{!vKx8Tg}swCni>{#%vDY$Ww$84 zew3c9BBovqb}_&BRo#^!G(1Eg((BScRZ}C)Oz?y`T5wOrv);)b^4XR8 zhJo7+<^7)qB>I;46!GySzdneZ>n_E1oWZY;kf94#)s)kWjuJN1c+wbVoNQcmnv}{> zN0pF+Sl3E}UQ$}slSZeLJrwT>Sr}#V(dVaezCQl2|4LN`7L7v&siYR|r7M(*JYfR$ zst3=YaDw$FSc{g}KHO&QiKxuhEzF{f%RJLKe3p*7=oo`WNP)M(9X1zIQPP0XHhY3c znrP{$4#Ol$A0s|4S7Gx2L23dv*Gv2o;h((XVn+9+$qvm}s%zi6nI-_s6?mG! zj{DV;qesJb&owKeEK?=J>UcAlYckA7Sl+I&IN=yasrZOkejir*kE@SN`fk<8Fgx*$ zy&fE6?}G)d_N`){P~U@1jRVA|2*69)KSe_}!~?+`Yb{Y=O~_+@!j<&oVQQMnhoIRU zA0CyF1OFfkK44n*JD~!2!SCPM;PRSk%1XL=0&rz00wxPs&-_eapJy#$h!eqY%nS0{ z!aGg58JIJPF3_ci%n)QSVpa2H`vIe$RD43;#IRfDV&Ibit z+?>HW4{2wOfC6Fw)}4x}i1maDxcE1qi@BS*qcxD2gE@h3#4cgU*D-&3z7D|tVZWt= z-Cy2+*Cm@P4GN_TPUtaVyVesbVDazF@)j8VJ4>XZv!f%}&eO1SvIgr}4`A*3#vat< z_MoByL(qW6L7SFZ#|Gc1fFN)L2PxY+{B8tJp+pxRyz*87)vXR}*=&ahXjBlQKguuf zX6x<<6fQulE^C*KH8~W%ptpaC0l?b=_{~*U4?5Vt;dgM4t_{&UZ1C2j?b>b+5}{IF_CUyvz-@QZPMlJ)r_tS$9kH%RPv#2_nMb zRLj5;chJ72*U`Z@Dqt4$@_+k$%|8m(HqLG!qT4P^DdfvGf&){gKnGCX#H0!;W=AGP zbA&Z`-__a)VTS}kKFjWGk z%|>yE?t*EJ!qeQ%dPk$;xIQ+P0;()PCBDgjJm6Buj{f^awNoVx+9<|lg3%-$G(*f) zll6oOkN|yamn1uyl2*N-lnqRI1cvs_JxLTeahEK=THV$Sz*gQhKNb*p0fNoda#-&F zB-qJgW^g}!TtM|0bS2QZekW7_tKu%GcJ!4?lObt0z_$mZ4rbQ0o=^curCs3bJK6sq z9fu-aW-l#>z~ca(B;4yv;2RZ?tGYAU)^)Kz{L|4oPj zdOf_?de|#yS)p2v8-N||+XL=O*%3+y)oI(HbM)Ds?q8~HPzIP(vs*G`iddbWq}! z(2!VjP&{Z1w+%eUq^ '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat deleted file mode 100644 index 107acd3..0000000 --- a/gradlew.bat +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/src/com/hypixel/fastutil/util/SneakyThrow.java b/src/com/hypixel/fastutil/util/SneakyThrow.java index 8b6743e..c16209b 100644 --- a/src/com/hypixel/fastutil/util/SneakyThrow.java +++ b/src/com/hypixel/fastutil/util/SneakyThrow.java @@ -1,9 +1,6 @@ package com.hypixel.fastutil.util; public class SneakyThrow { - public SneakyThrow() { - } - public static RuntimeException sneakyThrow(Throwable t) { if (t == null) { throw new NullPointerException("t"); diff --git a/src/com/hypixel/fastutil/util/TLRUtil.java b/src/com/hypixel/fastutil/util/TLRUtil.java index 40f5537..f13a3fb 100644 --- a/src/com/hypixel/fastutil/util/TLRUtil.java +++ b/src/com/hypixel/fastutil/util/TLRUtil.java @@ -9,9 +9,6 @@ public class TLRUtil { private static final Unsafe UNSAFE; private static final long PROBE; - public TLRUtil() { - } - public static void localInit() { ThreadLocalRandom.current(); } diff --git a/src/com/hypixel/hytale/LateMain.java b/src/com/hypixel/hytale/LateMain.java index 6303c79..d2e6039 100644 --- a/src/com/hypixel/hytale/LateMain.java +++ b/src/com/hypixel/hytale/LateMain.java @@ -12,9 +12,6 @@ import java.util.Map.Entry; import java.util.logging.Level; public class LateMain { - public LateMain() { - } - public static void lateMain(String[] args) { try { if (!Options.parse(args)) { diff --git a/src/com/hypixel/hytale/Main.java b/src/com/hypixel/hytale/Main.java index c8ef1a2..23decc1 100644 --- a/src/com/hypixel/hytale/Main.java +++ b/src/com/hypixel/hytale/Main.java @@ -13,9 +13,6 @@ import java.util.Locale; import javax.annotation.Nonnull; public final class Main { - public Main() { - } - public static void main(String[] args) { Locale.setDefault(Locale.ENGLISH); System.setProperty("java.awt.headless", "true"); diff --git a/src/com/hypixel/hytale/assetstore/AssetConstants.java b/src/com/hypixel/hytale/assetstore/AssetConstants.java index ccd1cac..df29b58 100644 --- a/src/com/hypixel/hytale/assetstore/AssetConstants.java +++ b/src/com/hypixel/hytale/assetstore/AssetConstants.java @@ -5,7 +5,4 @@ public class AssetConstants { public static final int EXPECTED_ASSETS_PER_PATH = 1; public static final int EXPECTED_VALUES_PER_TAG = 3; public static final int EXPECTED_ASSETS_PER_TAG = 3; - - public AssetConstants() { - } } diff --git a/src/com/hypixel/hytale/assetstore/AssetMap.java b/src/com/hypixel/hytale/assetstore/AssetMap.java index 226b1ca..a225752 100644 --- a/src/com/hypixel/hytale/assetstore/AssetMap.java +++ b/src/com/hypixel/hytale/assetstore/AssetMap.java @@ -11,9 +11,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public abstract class AssetMap> { - public AssetMap() { - } - @Nullable public abstract T getAsset(K var1); diff --git a/src/com/hypixel/hytale/assetstore/AssetRegistry.java b/src/com/hypixel/hytale/assetstore/AssetRegistry.java index 9563a5b..f92558c 100644 --- a/src/com/hypixel/hytale/assetstore/AssetRegistry.java +++ b/src/com/hypixel/hytale/assetstore/AssetRegistry.java @@ -26,9 +26,6 @@ public class AssetRegistry { private static final Object2IntMap TAG_MAP = new Object2IntOpenHashMap<>(); private static final Object2IntMap CLIENT_TAG_MAP = new Object2IntOpenHashMap<>(); - public AssetRegistry() { - } - @Nonnull public static Map, AssetStore> getStoreMap() { return storeMapUnmodifiable; diff --git a/src/com/hypixel/hytale/assetstore/AssetValidationResults.java b/src/com/hypixel/hytale/assetstore/AssetValidationResults.java index 36501d1..33f03cc 100644 --- a/src/com/hypixel/hytale/assetstore/AssetValidationResults.java +++ b/src/com/hypixel/hytale/assetstore/AssetValidationResults.java @@ -10,7 +10,6 @@ import java.util.HashSet; import java.util.Set; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class AssetValidationResults extends ValidationResults { private Set> disabledMissingAssetClasses; @@ -40,11 +39,11 @@ public class AssetValidationResults extends ValidationResults { } @Override - public void logOrThrowValidatorExceptions(@NonNullDecl HytaleLogger logger, @NonNullDecl String msg) { + public void logOrThrowValidatorExceptions(@Nonnull HytaleLogger logger, @Nonnull String msg) { this.logOrThrowValidatorExceptions(logger, msg, null, 0); } - public void logOrThrowValidatorExceptions(@NonNullDecl HytaleLogger logger, @NonNullDecl String msg, @Nullable Path path, int lineOffset) { + public void logOrThrowValidatorExceptions(@Nonnull HytaleLogger logger, @Nonnull String msg, @Nullable Path path, int lineOffset) { if (GithubMessageUtil.isGithub() && this.validatorExceptions != null && !this.validatorExceptions.isEmpty()) { for (ValidationResults.ValidatorResultsHolder holder : this.validatorExceptions) { String file = "unknown"; diff --git a/src/com/hypixel/hytale/assetstore/codec/ContainedAssetCodec.java b/src/com/hypixel/hytale/assetstore/codec/ContainedAssetCodec.java index 4408378..6d6257c 100644 --- a/src/com/hypixel/hytale/assetstore/codec/ContainedAssetCodec.java +++ b/src/com/hypixel/hytale/assetstore/codec/ContainedAssetCodec.java @@ -227,8 +227,5 @@ public class ContainedAssetCodec, M extends INHERIT_ID, INHERIT_ID_AND_PARENT, INJECT_PARENT; - - private Mode() { - } } } diff --git a/src/com/hypixel/hytale/assetstore/event/AssetsEvent.java b/src/com/hypixel/hytale/assetstore/event/AssetsEvent.java index e16ad85..8b84c8e 100644 --- a/src/com/hypixel/hytale/assetstore/event/AssetsEvent.java +++ b/src/com/hypixel/hytale/assetstore/event/AssetsEvent.java @@ -4,6 +4,4 @@ import com.hypixel.hytale.assetstore.JsonAsset; import com.hypixel.hytale.event.IEvent; public abstract class AssetsEvent> implements IEvent> { - public AssetsEvent() { - } } diff --git a/src/com/hypixel/hytale/assetstore/map/AssetMapWithIndexes.java b/src/com/hypixel/hytale/assetstore/map/AssetMapWithIndexes.java index 853e43f..75b4669 100644 --- a/src/com/hypixel/hytale/assetstore/map/AssetMapWithIndexes.java +++ b/src/com/hypixel/hytale/assetstore/map/AssetMapWithIndexes.java @@ -15,9 +15,6 @@ public abstract class AssetMapWithIndexes> extends Def protected final Int2ObjectConcurrentHashMap indexedTagStorage = new Int2ObjectConcurrentHashMap<>(); protected final Int2ObjectConcurrentHashMap unmodifiableIndexedTagStorage = new Int2ObjectConcurrentHashMap<>(); - public AssetMapWithIndexes() { - } - @Override protected void clear() { super.clear(); diff --git a/src/com/hypixel/hytale/assetstore/map/CaseInsensitiveHashStrategy.java b/src/com/hypixel/hytale/assetstore/map/CaseInsensitiveHashStrategy.java index 9b9f6aa..d7d9845 100644 --- a/src/com/hypixel/hytale/assetstore/map/CaseInsensitiveHashStrategy.java +++ b/src/com/hypixel/hytale/assetstore/map/CaseInsensitiveHashStrategy.java @@ -5,9 +5,6 @@ import it.unimi.dsi.fastutil.Hash.Strategy; public class CaseInsensitiveHashStrategy implements Strategy { private static final CaseInsensitiveHashStrategy INSTANCE = new CaseInsensitiveHashStrategy(); - public CaseInsensitiveHashStrategy() { - } - public static CaseInsensitiveHashStrategy getInstance() { return INSTANCE; } diff --git a/src/com/hypixel/hytale/builtin/adventure/camera/asset/CameraShakeConfig.java b/src/com/hypixel/hytale/builtin/adventure/camera/asset/CameraShakeConfig.java index 011d9da..c072403 100644 --- a/src/com/hypixel/hytale/builtin/adventure/camera/asset/CameraShakeConfig.java +++ b/src/com/hypixel/hytale/builtin/adventure/camera/asset/CameraShakeConfig.java @@ -45,9 +45,6 @@ public class CameraShakeConfig implements NetworkSerializable> { - public CameraShakePacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedAssetMap assetMap, @Nonnull Map assets) { return toCachedPacket(UpdateType.Init, assetMap, assets); diff --git a/src/com/hypixel/hytale/builtin/adventure/camera/asset/viewbobbing/ViewBobbing.java b/src/com/hypixel/hytale/builtin/adventure/camera/asset/viewbobbing/ViewBobbing.java index b2649cf..3ad0358 100644 --- a/src/com/hypixel/hytale/builtin/adventure/camera/asset/viewbobbing/ViewBobbing.java +++ b/src/com/hypixel/hytale/builtin/adventure/camera/asset/viewbobbing/ViewBobbing.java @@ -34,9 +34,6 @@ public class ViewBobbing @Nonnull protected CameraShakeConfig firstPerson; - public ViewBobbing() { - } - public MovementType getId() { return this.id; } diff --git a/src/com/hypixel/hytale/builtin/adventure/camera/asset/viewbobbing/ViewBobbingPacketGenerator.java b/src/com/hypixel/hytale/builtin/adventure/camera/asset/viewbobbing/ViewBobbingPacketGenerator.java index 20e2343..dd50293 100644 --- a/src/com/hypixel/hytale/builtin/adventure/camera/asset/viewbobbing/ViewBobbingPacketGenerator.java +++ b/src/com/hypixel/hytale/builtin/adventure/camera/asset/viewbobbing/ViewBobbingPacketGenerator.java @@ -14,9 +14,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class ViewBobbingPacketGenerator extends SimpleAssetPacketGenerator> { - public ViewBobbingPacketGenerator() { - } - @Nonnull @Override public Packet generateInitPacket(AssetMap assetMap, @Nonnull Map assets) { diff --git a/src/com/hypixel/hytale/builtin/adventure/camera/command/CameraEffectCommand.java b/src/com/hypixel/hytale/builtin/adventure/camera/command/CameraEffectCommand.java index 8fd1bfa..c601e87 100644 --- a/src/com/hypixel/hytale/builtin/adventure/camera/command/CameraEffectCommand.java +++ b/src/com/hypixel/hytale/builtin/adventure/camera/command/CameraEffectCommand.java @@ -19,8 +19,7 @@ import com.hypixel.hytale.server.core.universe.PlayerRef; import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import javax.annotation.Nullable; public class CameraEffectCommand extends AbstractCommandCollection { @Nonnull @@ -52,12 +51,12 @@ public class CameraEffectCommand extends AbstractCommandCollection { @Override protected void execute( - @NonNullDecl CommandContext context, - @NullableDecl Ref sourceRef, - @NonNullDecl Ref ref, - @NonNullDecl PlayerRef playerRef, - @NonNullDecl World world, - @NonNullDecl Store store + @Nonnull CommandContext context, + @Nullable Ref sourceRef, + @Nonnull Ref ref, + @Nonnull PlayerRef playerRef, + @Nonnull World world, + @Nonnull Store store ) { DamageCause damageCause = context.get(this.causeArg); float damageAmount = context.get(this.damageArg); @@ -95,12 +94,12 @@ public class CameraEffectCommand extends AbstractCommandCollection { @Override protected void execute( - @NonNullDecl CommandContext context, - @NullableDecl Ref sourceRef, - @NonNullDecl Ref ref, - @NonNullDecl PlayerRef playerRef, - @NonNullDecl World world, - @NonNullDecl Store store + @Nonnull CommandContext context, + @Nullable Ref sourceRef, + @Nonnull Ref ref, + @Nonnull PlayerRef playerRef, + @Nonnull World world, + @Nonnull Store store ) { CameraEffect cameraEffect = context.get(this.effectArg); float intensity = context.get(this.intensityArg); diff --git a/src/com/hypixel/hytale/builtin/adventure/camera/interaction/CameraShakeInteraction.java b/src/com/hypixel/hytale/builtin/adventure/camera/interaction/CameraShakeInteraction.java index 8fb3e36..e8bfdfd 100644 --- a/src/com/hypixel/hytale/builtin/adventure/camera/interaction/CameraShakeInteraction.java +++ b/src/com/hypixel/hytale/builtin/adventure/camera/interaction/CameraShakeInteraction.java @@ -40,9 +40,6 @@ public class CameraShakeInteraction extends SimpleInstantInteraction { protected String effectId; protected int effectIndex = Integer.MIN_VALUE; - public CameraShakeInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { if (this.effectIndex != Integer.MIN_VALUE) { diff --git a/src/com/hypixel/hytale/builtin/adventure/camera/system/CameraEffectSystem.java b/src/com/hypixel/hytale/builtin/adventure/camera/system/CameraEffectSystem.java index d779012..56811f1 100644 --- a/src/com/hypixel/hytale/builtin/adventure/camera/system/CameraEffectSystem.java +++ b/src/com/hypixel/hytale/builtin/adventure/camera/system/CameraEffectSystem.java @@ -28,9 +28,6 @@ public class CameraEffectSystem extends DamageEventSystem { @Nonnull private static final Query QUERY = Query.and(PLAYER_REF_COMPONENT_TYPE, ENTITY_STAT_MAP_COMPONENT_TYPE); - public CameraEffectSystem() { - } - @Nullable @Override public SystemGroup getGroup() { diff --git a/src/com/hypixel/hytale/builtin/adventure/farming/FarmingSystems.java b/src/com/hypixel/hytale/builtin/adventure/farming/FarmingSystems.java index 1162b5c..fea5d54 100644 --- a/src/com/hypixel/hytale/builtin/adventure/farming/FarmingSystems.java +++ b/src/com/hypixel/hytale/builtin/adventure/farming/FarmingSystems.java @@ -46,11 +46,25 @@ import java.util.UUID; import java.util.concurrent.ThreadLocalRandom; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; public class FarmingSystems { - public FarmingSystems() { + private static boolean hasCropAbove(BlockChunk blockChunk, int x, int y, int z) { + if (y + 1 >= 320) { + return false; + } else { + BlockSection aboveBlockSection = blockChunk.getSectionAtBlockY(y + 1); + if (aboveBlockSection == null) { + return false; + } else { + BlockType aboveBlockType = BlockType.getAssetMap().getAsset(aboveBlockSection.get(x, y + 1, z)); + if (aboveBlockType == null) { + return false; + } else { + FarmingData farmingConfig = aboveBlockType.getFarming(); + return farmingConfig != null && farmingConfig.getStages() != null; + } + } + } } private static boolean updateSoilDecayTime(CommandBuffer commandBuffer, TilledSoilBlock soilBlock, BlockType blockType) { @@ -79,9 +93,6 @@ public class FarmingSystems { public static class CoopResidentEntitySystem extends RefSystem { private static final ComponentType componentType = CoopResidentComponent.getComponentType(); - public CoopResidentEntitySystem() { - } - @Override public Query getQuery() { return componentType; @@ -89,19 +100,13 @@ public class FarmingSystems { @Override public void onEntityAdded( - @NonNullDecl Ref ref, - @NonNullDecl AddReason reason, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { } @Override public void onEntityRemove( - @NonNullDecl Ref ref, - @NonNullDecl RemoveReason reason, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, @Nonnull RemoveReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { if (reason != RemoveReason.UNLOAD) { UUIDComponent uuidComponent = commandBuffer.getComponent(ref, UUIDComponent.getComponentType()); @@ -148,9 +153,6 @@ public class FarmingSystems { public static class CoopResidentTicking extends EntityTickingSystem { private static final ComponentType componentType = CoopResidentComponent.getComponentType(); - public CoopResidentTicking() { - } - @Override public Query getQuery() { return componentType; @@ -160,9 +162,9 @@ public class FarmingSystems { public void tick( float dt, int index, - @NonNullDecl ArchetypeChunk archetypeChunk, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull ArchetypeChunk archetypeChunk, + @Nonnull Store store, + @Nonnull CommandBuffer commandBuffer ) { CoopResidentComponent coopResidentComponent = archetypeChunk.getComponent(index, CoopResidentComponent.getComponentType()); if (coopResidentComponent != null) { @@ -175,9 +177,6 @@ public class FarmingSystems { @Deprecated(forRemoval = true) public static class MigrateFarming extends BlockModule.MigrationSystem { - public MigrateFarming() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { FarmingBlockState oldState = holder.getComponent(FarmingPlugin.get().getFarmingBlockStateComponentType()); @@ -203,15 +202,9 @@ public class FarmingSystems { public static class OnCoopAdded extends RefSystem { private static final Query QUERY = Query.and(BlockModule.BlockStateInfo.getComponentType(), CoopBlock.getComponentType()); - public OnCoopAdded() { - } - @Override public void onEntityAdded( - @NonNullDecl Ref ref, - @NonNullDecl AddReason reason, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { CoopBlock coopBlock = commandBuffer.getComponent(ref, CoopBlock.getComponentType()); if (coopBlock != null) { @@ -238,10 +231,7 @@ public class FarmingSystems { @Override public void onEntityRemove( - @NonNullDecl Ref ref, - @NonNullDecl RemoveReason reason, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, @Nonnull RemoveReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { if (reason != RemoveReason.UNLOAD) { CoopBlock coop = commandBuffer.getComponent(ref, CoopBlock.getComponentType()); @@ -284,7 +274,7 @@ public class FarmingSystems { } } - @NullableDecl + @Nullable @Override public Query getQuery() { return QUERY; @@ -294,9 +284,6 @@ public class FarmingSystems { public static class OnFarmBlockAdded extends RefSystem { private static final Query QUERY = Query.and(BlockModule.BlockStateInfo.getComponentType(), FarmingBlock.getComponentType()); - public OnFarmBlockAdded() { - } - @Override public void onEntityAdded( @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer @@ -309,8 +296,8 @@ public class FarmingSystems { assert info != null; + BlockChunk blockChunk = commandBuffer.getComponent(info.getChunkRef(), BlockChunk.getComponentType()); if (farmingBlock.getLastTickGameTime() == null) { - BlockChunk blockChunk = commandBuffer.getComponent(info.getChunkRef(), BlockChunk.getComponentType()); int blockId = blockChunk.getBlock( ChunkUtil.xFromBlockInColumn(info.getIndex()), ChunkUtil.yFromBlockInColumn(info.getIndex()), ChunkUtil.zFromBlockInColumn(info.getIndex()) ); @@ -323,6 +310,7 @@ public class FarmingSystems { farmingBlock.setLastTickGameTime( store.getExternalData().getWorld().getEntityStore().getStore().getResource(WorldTimeResource.getResourceType()).getGameTime() ); + blockChunk.markNeedsSaving(); if (blockType.getFarming().getStages() != null) { FarmingStageData[] stages = blockType.getFarming().getStages().get(blockType.getFarming().getStartingStageSet()); if (stages != null && stages.length > 0) { @@ -370,6 +358,7 @@ public class FarmingSystems { farmingBlock.setLastTickGameTime( store.getExternalData().getWorld().getEntityStore().getStore().getResource(WorldTimeResource.getResourceType()).getGameTime() ); + blockChunk.markNeedsSaving(); } int x = ChunkUtil.xFromBlockInColumn(info.getIndex()); @@ -385,7 +374,7 @@ public class FarmingSystems { Ref section = column.getSection(ChunkUtil.chunkCoordinate(y)); BlockSection blockSection = commandBuffer.getComponent(section, BlockSection.getComponentType()); - FarmingUtil.tickFarming(commandBuffer, blockSection, section, ref, farmingBlock, x, y, z, true); + FarmingUtil.tickFarming(commandBuffer, blockChunk, blockSection, section, ref, farmingBlock, x, y, z, true); } @Override @@ -404,9 +393,6 @@ public class FarmingSystems { public static class OnSoilAdded extends RefSystem { private static final Query QUERY = Query.and(BlockModule.BlockStateInfo.getComponentType(), TilledSoilBlock.getComponentType()); - public OnSoilAdded() { - } - @Override public void onEntityAdded( @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer @@ -461,9 +447,6 @@ public class FarmingSystems { public static class Ticking extends EntityTickingSystem { private static final Query QUERY = Query.and(BlockSection.getComponentType(), ChunkSection.getComponentType()); - public Ticking() { - } - @Override public void tick( float dt, @@ -481,39 +464,45 @@ public class FarmingSystems { assert section != null; - BlockComponentChunk blockComponentChunk = commandBuffer.getComponent(section.getChunkColumnReference(), BlockComponentChunk.getComponentType()); + if (section.getChunkColumnReference() != null && section.getChunkColumnReference().isValid()) { + BlockComponentChunk blockComponentChunk = commandBuffer.getComponent(section.getChunkColumnReference(), BlockComponentChunk.getComponentType()); - assert blockComponentChunk != null; + assert blockComponentChunk != null; - Ref ref = archetypeChunk.getReferenceTo(index); - blocks.forEachTicking( - blockComponentChunk, commandBuffer, section.getY(), (blockComponentChunk1, commandBuffer1, localX, localY, localZ, blockId) -> { - Ref blockRef = blockComponentChunk1.getEntityReference(ChunkUtil.indexBlockInColumn(localX, localY, localZ)); - if (blockRef == null) { - return BlockTickStrategy.IGNORED; - } else { - FarmingBlock farming = commandBuffer1.getComponent(blockRef, FarmingBlock.getComponentType()); - if (farming != null) { - FarmingUtil.tickFarming(commandBuffer1, blocks, ref, blockRef, farming, localX, localY, localZ, false); - return BlockTickStrategy.SLEEP; + Ref ref = archetypeChunk.getReferenceTo(index); + BlockChunk blockChunk = commandBuffer.getComponent(section.getChunkColumnReference(), BlockChunk.getComponentType()); + + assert blockChunk != null; + + blocks.forEachTicking( + blockComponentChunk, commandBuffer, section.getY(), (blockComponentChunk1, commandBuffer1, localX, localY, localZ, blockId) -> { + Ref blockRef = blockComponentChunk1.getEntityReference(ChunkUtil.indexBlockInColumn(localX, localY, localZ)); + if (blockRef == null) { + return BlockTickStrategy.IGNORED; } else { - TilledSoilBlock soil = commandBuffer1.getComponent(blockRef, TilledSoilBlock.getComponentType()); - if (soil != null) { - tickSoil(commandBuffer1, blockComponentChunk1, blockRef, soil); + FarmingBlock farming = commandBuffer1.getComponent(blockRef, FarmingBlock.getComponentType()); + if (farming != null) { + FarmingUtil.tickFarming(commandBuffer1, blockChunk, blocks, ref, blockRef, farming, localX, localY, localZ, false); return BlockTickStrategy.SLEEP; } else { - CoopBlock coop = commandBuffer1.getComponent(blockRef, CoopBlock.getComponentType()); - if (coop != null) { - tickCoop(commandBuffer1, blockComponentChunk1, blockRef, coop); + TilledSoilBlock soil = commandBuffer1.getComponent(blockRef, TilledSoilBlock.getComponentType()); + if (soil != null) { + tickSoil(commandBuffer1, blockComponentChunk1, blockRef, soil); return BlockTickStrategy.SLEEP; } else { - return BlockTickStrategy.IGNORED; + CoopBlock coop = commandBuffer1.getComponent(blockRef, CoopBlock.getComponentType()); + if (coop != null) { + tickCoop(commandBuffer1, blockComponentChunk1, blockRef, coop); + return BlockTickStrategy.SLEEP; + } else { + return BlockTickStrategy.IGNORED; + } } } } } - } - ); + ); + } } } @@ -528,14 +517,6 @@ public class FarmingSystems { int y = ChunkUtil.yFromBlockInColumn(info.getIndex()); int z = ChunkUtil.zFromBlockInColumn(info.getIndex()); if (y < 320) { - int checkIndex = ChunkUtil.indexBlockInColumn(x, y + 1, z); - Ref aboveBlockRef = blockComponentChunk.getEntityReference(checkIndex); - boolean hasCrop = false; - if (aboveBlockRef != null) { - FarmingBlock farmingBlock = commandBuffer.getComponent(aboveBlockRef, FarmingBlock.getComponentType()); - hasCrop = farmingBlock != null; - } - assert info.getChunkRef() != null; BlockChunk blockChunk = commandBuffer.getComponent(info.getChunkRef(), BlockChunk.getComponentType()); @@ -543,6 +524,7 @@ public class FarmingSystems { assert blockChunk != null; BlockSection blockSection = blockChunk.getSectionAtBlockY(y); + boolean hasCrop = FarmingSystems.hasCropAbove(blockChunk, x, y, z); BlockType blockType = BlockType.getAssetMap().getAsset(blockSection.get(x, y, z)); Instant currentTime = commandBuffer.getExternalData() .getWorld() diff --git a/src/com/hypixel/hytale/builtin/adventure/farming/FarmingUtil.java b/src/com/hypixel/hytale/builtin/adventure/farming/FarmingUtil.java index 1a17501..0b100ea 100644 --- a/src/com/hypixel/hytale/builtin/adventure/farming/FarmingUtil.java +++ b/src/com/hypixel/hytale/builtin/adventure/farming/FarmingUtil.java @@ -25,6 +25,7 @@ import com.hypixel.hytale.server.core.modules.entity.component.PersistentModel; import com.hypixel.hytale.server.core.modules.interaction.BlockHarvestUtils; import com.hypixel.hytale.server.core.modules.time.WorldTimeResource; import com.hypixel.hytale.server.core.universe.world.World; +import com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk; import com.hypixel.hytale.server.core.universe.world.chunk.BlockComponentChunk; import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk; import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection; @@ -35,17 +36,15 @@ import com.hypixel.hytale.server.npc.metadata.CapturedNPCMetadata; import java.time.Instant; import java.util.Map; import javax.annotation.Nonnull; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import javax.annotation.Nullable; public class FarmingUtil { private static final int MAX_SECONDS_BETWEEN_TICKS = 15; private static final int BETWEEN_RANDOM = 10; - public FarmingUtil() { - } - public static void tickFarming( CommandBuffer commandBuffer, + BlockChunk blockChunk, BlockSection blockSection, Ref sectionRef, Ref blockRef, @@ -68,7 +67,18 @@ public class FarmingUtil { float currentProgress = farmingBlock.getGrowthProgress(); int currentStage = (int)currentProgress; String currentStageSet = farmingBlock.getCurrentStageSet(); - FarmingStageData[] stages = farmingConfig.getStages().get(currentStageSet); + FarmingStageData[] stages = currentStageSet != null ? farmingConfig.getStages().get(currentStageSet) : null; + if (stages == null) { + currentStageSet = farmingConfig.getStartingStageSet(); + if (currentStageSet == null) { + return; + } + + farmingBlock.setCurrentStageSet(currentStageSet); + stages = farmingConfig.getStages().get(currentStageSet); + blockChunk.markNeedsSaving(); + } + if (stages != null) { if (currentStage < 0) { currentStage = 0; @@ -88,6 +98,7 @@ public class FarmingUtil { while (currentStage < stages.length) { FarmingStageData stage = stages[currentStage]; if (stage.shouldStop(commandBuffer, sectionRef, blockRef, x, y, z)) { + blockChunk.markNeedsSaving(); farmingBlock.setGrowthProgress(stages.length); commandBuffer.removeEntity(blockRef, RemoveReason.REMOVE); break; @@ -95,6 +106,7 @@ public class FarmingUtil { Rangef range = stage.getDuration(); if (range == null) { + blockChunk.markNeedsSaving(); commandBuffer.removeEntity(blockRef, RemoveReason.REMOVE); break; } @@ -131,6 +143,7 @@ public class FarmingUtil { remainingTimeSeconds -= remainingDurationSeconds; currentProgress = ++currentStage; farmingBlock.setGrowthProgress(currentProgress); + blockChunk.markNeedsSaving(); farmingBlock.setGeneration(farmingBlock.getGeneration() + 1); if (currentStage >= stages.length) { if (stages[currentStage - 1].implementsShouldStop()) { @@ -168,8 +181,10 @@ public class FarmingUtil { } } - @NullableDecl - public static CapturedNPCMetadata generateCapturedNPCMetadata(ComponentAccessor componentAccessor, Ref entityRef, int roleIndex) { + @Nullable + public static CapturedNPCMetadata generateCapturedNPCMetadata( + @Nonnull ComponentAccessor componentAccessor, @Nonnull Ref entityRef, int roleIndex + ) { PersistentModel persistentModel = componentAccessor.getComponent(entityRef, PersistentModel.getComponentType()); if (persistentModel == null) { return null; diff --git a/src/com/hypixel/hytale/builtin/adventure/farming/component/CoopResidentComponent.java b/src/com/hypixel/hytale/builtin/adventure/farming/component/CoopResidentComponent.java index 772c55b..263afae 100644 --- a/src/com/hypixel/hytale/builtin/adventure/farming/component/CoopResidentComponent.java +++ b/src/com/hypixel/hytale/builtin/adventure/farming/component/CoopResidentComponent.java @@ -7,7 +7,7 @@ import com.hypixel.hytale.component.Component; import com.hypixel.hytale.component.ComponentType; import com.hypixel.hytale.math.vector.Vector3i; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import javax.annotation.Nullable; public class CoopResidentComponent implements Component { public static final BuilderCodec CODEC = BuilderCodec.builder(CoopResidentComponent.class, CoopResidentComponent::new) @@ -23,9 +23,6 @@ public class CoopResidentComponent implements Component { private Vector3i coopLocation = new Vector3i(); private boolean markedForDespawn; - public CoopResidentComponent() { - } - public static ComponentType getComponentType() { return FarmingPlugin.get().getCoopResidentComponentType(); } @@ -46,7 +43,7 @@ public class CoopResidentComponent implements Component { return this.markedForDespawn; } - @NullableDecl + @Nullable @Override public Component clone() { CoopResidentComponent component = new CoopResidentComponent(); diff --git a/src/com/hypixel/hytale/builtin/adventure/farming/config/modifiers/FertilizerGrowthModifierAsset.java b/src/com/hypixel/hytale/builtin/adventure/farming/config/modifiers/FertilizerGrowthModifierAsset.java index 2b266b5..c061d2d 100644 --- a/src/com/hypixel/hytale/builtin/adventure/farming/config/modifiers/FertilizerGrowthModifierAsset.java +++ b/src/com/hypixel/hytale/builtin/adventure/farming/config/modifiers/FertilizerGrowthModifierAsset.java @@ -16,9 +16,6 @@ public class FertilizerGrowthModifierAsset extends GrowthModifierAsset { ) .build(); - public FertilizerGrowthModifierAsset() { - } - @Override public double getCurrentGrowthMultiplier( CommandBuffer commandBuffer, Ref sectionRef, Ref blockRef, int x, int y, int z, boolean initialTick diff --git a/src/com/hypixel/hytale/builtin/adventure/farming/config/modifiers/LightLevelGrowthModifierAsset.java b/src/com/hypixel/hytale/builtin/adventure/farming/config/modifiers/LightLevelGrowthModifierAsset.java index c29be91..7a8521d 100644 --- a/src/com/hypixel/hytale/builtin/adventure/farming/config/modifiers/LightLevelGrowthModifierAsset.java +++ b/src/com/hypixel/hytale/builtin/adventure/farming/config/modifiers/LightLevelGrowthModifierAsset.java @@ -37,9 +37,6 @@ public class LightLevelGrowthModifierAsset extends GrowthModifierAsset { protected Rangef sunlight; protected boolean requireBoth; - public LightLevelGrowthModifierAsset() { - } - public LightLevelGrowthModifierAsset.ArtificialLight getArtificialLight() { return this.artificialLight; } @@ -131,9 +128,6 @@ public class LightLevelGrowthModifierAsset extends GrowthModifierAsset { protected Range green; protected Range blue; - public ArtificialLight() { - } - public Range getRed() { return this.red; } diff --git a/src/com/hypixel/hytale/builtin/adventure/farming/config/modifiers/WaterGrowthModifierAsset.java b/src/com/hypixel/hytale/builtin/adventure/farming/config/modifiers/WaterGrowthModifierAsset.java index f2134d8..bf7339d 100644 --- a/src/com/hypixel/hytale/builtin/adventure/farming/config/modifiers/WaterGrowthModifierAsset.java +++ b/src/com/hypixel/hytale/builtin/adventure/farming/config/modifiers/WaterGrowthModifierAsset.java @@ -62,9 +62,6 @@ public class WaterGrowthModifierAsset extends GrowthModifierAsset { protected IntOpenHashSet weatherIds; protected int rainDuration; - public WaterGrowthModifierAsset() { - } - public String[] getFluids() { return this.fluids; } diff --git a/src/com/hypixel/hytale/builtin/adventure/farming/config/stages/BlockStateFarmingStageData.java b/src/com/hypixel/hytale/builtin/adventure/farming/config/stages/BlockStateFarmingStageData.java index fb84145..096423c 100644 --- a/src/com/hypixel/hytale/builtin/adventure/farming/config/stages/BlockStateFarmingStageData.java +++ b/src/com/hypixel/hytale/builtin/adventure/farming/config/stages/BlockStateFarmingStageData.java @@ -23,9 +23,6 @@ public class BlockStateFarmingStageData extends FarmingStageData { .build(); protected String state; - public BlockStateFarmingStageData() { - } - public String getState() { return this.state; } diff --git a/src/com/hypixel/hytale/builtin/adventure/farming/config/stages/BlockTypeFarmingStageData.java b/src/com/hypixel/hytale/builtin/adventure/farming/config/stages/BlockTypeFarmingStageData.java index dcc0aa3..1e20b21 100644 --- a/src/com/hypixel/hytale/builtin/adventure/farming/config/stages/BlockTypeFarmingStageData.java +++ b/src/com/hypixel/hytale/builtin/adventure/farming/config/stages/BlockTypeFarmingStageData.java @@ -24,9 +24,6 @@ public class BlockTypeFarmingStageData extends FarmingStageData { .build(); protected String block; - public BlockTypeFarmingStageData() { - } - public String getBlock() { return this.block; } diff --git a/src/com/hypixel/hytale/builtin/adventure/farming/config/stages/PrefabFarmingStageData.java b/src/com/hypixel/hytale/builtin/adventure/farming/config/stages/PrefabFarmingStageData.java index ca12622..f5785e9 100644 --- a/src/com/hypixel/hytale/builtin/adventure/farming/config/stages/PrefabFarmingStageData.java +++ b/src/com/hypixel/hytale/builtin/adventure/farming/config/stages/PrefabFarmingStageData.java @@ -71,9 +71,6 @@ public class PrefabFarmingStageData extends FarmingStageData { private String[] replaceMaskTags = EMPTY_REPLACE_MASK; private int[] replaceMaskTagIndices; - public PrefabFarmingStageData() { - } - private static double computeParticlesRate(@Nonnull IPrefabBuffer prefab) { double xLength = prefab.getMaxX() - prefab.getMinX(); double yLength = prefab.getMaxY() - prefab.getMinY(); @@ -350,9 +347,6 @@ public class PrefabFarmingStageData extends FarmingStageData { protected int weight = 1; protected String path; - public PrefabStage() { - } - @Override public double getWeight() { return this.weight; diff --git a/src/com/hypixel/hytale/builtin/adventure/farming/config/stages/spread/DirectionalGrowthBehaviour.java b/src/com/hypixel/hytale/builtin/adventure/farming/config/stages/spread/DirectionalGrowthBehaviour.java index 06623d2..82226cb 100644 --- a/src/com/hypixel/hytale/builtin/adventure/farming/config/stages/spread/DirectionalGrowthBehaviour.java +++ b/src/com/hypixel/hytale/builtin/adventure/farming/config/stages/spread/DirectionalGrowthBehaviour.java @@ -74,9 +74,6 @@ public class DirectionalGrowthBehaviour extends SpreadGrowthBehaviour { protected IntRange verticalRange; protected DirectionalGrowthBehaviour.VerticalDirection verticalDirection = DirectionalGrowthBehaviour.VerticalDirection.BOTH; - public DirectionalGrowthBehaviour() { - } - public IWeightedMap getBlockTypes() { return this.blockTypes; } @@ -236,9 +233,6 @@ public class DirectionalGrowthBehaviour extends SpreadGrowthBehaviour { protected double weight = 1.0; protected String blockTypeKey; - public BlockTypeWeight() { - } - @Override public double getWeight() { return this.weight; diff --git a/src/com/hypixel/hytale/builtin/adventure/farming/config/stages/spread/SpreadFarmingStageData.java b/src/com/hypixel/hytale/builtin/adventure/farming/config/stages/spread/SpreadFarmingStageData.java index 0a1e153..b1cf33e 100644 --- a/src/com/hypixel/hytale/builtin/adventure/farming/config/stages/spread/SpreadFarmingStageData.java +++ b/src/com/hypixel/hytale/builtin/adventure/farming/config/stages/spread/SpreadFarmingStageData.java @@ -66,9 +66,6 @@ public class SpreadFarmingStageData extends FarmingStageData { protected IntRange spreadDecayPercent; protected SpreadGrowthBehaviour[] spreadGrowthBehaviours; - public SpreadFarmingStageData() { - } - public IntRange getExecutions() { return this.executions; } diff --git a/src/com/hypixel/hytale/builtin/adventure/farming/config/stages/spread/SpreadGrowthBehaviour.java b/src/com/hypixel/hytale/builtin/adventure/farming/config/stages/spread/SpreadGrowthBehaviour.java index 6d917fc..60d81e8 100644 --- a/src/com/hypixel/hytale/builtin/adventure/farming/config/stages/spread/SpreadGrowthBehaviour.java +++ b/src/com/hypixel/hytale/builtin/adventure/farming/config/stages/spread/SpreadGrowthBehaviour.java @@ -23,9 +23,6 @@ public abstract class SpreadGrowthBehaviour { .build(); protected WorldLocationCondition[] worldLocationConditions; - public SpreadGrowthBehaviour() { - } - public abstract void execute(ComponentAccessor var1, Ref var2, Ref var3, int var4, int var5, int var6, float var7); protected boolean validatePosition(World world, int worldX, int worldY, int worldZ) { diff --git a/src/com/hypixel/hytale/builtin/adventure/farming/interactions/ChangeFarmingStageInteraction.java b/src/com/hypixel/hytale/builtin/adventure/farming/interactions/ChangeFarmingStageInteraction.java index 1d1152b..2f8c5ca 100644 --- a/src/com/hypixel/hytale/builtin/adventure/farming/interactions/ChangeFarmingStageInteraction.java +++ b/src/com/hypixel/hytale/builtin/adventure/farming/interactions/ChangeFarmingStageInteraction.java @@ -81,9 +81,6 @@ public class ChangeFarmingStageInteraction extends SimpleBlockInteraction { @Nullable protected String targetStageSet = null; - public ChangeFarmingStageInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { diff --git a/src/com/hypixel/hytale/builtin/adventure/farming/interactions/FertilizeSoilInteraction.java b/src/com/hypixel/hytale/builtin/adventure/farming/interactions/FertilizeSoilInteraction.java index 3fc0d9b..7774f93 100644 --- a/src/com/hypixel/hytale/builtin/adventure/farming/interactions/FertilizeSoilInteraction.java +++ b/src/com/hypixel/hytale/builtin/adventure/farming/interactions/FertilizeSoilInteraction.java @@ -38,9 +38,6 @@ public class FertilizeSoilInteraction extends SimpleBlockInteraction { .build(); protected String[] refreshModifiers; - public FertilizeSoilInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { diff --git a/src/com/hypixel/hytale/builtin/adventure/farming/interactions/HarvestCropInteraction.java b/src/com/hypixel/hytale/builtin/adventure/farming/interactions/HarvestCropInteraction.java index c404cb9..ece6658 100644 --- a/src/com/hypixel/hytale/builtin/adventure/farming/interactions/HarvestCropInteraction.java +++ b/src/com/hypixel/hytale/builtin/adventure/farming/interactions/HarvestCropInteraction.java @@ -28,9 +28,6 @@ public class HarvestCropInteraction extends SimpleBlockInteraction { .documentation("Harvests the resources from the target farmable block.") .build(); - public HarvestCropInteraction() { - } - @Override protected void interactWithBlock( @Nonnull World world, diff --git a/src/com/hypixel/hytale/builtin/adventure/farming/interactions/UseCaptureCrateInteraction.java b/src/com/hypixel/hytale/builtin/adventure/farming/interactions/UseCaptureCrateInteraction.java index 401bd8d..8c11f3c 100644 --- a/src/com/hypixel/hytale/builtin/adventure/farming/interactions/UseCaptureCrateInteraction.java +++ b/src/com/hypixel/hytale/builtin/adventure/farming/interactions/UseCaptureCrateInteraction.java @@ -37,8 +37,8 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import com.hypixel.hytale.server.npc.NPCPlugin; import com.hypixel.hytale.server.npc.entities.NPCEntity; import com.hypixel.hytale.server.npc.metadata.CapturedNPCMetadata; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; public class UseCaptureCrateInteraction extends SimpleBlockInteraction { public static final BuilderCodec CODEC = BuilderCodec.builder( @@ -69,12 +69,9 @@ public class UseCaptureCrateInteraction extends SimpleBlockInteraction { protected int[] acceptedNpcGroupIndexes; protected String fullIcon; - public UseCaptureCrateInteraction() { - } - @Override protected void tick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @NonNullDecl InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { CommandBuffer commandBuffer = context.getCommandBuffer(); if (commandBuffer == null) { @@ -84,59 +81,62 @@ public class UseCaptureCrateInteraction extends SimpleBlockInteraction { if (item == null) { context.getState().state = InteractionState.Failed; } else { - Ref playerRef = context.getEntity(); - LivingEntity playerEntity = (LivingEntity)EntityUtils.getEntity(playerRef, commandBuffer); - Inventory playerInventory = playerEntity.getInventory(); - byte activeHotbarSlot = playerInventory.getActiveHotbarSlot(); - ItemStack inHandItemStack = playerInventory.getActiveHotbarItem(); - CapturedNPCMetadata existingMeta = item.getFromMetadataOrNull("CapturedEntity", CapturedNPCMetadata.CODEC); - if (existingMeta != null) { - super.tick0(firstRun, time, type, context, cooldownHandler); + Ref ref = context.getEntity(); + if (!(EntityUtils.getEntity(ref, commandBuffer) instanceof LivingEntity livingEntity)) { + context.getState().state = InteractionState.Failed; } else { - Ref targetEntity = context.getTargetEntity(); - if (targetEntity == null) { - context.getState().state = InteractionState.Failed; + Inventory inventory = livingEntity.getInventory(); + byte activeHotbarSlot = inventory.getActiveHotbarSlot(); + ItemStack inHandItemStack = inventory.getActiveHotbarItem(); + CapturedNPCMetadata existingMeta = item.getFromMetadataOrNull("CapturedEntity", CapturedNPCMetadata.CODEC); + if (existingMeta != null) { + super.tick0(firstRun, time, type, context, cooldownHandler); } else { - NPCEntity npc = commandBuffer.getComponent(targetEntity, NPCEntity.getComponentType()); - if (npc == null) { + Ref targetEntity = context.getTargetEntity(); + if (targetEntity == null) { context.getState().state = InteractionState.Failed; } else { - TagSetPlugin.TagSetLookup tagSetPlugin = TagSetPlugin.get(NPCGroup.class); - boolean tagFound = false; - - for (int group : this.acceptedNpcGroupIndexes) { - if (tagSetPlugin.tagInSet(group, npc.getRoleIndex())) { - tagFound = true; - break; - } - } - - if (!tagFound) { + NPCEntity npcComponent = commandBuffer.getComponent(targetEntity, NPCEntity.getComponentType()); + if (npcComponent == null) { context.getState().state = InteractionState.Failed; } else { - PersistentModel persistentModel = commandBuffer.getComponent(targetEntity, PersistentModel.getComponentType()); - if (persistentModel == null) { + TagSetPlugin.TagSetLookup tagSetPlugin = TagSetPlugin.get(NPCGroup.class); + boolean tagFound = false; + + for (int group : this.acceptedNpcGroupIndexes) { + if (tagSetPlugin.tagInSet(group, npcComponent.getRoleIndex())) { + tagFound = true; + break; + } + } + + if (!tagFound) { context.getState().state = InteractionState.Failed; } else { - ModelAsset modelAsset = ModelAsset.getAssetMap().getAsset(persistentModel.getModelReference().getModelAssetId()); - CapturedNPCMetadata meta = inHandItemStack.getFromMetadataOrDefault("CapturedEntity", CapturedNPCMetadata.CODEC); - if (modelAsset != null) { - meta.setIconPath(modelAsset.getIcon()); - } + PersistentModel persistentModel = commandBuffer.getComponent(targetEntity, PersistentModel.getComponentType()); + if (persistentModel == null) { + context.getState().state = InteractionState.Failed; + } else { + ModelAsset modelAsset = ModelAsset.getAssetMap().getAsset(persistentModel.getModelReference().getModelAssetId()); + CapturedNPCMetadata meta = inHandItemStack.getFromMetadataOrDefault("CapturedEntity", CapturedNPCMetadata.CODEC); + if (modelAsset != null) { + meta.setIconPath(modelAsset.getIcon()); + } - meta.setRoleIndex(npc.getRoleIndex()); - String npcName = NPCPlugin.get().getName(npc.getRoleIndex()); - if (npcName != null) { - meta.setNpcNameKey(npcName); - } + meta.setRoleIndex(npcComponent.getRoleIndex()); + String npcName = NPCPlugin.get().getName(npcComponent.getRoleIndex()); + if (npcName != null) { + meta.setNpcNameKey(npcName); + } - if (this.fullIcon != null) { - meta.setFullItemIcon(this.fullIcon); - } + if (this.fullIcon != null) { + meta.setFullItemIcon(this.fullIcon); + } - ItemStack itemWithNPC = inHandItemStack.withMetadata(CapturedNPCMetadata.KEYED_CODEC, meta); - playerInventory.getHotbar().replaceItemStackInSlot(activeHotbarSlot, item, itemWithNPC); - commandBuffer.removeEntity(targetEntity, RemoveReason.REMOVE); + ItemStack itemWithNPC = inHandItemStack.withMetadata(CapturedNPCMetadata.KEYED_CODEC, meta); + inventory.getHotbar().replaceItemStackInSlot(activeHotbarSlot, item, itemWithNPC); + commandBuffer.removeEntity(targetEntity, RemoveReason.REMOVE); + } } } } @@ -148,82 +148,81 @@ public class UseCaptureCrateInteraction extends SimpleBlockInteraction { @Override protected void interactWithBlock( - @NonNullDecl World world, - @NonNullDecl CommandBuffer commandBuffer, - @NonNullDecl InteractionType type, - @NonNullDecl InteractionContext context, - @NullableDecl ItemStack itemInHand, - @NonNullDecl Vector3i targetBlock, - @NonNullDecl CooldownHandler cooldownHandler + @Nonnull World world, + @Nonnull CommandBuffer commandBuffer, + @Nonnull InteractionType type, + @Nonnull InteractionContext context, + @Nullable ItemStack itemInHand, + @Nonnull Vector3i targetBlock, + @Nonnull CooldownHandler cooldownHandler ) { ItemStack item = context.getHeldItem(); if (item == null) { context.getState().state = InteractionState.Failed; } else { - Ref playerRef = context.getEntity(); - LivingEntity playerEntity = (LivingEntity)EntityUtils.getEntity(playerRef, commandBuffer); - Inventory playerInventory = playerEntity.getInventory(); - byte activeHotbarSlot = playerInventory.getActiveHotbarSlot(); - CapturedNPCMetadata existingMeta = item.getFromMetadataOrNull("CapturedEntity", CapturedNPCMetadata.CODEC); - if (existingMeta == null) { - context.getState().state = InteractionState.Failed; - } else { - BlockPosition pos = context.getTargetBlock(); - if (pos == null) { + Ref ref = context.getEntity(); + if (EntityUtils.getEntity(ref, commandBuffer) instanceof LivingEntity livingEntity) { + Inventory inventory = livingEntity.getInventory(); + byte activeHotbarSlot = inventory.getActiveHotbarSlot(); + CapturedNPCMetadata existingMeta = item.getFromMetadataOrNull("CapturedEntity", CapturedNPCMetadata.CODEC); + if (existingMeta == null) { context.getState().state = InteractionState.Failed; } else { - WorldChunk worldChunk = world.getChunk(ChunkUtil.indexChunkFromBlock(pos.x, pos.z)); - Ref blockRef = worldChunk.getBlockComponentEntity(pos.x, pos.y, pos.z); - if (blockRef == null) { - blockRef = BlockModule.ensureBlockEntity(worldChunk, pos.x, pos.y, pos.z); - } + BlockPosition pos = context.getTargetBlock(); + if (pos == null) { + context.getState().state = InteractionState.Failed; + } else { + WorldChunk worldChunk = world.getChunk(ChunkUtil.indexChunkFromBlock(pos.x, pos.z)); + Ref blockRef = worldChunk.getBlockComponentEntity(pos.x, pos.y, pos.z); + if (blockRef == null) { + blockRef = BlockModule.ensureBlockEntity(worldChunk, pos.x, pos.y, pos.z); + } - ItemStack noMetaItemStack = item.withMetadata(null); - if (blockRef != null) { - Store chunkStore = world.getChunkStore().getStore(); - CoopBlock coopBlockState = chunkStore.getComponent(blockRef, CoopBlock.getComponentType()); - if (coopBlockState != null) { - WorldTimeResource worldTimeResource = commandBuffer.getResource(WorldTimeResource.getResourceType()); - if (coopBlockState.tryPutResident(existingMeta, worldTimeResource)) { - world.execute( - () -> coopBlockState.ensureSpawnResidentsInWorld( - world, world.getEntityStore().getStore(), new Vector3d(pos.x, pos.y, pos.z), new Vector3d().assign(Vector3d.FORWARD) - ) - ); - playerInventory.getHotbar().replaceItemStackInSlot(activeHotbarSlot, item, noMetaItemStack); - } else { - context.getState().state = InteractionState.Failed; + ItemStack noMetaItemStack = item.withMetadata(null); + if (blockRef != null) { + Store chunkStore = world.getChunkStore().getStore(); + CoopBlock coopBlockState = chunkStore.getComponent(blockRef, CoopBlock.getComponentType()); + if (coopBlockState != null) { + WorldTimeResource worldTimeResource = commandBuffer.getResource(WorldTimeResource.getResourceType()); + if (coopBlockState.tryPutResident(existingMeta, worldTimeResource)) { + world.execute( + () -> coopBlockState.ensureSpawnResidentsInWorld( + world, world.getEntityStore().getStore(), new Vector3d(pos.x, pos.y, pos.z), new Vector3d().assign(Vector3d.FORWARD) + ) + ); + inventory.getHotbar().replaceItemStackInSlot(activeHotbarSlot, item, noMetaItemStack); + } else { + context.getState().state = InteractionState.Failed; + } + + return; } - - return; } - } - Vector3d spawnPos = new Vector3d(pos.x + 0.5F, pos.y, pos.z + 0.5F); - if (context.getClientState() != null) { - BlockFace blockFace = BlockFace.fromProtocolFace(context.getClientState().blockFace); - if (blockFace != null) { - spawnPos.add(blockFace.getDirection()); + Vector3d spawnPos = new Vector3d(pos.x + 0.5F, pos.y, pos.z + 0.5F); + if (context.getClientState() != null) { + BlockFace blockFace = BlockFace.fromProtocolFace(context.getClientState().blockFace); + if (blockFace != null) { + spawnPos.add(blockFace.getDirection()); + } } - } - NPCPlugin npcModule = NPCPlugin.get(); - Store store = context.getCommandBuffer().getStore(); - int roleIndex = existingMeta.getRoleIndex(); - commandBuffer.run(_store -> npcModule.spawnEntity(store, roleIndex, spawnPos, Vector3f.ZERO, null, null)); - playerInventory.getHotbar().replaceItemStackInSlot(activeHotbarSlot, item, noMetaItemStack); + NPCPlugin npcModule = NPCPlugin.get(); + Store store = context.getCommandBuffer().getStore(); + int roleIndex = existingMeta.getRoleIndex(); + commandBuffer.run(_store -> npcModule.spawnEntity(store, roleIndex, spawnPos, Vector3f.ZERO, null, null)); + inventory.getHotbar().replaceItemStackInSlot(activeHotbarSlot, item, noMetaItemStack); + } } + } else { + context.getState().state = InteractionState.Failed; } } } @Override protected void simulateInteractWithBlock( - @NonNullDecl InteractionType type, - @NonNullDecl InteractionContext context, - @NullableDecl ItemStack itemInHand, - @NonNullDecl World world, - @NonNullDecl Vector3i targetBlock + @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nullable ItemStack itemInHand, @Nonnull World world, @Nonnull Vector3i targetBlock ) { } } diff --git a/src/com/hypixel/hytale/builtin/adventure/farming/interactions/UseCoopInteraction.java b/src/com/hypixel/hytale/builtin/adventure/farming/interactions/UseCoopInteraction.java index 5c543a6..532287f 100644 --- a/src/com/hypixel/hytale/builtin/adventure/farming/interactions/UseCoopInteraction.java +++ b/src/com/hypixel/hytale/builtin/adventure/farming/interactions/UseCoopInteraction.java @@ -22,8 +22,8 @@ import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk; import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; public class UseCoopInteraction extends SimpleBlockInteraction { public static final BuilderCodec CODEC = BuilderCodec.builder( @@ -31,18 +31,15 @@ public class UseCoopInteraction extends SimpleBlockInteraction { ) .build(); - public UseCoopInteraction() { - } - @Override protected void interactWithBlock( - @NonNullDecl World world, - @NonNullDecl CommandBuffer commandBuffer, - @NonNullDecl InteractionType type, - @NonNullDecl InteractionContext context, - @NullableDecl ItemStack itemInHand, - @NonNullDecl Vector3i targetBlock, - @NonNullDecl CooldownHandler cooldownHandler + @Nonnull World world, + @Nonnull CommandBuffer commandBuffer, + @Nonnull InteractionType type, + @Nonnull InteractionContext context, + @Nullable ItemStack itemInHand, + @Nonnull Vector3i targetBlock, + @Nonnull CooldownHandler cooldownHandler ) { int x = targetBlock.getX(); int z = targetBlock.getZ(); @@ -85,11 +82,7 @@ public class UseCoopInteraction extends SimpleBlockInteraction { @Override protected void simulateInteractWithBlock( - @NonNullDecl InteractionType type, - @NonNullDecl InteractionContext context, - @NullableDecl ItemStack itemInHand, - @NonNullDecl World world, - @NonNullDecl Vector3i targetBlock + @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nullable ItemStack itemInHand, @Nonnull World world, @Nonnull Vector3i targetBlock ) { } } diff --git a/src/com/hypixel/hytale/builtin/adventure/farming/interactions/UseWateringCanInteraction.java b/src/com/hypixel/hytale/builtin/adventure/farming/interactions/UseWateringCanInteraction.java index b4f37ed..1d339cb 100644 --- a/src/com/hypixel/hytale/builtin/adventure/farming/interactions/UseWateringCanInteraction.java +++ b/src/com/hypixel/hytale/builtin/adventure/farming/interactions/UseWateringCanInteraction.java @@ -43,9 +43,6 @@ public class UseWateringCanInteraction extends SimpleBlockInteraction { protected long duration; protected String[] refreshModifiers; - public UseWateringCanInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { diff --git a/src/com/hypixel/hytale/builtin/adventure/farming/states/CoopBlock.java b/src/com/hypixel/hytale/builtin/adventure/farming/states/CoopBlock.java index b6ab6b8..0cc5209 100644 --- a/src/com/hypixel/hytale/builtin/adventure/farming/states/CoopBlock.java +++ b/src/com/hypixel/hytale/builtin/adventure/farming/states/CoopBlock.java @@ -45,6 +45,7 @@ import com.hypixel.hytale.server.spawning.ISpawnableWithModel; import com.hypixel.hytale.server.spawning.SpawnTestResult; import com.hypixel.hytale.server.spawning.SpawningContext; import it.unimi.dsi.fastutil.Pair; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; import java.time.Duration; import java.time.Instant; import java.time.LocalDateTime; @@ -55,7 +56,7 @@ import java.util.List; import java.util.Map; import java.util.UUID; import java.util.concurrent.ThreadLocalRandom; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import javax.annotation.Nullable; public class CoopBlock implements Component { public static final String STATE_PRODUCE = "Produce_Ready"; @@ -71,7 +72,6 @@ public class CoopBlock implements Component { .append(new KeyedCodec<>("Storage", ItemContainer.CODEC), (coop, storage) -> coop.itemContainer = storage, coop -> coop.itemContainer) .add() .build(); - HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); protected String coopAssetId; protected List residents = new ArrayList<>(); protected ItemContainer itemContainer = EmptyItemContainer.INSTANCE; @@ -85,7 +85,7 @@ public class CoopBlock implements Component { this.itemContainer = ItemContainer.ensureContainerCapacity(this.itemContainer, (short)5, SimpleItemContainer::new, remainder); } - @NullableDecl + @Nullable public FarmingCoopAsset getCoopAsset() { return FarmingCoopAsset.getAssetMap().getAsset(this.coopAssetId); } @@ -94,7 +94,7 @@ public class CoopBlock implements Component { this.coopAssetId = farmingCoopId; this.residents.addAll(residents); this.itemContainer = itemContainer.clone(); - ArrayList remainder = new ArrayList<>(); + List remainder = new ObjectArrayList<>(); this.itemContainer = ItemContainer.ensureContainerCapacity(this.itemContainer, (short)5, SimpleItemContainer::new, remainder); } @@ -336,7 +336,7 @@ public class CoopBlock implements Component { } } - @NullableDecl + @Nullable public Instant getNextScheduledTick(WorldTimeResource worldTimeResource) { Instant gameTime = worldTimeResource.getGameTime(); LocalDateTime gameDateTime = worldTimeResource.getGameDateTime(); @@ -431,7 +431,7 @@ public class CoopBlock implements Component { .add() .build(); protected CapturedNPCMetadata metadata; - @NullableDecl + @Nullable protected PersistentRef persistentRef; protected boolean deployedToWorld; protected Instant lastProduced; @@ -449,12 +449,12 @@ public class CoopBlock implements Component { return this.metadata; } - @NullableDecl + @Nullable public PersistentRef getPersistentRef() { return this.persistentRef; } - public void setPersistentRef(@NullableDecl PersistentRef persistentRef) { + public void setPersistentRef(@Nullable PersistentRef persistentRef) { this.persistentRef = persistentRef; } diff --git a/src/com/hypixel/hytale/builtin/adventure/farming/states/FarmingBlockState.java b/src/com/hypixel/hytale/builtin/adventure/farming/states/FarmingBlockState.java index b490d86..967bc3f 100644 --- a/src/com/hypixel/hytale/builtin/adventure/farming/states/FarmingBlockState.java +++ b/src/com/hypixel/hytale/builtin/adventure/farming/states/FarmingBlockState.java @@ -43,9 +43,6 @@ public class FarmingBlockState implements Component { public double lastGrowthMultiplier; public float spreadRate = 1.0F; - public FarmingBlockState() { - } - public String getCurrentFarmingStageSetName() { return this.currentFarmingStageSetName; } @@ -115,8 +112,5 @@ public class FarmingBlockState implements Component { protected static final int ON_UNLOADING = 3; protected static final int ON_LOADING = 5; protected static final int NONE = 0; - - protected RefreshFlags() { - } } } diff --git a/src/com/hypixel/hytale/builtin/adventure/memories/MemoriesGameplayConfig.java b/src/com/hypixel/hytale/builtin/adventure/memories/MemoriesGameplayConfig.java index 0dade29..d435c18 100644 --- a/src/com/hypixel/hytale/builtin/adventure/memories/MemoriesGameplayConfig.java +++ b/src/com/hypixel/hytale/builtin/adventure/memories/MemoriesGameplayConfig.java @@ -6,6 +6,7 @@ import com.hypixel.hytale.codec.builder.BuilderCodec; import com.hypixel.hytale.codec.validation.Validators; import com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig; import com.hypixel.hytale.server.core.asset.type.item.config.Item; +import com.hypixel.hytale.server.core.asset.type.model.config.ModelParticle; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -37,13 +38,28 @@ public class MemoriesGameplayConfig { .addValidator(Validators.nonNull()) .addValidator(Item.VALIDATOR_CACHE.getValidator()) .add() + .appendInherited( + new KeyedCodec<>("MemoriesCatchEntityParticle", ModelParticle.CODEC), + (activationEffects, s) -> activationEffects.memoriesCatchEntityParticle = s, + activationEffects -> activationEffects.memoriesCatchEntityParticle, + (activationEffects, parent) -> activationEffects.memoriesCatchEntityParticle = parent.memoriesCatchEntityParticle + ) + .addValidator(Validators.nonNull()) + .add() + .appendInherited( + new KeyedCodec<>("MemoriesCatchParticleViewDistance", Codec.INTEGER), + (memoriesGameplayConfig, integer) -> memoriesGameplayConfig.memoriesCatchParticleViewDistance = integer, + memoriesGameplayConfig -> memoriesGameplayConfig.memoriesCatchParticleViewDistance, + (memoriesGameplayConfig, parent) -> memoriesGameplayConfig.memoriesCatchParticleViewDistance = parent.memoriesCatchParticleViewDistance + ) + .addValidator(Validators.greaterThan(16)) + .add() .build(); private int[] memoriesAmountPerLevel; private String memoriesRecordParticles; private String memoriesCatchItemId; - - public MemoriesGameplayConfig() { - } + private ModelParticle memoriesCatchEntityParticle; + private int memoriesCatchParticleViewDistance = 64; @Nullable public static MemoriesGameplayConfig get(@Nonnull GameplayConfig config) { @@ -61,4 +77,12 @@ public class MemoriesGameplayConfig { public String getMemoriesCatchItemId() { return this.memoriesCatchItemId; } + + public ModelParticle getMemoriesCatchEntityParticle() { + return this.memoriesCatchEntityParticle; + } + + public int getMemoriesCatchParticleViewDistance() { + return this.memoriesCatchParticleViewDistance; + } } diff --git a/src/com/hypixel/hytale/builtin/adventure/memories/MemoriesPlugin.java b/src/com/hypixel/hytale/builtin/adventure/memories/MemoriesPlugin.java index 585e97f..db16993 100644 --- a/src/com/hypixel/hytale/builtin/adventure/memories/MemoriesPlugin.java +++ b/src/com/hypixel/hytale/builtin/adventure/memories/MemoriesPlugin.java @@ -10,6 +10,8 @@ import com.hypixel.hytale.builtin.adventure.memories.memories.npc.NPCMemory; import com.hypixel.hytale.builtin.adventure.memories.memories.npc.NPCMemoryProvider; import com.hypixel.hytale.builtin.adventure.memories.page.MemoriesPage; import com.hypixel.hytale.builtin.adventure.memories.page.MemoriesPageSupplier; +import com.hypixel.hytale.builtin.adventure.memories.page.MemoriesUnlockedPage; +import com.hypixel.hytale.builtin.adventure.memories.page.MemoriesUnlockedPageSuplier; import com.hypixel.hytale.builtin.adventure.memories.temple.ForgottenTempleConfig; import com.hypixel.hytale.builtin.adventure.memories.temple.TempleRespawnPlayersSystem; import com.hypixel.hytale.builtin.adventure.memories.window.MemoriesWindow; @@ -51,7 +53,7 @@ import com.hypixel.hytale.server.npc.AllNPCsLoadedEvent; import it.unimi.dsi.fastutil.objects.Object2DoubleMap; import it.unimi.dsi.fastutil.objects.Object2DoubleMaps; import it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.objects.Object2ObjectRBTreeMap; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import java.io.IOException; import java.nio.file.Files; @@ -70,7 +72,7 @@ public class MemoriesPlugin extends JavaPlugin { private static MemoriesPlugin instance; private final Config config = this.withConfig(MemoriesPlugin.MemoriesPluginConfig.CODEC); private final List> providers = new ObjectArrayList<>(); - private final Map> allMemories = new Object2ObjectOpenHashMap<>(); + private final Map> allMemories = new Object2ObjectRBTreeMap<>(); private ComponentType playerMemoriesComponentType; @Nullable private MemoriesPlugin.RecordedMemories recordedMemories; @@ -90,6 +92,7 @@ public class MemoriesPlugin extends JavaPlugin { ComponentRegistryProxy entityStoreRegistry = this.getEntityStoreRegistry(); this.getCommandRegistry().registerCommand(new MemoriesCommand()); OpenCustomUIInteraction.registerCustomPageSupplier(this, MemoriesPage.class, "Memories", new MemoriesPageSupplier()); + OpenCustomUIInteraction.registerCustomPageSupplier(this, MemoriesUnlockedPage.class, "MemoriesUnlocked", new MemoriesUnlockedPageSuplier()); Window.CLIENT_REQUESTABLE_WINDOW_TYPES.put(WindowType.Memories, MemoriesWindow::new); this.playerMemoriesComponentType = entityStoreRegistry.registerComponent(PlayerMemories.class, "PlayerMemories", PlayerMemories.CODEC); NPCMemoryProvider npcMemoryProvider = new NPCMemoryProvider(); @@ -129,14 +132,16 @@ public class MemoriesPlugin extends JavaPlugin { @Override protected void shutdown() { - this.recordedMemories.lock.readLock().lock(); + if (this.hasInitializedMemories) { + this.recordedMemories.lock.readLock().lock(); - try { - BsonUtil.writeSync(Constants.UNIVERSE_PATH.resolve("memories.json"), MemoriesPlugin.RecordedMemories.CODEC, this.recordedMemories, this.getLogger()); - } catch (IOException var5) { - throw new RuntimeException(var5); - } finally { - this.recordedMemories.lock.readLock().unlock(); + try { + BsonUtil.writeSync(Constants.UNIVERSE_PATH.resolve("memories.json"), MemoriesPlugin.RecordedMemories.CODEC, this.recordedMemories, this.getLogger()); + } catch (IOException var5) { + throw new RuntimeException(var5); + } finally { + this.recordedMemories.lock.readLock().unlock(); + } } } @@ -177,30 +182,16 @@ public class MemoriesPlugin extends JavaPlugin { int recordedMemoriesCount = this.getRecordedMemories().size(); int[] memoriesAmountPerLevel = config.getMemoriesAmountPerLevel(); - for (int i = 0; i < memoriesAmountPerLevel.length && recordedMemoriesCount >= memoriesAmountPerLevel[i]; i++) { - memoriesLevel += i + 1; + for (int i = memoriesAmountPerLevel.length - 1; i >= 0; i--) { + if (recordedMemoriesCount >= memoriesAmountPerLevel[i]) { + return i + 2; + } } return memoriesLevel; } } - public int getMemoriesForNextLevel(@Nonnull GameplayConfig gameplayConfig) { - MemoriesGameplayConfig memoriesConfig = MemoriesGameplayConfig.get(gameplayConfig); - if (memoriesConfig == null) { - return -1; - } else { - int memoriesLevel = this.getMemoriesLevel(gameplayConfig); - int[] memoriesAmountPerLevel = memoriesConfig.getMemoriesAmountPerLevel(); - if (memoriesLevel >= memoriesAmountPerLevel.length) { - return -1; - } else { - int recordedMemoriesCount = this.getRecordedMemories().size(); - return memoriesAmountPerLevel[memoriesLevel] - recordedMemoriesCount; - } - } - } - public boolean hasRecordedMemory(Memory memory) { this.recordedMemories.lock.readLock().lock(); @@ -274,6 +265,39 @@ public class MemoriesPlugin extends JavaPlugin { } } + public int setRecordedMemoriesCount(int count) { + if (count < 0) { + count = 0; + } + + this.recordedMemories.lock.writeLock().lock(); + + int var12; + try { + this.recordedMemories.memories.clear(); + List allAvailableMemories = new ObjectArrayList<>(); + + for (Entry> entry : this.allMemories.entrySet()) { + allAvailableMemories.addAll(entry.getValue()); + } + + int actualCount = Math.min(count, allAvailableMemories.size()); + + for (int i = 0; i < actualCount; i++) { + this.recordedMemories.memories.add(allAvailableMemories.get(i)); + } + + BsonUtil.writeSync(Constants.UNIVERSE_PATH.resolve("memories.json"), MemoriesPlugin.RecordedMemories.CODEC, this.recordedMemories, this.getLogger()); + var12 = actualCount; + } catch (IOException var8) { + throw new RuntimeException(var8); + } finally { + this.recordedMemories.lock.writeLock().unlock(); + } + + return var12; + } + public static class MemoriesPluginConfig { public static final BuilderCodec CODEC = BuilderCodec.builder( MemoriesPlugin.MemoriesPluginConfig.class, MemoriesPlugin.MemoriesPluginConfig::new @@ -287,9 +311,6 @@ public class MemoriesPlugin extends JavaPlugin { .build(); private Object2DoubleMap collectionRadius; - public MemoriesPluginConfig() { - } - @Nonnull public Object2DoubleMap getCollectionRadius() { return (Object2DoubleMap)(this.collectionRadius != null ? this.collectionRadius : Object2DoubleMaps.EMPTY_MAP); @@ -302,9 +323,6 @@ public class MemoriesPlugin extends JavaPlugin { @Nonnull private final Query query = Query.and(Player.getComponentType(), PlayerRef.getComponentType()); - public PlayerAddedSystem() { - } - @Nonnull @Override public Query getQuery() { @@ -355,8 +373,5 @@ public class MemoriesPlugin extends JavaPlugin { .build(); private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); private final Set memories = new HashSet<>(); - - private RecordedMemories() { - } } } diff --git a/src/com/hypixel/hytale/builtin/adventure/memories/commands/MemoriesCommand.java b/src/com/hypixel/hytale/builtin/adventure/memories/commands/MemoriesCommand.java index dd661f7..eacb28e 100644 --- a/src/com/hypixel/hytale/builtin/adventure/memories/commands/MemoriesCommand.java +++ b/src/com/hypixel/hytale/builtin/adventure/memories/commands/MemoriesCommand.java @@ -9,5 +9,6 @@ public class MemoriesCommand extends AbstractCommandCollection { this.addSubCommand(new MemoriesCapacityCommand()); this.addSubCommand(new MemoriesLevelCommand()); this.addSubCommand(new MemoriesUnlockCommand()); + this.addSubCommand(new MemoriesSetCountCommand()); } } diff --git a/src/com/hypixel/hytale/builtin/adventure/memories/commands/MemoriesSetCountCommand.java b/src/com/hypixel/hytale/builtin/adventure/memories/commands/MemoriesSetCountCommand.java new file mode 100644 index 0000000..7d60f7e --- /dev/null +++ b/src/com/hypixel/hytale/builtin/adventure/memories/commands/MemoriesSetCountCommand.java @@ -0,0 +1,34 @@ +package com.hypixel.hytale.builtin.adventure.memories.commands; + +import com.hypixel.hytale.builtin.adventure.memories.MemoriesPlugin; +import com.hypixel.hytale.component.Store; +import com.hypixel.hytale.server.core.Message; +import com.hypixel.hytale.server.core.command.system.CommandContext; +import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg; +import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes; +import com.hypixel.hytale.server.core.command.system.basecommands.AbstractWorldCommand; +import com.hypixel.hytale.server.core.universe.world.World; +import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; +import javax.annotation.Nonnull; + +public class MemoriesSetCountCommand extends AbstractWorldCommand { + @Nonnull + private static final Message MESSAGE_COMMANDS_MEMORIES_SETCOUNT_INVALID = Message.translation("server.commands.memories.setCount.invalid"); + @Nonnull + private final RequiredArg countArg = this.withRequiredArg("count", "server.commands.memories.setCount.count.desc", ArgTypes.INTEGER); + + public MemoriesSetCountCommand() { + super("setCount", "server.commands.memories.setCount.desc"); + } + + @Override + protected void execute(@Nonnull CommandContext context, @Nonnull World world, @Nonnull Store store) { + int count = this.countArg.get(context); + if (count < 0) { + context.sendMessage(MESSAGE_COMMANDS_MEMORIES_SETCOUNT_INVALID); + } else { + int actualCount = MemoriesPlugin.get().setRecordedMemoriesCount(count); + context.sendMessage(Message.translation("server.commands.memories.setCount.success").param("requested", count).param("actual", actualCount)); + } + } +} diff --git a/src/com/hypixel/hytale/builtin/adventure/memories/component/PlayerMemories.java b/src/com/hypixel/hytale/builtin/adventure/memories/component/PlayerMemories.java index 04e06da..10580a0 100644 --- a/src/com/hypixel/hytale/builtin/adventure/memories/component/PlayerMemories.java +++ b/src/com/hypixel/hytale/builtin/adventure/memories/component/PlayerMemories.java @@ -32,9 +32,6 @@ public class PlayerMemories implements Component { private final Set memories = new LinkedHashSet<>(); private int memoriesCapacity; - public PlayerMemories() { - } - public static ComponentType getComponentType() { return MemoriesPlugin.get().getPlayerMemoriesComponentType(); } diff --git a/src/com/hypixel/hytale/builtin/adventure/memories/interactions/MemoriesConditionInteraction.java b/src/com/hypixel/hytale/builtin/adventure/memories/interactions/MemoriesConditionInteraction.java index 602952c..3b8f3de 100644 --- a/src/com/hypixel/hytale/builtin/adventure/memories/interactions/MemoriesConditionInteraction.java +++ b/src/com/hypixel/hytale/builtin/adventure/memories/interactions/MemoriesConditionInteraction.java @@ -28,7 +28,6 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap.Entry; import java.util.Arrays; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class MemoriesConditionInteraction extends Interaction { @Nonnull @@ -68,12 +67,9 @@ public class MemoriesConditionInteraction extends Interaction { @Nullable private String failed; - public MemoriesConditionInteraction() { - } - @Override protected void tick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @NonNullDecl InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { CommandBuffer commandBuffer = context.getCommandBuffer(); @@ -95,7 +91,7 @@ public class MemoriesConditionInteraction extends Interaction { @Override protected void simulateTick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @NonNullDecl InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { int memoriesLevel = context.getServerState().chainingIndex; int labelIndex = this.levelToLabel.get(memoriesLevel); diff --git a/src/com/hypixel/hytale/builtin/adventure/memories/interactions/SetMemoriesCapacityInteraction.java b/src/com/hypixel/hytale/builtin/adventure/memories/interactions/SetMemoriesCapacityInteraction.java index c5a9fc3..8692daa 100644 --- a/src/com/hypixel/hytale/builtin/adventure/memories/interactions/SetMemoriesCapacityInteraction.java +++ b/src/com/hypixel/hytale/builtin/adventure/memories/interactions/SetMemoriesCapacityInteraction.java @@ -33,9 +33,6 @@ public class SetMemoriesCapacityInteraction extends SimpleInstantInteraction { .build(); private int capacity; - public SetMemoriesCapacityInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { Ref ref = context.getEntity(); diff --git a/src/com/hypixel/hytale/builtin/adventure/memories/memories/Memory.java b/src/com/hypixel/hytale/builtin/adventure/memories/memories/Memory.java index 2b134c6..3710f4d 100644 --- a/src/com/hypixel/hytale/builtin/adventure/memories/memories/Memory.java +++ b/src/com/hypixel/hytale/builtin/adventure/memories/memories/Memory.java @@ -8,9 +8,6 @@ import javax.annotation.Nullable; public abstract class Memory { public static final CodecMapCodec CODEC = new CodecMapCodec<>(); - public Memory() { - } - public abstract String getId(); public abstract String getTitle(); diff --git a/src/com/hypixel/hytale/builtin/adventure/memories/memories/npc/NPCMemory.java b/src/com/hypixel/hytale/builtin/adventure/memories/memories/npc/NPCMemory.java index 3c044e3..72b97a4 100644 --- a/src/com/hypixel/hytale/builtin/adventure/memories/memories/npc/NPCMemory.java +++ b/src/com/hypixel/hytale/builtin/adventure/memories/memories/npc/NPCMemory.java @@ -18,17 +18,22 @@ import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.Store; import com.hypixel.hytale.component.query.Query; import com.hypixel.hytale.component.spatial.SpatialResource; +import com.hypixel.hytale.component.spatial.SpatialStructure; import com.hypixel.hytale.component.system.tick.EntityTickingSystem; import com.hypixel.hytale.math.util.MathUtil; import com.hypixel.hytale.math.vector.Vector3d; import com.hypixel.hytale.protocol.GameMode; +import com.hypixel.hytale.protocol.packets.entities.SpawnModelParticles; import com.hypixel.hytale.server.core.Message; +import com.hypixel.hytale.server.core.asset.type.model.config.ModelParticle; import com.hypixel.hytale.server.core.entity.entities.Player; import com.hypixel.hytale.server.core.inventory.ItemStack; +import com.hypixel.hytale.server.core.modules.entity.EntityModule; import com.hypixel.hytale.server.core.modules.entity.component.BoundingBox; import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent; import com.hypixel.hytale.server.core.modules.entity.item.ItemComponent; import com.hypixel.hytale.server.core.modules.entity.item.PickupItemComponent; +import com.hypixel.hytale.server.core.modules.entity.tracker.NetworkId; import com.hypixel.hytale.server.core.modules.i18n.I18nModule; import com.hypixel.hytale.server.core.universe.PlayerRef; import com.hypixel.hytale.server.core.universe.world.World; @@ -229,6 +234,7 @@ public class NPCMemory extends Memory { assert playerRefComponent != null; + Ref ref = archetypeChunk.getReferenceTo(index); MemoriesPlugin memoriesPlugin = MemoriesPlugin.get(); PlayerMemories playerMemoriesComponent = archetypeChunk.getComponent(index, PlayerMemories.getComponentType()); @@ -269,17 +275,22 @@ public class NPCMemory extends Memory { if (memoriesGameplayConfig != null) { ItemStack memoryItemStack = new ItemStack(memoriesGameplayConfig.getMemoriesCatchItemId()); Vector3d memoryItemHolderPosition = npcTransformComponent.getPosition().clone(); - BoundingBox boundingBox = commandBuffer.getComponent(npcRef, BoundingBox.getComponentType()); - if (boundingBox != null) { - memoryItemHolderPosition.y = memoryItemHolderPosition.y + boundingBox.getBoundingBox().middleY(); + BoundingBox boundingBoxComponent = commandBuffer.getComponent(npcRef, BoundingBox.getComponentType()); + if (boundingBoxComponent != null) { + memoryItemHolderPosition.y = memoryItemHolderPosition.y + boundingBoxComponent.getBoundingBox().middleY(); } Holder memoryItemHolder = ItemComponent.generatePickedUpItem( - memoryItemStack, memoryItemHolderPosition, commandBuffer, playerRefComponent.getReference() + memoryItemStack, memoryItemHolderPosition, commandBuffer, ref ); float memoryCatchItemLifetimeS = 0.62F; - memoryItemHolder.getComponent(PickupItemComponent.getComponentType()).setInitialLifeTime(memoryCatchItemLifetimeS); + PickupItemComponent pickupItemComponent = memoryItemHolder.getComponent(PickupItemComponent.getComponentType()); + + assert pickupItemComponent != null; + + pickupItemComponent.setInitialLifeTime(0.62F); commandBuffer.addEntity(memoryItemHolder, AddReason.SPAWN); + displayCatchEntityParticles(memoriesGameplayConfig, memoryItemHolderPosition, npcRef, commandBuffer); } } } @@ -308,6 +319,31 @@ public class NPCMemory extends Memory { } } + private static void displayCatchEntityParticles( + MemoriesGameplayConfig memoriesGameplayConfig, Vector3d targetPosition, Ref targetRef, @Nonnull CommandBuffer commandBuffer + ) { + ModelParticle particle = memoriesGameplayConfig.getMemoriesCatchEntityParticle(); + if (particle != null) { + NetworkId networkIdComponent = commandBuffer.getComponent(targetRef, NetworkId.getComponentType()); + if (networkIdComponent != null) { + com.hypixel.hytale.protocol.ModelParticle[] modelParticlesProtocol = new com.hypixel.hytale.protocol.ModelParticle[]{particle.toPacket()}; + SpawnModelParticles packet = new SpawnModelParticles(networkIdComponent.getId(), modelParticlesProtocol); + SpatialResource, EntityStore> spatialResource = commandBuffer.getResource(EntityModule.get().getPlayerSpatialResourceType()); + SpatialStructure> spatialStructure = spatialResource.getSpatialStructure(); + ObjectList> results = SpatialResource.getThreadLocalReferenceList(); + spatialStructure.ordered(targetPosition, memoriesGameplayConfig.getMemoriesCatchParticleViewDistance(), results); + + for (Ref ref : results) { + PlayerRef playerRefComponent = commandBuffer.getComponent(ref, PlayerRef.getComponentType()); + + assert playerRefComponent != null; + + playerRefComponent.getPacketHandler().write(packet); + } + } + } + } + @Nonnull @Override public Query getQuery() { diff --git a/src/com/hypixel/hytale/builtin/adventure/memories/memories/npc/NPCMemoryProvider.java b/src/com/hypixel/hytale/builtin/adventure/memories/memories/npc/NPCMemoryProvider.java index 234ea7c..551e6bf 100644 --- a/src/com/hypixel/hytale/builtin/adventure/memories/memories/npc/NPCMemoryProvider.java +++ b/src/com/hypixel/hytale/builtin/adventure/memories/memories/npc/NPCMemoryProvider.java @@ -18,7 +18,6 @@ import java.util.Set; import java.util.logging.Level; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; public class NPCMemoryProvider extends MemoryProvider { public static final double DEFAULT_RADIUS = 10.0; @@ -82,7 +81,7 @@ public class NPCMemoryProvider extends MemoryProvider { } } - @NullableDecl + @Nullable private static String getMemoriesNameOverride(@Nonnull Builder builder) { if (builder instanceof ISpawnableWithModel spawnableWithModel) { ExecutionContext executionContext = new ExecutionContext(); diff --git a/src/com/hypixel/hytale/builtin/adventure/memories/page/MemoriesPage.java b/src/com/hypixel/hytale/builtin/adventure/memories/page/MemoriesPage.java index b88675e..9ddd995 100644 --- a/src/com/hypixel/hytale/builtin/adventure/memories/page/MemoriesPage.java +++ b/src/com/hypixel/hytale/builtin/adventure/memories/page/MemoriesPage.java @@ -76,6 +76,9 @@ public class MemoriesPage extends InteractiveCustomUIPage CODEC = new EnumCodec<>(MemoriesPage.PageAction.class); - - private PageAction() { - } } public static class PageEventData { @@ -395,8 +402,5 @@ public class MemoriesPage extends InteractiveCustomUIPage ref, ComponentAccessor componentAccessor, PlayerRef playerRef, InteractionContext context) { return new MemoriesPage(playerRef, context.getTargetBlock()); diff --git a/src/com/hypixel/hytale/builtin/adventure/memories/page/MemoriesUnlockedPage.java b/src/com/hypixel/hytale/builtin/adventure/memories/page/MemoriesUnlockedPage.java new file mode 100644 index 0000000..012a830 --- /dev/null +++ b/src/com/hypixel/hytale/builtin/adventure/memories/page/MemoriesUnlockedPage.java @@ -0,0 +1,71 @@ +package com.hypixel.hytale.builtin.adventure.memories.page; + +import com.hypixel.hytale.builtin.adventure.memories.MemoriesPlugin; +import com.hypixel.hytale.codec.Codec; +import com.hypixel.hytale.codec.KeyedCodec; +import com.hypixel.hytale.codec.builder.BuilderCodec; +import com.hypixel.hytale.codec.codecs.EnumCodec; +import com.hypixel.hytale.component.Ref; +import com.hypixel.hytale.component.Store; +import com.hypixel.hytale.protocol.BlockPosition; +import com.hypixel.hytale.protocol.packets.interface_.CustomPageLifetime; +import com.hypixel.hytale.protocol.packets.interface_.CustomUIEventBindingType; +import com.hypixel.hytale.server.core.entity.entities.Player; +import com.hypixel.hytale.server.core.entity.entities.player.pages.InteractiveCustomUIPage; +import com.hypixel.hytale.server.core.ui.builder.EventData; +import com.hypixel.hytale.server.core.ui.builder.UICommandBuilder; +import com.hypixel.hytale.server.core.ui.builder.UIEventBuilder; +import com.hypixel.hytale.server.core.universe.PlayerRef; +import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; +import javax.annotation.Nonnull; + +public class MemoriesUnlockedPage extends InteractiveCustomUIPage { + private final BlockPosition blockPosition; + + public MemoriesUnlockedPage(@Nonnull PlayerRef playerRef, BlockPosition blockPosition) { + super(playerRef, CustomPageLifetime.CanDismissOrCloseThroughInteraction, MemoriesUnlockedPage.PageEventData.CODEC); + this.blockPosition = blockPosition; + } + + @Override + public void build( + @Nonnull Ref ref, @Nonnull UICommandBuilder commandBuilder, @Nonnull UIEventBuilder eventBuilder, @Nonnull Store store + ) { + MemoriesPlugin memoriesPlugin = MemoriesPlugin.get(); + commandBuilder.append("Pages/Memories/MemoriesUnlocked.ui"); + eventBuilder.addEventBinding( + CustomUIEventBindingType.Activating, "#DiscoverMemoriesButton", new EventData().append("Action", MemoriesUnlockedPage.PageAction.DiscoverMemories) + ); + } + + public void handleDataEvent(@Nonnull Ref ref, @Nonnull Store store, @Nonnull MemoriesUnlockedPage.PageEventData data) { + Player player = store.getComponent(ref, Player.getComponentType()); + + assert player != null; + + if (data.action == MemoriesUnlockedPage.PageAction.DiscoverMemories) { + player.getPageManager().openCustomPage(ref, store, new MemoriesPage(this.playerRef, this.blockPosition)); + } + } + + public static enum PageAction { + DiscoverMemories; + + public static final Codec CODEC = new EnumCodec<>(MemoriesUnlockedPage.PageAction.class); + } + + public static class PageEventData { + public static final String KEY_ACTION = "Action"; + public static final BuilderCodec CODEC = BuilderCodec.builder( + MemoriesUnlockedPage.PageEventData.class, MemoriesUnlockedPage.PageEventData::new + ) + .append( + new KeyedCodec<>("Action", MemoriesUnlockedPage.PageAction.CODEC), + (pageEventData, pageAction) -> pageEventData.action = pageAction, + pageEventData -> pageEventData.action + ) + .add() + .build(); + public MemoriesUnlockedPage.PageAction action; + } +} diff --git a/src/com/hypixel/hytale/builtin/adventure/memories/page/MemoriesUnlockedPageSuplier.java b/src/com/hypixel/hytale/builtin/adventure/memories/page/MemoriesUnlockedPageSuplier.java new file mode 100644 index 0000000..801c140 --- /dev/null +++ b/src/com/hypixel/hytale/builtin/adventure/memories/page/MemoriesUnlockedPageSuplier.java @@ -0,0 +1,18 @@ +package com.hypixel.hytale.builtin.adventure.memories.page; + +import com.hypixel.hytale.component.ComponentAccessor; +import com.hypixel.hytale.component.Ref; +import com.hypixel.hytale.server.core.entity.InteractionContext; +import com.hypixel.hytale.server.core.entity.entities.player.pages.CustomUIPage; +import com.hypixel.hytale.server.core.modules.interaction.interaction.config.server.OpenCustomUIInteraction; +import com.hypixel.hytale.server.core.universe.PlayerRef; +import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; +import javax.annotation.Nullable; + +public class MemoriesUnlockedPageSuplier implements OpenCustomUIInteraction.CustomPageSupplier { + @Nullable + @Override + public CustomUIPage tryCreate(Ref ref, ComponentAccessor componentAccessor, PlayerRef playerRef, InteractionContext context) { + return new MemoriesUnlockedPage(playerRef, context.getTargetBlock()); + } +} diff --git a/src/com/hypixel/hytale/builtin/adventure/memories/temple/ForgottenTempleConfig.java b/src/com/hypixel/hytale/builtin/adventure/memories/temple/ForgottenTempleConfig.java index 8d19bc4..67760a9 100644 --- a/src/com/hypixel/hytale/builtin/adventure/memories/temple/ForgottenTempleConfig.java +++ b/src/com/hypixel/hytale/builtin/adventure/memories/temple/ForgottenTempleConfig.java @@ -17,9 +17,6 @@ public class ForgottenTempleConfig { private double minYRespawn = 5.0; private String respawnSound; - public ForgottenTempleConfig() { - } - public double getMinYRespawn() { return this.minYRespawn; } diff --git a/src/com/hypixel/hytale/builtin/adventure/memories/temple/TempleRespawnPlayersSystem.java b/src/com/hypixel/hytale/builtin/adventure/memories/temple/TempleRespawnPlayersSystem.java index 7d98f16..16da925 100644 --- a/src/com/hypixel/hytale/builtin/adventure/memories/temple/TempleRespawnPlayersSystem.java +++ b/src/com/hypixel/hytale/builtin/adventure/memories/temple/TempleRespawnPlayersSystem.java @@ -17,8 +17,8 @@ import com.hypixel.hytale.server.core.universe.world.SoundUtil; import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.spawn.ISpawnProvider; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; public class TempleRespawnPlayersSystem extends DelayedEntitySystem { public static final Query QUERY = Query.and(PlayerRef.getComponentType(), TransformComponent.getComponentType()); @@ -31,27 +31,32 @@ public class TempleRespawnPlayersSystem extends DelayedEntitySystem public void tick( float dt, int index, - @NonNullDecl ArchetypeChunk archetypeChunk, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull ArchetypeChunk archetypeChunk, + @Nonnull Store store, + @Nonnull CommandBuffer commandBuffer ) { World world = store.getExternalData().getWorld(); GameplayConfig gameplayConfig = world.getGameplayConfig(); ForgottenTempleConfig config = gameplayConfig.getPluginConfig().get(ForgottenTempleConfig.class); if (config != null) { - Vector3d position = archetypeChunk.getComponent(index, TransformComponent.getComponentType()).getPosition(); + TransformComponent transformComponent = archetypeChunk.getComponent(index, TransformComponent.getComponentType()); + + assert transformComponent != null; + + Vector3d position = transformComponent.getPosition(); if (!(position.getY() > config.getMinYRespawn())) { Ref ref = archetypeChunk.getReferenceTo(index); ISpawnProvider spawnProvider = world.getWorldConfig().getSpawnProvider(); - Transform spawnPoint = spawnProvider.getSpawnPoint(ref, commandBuffer); - commandBuffer.addComponent(ref, Teleport.getComponentType(), new Teleport(null, spawnPoint)); + Transform spawnTransform = spawnProvider.getSpawnPoint(ref, commandBuffer); + Teleport teleportComponent = Teleport.createForPlayer(null, spawnTransform); + commandBuffer.addComponent(ref, Teleport.getComponentType(), teleportComponent); PlayerRef playerRef = archetypeChunk.getComponent(index, PlayerRef.getComponentType()); SoundUtil.playSoundEvent2dToPlayer(playerRef, config.getRespawnSoundIndex(), SoundCategory.SFX); } } } - @NullableDecl + @Nullable @Override public Query getQuery() { return QUERY; diff --git a/src/com/hypixel/hytale/builtin/adventure/memories/window/MemoriesWindow.java b/src/com/hypixel/hytale/builtin/adventure/memories/window/MemoriesWindow.java index 6b239ee..c5b8eb0 100644 --- a/src/com/hypixel/hytale/builtin/adventure/memories/window/MemoriesWindow.java +++ b/src/com/hypixel/hytale/builtin/adventure/memories/window/MemoriesWindow.java @@ -6,7 +6,9 @@ import com.hypixel.hytale.builtin.adventure.memories.MemoriesPlugin; import com.hypixel.hytale.builtin.adventure.memories.component.PlayerMemories; import com.hypixel.hytale.builtin.adventure.memories.memories.Memory; import com.hypixel.hytale.codec.EmptyExtraInfo; +import com.hypixel.hytale.component.ComponentAccessor; import com.hypixel.hytale.component.Ref; +import com.hypixel.hytale.component.Store; import com.hypixel.hytale.protocol.packets.window.WindowType; import com.hypixel.hytale.server.core.Message; import com.hypixel.hytale.server.core.entity.entities.player.windows.Window; @@ -32,14 +34,13 @@ public class MemoriesWindow extends Window { } @Override - public boolean onOpen0() { + public boolean onOpen0(@Nonnull Ref ref, @Nonnull Store store) { JsonArray array = new JsonArray(); - Ref ref = this.getPlayerRef().getReference(); - PlayerMemories playerMemories = ref.getStore().getComponent(ref, PlayerMemories.getComponentType()); - if (playerMemories != null) { - this.windowData.addProperty("capacity", playerMemories.getMemoriesCapacity()); + PlayerMemories playerMemoriesComponent = store.getComponent(ref, PlayerMemories.getComponentType()); + if (playerMemoriesComponent != null) { + this.windowData.addProperty("capacity", playerMemoriesComponent.getMemoriesCapacity()); - for (Memory memory : playerMemories.getRecordedMemories()) { + for (Memory memory : playerMemoriesComponent.getRecordedMemories()) { JsonObject obj = new JsonObject(); obj.addProperty("title", memory.getTitle()); obj.add("tooltipText", BsonUtil.translateBsonToJson(Message.CODEC.encode(memory.getTooltipText(), EmptyExtraInfo.EMPTY).asDocument())); @@ -79,6 +80,6 @@ public class MemoriesWindow extends Window { } @Override - public void onClose0() { + public void onClose0(@Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor) { } } diff --git a/src/com/hypixel/hytale/builtin/adventure/npcobjectives/assets/KillSpawnBeaconObjectiveTaskAsset.java b/src/com/hypixel/hytale/builtin/adventure/npcobjectives/assets/KillSpawnBeaconObjectiveTaskAsset.java index e805fbb..4b3247b 100644 --- a/src/com/hypixel/hytale/builtin/adventure/npcobjectives/assets/KillSpawnBeaconObjectiveTaskAsset.java +++ b/src/com/hypixel/hytale/builtin/adventure/npcobjectives/assets/KillSpawnBeaconObjectiveTaskAsset.java @@ -97,9 +97,6 @@ public class KillSpawnBeaconObjectiveTaskAsset extends KillObjectiveTaskAsset { protected Vector3d offset; protected WorldLocationProvider worldLocationProvider; - public ObjectiveSpawnBeacon() { - } - public String getSpawnBeaconId() { return this.spawnBeaconId; } diff --git a/src/com/hypixel/hytale/builtin/adventure/npcobjectives/npc/builders/BuilderActionCompleteTask.java b/src/com/hypixel/hytale/builtin/adventure/npcobjectives/npc/builders/BuilderActionCompleteTask.java index 31c67c7..1d1a6a2 100644 --- a/src/com/hypixel/hytale/builtin/adventure/npcobjectives/npc/builders/BuilderActionCompleteTask.java +++ b/src/com/hypixel/hytale/builtin/adventure/npcobjectives/npc/builders/BuilderActionCompleteTask.java @@ -13,9 +13,6 @@ import javax.annotation.Nonnull; public class BuilderActionCompleteTask extends BuilderActionPlayAnimation { protected final BooleanHolder playAnimation = new BooleanHolder(); - public BuilderActionCompleteTask() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/builtin/adventure/npcobjectives/npc/builders/BuilderActionStartObjective.java b/src/com/hypixel/hytale/builtin/adventure/npcobjectives/npc/builders/BuilderActionStartObjective.java index 93ccc22..a65a07d 100644 --- a/src/com/hypixel/hytale/builtin/adventure/npcobjectives/npc/builders/BuilderActionStartObjective.java +++ b/src/com/hypixel/hytale/builtin/adventure/npcobjectives/npc/builders/BuilderActionStartObjective.java @@ -14,9 +14,6 @@ import javax.annotation.Nonnull; public class BuilderActionStartObjective extends BuilderActionBase { protected final AssetHolder objectiveId = new AssetHolder(); - public BuilderActionStartObjective() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/builtin/adventure/npcobjectives/npc/builders/BuilderSensorHasTask.java b/src/com/hypixel/hytale/builtin/adventure/npcobjectives/npc/builders/BuilderSensorHasTask.java index 1af9bb2..a55f799 100644 --- a/src/com/hypixel/hytale/builtin/adventure/npcobjectives/npc/builders/BuilderSensorHasTask.java +++ b/src/com/hypixel/hytale/builtin/adventure/npcobjectives/npc/builders/BuilderSensorHasTask.java @@ -17,9 +17,6 @@ import javax.annotation.Nullable; public class BuilderSensorHasTask extends BuilderSensorBase { protected final StringArrayHolder tasksById = new StringArrayHolder(); - public BuilderSensorHasTask() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/builtin/adventure/npcobjectives/resources/KillTrackerResource.java b/src/com/hypixel/hytale/builtin/adventure/npcobjectives/resources/KillTrackerResource.java index 64dd1f8..53d2d44 100644 --- a/src/com/hypixel/hytale/builtin/adventure/npcobjectives/resources/KillTrackerResource.java +++ b/src/com/hypixel/hytale/builtin/adventure/npcobjectives/resources/KillTrackerResource.java @@ -12,9 +12,6 @@ import javax.annotation.Nonnull; public class KillTrackerResource implements Resource { private final List killTasks = new ObjectArrayList<>(); - public KillTrackerResource() { - } - public static ResourceType getResourceType() { return NPCObjectivesPlugin.get().getKillTrackerResourceType(); } diff --git a/src/com/hypixel/hytale/builtin/adventure/npcobjectives/systems/KillTrackerSystem.java b/src/com/hypixel/hytale/builtin/adventure/npcobjectives/systems/KillTrackerSystem.java index fb7a166..1afcd58 100644 --- a/src/com/hypixel/hytale/builtin/adventure/npcobjectives/systems/KillTrackerSystem.java +++ b/src/com/hypixel/hytale/builtin/adventure/npcobjectives/systems/KillTrackerSystem.java @@ -15,9 +15,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class KillTrackerSystem extends DeathSystems.OnDeathSystem { - public KillTrackerSystem() { - } - @Nullable @Override public Query getQuery() { diff --git a/src/com/hypixel/hytale/builtin/adventure/npcobjectives/systems/SpawnBeaconCheckRemovalSystem.java b/src/com/hypixel/hytale/builtin/adventure/npcobjectives/systems/SpawnBeaconCheckRemovalSystem.java index 1505f22..81bec39 100644 --- a/src/com/hypixel/hytale/builtin/adventure/npcobjectives/systems/SpawnBeaconCheckRemovalSystem.java +++ b/src/com/hypixel/hytale/builtin/adventure/npcobjectives/systems/SpawnBeaconCheckRemovalSystem.java @@ -14,9 +14,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class SpawnBeaconCheckRemovalSystem extends HolderSystem { - public SpawnBeaconCheckRemovalSystem() { - } - @Nullable @Override public Query getQuery() { diff --git a/src/com/hypixel/hytale/builtin/adventure/npcreputation/ReputationAttitudeSystem.java b/src/com/hypixel/hytale/builtin/adventure/npcreputation/ReputationAttitudeSystem.java index a3c6736..423ecdb 100644 --- a/src/com/hypixel/hytale/builtin/adventure/npcreputation/ReputationAttitudeSystem.java +++ b/src/com/hypixel/hytale/builtin/adventure/npcreputation/ReputationAttitudeSystem.java @@ -13,9 +13,6 @@ import javax.annotation.Nonnull; public class ReputationAttitudeSystem extends StoreSystem { private final ResourceType resourceType = Blackboard.getResourceType(); - public ReputationAttitudeSystem() { - } - @Override public void onSystemAddedToStore(@Nonnull Store store) { Blackboard blackboard = store.getResource(this.resourceType); diff --git a/src/com/hypixel/hytale/builtin/adventure/npcshop/npc/builders/BuilderActionOpenBarterShop.java b/src/com/hypixel/hytale/builtin/adventure/npcshop/npc/builders/BuilderActionOpenBarterShop.java index c95945f..3cccc8c 100644 --- a/src/com/hypixel/hytale/builtin/adventure/npcshop/npc/builders/BuilderActionOpenBarterShop.java +++ b/src/com/hypixel/hytale/builtin/adventure/npcshop/npc/builders/BuilderActionOpenBarterShop.java @@ -15,9 +15,6 @@ import javax.annotation.Nonnull; public class BuilderActionOpenBarterShop extends BuilderActionBase { protected final AssetHolder shopId = new AssetHolder(); - public BuilderActionOpenBarterShop() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/builtin/adventure/npcshop/npc/builders/BuilderActionOpenShop.java b/src/com/hypixel/hytale/builtin/adventure/npcshop/npc/builders/BuilderActionOpenShop.java index c534425..2465143 100644 --- a/src/com/hypixel/hytale/builtin/adventure/npcshop/npc/builders/BuilderActionOpenShop.java +++ b/src/com/hypixel/hytale/builtin/adventure/npcshop/npc/builders/BuilderActionOpenShop.java @@ -15,9 +15,6 @@ import javax.annotation.Nonnull; public class BuilderActionOpenShop extends BuilderActionBase { protected final AssetHolder shopId = new AssetHolder(); - public BuilderActionOpenShop() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/DialogPage.java b/src/com/hypixel/hytale/builtin/adventure/objectives/DialogPage.java index d06ad12..65c1705 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/DialogPage.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/DialogPage.java @@ -45,8 +45,5 @@ public class DialogPage extends InteractiveCustomUIPage ref, @Nonnull ComponentAccessor componentAccessor) { if (!this.opened) { diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/commands/ObjectiveLocationMarkerCommand.java b/src/com/hypixel/hytale/builtin/adventure/objectives/commands/ObjectiveLocationMarkerCommand.java index a6f804a..73404ef 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/commands/ObjectiveLocationMarkerCommand.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/commands/ObjectiveLocationMarkerCommand.java @@ -31,17 +31,6 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class ObjectiveLocationMarkerCommand extends AbstractCommandCollection { - @Nonnull - private static final Message MESSAGE_COMMANDS_OBJECTIVE_LOCATION_MARKER_NOT_FOUND = Message.translation("server.commands.objective.locationMarker.notFound"); - @Nonnull - private static final Message MESSAGE_GENERAL_FAILED_DID_YOU_MEAN = Message.translation("server.general.failed.didYouMean"); - @Nonnull - private static final Message MESSAGE_COMMANDS_OBJECTIVE_LOCATION_MARKER_ADDED = Message.translation("server.commands.objective.locationMarker.added"); - @Nonnull - private static final Message MESSAGE_COMMANDS_OBJECTIVE_LOCATION_MARKER_ENABLED = Message.translation("server.commands.objective.locationMarker.enabled"); - @Nonnull - private static final Message MESSAGE_COMMANDS_OBJECTIVE_LOCATION_MARKER_DISABLED = Message.translation("server.commands.objective.locationMarker.disabled"); - public ObjectiveLocationMarkerCommand() { super("locationmarker", "server.commands.objective.locationMarker"); this.addAliases("marker"); @@ -71,9 +60,9 @@ public class ObjectiveLocationMarkerCommand extends AbstractCommandCollection { String objectiveLocationMarkerId = this.locationMarkerArg.get(context); if (ObjectiveLocationMarkerAsset.getAssetMap().getAsset(objectiveLocationMarkerId) == null) { - context.sendMessage(ObjectiveLocationMarkerCommand.MESSAGE_COMMANDS_OBJECTIVE_LOCATION_MARKER_NOT_FOUND.param("id", objectiveLocationMarkerId)); + context.sendMessage(Message.translation("server.commands.objective.locationMarker.notFound").param("id", objectiveLocationMarkerId)); context.sendMessage( - ObjectiveLocationMarkerCommand.MESSAGE_GENERAL_FAILED_DID_YOU_MEAN + Message.translation("server.general.failed.didYouMean") .param( "choices", StringUtil.sortByFuzzyDistance( @@ -95,7 +84,7 @@ public class ObjectiveLocationMarkerCommand extends AbstractCommandCollection { holder.ensureComponent(Intangible.getComponentType()); holder.ensureComponent(HiddenFromAdventurePlayers.getComponentType()); store.addEntity(holder, AddReason.SPAWN); - context.sendMessage(ObjectiveLocationMarkerCommand.MESSAGE_COMMANDS_OBJECTIVE_LOCATION_MARKER_ADDED.param("id", objectiveLocationMarkerId)); + context.sendMessage(Message.translation("server.commands.objective.locationMarker.added").param("id", objectiveLocationMarkerId)); } } } @@ -110,7 +99,7 @@ public class ObjectiveLocationMarkerCommand extends AbstractCommandCollection { WorldConfig worldConfig = world.getWorldConfig(); worldConfig.setObjectiveMarkersEnabled(false); worldConfig.markChanged(); - context.sendMessage(ObjectiveLocationMarkerCommand.MESSAGE_COMMANDS_OBJECTIVE_LOCATION_MARKER_DISABLED.param("worldName", world.getName())); + context.sendMessage(Message.translation("server.commands.objective.locationMarker.disabled").param("worldName", world.getName())); } } @@ -124,7 +113,7 @@ public class ObjectiveLocationMarkerCommand extends AbstractCommandCollection { WorldConfig worldConfig = world.getWorldConfig(); worldConfig.setObjectiveMarkersEnabled(true); worldConfig.markChanged(); - context.sendMessage(ObjectiveLocationMarkerCommand.MESSAGE_COMMANDS_OBJECTIVE_LOCATION_MARKER_ENABLED.param("worldName", world.getName())); + context.sendMessage(Message.translation("server.commands.objective.locationMarker.enabled").param("worldName", world.getName())); } } } diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/commands/ObjectiveReachLocationMarkerCommand.java b/src/com/hypixel/hytale/builtin/adventure/objectives/commands/ObjectiveReachLocationMarkerCommand.java index b2622d9..88497d5 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/commands/ObjectiveReachLocationMarkerCommand.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/commands/ObjectiveReachLocationMarkerCommand.java @@ -29,17 +29,6 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class ObjectiveReachLocationMarkerCommand extends AbstractCommandCollection { - @Nonnull - private static final Message MESSAGE_COMMANDS_OBJECTIVE_REACH_LOCATION_MARKER_NOT_FOUND = Message.translation( - "server.commands.objective.reachLocationMarker.notFound" - ); - @Nonnull - private static final Message MESSAGE_GENERAL_FAILED_DID_YOU_MEAN = Message.translation("server.general.failed.didYouMean"); - @Nonnull - private static final Message MESSAGE_COMMANDS_OBJECTIVE_REACH_LOCATION_MARKER_ADDED = Message.translation( - "server.commands.objective.reachLocationMarker.added" - ); - public ObjectiveReachLocationMarkerCommand() { super("reachlocationmarker", "server.commands.objective.reachLocationMarker"); this.addSubCommand(new ObjectiveReachLocationMarkerCommand.AddReachLocationMarkerCommand()); @@ -61,11 +50,9 @@ public class ObjectiveReachLocationMarkerCommand extends AbstractCommandCollecti ) { String reachLocationMarkerId = this.reachLocationMarkerArg.get(context); if (ReachLocationMarkerAsset.getAssetMap().getAsset(reachLocationMarkerId) == null) { + context.sendMessage(Message.translation("server.commands.objective.reachLocationMarker.notFound").param("id", reachLocationMarkerId)); context.sendMessage( - ObjectiveReachLocationMarkerCommand.MESSAGE_COMMANDS_OBJECTIVE_REACH_LOCATION_MARKER_NOT_FOUND.param("id", reachLocationMarkerId) - ); - context.sendMessage( - ObjectiveReachLocationMarkerCommand.MESSAGE_GENERAL_FAILED_DID_YOU_MEAN + Message.translation("server.general.failed.didYouMean") .param( "choices", StringUtil.sortByFuzzyDistance( @@ -91,7 +78,7 @@ public class ObjectiveReachLocationMarkerCommand extends AbstractCommandCollecti holder.ensureComponent(Intangible.getComponentType()); holder.ensureComponent(HiddenFromAdventurePlayers.getComponentType()); store.addEntity(holder, AddReason.SPAWN); - context.sendMessage(ObjectiveReachLocationMarkerCommand.MESSAGE_COMMANDS_OBJECTIVE_REACH_LOCATION_MARKER_ADDED.param("id", reachLocationMarkerId)); + context.sendMessage(Message.translation("server.commands.objective.reachLocationMarker.added").param("id", reachLocationMarkerId)); } } } diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/commands/ObjectiveStartCommand.java b/src/com/hypixel/hytale/builtin/adventure/objectives/commands/ObjectiveStartCommand.java index 372dc99..2cc8206 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/commands/ObjectiveStartCommand.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/commands/ObjectiveStartCommand.java @@ -29,10 +29,6 @@ public class ObjectiveStartCommand extends AbstractCommandCollection { } public static class StartObjectiveCommand extends AbstractPlayerCommand { - @Nonnull - private static final Message MESSAGE_COMMANDS_OBJECTIVE_OBJECTIVE_NOT_FOUND = Message.translation("server.commands.objective.objectiveNotFound"); - @Nonnull - private static final Message MESSAGE_GENERAL_FAILED_DID_YOU_MEAN = Message.translation("server.general.failed.didYouMean"); @Nonnull private final RequiredArg objectiveArg = this.withRequiredArg( "objectiveId", "server.commands.objective.start.objective.arg.objectiveId.desc", ArgTypes.STRING @@ -49,12 +45,13 @@ public class ObjectiveStartCommand extends AbstractCommandCollection { String objectiveId = this.objectiveArg.get(context); ObjectiveAsset asset = ObjectiveAsset.getAssetMap().getAsset(objectiveId); if (asset == null) { - context.sendMessage(MESSAGE_COMMANDS_OBJECTIVE_OBJECTIVE_NOT_FOUND.param("id", objectiveId)); + context.sendMessage(Message.translation("server.commands.objective.objectiveNotFound").param("id", objectiveId)); context.sendMessage( - MESSAGE_GENERAL_FAILED_DID_YOU_MEAN.param( - "choices", - StringUtil.sortByFuzzyDistance(objectiveId, ObjectiveAsset.getAssetMap().getAssetMap().keySet(), CommandUtil.RECOMMEND_COUNT).toString() - ) + Message.translation("server.general.failed.didYouMean") + .param( + "choices", + StringUtil.sortByFuzzyDistance(objectiveId, ObjectiveAsset.getAssetMap().getAssetMap().keySet(), CommandUtil.RECOMMEND_COUNT).toString() + ) ); } else { HashSet playerSet = new HashSet<>(); @@ -68,10 +65,6 @@ public class ObjectiveStartCommand extends AbstractCommandCollection { } public static class StartObjectiveLineCommand extends AbstractPlayerCommand { - @Nonnull - private static final Message MESSAGE_COMMANDS_OBJECTIVE_OBJECTIVE_LINE_NOT_FOUND = Message.translation("server.commands.objective.objectiveLineNotFound"); - @Nonnull - private static final Message MESSAGE_GENERAL_FAILED_DID_YOU_MEAN = Message.translation("server.general.failed.didYouMean"); @Nonnull private final RequiredArg objectiveLineArg = this.withRequiredArg( "objectiveLineId", "server.commands.objective.start.objectiveLine.arg.objectiveLineId.desc", ArgTypes.STRING @@ -87,13 +80,14 @@ public class ObjectiveStartCommand extends AbstractCommandCollection { ) { String objectiveLineId = this.objectiveLineArg.get(context); if (ObjectiveLineAsset.getAssetMap().getAsset(objectiveLineId) == null) { - context.sendMessage(MESSAGE_COMMANDS_OBJECTIVE_OBJECTIVE_LINE_NOT_FOUND.param("id", objectiveLineId)); + context.sendMessage(Message.translation("server.commands.objective.objectiveLineNotFound").param("id", objectiveLineId)); context.sendMessage( - MESSAGE_GENERAL_FAILED_DID_YOU_MEAN.param( - "choices", - StringUtil.sortByFuzzyDistance(objectiveLineId, ObjectiveLineAsset.getAssetMap().getAssetMap().keySet(), CommandUtil.RECOMMEND_COUNT) - .toString() - ) + Message.translation("server.general.failed.didYouMean") + .param( + "choices", + StringUtil.sortByFuzzyDistance(objectiveLineId, ObjectiveLineAsset.getAssetMap().getAssetMap().keySet(), CommandUtil.RECOMMEND_COUNT) + .toString() + ) ); } else { HashSet playerSet = new HashSet<>(); diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/completion/ClearObjectiveItemsCompletion.java b/src/com/hypixel/hytale/builtin/adventure/objectives/completion/ClearObjectiveItemsCompletion.java index 182f383..491264e 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/completion/ClearObjectiveItemsCompletion.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/completion/ClearObjectiveItemsCompletion.java @@ -5,7 +5,6 @@ import com.hypixel.hytale.builtin.adventure.objectives.config.completion.ClearOb import com.hypixel.hytale.builtin.adventure.objectives.config.completion.ObjectiveCompletionAsset; import com.hypixel.hytale.builtin.adventure.objectives.interactions.StartObjectiveInteraction; import com.hypixel.hytale.component.ComponentAccessor; -import com.hypixel.hytale.server.core.entity.Entity; import com.hypixel.hytale.server.core.entity.EntityUtils; import com.hypixel.hytale.server.core.entity.LivingEntity; import com.hypixel.hytale.server.core.inventory.ItemStack; @@ -27,9 +26,8 @@ public class ClearObjectiveItemsCompletion extends ObjectiveCompletion { @Override public void handle(@Nonnull Objective objective, @Nonnull ComponentAccessor componentAccessor) { objective.forEachParticipant((participantReference, objectiveUuid) -> { - Entity entity = EntityUtils.getEntity(participantReference, componentAccessor); - if (entity instanceof LivingEntity) { - CombinedItemContainer inventory = ((LivingEntity)entity).getInventory().getCombinedHotbarFirst(); + if (EntityUtils.getEntity(participantReference, componentAccessor) instanceof LivingEntity livingEntity) { + CombinedItemContainer inventory = livingEntity.getInventory().getCombinedHotbarFirst(); for (short i = 0; i < inventory.getCapacity(); i++) { ItemStack itemStack = inventory.getItemStack(i); diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/components/ObjectiveHistoryComponent.java b/src/com/hypixel/hytale/builtin/adventure/objectives/components/ObjectiveHistoryComponent.java index bd365cf..17afea2 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/components/ObjectiveHistoryComponent.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/components/ObjectiveHistoryComponent.java @@ -29,9 +29,6 @@ public class ObjectiveHistoryComponent implements Component { private Map objectiveHistoryMap = new Object2ObjectOpenHashMap<>(); private Map objectiveLineHistoryMap = new Object2ObjectOpenHashMap<>(); - public ObjectiveHistoryComponent() { - } - public Map getObjectiveHistoryMap() { return this.objectiveHistoryMap; } diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/config/ObjectiveLocationMarkerAsset.java b/src/com/hypixel/hytale/builtin/adventure/objectives/config/ObjectiveLocationMarkerAsset.java index a5da578..79811ec 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/config/ObjectiveLocationMarkerAsset.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/config/ObjectiveLocationMarkerAsset.java @@ -96,9 +96,6 @@ public class ObjectiveLocationMarkerAsset implements JsonAssetWithMap)getAssetStore().getAssetMap(); } - public ObjectiveLocationMarkerAsset() { - } - public String getId() { return this.id; } diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/config/gameplayconfig/ObjectiveGameplayConfig.java b/src/com/hypixel/hytale/builtin/adventure/objectives/config/gameplayconfig/ObjectiveGameplayConfig.java index 0e06831..a1e4da0 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/config/gameplayconfig/ObjectiveGameplayConfig.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/config/gameplayconfig/ObjectiveGameplayConfig.java @@ -25,9 +25,6 @@ public class ObjectiveGameplayConfig { .build(); protected Map starterObjectiveLinePerWorld; - public ObjectiveGameplayConfig() { - } - @Nullable public static ObjectiveGameplayConfig get(@Nonnull GameplayConfig config) { return config.getPluginConfig().get(ObjectiveGameplayConfig.class); diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/config/markerarea/ObjectiveLocationMarkerArea.java b/src/com/hypixel/hytale/builtin/adventure/objectives/config/markerarea/ObjectiveLocationMarkerArea.java index a7a21d0..f350bf7 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/config/markerarea/ObjectiveLocationMarkerArea.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/config/markerarea/ObjectiveLocationMarkerArea.java @@ -18,9 +18,6 @@ public abstract class ObjectiveLocationMarkerArea { protected Box entryAreaBox; protected Box exitAreaBox; - public ObjectiveLocationMarkerArea() { - } - public abstract void getPlayersInEntryArea( @Nonnull SpatialResource, EntityStore> var1, @Nonnull List> var2, @Nonnull Vector3d var3 ); diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/config/objectivesetup/ObjectiveTypeSetup.java b/src/com/hypixel/hytale/builtin/adventure/objectives/config/objectivesetup/ObjectiveTypeSetup.java index cb0089a..3687e4e 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/config/objectivesetup/ObjectiveTypeSetup.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/config/objectivesetup/ObjectiveTypeSetup.java @@ -13,9 +13,6 @@ public abstract class ObjectiveTypeSetup { @Nonnull public static final CodecMapCodec CODEC = new CodecMapCodec<>("Type"); - public ObjectiveTypeSetup() { - } - @Nullable public abstract String getObjectiveIdToStart(); diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/config/objectivesetup/SetupObjective.java b/src/com/hypixel/hytale/builtin/adventure/objectives/config/objectivesetup/SetupObjective.java index 092c7c8..218cedc 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/config/objectivesetup/SetupObjective.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/config/objectivesetup/SetupObjective.java @@ -25,9 +25,6 @@ public class SetupObjective extends ObjectiveTypeSetup { .build(); protected String objectiveId; - public SetupObjective() { - } - @Override public String getObjectiveIdToStart() { return this.objectiveId; diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/config/objectivesetup/SetupObjectiveLine.java b/src/com/hypixel/hytale/builtin/adventure/objectives/config/objectivesetup/SetupObjectiveLine.java index 3559594..c1892a8 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/config/objectivesetup/SetupObjectiveLine.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/config/objectivesetup/SetupObjectiveLine.java @@ -27,9 +27,6 @@ public class SetupObjectiveLine extends ObjectiveTypeSetup { .build(); protected String objectiveLineId; - public SetupObjectiveLine() { - } - @Nullable @Override public String getObjectiveIdToStart() { diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/config/task/ObjectiveTaskAsset.java b/src/com/hypixel/hytale/builtin/adventure/objectives/config/task/ObjectiveTaskAsset.java index 0e059f4..fae15f2 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/config/task/ObjectiveTaskAsset.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/config/task/ObjectiveTaskAsset.java @@ -104,9 +104,6 @@ public abstract class ObjectiveTaskAsset { MARKER, PLAYER_AND_MARKER; - private TaskScope() { - } - public boolean isTaskPossibleForMarker() { return this == MARKER || this == PLAYER_AND_MARKER; } diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/config/task/ReachLocationTaskAsset.java b/src/com/hypixel/hytale/builtin/adventure/objectives/config/task/ReachLocationTaskAsset.java index 22b190f..439963f 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/config/task/ReachLocationTaskAsset.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/config/task/ReachLocationTaskAsset.java @@ -21,9 +21,6 @@ public class ReachLocationTaskAsset extends ObjectiveTaskAsset { .build(); protected String targetLocationId; - public ReachLocationTaskAsset() { - } - @Nonnull @Override public ObjectiveTaskAsset.TaskScope getTaskScope() { diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/config/task/TreasureMapObjectiveTaskAsset.java b/src/com/hypixel/hytale/builtin/adventure/objectives/config/task/TreasureMapObjectiveTaskAsset.java index e625099..3d121ac 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/config/task/TreasureMapObjectiveTaskAsset.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/config/task/TreasureMapObjectiveTaskAsset.java @@ -112,9 +112,6 @@ public class TreasureMapObjectiveTaskAsset extends ObjectiveTaskAsset { protected WorldLocationProvider worldLocationProvider; protected String chestBlockTypeKey; - public ChestConfig() { - } - public float getMinRadius() { return this.minRadius; } diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/config/taskcondition/SoloInventoryCondition.java b/src/com/hypixel/hytale/builtin/adventure/objectives/config/taskcondition/SoloInventoryCondition.java index b1af7ca..08e8004 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/config/taskcondition/SoloInventoryCondition.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/config/taskcondition/SoloInventoryCondition.java @@ -50,9 +50,6 @@ public class SoloInventoryCondition extends TaskConditionAsset { protected boolean consumeOnCompletion; protected boolean holdInHand; - public SoloInventoryCondition() { - } - public BlockTagOrItemIdField getBlockTypeOrTagTask() { return this.blockTypeOrTagTask; } diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/config/triggercondition/HourRangeTriggerCondition.java b/src/com/hypixel/hytale/builtin/adventure/objectives/config/triggercondition/HourRangeTriggerCondition.java index 0c3e649..4ee8872 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/config/triggercondition/HourRangeTriggerCondition.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/config/triggercondition/HourRangeTriggerCondition.java @@ -30,9 +30,6 @@ public class HourRangeTriggerCondition extends ObjectiveLocationTriggerCondition protected int minHour; protected int maxHour; - public HourRangeTriggerCondition() { - } - @Override public boolean isConditionMet( @Nonnull ComponentAccessor componentAccessor, Ref ref, ObjectiveLocationMarker objectiveLocationMarker diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/config/triggercondition/ObjectiveLocationTriggerCondition.java b/src/com/hypixel/hytale/builtin/adventure/objectives/config/triggercondition/ObjectiveLocationTriggerCondition.java index 5ad2faa..1d18a35 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/config/triggercondition/ObjectiveLocationTriggerCondition.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/config/triggercondition/ObjectiveLocationTriggerCondition.java @@ -10,9 +10,6 @@ import javax.annotation.Nonnull; public abstract class ObjectiveLocationTriggerCondition { public static final CodecMapCodec CODEC = new CodecMapCodec<>("Type"); - public ObjectiveLocationTriggerCondition() { - } - @Nonnull @Override public String toString() { diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/config/triggercondition/WeatherTriggerCondition.java b/src/com/hypixel/hytale/builtin/adventure/objectives/config/triggercondition/WeatherTriggerCondition.java index f6813df..522da92 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/config/triggercondition/WeatherTriggerCondition.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/config/triggercondition/WeatherTriggerCondition.java @@ -56,9 +56,6 @@ public class WeatherTriggerCondition extends ObjectiveLocationTriggerCondition { protected String[] weatherIds; protected int[] weatherIndexes; - public WeatherTriggerCondition() { - } - @Override public boolean isConditionMet( @Nonnull ComponentAccessor componentAccessor, @Nonnull Ref ref, ObjectiveLocationMarker objectiveLocationMarker diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/config/worldlocationproviders/LocationRadiusProvider.java b/src/com/hypixel/hytale/builtin/adventure/objectives/config/worldlocationproviders/LocationRadiusProvider.java index 435696e..6c36387 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/config/worldlocationproviders/LocationRadiusProvider.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/config/worldlocationproviders/LocationRadiusProvider.java @@ -45,9 +45,6 @@ public class LocationRadiusProvider extends WorldLocationProvider { protected int minRadius = 10; protected int maxRadius = 50; - public LocationRadiusProvider() { - } - @Nonnull @Override public Vector3i runCondition(@Nonnull World world, @Nonnull Vector3i position) { diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/config/worldlocationproviders/WorldLocationProvider.java b/src/com/hypixel/hytale/builtin/adventure/objectives/config/worldlocationproviders/WorldLocationProvider.java index 11fc8d7..997cff9 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/config/worldlocationproviders/WorldLocationProvider.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/config/worldlocationproviders/WorldLocationProvider.java @@ -11,9 +11,6 @@ public abstract class WorldLocationProvider { public static final CodecMapCodec CODEC = new CodecMapCodec<>("Type"); public static final BuilderCodec BASE_CODEC = BuilderCodec.abstractBuilder(WorldLocationProvider.class).build(); - public WorldLocationProvider() { - } - @Nullable public abstract Vector3i runCondition(World var1, Vector3i var2); diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/historydata/ObjectiveRewardHistoryData.java b/src/com/hypixel/hytale/builtin/adventure/objectives/historydata/ObjectiveRewardHistoryData.java index 333ded0..438727e 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/historydata/ObjectiveRewardHistoryData.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/historydata/ObjectiveRewardHistoryData.java @@ -6,7 +6,4 @@ import com.hypixel.hytale.codec.lookup.CodecMapCodec; public abstract class ObjectiveRewardHistoryData { public static final CodecMapCodec CODEC = new CodecMapCodec<>("Type"); public static final BuilderCodec BASE_CODEC = BuilderCodec.abstractBuilder(ObjectiveRewardHistoryData.class).build(); - - public ObjectiveRewardHistoryData() { - } } diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/interactions/CanBreakRespawnPointInteraction.java b/src/com/hypixel/hytale/builtin/adventure/objectives/interactions/CanBreakRespawnPointInteraction.java index 216df0a..1f5f135 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/interactions/CanBreakRespawnPointInteraction.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/interactions/CanBreakRespawnPointInteraction.java @@ -28,9 +28,6 @@ public class CanBreakRespawnPointInteraction extends SimpleBlockInteraction { ) .build(); - public CanBreakRespawnPointInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/interactions/StartObjectiveInteraction.java b/src/com/hypixel/hytale/builtin/adventure/objectives/interactions/StartObjectiveInteraction.java index d513d3d..a1b1e6e 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/interactions/StartObjectiveInteraction.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/interactions/StartObjectiveInteraction.java @@ -41,9 +41,6 @@ public class StartObjectiveInteraction extends SimpleInstantInteraction { public static final KeyedCodec OBJECTIVE_UUID = new KeyedCodec<>("ObjectiveUUID", Codec.UUID_BINARY); protected ObjectiveTypeSetup objectiveTypeSetup; - public StartObjectiveInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { CommandBuffer commandBuffer = context.getCommandBuffer(); diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/markers/ObjectiveMarkerProvider.java b/src/com/hypixel/hytale/builtin/adventure/objectives/markers/ObjectiveMarkerProvider.java index 440fac2..c368c50 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/markers/ObjectiveMarkerProvider.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/markers/ObjectiveMarkerProvider.java @@ -5,11 +5,10 @@ import com.hypixel.hytale.builtin.adventure.objectives.ObjectiveDataStore; import com.hypixel.hytale.builtin.adventure.objectives.ObjectivePlugin; import com.hypixel.hytale.builtin.adventure.objectives.task.ObjectiveTask; import com.hypixel.hytale.protocol.packets.worldmap.MapMarker; -import com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig; import com.hypixel.hytale.server.core.entity.entities.Player; import com.hypixel.hytale.server.core.universe.world.World; -import com.hypixel.hytale.server.core.universe.world.WorldMapTracker; import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager; +import com.hypixel.hytale.server.core.universe.world.worldmap.markers.MapMarkerTracker; import java.util.Set; import java.util.UUID; import javax.annotation.Nonnull; @@ -21,9 +20,7 @@ public class ObjectiveMarkerProvider implements WorldMapManager.MarkerProvider { } @Override - public void update( - @Nonnull World world, @Nonnull GameplayConfig gameplayConfig, @Nonnull WorldMapTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ - ) { + public void update(@Nonnull World world, @Nonnull MapMarkerTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ) { Player player = tracker.getPlayer(); Set activeObjectiveUUIDs = player.getPlayerConfigData().getActiveObjectiveUUIDs(); if (!activeObjectiveUUIDs.isEmpty()) { diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/markers/objectivelocation/ObjectiveLocationMarkerSystems.java b/src/com/hypixel/hytale/builtin/adventure/objectives/markers/objectivelocation/ObjectiveLocationMarkerSystems.java index 227282d..9bbd9fe 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/markers/objectivelocation/ObjectiveLocationMarkerSystems.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/markers/objectivelocation/ObjectiveLocationMarkerSystems.java @@ -55,16 +55,10 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class ObjectiveLocationMarkerSystems { - public ObjectiveLocationMarkerSystems() { - } - public static class EnsureNetworkSendableSystem extends HolderSystem { @Nonnull private final Query query = Query.and(ObjectiveLocationMarker.getComponentType(), Query.not(NetworkId.getComponentType())); - public EnsureNetworkSendableSystem() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { holder.addComponent(NetworkId.getComponentType(), new NetworkId(store.getExternalData().takeNextNetworkId())); diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/markers/reachlocation/ReachLocationMarkerAsset.java b/src/com/hypixel/hytale/builtin/adventure/objectives/markers/reachlocation/ReachLocationMarkerAsset.java index 3684d07..8f1fb15 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/markers/reachlocation/ReachLocationMarkerAsset.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/markers/reachlocation/ReachLocationMarkerAsset.java @@ -46,9 +46,6 @@ public class ReachLocationMarkerAsset implements JsonAssetWithMap> getAssetStore() { if (ASSET_STORE == null) { ASSET_STORE = AssetRegistry.getAssetStore(ReachLocationMarkerAsset.class); diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/markers/reachlocation/ReachLocationMarkerSystems.java b/src/com/hypixel/hytale/builtin/adventure/objectives/markers/reachlocation/ReachLocationMarkerSystems.java index df251cc..c3c5f9c 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/markers/reachlocation/ReachLocationMarkerSystems.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/markers/reachlocation/ReachLocationMarkerSystems.java @@ -41,15 +41,9 @@ public class ReachLocationMarkerSystems { private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); private static final ThreadLocal> THREAD_LOCAL_TEMP_UUIDS = ThreadLocal.withInitial(HashSet::new); - public ReachLocationMarkerSystems() { - } - public static class EnsureNetworkSendable extends HolderSystem { private final Query query = Query.and(ReachLocationMarker.getComponentType(), Query.not(NetworkId.getComponentType())); - public EnsureNetworkSendable() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { holder.addComponent(NetworkId.getComponentType(), new NetworkId(store.getExternalData().takeNextNetworkId())); diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/systems/ObjectiveItemEntityRemovalSystem.java b/src/com/hypixel/hytale/builtin/adventure/objectives/systems/ObjectiveItemEntityRemovalSystem.java index c35cf9b..229390a 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/systems/ObjectiveItemEntityRemovalSystem.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/systems/ObjectiveItemEntityRemovalSystem.java @@ -18,9 +18,6 @@ import javax.annotation.Nonnull; public class ObjectiveItemEntityRemovalSystem extends HolderSystem { private static final ComponentType COMPONENT_TYPE = ItemComponent.getComponentType(); - public ObjectiveItemEntityRemovalSystem() { - } - @Nonnull @Override public Query getQuery() { diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/task/GatherObjectiveTask.java b/src/com/hypixel/hytale/builtin/adventure/objectives/task/GatherObjectiveTask.java index 1c229bc..5d73b80 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/task/GatherObjectiveTask.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/task/GatherObjectiveTask.java @@ -60,18 +60,21 @@ public class GatherObjectiveTask extends CountObjectiveTask { LivingEntity livingEntity = event.getEntity(); if (livingEntity instanceof Player) { Ref ref = livingEntity.getReference(); - World refWorld = store.getExternalData().getWorld(); - refWorld.execute(() -> { - UUIDComponent uuidComponent = store.getComponent(ref, UUIDComponent.getComponentType()); - - assert uuidComponent != null; - - Set activePlayerUUIDs = objective.getActivePlayerUUIDs(); - if (activePlayerUUIDs.contains(uuidComponent.getUuid())) { - int count = this.countObjectiveItemInInventories(activePlayerUUIDs, store); - this.setTaskCompletion(store, ref, count, objective); - } - }); + if (ref != null && ref.isValid()) { + World refWorld = store.getExternalData().getWorld(); + refWorld.execute(() -> { + if (ref.isValid()) { + UUIDComponent uuidComponent = store.getComponent(ref, UUIDComponent.getComponentType()); + if (uuidComponent != null) { + Set activePlayerUUIDs = objective.getActivePlayerUUIDs(); + if (activePlayerUUIDs.contains(uuidComponent.getUuid())) { + int count = this.countObjectiveItemInInventories(activePlayerUUIDs, store); + this.setTaskCompletion(store, ref, count, objective); + } + } + } + }); + } } }); return RegistrationTransactionRecord.wrap(this.eventRegistry); diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/transaction/TransactionRecord.java b/src/com/hypixel/hytale/builtin/adventure/objectives/transaction/TransactionRecord.java index 714ae39..8228efb 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/transaction/TransactionRecord.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/transaction/TransactionRecord.java @@ -21,9 +21,6 @@ public abstract class TransactionRecord { protected TransactionStatus status = TransactionStatus.SUCCESS; private String reason; - public TransactionRecord() { - } - public TransactionStatus getStatus() { return this.status; } diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/transaction/TransactionStatus.java b/src/com/hypixel/hytale/builtin/adventure/objectives/transaction/TransactionStatus.java index a2cac3b..5c90c9a 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/transaction/TransactionStatus.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/transaction/TransactionStatus.java @@ -3,7 +3,4 @@ package com.hypixel.hytale.builtin.adventure.objectives.transaction; enum TransactionStatus { SUCCESS, FAIL; - - private TransactionStatus() { - } } diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/transaction/TransactionUtil.java b/src/com/hypixel/hytale/builtin/adventure/objectives/transaction/TransactionUtil.java index b44cdad..854369c 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/transaction/TransactionUtil.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/transaction/TransactionUtil.java @@ -3,9 +3,6 @@ package com.hypixel.hytale.builtin.adventure.objectives.transaction; import javax.annotation.Nullable; public class TransactionUtil { - public TransactionUtil() { - } - public static boolean anyFailed(@Nullable TransactionRecord[] transactionRecords) { if (transactionRecords == null) { return false; diff --git a/src/com/hypixel/hytale/builtin/adventure/objectives/transaction/WorldTransactionRecord.java b/src/com/hypixel/hytale/builtin/adventure/objectives/transaction/WorldTransactionRecord.java index 4b3c306..7899b02 100644 --- a/src/com/hypixel/hytale/builtin/adventure/objectives/transaction/WorldTransactionRecord.java +++ b/src/com/hypixel/hytale/builtin/adventure/objectives/transaction/WorldTransactionRecord.java @@ -3,9 +3,6 @@ package com.hypixel.hytale.builtin.adventure.objectives.transaction; import javax.annotation.Nonnull; public class WorldTransactionRecord extends TransactionRecord { - public WorldTransactionRecord() { - } - @Override public void revert() { } diff --git a/src/com/hypixel/hytale/builtin/adventure/reputation/ReputationGameplayConfig.java b/src/com/hypixel/hytale/builtin/adventure/reputation/ReputationGameplayConfig.java index 687dd03..841c314 100644 --- a/src/com/hypixel/hytale/builtin/adventure/reputation/ReputationGameplayConfig.java +++ b/src/com/hypixel/hytale/builtin/adventure/reputation/ReputationGameplayConfig.java @@ -22,9 +22,6 @@ public class ReputationGameplayConfig { @Nonnull protected ReputationGameplayConfig.ReputationStorageType reputationStorageType = ReputationGameplayConfig.ReputationStorageType.PerPlayer; - public ReputationGameplayConfig() { - } - @Nullable public static ReputationGameplayConfig get(@Nonnull GameplayConfig config) { return config.getPluginConfig().get(ReputationGameplayConfig.class); @@ -49,8 +46,5 @@ public class ReputationGameplayConfig { public static enum ReputationStorageType { PerPlayer, PerWorld; - - private ReputationStorageType() { - } } } diff --git a/src/com/hypixel/hytale/builtin/adventure/reputation/store/ReputationDataResource.java b/src/com/hypixel/hytale/builtin/adventure/reputation/store/ReputationDataResource.java index dc6cfde..8e44910 100644 --- a/src/com/hypixel/hytale/builtin/adventure/reputation/store/ReputationDataResource.java +++ b/src/com/hypixel/hytale/builtin/adventure/reputation/store/ReputationDataResource.java @@ -23,9 +23,6 @@ public class ReputationDataResource implements Resource { @Nonnull private Object2IntMap reputationStats = new Object2IntOpenHashMap<>(0); - public ReputationDataResource() { - } - @Nonnull public Object2IntMap getReputationStats() { return this.reputationStats; diff --git a/src/com/hypixel/hytale/builtin/adventure/shop/ShopElement.java b/src/com/hypixel/hytale/builtin/adventure/shop/ShopElement.java index cb4cbf7..654981c 100644 --- a/src/com/hypixel/hytale/builtin/adventure/shop/ShopElement.java +++ b/src/com/hypixel/hytale/builtin/adventure/shop/ShopElement.java @@ -25,9 +25,6 @@ public class ShopElement extends ChoiceElement { protected int cost; protected String iconPath; - public ShopElement() { - } - @Override public void addButton(@Nonnull UICommandBuilder commandBuilder, UIEventBuilder eventBuilder, String selector, PlayerRef playerRef) { commandBuilder.append("#ElementList", "Pages/ShopElementButton.ui"); diff --git a/src/com/hypixel/hytale/builtin/adventure/shop/ShopPageSupplier.java b/src/com/hypixel/hytale/builtin/adventure/shop/ShopPageSupplier.java index 7a23f30..4e7e0d8 100644 --- a/src/com/hypixel/hytale/builtin/adventure/shop/ShopPageSupplier.java +++ b/src/com/hypixel/hytale/builtin/adventure/shop/ShopPageSupplier.java @@ -21,9 +21,6 @@ public class ShopPageSupplier implements OpenCustomUIInteraction.CustomPageSuppl .build(); protected String shopId; - public ShopPageSupplier() { - } - @Nonnull @Override public CustomUIPage tryCreate( diff --git a/src/com/hypixel/hytale/builtin/adventure/shop/barter/BarterPage.java b/src/com/hypixel/hytale/builtin/adventure/shop/barter/BarterPage.java index d59e711..411833e 100644 --- a/src/com/hypixel/hytale/builtin/adventure/shop/barter/BarterPage.java +++ b/src/com/hypixel/hytale/builtin/adventure/shop/barter/BarterPage.java @@ -345,9 +345,6 @@ public class BarterPage extends InteractiveCustomUIPage { - private TeleporterOwnedWarpRefChangeSystem() { - } - @Nonnull @Override public ComponentType componentType() { @@ -101,9 +98,6 @@ public class TeleporterPlugin extends JavaPlugin { private static class TeleporterOwnedWarpRefSystem extends RefSystem { public static final ComponentType COMPONENT_TYPE = Teleporter.getComponentType(); - private TeleporterOwnedWarpRefSystem() { - } - @Override public void onEntityAdded( @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer diff --git a/src/com/hypixel/hytale/builtin/adventure/teleporter/component/Teleporter.java b/src/com/hypixel/hytale/builtin/adventure/teleporter/component/Teleporter.java index 0658d99..86cc8ff 100644 --- a/src/com/hypixel/hytale/builtin/adventure/teleporter/component/Teleporter.java +++ b/src/com/hypixel/hytale/builtin/adventure/teleporter/component/Teleporter.java @@ -55,9 +55,6 @@ public class Teleporter implements Component { private boolean isCustomName; private String warpNameWordListKey; - public Teleporter() { - } - public static ComponentType getComponentType() { return TeleporterPlugin.get().getTeleporterComponentType(); } @@ -167,19 +164,19 @@ public class Teleporter implements Component { if (this.relativeMask != 0) { Transform teleportTransform = this.transform.clone(); Transform.applyMaskedRelativeTransform(teleportTransform, this.relativeMask, currentPosition, currentRotation, blockPosition); - return new Teleport(world, teleportTransform); + return Teleport.createForPlayer(world, teleportTransform); } - return new Teleport(world, this.transform); + return Teleport.createForPlayer(world, this.transform); } } if (this.relativeMask != 0) { Transform teleportTransform = this.transform.clone(); Transform.applyMaskedRelativeTransform(teleportTransform, this.relativeMask, currentPosition, currentRotation, blockPosition); - return new Teleport(teleportTransform); + return Teleport.createForPlayer(teleportTransform); } else { - return new Teleport(this.transform); + return Teleport.createForPlayer(this.transform); } } else { return null; diff --git a/src/com/hypixel/hytale/builtin/adventure/teleporter/interaction/server/TeleporterInteraction.java b/src/com/hypixel/hytale/builtin/adventure/teleporter/interaction/server/TeleporterInteraction.java index 73ca0ad..88df5cd 100644 --- a/src/com/hypixel/hytale/builtin/adventure/teleporter/interaction/server/TeleporterInteraction.java +++ b/src/com/hypixel/hytale/builtin/adventure/teleporter/interaction/server/TeleporterInteraction.java @@ -22,6 +22,7 @@ import com.hypixel.hytale.server.core.modules.entity.EntityModule; import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent; import com.hypixel.hytale.server.core.modules.entity.teleport.PendingTeleport; import com.hypixel.hytale.server.core.modules.entity.teleport.Teleport; +import com.hypixel.hytale.server.core.modules.entity.teleport.TeleportRecord; import com.hypixel.hytale.server.core.modules.interaction.interaction.CooldownHandler; import com.hypixel.hytale.server.core.modules.interaction.interaction.config.client.SimpleBlockInteraction; import com.hypixel.hytale.server.core.universe.world.ParticleUtil; @@ -31,6 +32,7 @@ import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk; import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import it.unimi.dsi.fastutil.objects.ObjectList; +import java.time.Duration; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -48,12 +50,10 @@ public class TeleporterInteraction extends SimpleBlockInteraction { .documentation("The particle to play on the entity when teleporting.") .add() .build(); + private static final Duration TELEPORT_GLOBAL_COOLDOWN = Duration.ofMillis(250L); @Nullable private String particle; - public TeleporterInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { @@ -88,12 +88,12 @@ public class TeleporterInteraction extends SimpleBlockInteraction { if (playerComponent == null || !playerComponent.isWaitingForClientReady()) { Archetype archetype = commandBuffer.getArchetype(ref); if (!archetype.contains(Teleport.getComponentType()) && !archetype.contains(PendingTeleport.getComponentType())) { + WorldChunk worldChunkComponent = chunkRef.getStore().getComponent(chunkRef, WorldChunk.getComponentType()); + + assert worldChunkComponent != null; + + BlockType blockType = worldChunkComponent.getBlockType(targetBlock.x, targetBlock.y, targetBlock.z); if (!teleporter.isValid()) { - WorldChunk worldChunkComponent = chunkRef.getStore().getComponent(chunkRef, WorldChunk.getComponentType()); - - assert worldChunkComponent != null; - - BlockType blockType = worldChunkComponent.getBlockType(targetBlock.x, targetBlock.y, targetBlock.z); String currentState = blockType.getStateForBlock(blockType); if (!"default".equals(currentState)) { BlockType variantBlockType = blockType.getBlockForState("default"); @@ -109,15 +109,18 @@ public class TeleporterInteraction extends SimpleBlockInteraction { Teleport teleportComponent = teleporter.toTeleport(transformComponent.getPosition(), transformComponent.getRotation(), targetBlock); if (teleportComponent != null) { - commandBuffer.addComponent(ref, Teleport.getComponentType(), teleportComponent); - if (this.particle != null) { - Vector3d particlePosition = transformComponent.getPosition(); - SpatialResource, EntityStore> playerSpatialResource = commandBuffer.getResource( - EntityModule.get().getPlayerSpatialResourceType() - ); - ObjectList> results = SpatialResource.getThreadLocalReferenceList(); - playerSpatialResource.getSpatialStructure().collect(particlePosition, 75.0, results); - ParticleUtil.spawnParticleEffect(this.particle, particlePosition, results, commandBuffer); + TeleportRecord recorder = commandBuffer.getComponent(ref, TeleportRecord.getComponentType()); + if (recorder == null || recorder.hasElapsedSinceLastTeleport(TELEPORT_GLOBAL_COOLDOWN)) { + commandBuffer.addComponent(ref, Teleport.getComponentType(), teleportComponent); + if (this.particle != null) { + Vector3d particlePosition = transformComponent.getPosition(); + SpatialResource, EntityStore> playerSpatialResource = commandBuffer.getResource( + EntityModule.get().getPlayerSpatialResourceType() + ); + ObjectList> results = SpatialResource.getThreadLocalReferenceList(); + playerSpatialResource.getSpatialStructure().collect(particlePosition, 75.0, results); + ParticleUtil.spawnParticleEffect(this.particle, particlePosition, results, commandBuffer); + } } } } diff --git a/src/com/hypixel/hytale/builtin/adventure/teleporter/page/TeleporterSettingsPage.java b/src/com/hypixel/hytale/builtin/adventure/teleporter/page/TeleporterSettingsPage.java index e189c00..6fbc5ca 100644 --- a/src/com/hypixel/hytale/builtin/adventure/teleporter/page/TeleporterSettingsPage.java +++ b/src/com/hypixel/hytale/builtin/adventure/teleporter/page/TeleporterSettingsPage.java @@ -281,9 +281,6 @@ public class TeleporterSettingsPage extends InteractiveCustomUIPage CODEC = new EnumCodec<>(TeleporterSettingsPage.Mode.class); - - private Mode() { - } } public static class PageEventData { @@ -378,8 +375,5 @@ public class TeleporterSettingsPage extends InteractiveCustomUIPage { - @Nonnull - public static final Vector3d WARP_OFFSET = new Vector3d(-3.5, 0.0, -3.5); - - public CreateWarpWhenTeleporterPlacedSystem() { - } - public void onComponentAdded( @Nonnull Ref ref, @Nonnull PlacedByInteractionComponent placedBy, @@ -88,29 +83,14 @@ public class CreateWarpWhenTeleporterPlacedSystem extends RefChangeSystem { private final UpdateEnvironmentMusic musicPacket = new UpdateEnvironmentMusic(0); private int forcedMusicIndex; - public AmbienceTracker() { - } - public static ComponentType getComponentType() { return AmbiencePlugin.get().getAmbienceTrackerComponentType(); } diff --git a/src/com/hypixel/hytale/builtin/ambience/components/AmbientEmitterComponent.java b/src/com/hypixel/hytale/builtin/ambience/components/AmbientEmitterComponent.java index 12be0a0..0a0a3ae 100644 --- a/src/com/hypixel/hytale/builtin/ambience/components/AmbientEmitterComponent.java +++ b/src/com/hypixel/hytale/builtin/ambience/components/AmbientEmitterComponent.java @@ -18,9 +18,6 @@ public class AmbientEmitterComponent implements Component { private String soundEventId; private Ref spawnedEmitter; - public AmbientEmitterComponent() { - } - public static ComponentType getComponentType() { return AmbiencePlugin.get().getAmbientEmitterComponentType(); } diff --git a/src/com/hypixel/hytale/builtin/ambience/resources/AmbienceResource.java b/src/com/hypixel/hytale/builtin/ambience/resources/AmbienceResource.java index 97bc6cc..2d5ffa1 100644 --- a/src/com/hypixel/hytale/builtin/ambience/resources/AmbienceResource.java +++ b/src/com/hypixel/hytale/builtin/ambience/resources/AmbienceResource.java @@ -10,9 +10,6 @@ import javax.annotation.Nullable; public class AmbienceResource implements Resource { private int forcedMusicIndex; - public AmbienceResource() { - } - public static ResourceType getResourceType() { return AmbiencePlugin.get().getAmbienceResourceType(); } diff --git a/src/com/hypixel/hytale/builtin/ambience/systems/AmbientEmitterSystems.java b/src/com/hypixel/hytale/builtin/ambience/systems/AmbientEmitterSystems.java index a78a3ed..55ab3e1 100644 --- a/src/com/hypixel/hytale/builtin/ambience/systems/AmbientEmitterSystems.java +++ b/src/com/hypixel/hytale/builtin/ambience/systems/AmbientEmitterSystems.java @@ -26,15 +26,9 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class AmbientEmitterSystems { - public AmbientEmitterSystems() { - } - public static class EntityAdded extends HolderSystem { private final Query query = Query.and(AmbientEmitterComponent.getComponentType(), TransformComponent.getComponentType()); - public EntityAdded() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { if (!holder.getArchetype().contains(NetworkId.getComponentType())) { @@ -58,9 +52,6 @@ public class AmbientEmitterSystems { public static class EntityRefAdded extends RefSystem { private final Query query = Query.and(AmbientEmitterComponent.getComponentType(), TransformComponent.getComponentType()); - public EntityRefAdded() { - } - @Override public void onEntityAdded( @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer @@ -110,9 +101,6 @@ public class AmbientEmitterSystems { public static class Ticking extends EntityTickingSystem { private final Query query = Query.and(AmbientEmitterComponent.getComponentType(), TransformComponent.getComponentType()); - public Ticking() { - } - @Override public void tick( float dt, diff --git a/src/com/hypixel/hytale/builtin/ambience/systems/ForcedMusicSystems.java b/src/com/hypixel/hytale/builtin/ambience/systems/ForcedMusicSystems.java index 2a05a40..3e9d3f1 100644 --- a/src/com/hypixel/hytale/builtin/ambience/systems/ForcedMusicSystems.java +++ b/src/com/hypixel/hytale/builtin/ambience/systems/ForcedMusicSystems.java @@ -24,13 +24,7 @@ public class ForcedMusicSystems { Player.getComponentType(), PlayerRef.getComponentType(), AmbienceTracker.getComponentType() ); - public ForcedMusicSystems() { - } - public static class PlayerAdded extends HolderSystem { - public PlayerAdded() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { holder.ensureComponent(AmbienceTracker.getComponentType()); @@ -38,24 +32,27 @@ public class ForcedMusicSystems { @Override public void onEntityRemoved(@Nonnull Holder holder, @Nonnull RemoveReason reason, @Nonnull Store store) { - AmbienceTracker tracker = holder.getComponent(AmbienceTracker.getComponentType()); - PlayerRef playerRef = holder.getComponent(PlayerRef.getComponentType()); - UpdateEnvironmentMusic pooledPacket = tracker.getMusicPacket(); + AmbienceTracker ambienceTrackerComponent = holder.getComponent(AmbienceTracker.getComponentType()); + + assert ambienceTrackerComponent != null; + + PlayerRef playerRefComponent = holder.getComponent(PlayerRef.getComponentType()); + + assert playerRefComponent != null; + + UpdateEnvironmentMusic pooledPacket = ambienceTrackerComponent.getMusicPacket(); pooledPacket.environmentIndex = 0; - playerRef.getPacketHandler().write(pooledPacket); + playerRefComponent.getPacketHandler().write(pooledPacket); } @Nullable @Override public Query getQuery() { - return PlayerRef.getComponentType(); + return Query.and(PlayerRef.getComponentType(), AmbienceTracker.getComponentType()); } } public static class Tick extends EntityTickingSystem { - public Tick() { - } - @Override public void tick( float dt, diff --git a/src/com/hypixel/hytale/builtin/asseteditor/AssetEditorPlugin.java b/src/com/hypixel/hytale/builtin/asseteditor/AssetEditorPlugin.java index 4116c6c..0dfadce 100644 --- a/src/com/hypixel/hytale/builtin/asseteditor/AssetEditorPlugin.java +++ b/src/com/hypixel/hytale/builtin/asseteditor/AssetEditorPlugin.java @@ -115,7 +115,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bson.BsonDocument; import org.bson.BsonValue; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; public class AssetEditorPlugin extends JavaPlugin { private static AssetEditorPlugin instance; @@ -145,7 +144,7 @@ public class AssetEditorPlugin extends JavaPlugin { super(init); } - @NullableDecl + @Nullable DataSource registerDataSourceForPack(AssetPack assetPack) { PluginManifest manifest = assetPack.getManifest(); if (manifest == null) { @@ -1859,17 +1858,11 @@ public class AssetEditorPlugin extends JavaPlugin { FAILED, SUCCEEDED, SUCCEEDED_COMMON_ASSETS_CHANGED; - - private DiscardResult() { - } } static enum InitState { NOT_INITIALIZED, INITIALIZING, INITIALIZED; - - private InitState() { - } } } diff --git a/src/com/hypixel/hytale/builtin/asseteditor/AssetSpecificFunctionality.java b/src/com/hypixel/hytale/builtin/asseteditor/AssetSpecificFunctionality.java index a0f1f67..4c3b1f5 100644 --- a/src/com/hypixel/hytale/builtin/asseteditor/AssetSpecificFunctionality.java +++ b/src/com/hypixel/hytale/builtin/asseteditor/AssetSpecificFunctionality.java @@ -75,9 +75,6 @@ public class AssetSpecificFunctionality { 0.25F, new Vector3f(0.0F, 75.0F, 0.0F), new Vector3f(0.0F, (float)Math.toRadians(45.0), 0.0F) ); - public AssetSpecificFunctionality() { - } - public static void setup() { getEventRegistry().register(LoadedAssetsEvent.class, ModelAsset.class, AssetSpecificFunctionality::onModelAssetLoaded); getEventRegistry().register(LoadedAssetsEvent.class, Item.class, AssetSpecificFunctionality::onItemAssetLoaded); @@ -495,8 +492,5 @@ public class AssetSpecificFunctionality { @Nullable private Path weatherAssetPath; private boolean keepPreview; - - public PlayerPreviewData() { - } } } diff --git a/src/com/hypixel/hytale/builtin/asseteditor/AssetTypeRegistry.java b/src/com/hypixel/hytale/builtin/asseteditor/AssetTypeRegistry.java index 7b28f47..519f3a6 100644 --- a/src/com/hypixel/hytale/builtin/asseteditor/AssetTypeRegistry.java +++ b/src/com/hypixel/hytale/builtin/asseteditor/AssetTypeRegistry.java @@ -21,9 +21,6 @@ public class AssetTypeRegistry { private final ConcurrentHashMap assetTypeHandlers = new ConcurrentHashMap<>(); private AssetEditorSetupAssetTypes setupPacket; - public AssetTypeRegistry() { - } - @Nonnull public Map getRegisteredAssetTypeHandlers() { return this.assetTypeHandlers; diff --git a/src/com/hypixel/hytale/builtin/asseteditor/Messages.java b/src/com/hypixel/hytale/builtin/asseteditor/Messages.java index 3ee9380..110e717 100644 --- a/src/com/hypixel/hytale/builtin/asseteditor/Messages.java +++ b/src/com/hypixel/hytale/builtin/asseteditor/Messages.java @@ -7,7 +7,4 @@ public class Messages { public static final Message INVALID_FILENAME_MESSAGE = Message.translation("server.assetEditor.messages.invalidFileName"); public static final Message OUTSIDE_ASSET_ROOT_MESSAGE = Message.translation("server.assetEditor.messages.directoryOutsideAssetTypeRoot"); public static final Message UNKNOWN_ASSETPACK_MESSAGE = Message.translation("server.assetEditor.messages.unknownAssetPack"); - - public Messages() { - } } diff --git a/src/com/hypixel/hytale/builtin/asseteditor/UndoRedoManager.java b/src/com/hypixel/hytale/builtin/asseteditor/UndoRedoManager.java index 4baf420..db5cd28 100644 --- a/src/com/hypixel/hytale/builtin/asseteditor/UndoRedoManager.java +++ b/src/com/hypixel/hytale/builtin/asseteditor/UndoRedoManager.java @@ -7,9 +7,6 @@ import java.util.Map; public class UndoRedoManager { private final Map assetUndoRedoInfo = new Object2ObjectOpenHashMap<>(); - public UndoRedoManager() { - } - public AssetUndoRedoInfo getOrCreateUndoRedoStack(AssetPath path) { return this.assetUndoRedoInfo.computeIfAbsent(path, k -> new AssetUndoRedoInfo()); } diff --git a/src/com/hypixel/hytale/builtin/asseteditor/assettypehandler/AssetTypeHandler.java b/src/com/hypixel/hytale/builtin/asseteditor/assettypehandler/AssetTypeHandler.java index c8a9cde..8c3e158 100644 --- a/src/com/hypixel/hytale/builtin/asseteditor/assettypehandler/AssetTypeHandler.java +++ b/src/com/hypixel/hytale/builtin/asseteditor/assettypehandler/AssetTypeHandler.java @@ -57,8 +57,5 @@ public abstract class AssetTypeHandler { ASSETS_UNCHANGED, ASSETS_CHANGED, COMMON_ASSETS_CHANGED; - - private AssetLoadResult() { - } } } diff --git a/src/com/hypixel/hytale/builtin/asseteditor/data/AssetState.java b/src/com/hypixel/hytale/builtin/asseteditor/data/AssetState.java index f3ec6cb..a936f33 100644 --- a/src/com/hypixel/hytale/builtin/asseteditor/data/AssetState.java +++ b/src/com/hypixel/hytale/builtin/asseteditor/data/AssetState.java @@ -4,7 +4,4 @@ public enum AssetState { CHANGED, NEW, DELETED; - - private AssetState() { - } } diff --git a/src/com/hypixel/hytale/builtin/asseteditor/data/AssetUndoRedoInfo.java b/src/com/hypixel/hytale/builtin/asseteditor/data/AssetUndoRedoInfo.java index 56ee22c..08094d4 100644 --- a/src/com/hypixel/hytale/builtin/asseteditor/data/AssetUndoRedoInfo.java +++ b/src/com/hypixel/hytale/builtin/asseteditor/data/AssetUndoRedoInfo.java @@ -7,7 +7,4 @@ import java.util.Deque; public class AssetUndoRedoInfo { public final Deque undoStack = new ArrayDeque<>(); public final Deque redoStack = new ArrayDeque<>(); - - public AssetUndoRedoInfo() { - } } diff --git a/src/com/hypixel/hytale/builtin/asseteditor/data/ModifiedAsset.java b/src/com/hypixel/hytale/builtin/asseteditor/data/ModifiedAsset.java index a8459ac..dbd5aae 100644 --- a/src/com/hypixel/hytale/builtin/asseteditor/data/ModifiedAsset.java +++ b/src/com/hypixel/hytale/builtin/asseteditor/data/ModifiedAsset.java @@ -57,9 +57,6 @@ public class ModifiedAsset { public UUID lastModificationPlayerUuid; public String lastModificationUsername; - public ModifiedAsset() { - } - public void markEditedBy(@Nonnull EditorClient editorClient) { this.lastModificationTimestamp = Instant.now(); this.lastModificationUsername = editorClient.getUsername(); diff --git a/src/com/hypixel/hytale/builtin/asseteditor/util/AssetPathUtil.java b/src/com/hypixel/hytale/builtin/asseteditor/util/AssetPathUtil.java index fb15f94..3070377 100644 --- a/src/com/hypixel/hytale/builtin/asseteditor/util/AssetPathUtil.java +++ b/src/com/hypixel/hytale/builtin/asseteditor/util/AssetPathUtil.java @@ -39,9 +39,6 @@ public class AssetPathUtil { "LPT9" }; - public AssetPathUtil() { - } - public static boolean isInvalidFileName(@Nonnull Path path) { String fileName = path.getFileName().toString(); if (fileName.isEmpty()) { diff --git a/src/com/hypixel/hytale/builtin/asseteditor/util/AssetStoreUtil.java b/src/com/hypixel/hytale/builtin/asseteditor/util/AssetStoreUtil.java index 3f2f90a..6f0fdf4 100644 --- a/src/com/hypixel/hytale/builtin/asseteditor/util/AssetStoreUtil.java +++ b/src/com/hypixel/hytale/builtin/asseteditor/util/AssetStoreUtil.java @@ -9,9 +9,6 @@ import com.hypixel.hytale.assetstore.map.LookupTableAssetMap; import javax.annotation.Nonnull; public class AssetStoreUtil { - public AssetStoreUtil() { - } - @Deprecated public static , M extends AssetMap> String getIdFromIndex(@Nonnull AssetStore assetStore, int assetIndex) { M assetMap = assetStore.getAssetMap(); diff --git a/src/com/hypixel/hytale/builtin/asseteditor/util/BsonTransformationUtil.java b/src/com/hypixel/hytale/builtin/asseteditor/util/BsonTransformationUtil.java index da7f51c..a442c6e 100644 --- a/src/com/hypixel/hytale/builtin/asseteditor/util/BsonTransformationUtil.java +++ b/src/com/hypixel/hytale/builtin/asseteditor/util/BsonTransformationUtil.java @@ -9,9 +9,6 @@ import org.bson.BsonNull; import org.bson.BsonValue; public class BsonTransformationUtil { - public BsonTransformationUtil() { - } - private static void actionOnProperty(BsonDocument entity, @Nonnull String[] propertyPath, @Nonnull BiConsumer biConsumer, boolean create) { BsonValue current = entity; diff --git a/src/com/hypixel/hytale/builtin/beds/interactions/BedInteraction.java b/src/com/hypixel/hytale/builtin/beds/interactions/BedInteraction.java index 50f60a1..813a81e 100644 --- a/src/com/hypixel/hytale/builtin/beds/interactions/BedInteraction.java +++ b/src/com/hypixel/hytale/builtin/beds/interactions/BedInteraction.java @@ -38,26 +38,24 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList; import java.util.UUID; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; public class BedInteraction extends SimpleBlockInteraction { + @Nonnull + private static final Message MESSAGE_SERVER_CUSTOM_UI_RESPAWN_POINT_CLAIMED = Message.translation("server.customUI.respawnPointClaimed"); + @Nonnull public static final BuilderCodec CODEC = BuilderCodec.builder(BedInteraction.class, BedInteraction::new, SimpleBlockInteraction.CODEC) .documentation("Interact with a bed block, ostensibly to sleep in it.") .build(); - public BedInteraction() { - } - @Override protected void interactWithBlock( - @NonNullDecl World world, - @NonNullDecl CommandBuffer commandBuffer, - @NonNullDecl InteractionType type, - @NonNullDecl InteractionContext context, - @NullableDecl ItemStack itemInHand, - @NonNullDecl Vector3i pos, - @NonNullDecl CooldownHandler cooldownHandler + @Nonnull World world, + @Nonnull CommandBuffer commandBuffer, + @Nonnull InteractionType type, + @Nonnull InteractionContext context, + @Nullable ItemStack itemInHand, + @Nonnull Vector3i pos, + @Nonnull CooldownHandler cooldownHandler ) { Ref ref = context.getEntity(); Player player = commandBuffer.getComponent(ref, Player.getComponentType()); @@ -88,9 +86,9 @@ public class BedInteraction extends SimpleBlockInteraction { blockRef = chunkStore.addEntity(holder, AddReason.SPAWN); } - RespawnBlock respawnBlock = chunkStore.getComponent(blockRef, RespawnBlock.getComponentType()); - if (respawnBlock != null) { - UUID ownerUUID = respawnBlock.getOwnerUUID(); + RespawnBlock respawnBlockComponent = chunkStore.getComponent(blockRef, RespawnBlock.getComponentType()); + if (respawnBlockComponent != null) { + UUID ownerUUID = respawnBlockComponent.getOwnerUUID(); PageManager pageManager = player.getPageManager(); boolean isOwner = playerUuid.equals(ownerUUID); if (isOwner) { @@ -103,22 +101,26 @@ public class BedInteraction extends SimpleBlockInteraction { commandBuffer.putComponent(ref, PlayerSomnolence.getComponentType(), PlayerSleep.NoddingOff.createComponent()); } } else if (ownerUUID != null) { - player.sendMessage(Message.translation("server.customUI.respawnPointClaimed")); + player.sendMessage(MESSAGE_SERVER_CUSTOM_UI_RESPAWN_POINT_CLAIMED); } else { PlayerRespawnPointData[] respawnPoints = player.getPlayerConfigData().getPerWorldData(world.getName()).getRespawnPoints(); RespawnConfig respawnConfig = world.getGameplayConfig().getRespawnConfig(); int radiusLimitRespawnPoint = respawnConfig.getRadiusLimitRespawnPoint(); - PlayerRespawnPointData[] nearbyRespawnPoints = this.getNearbySavedRespawnPoints(pos, respawnBlock, respawnPoints, radiusLimitRespawnPoint); + PlayerRespawnPointData[] nearbyRespawnPoints = this.getNearbySavedRespawnPoints( + pos, respawnBlockComponent, respawnPoints, radiusLimitRespawnPoint + ); if (nearbyRespawnPoints != null) { pageManager.openCustomPage( ref, store, - new OverrideNearbyRespawnPointPage(playerRefComponent, type, pos, respawnBlock, nearbyRespawnPoints, radiusLimitRespawnPoint) + new OverrideNearbyRespawnPointPage(playerRefComponent, type, pos, respawnBlockComponent, nearbyRespawnPoints, radiusLimitRespawnPoint) ); } else if (respawnPoints != null && respawnPoints.length >= respawnConfig.getMaxRespawnPointsPerPlayer()) { - pageManager.openCustomPage(ref, store, new SelectOverrideRespawnPointPage(playerRefComponent, type, pos, respawnBlock, respawnPoints)); + pageManager.openCustomPage( + ref, store, new SelectOverrideRespawnPointPage(playerRefComponent, type, pos, respawnBlockComponent, respawnPoints) + ); } else { - pageManager.openCustomPage(ref, store, new SetNameRespawnPointPage(playerRefComponent, type, pos, respawnBlock)); + pageManager.openCustomPage(ref, store, new SetNameRespawnPointPage(playerRefComponent, type, pos, respawnBlockComponent)); } } } @@ -128,11 +130,7 @@ public class BedInteraction extends SimpleBlockInteraction { @Override protected void simulateInteractWithBlock( - @NonNullDecl InteractionType type, - @NonNullDecl InteractionContext context, - @NullableDecl ItemStack itemInHand, - @NonNullDecl World world, - @NonNullDecl Vector3i targetBlock + @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nullable ItemStack itemInHand, @Nonnull World world, @Nonnull Vector3i targetBlock ) { } @@ -162,7 +160,7 @@ public class BedInteraction extends SimpleBlockInteraction { } } - @NonNullDecl + @Nonnull @Override public String toString() { return "BedInteraction{} " + super.toString(); diff --git a/src/com/hypixel/hytale/builtin/beds/respawn/RespawnPointPage.java b/src/com/hypixel/hytale/builtin/beds/respawn/RespawnPointPage.java index 1c57427..c276f84 100644 --- a/src/com/hypixel/hytale/builtin/beds/respawn/RespawnPointPage.java +++ b/src/com/hypixel/hytale/builtin/beds/respawn/RespawnPointPage.java @@ -177,9 +177,6 @@ public abstract class RespawnPointPage extends InteractiveCustomUIPage { public static PlayerSomnolence AWAKE = new PlayerSomnolence(PlayerSleep.FullyAwake.INSTANCE); @@ -25,7 +25,7 @@ public class PlayerSomnolence implements Component { return this.state; } - @NullableDecl + @Nullable @Override public Component clone() { PlayerSomnolence clone = new PlayerSomnolence(); diff --git a/src/com/hypixel/hytale/builtin/beds/sleep/components/SleepTracker.java b/src/com/hypixel/hytale/builtin/beds/sleep/components/SleepTracker.java index 2c052e9..d8e4de8 100644 --- a/src/com/hypixel/hytale/builtin/beds/sleep/components/SleepTracker.java +++ b/src/com/hypixel/hytale/builtin/beds/sleep/components/SleepTracker.java @@ -6,14 +6,10 @@ import com.hypixel.hytale.component.ComponentType; import com.hypixel.hytale.protocol.packets.world.UpdateSleepState; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; public class SleepTracker implements Component { private UpdateSleepState lastSentPacket = new UpdateSleepState(false, false, null, null); - public SleepTracker() { - } - public static ComponentType getComponentType() { return BedsPlugin.getInstance().getSleepTrackerComponentType(); } @@ -28,7 +24,7 @@ public class SleepTracker implements Component { } } - @NullableDecl + @Nullable @Override public Component clone() { return new SleepTracker(); diff --git a/src/com/hypixel/hytale/builtin/beds/sleep/resources/WorldSleep.java b/src/com/hypixel/hytale/builtin/beds/sleep/resources/WorldSleep.java index 55406b5..3177a20 100644 --- a/src/com/hypixel/hytale/builtin/beds/sleep/resources/WorldSleep.java +++ b/src/com/hypixel/hytale/builtin/beds/sleep/resources/WorldSleep.java @@ -3,8 +3,5 @@ package com.hypixel.hytale.builtin.beds.sleep.resources; public sealed interface WorldSleep permits WorldSleep.Awake, WorldSlumber { public static enum Awake implements WorldSleep { INSTANCE; - - private Awake() { - } } } diff --git a/src/com/hypixel/hytale/builtin/beds/sleep/resources/WorldSomnolence.java b/src/com/hypixel/hytale/builtin/beds/sleep/resources/WorldSomnolence.java index f66d33c..84e3906 100644 --- a/src/com/hypixel/hytale/builtin/beds/sleep/resources/WorldSomnolence.java +++ b/src/com/hypixel/hytale/builtin/beds/sleep/resources/WorldSomnolence.java @@ -4,14 +4,12 @@ import com.hypixel.hytale.builtin.beds.BedsPlugin; import com.hypixel.hytale.component.Resource; import com.hypixel.hytale.component.ResourceType; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; public class WorldSomnolence implements Resource { private WorldSleep state = WorldSleep.Awake.INSTANCE; - public WorldSomnolence() { - } - public static ResourceType getResourceType() { return BedsPlugin.getInstance().getWorldSomnolenceResourceType(); } @@ -20,11 +18,11 @@ public class WorldSomnolence implements Resource { return this.state; } - public void setState(WorldSleep state) { + public void setState(@Nonnull WorldSleep state) { this.state = state; } - @NullableDecl + @Nullable @Override public Resource clone() { WorldSomnolence clone = new WorldSomnolence(); diff --git a/src/com/hypixel/hytale/builtin/beds/sleep/systems/player/EnterBedSystem.java b/src/com/hypixel/hytale/builtin/beds/sleep/systems/player/EnterBedSystem.java index 1065202..69b6091 100644 --- a/src/com/hypixel/hytale/builtin/beds/sleep/systems/player/EnterBedSystem.java +++ b/src/com/hypixel/hytale/builtin/beds/sleep/systems/player/EnterBedSystem.java @@ -17,15 +17,12 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import java.time.Duration; import java.time.LocalDateTime; import java.time.LocalTime; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; public class EnterBedSystem extends RefChangeSystem { public static final Query QUERY = Query.and(MountedComponent.getComponentType(), PlayerRef.getComponentType()); - public EnterBedSystem() { - } - @Override public ComponentType componentType() { return MountedComponent.getComponentType(); @@ -37,29 +34,23 @@ public class EnterBedSystem extends RefChangeSystem ref, - @NonNullDecl MountedComponent component, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, @Nonnull MountedComponent component, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { this.check(ref, component, store); } public void onComponentSet( - @NonNullDecl Ref ref, - @NullableDecl MountedComponent oldComponent, - @NonNullDecl MountedComponent newComponent, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, + @Nullable MountedComponent oldComponent, + @Nonnull MountedComponent newComponent, + @Nonnull Store store, + @Nonnull CommandBuffer commandBuffer ) { this.check(ref, newComponent, store); } public void onComponentRemoved( - @NonNullDecl Ref ref, - @NonNullDecl MountedComponent component, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, @Nonnull MountedComponent component, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { } @@ -74,6 +65,9 @@ public class EnterBedSystem extends RefChangeSystem { - public RegisterTrackerSystem() { - } - @Override - public void onEntityAdd(@NonNullDecl Holder holder, @NonNullDecl AddReason reason, @NonNullDecl Store store) { + public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { holder.ensureComponent(SleepTracker.getComponentType()); } @Override - public void onEntityRemoved(@NonNullDecl Holder holder, @NonNullDecl RemoveReason reason, @NonNullDecl Store store) { + public void onEntityRemoved(@Nonnull Holder holder, @Nonnull RemoveReason reason, @Nonnull Store store) { } - @NullableDecl + @Nullable @Override public Query getQuery() { return PlayerRef.getComponentType(); diff --git a/src/com/hypixel/hytale/builtin/beds/sleep/systems/player/UpdateSleepPacketSystem.java b/src/com/hypixel/hytale/builtin/beds/sleep/systems/player/UpdateSleepPacketSystem.java index 91f226f..da936c2 100644 --- a/src/com/hypixel/hytale/builtin/beds/sleep/systems/player/UpdateSleepPacketSystem.java +++ b/src/com/hypixel/hytale/builtin/beds/sleep/systems/player/UpdateSleepPacketSystem.java @@ -26,8 +26,8 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.UUID; +import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class UpdateSleepPacketSystem extends DelayedEntitySystem { public static final Query QUERY = Query.and(PlayerRef.getComponentType(), PlayerSomnolence.getComponentType(), SleepTracker.getComponentType()); @@ -49,25 +49,34 @@ public class UpdateSleepPacketSystem extends DelayedEntitySystem { public void tick( float dt, int index, - @NonNullDecl ArchetypeChunk archetypeChunk, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull ArchetypeChunk archetypeChunk, + @Nonnull Store store, + @Nonnull CommandBuffer commandBuffer ) { UpdateSleepState packet = this.createSleepPacket(store, index, archetypeChunk); - SleepTracker sleepTracker = archetypeChunk.getComponent(index, SleepTracker.getComponentType()); - packet = sleepTracker.generatePacketToSend(packet); + SleepTracker sleepTrackerComponent = archetypeChunk.getComponent(index, SleepTracker.getComponentType()); + + assert sleepTrackerComponent != null; + + packet = sleepTrackerComponent.generatePacketToSend(packet); if (packet != null) { - PlayerRef playerRef = archetypeChunk.getComponent(index, PlayerRef.getComponentType()); - playerRef.getPacketHandler().write(packet); + PlayerRef playerRefComponent = archetypeChunk.getComponent(index, PlayerRef.getComponentType()); + + assert playerRefComponent != null; + + playerRefComponent.getPacketHandler().write(packet); } } - private UpdateSleepState createSleepPacket(Store store, int index, ArchetypeChunk archetypeChunk) { + private UpdateSleepState createSleepPacket(@Nonnull Store store, int index, @Nonnull ArchetypeChunk archetypeChunk) { World world = store.getExternalData().getWorld(); WorldSomnolence worldSomnolence = store.getResource(WorldSomnolence.getResourceType()); WorldSleep worldSleepState = worldSomnolence.getState(); - PlayerSomnolence playerSomnolence = archetypeChunk.getComponent(index, PlayerSomnolence.getComponentType()); - PlayerSleep playerSleepState = playerSomnolence.getSleepState(); + PlayerSomnolence playerSomnolenceComponent = archetypeChunk.getComponent(index, PlayerSomnolence.getComponentType()); + + assert playerSomnolenceComponent != null; + + PlayerSleep playerSleepState = playerSomnolenceComponent.getSleepState(); SleepClock clock = worldSleepState instanceof WorldSlumber slumber ? slumber.createSleepClock() : null; return switch (playerSleepState) { @@ -90,9 +99,10 @@ public class UpdateSleepPacketSystem extends DelayedEntitySystem { } @Nullable - private SleepMultiplayer createSleepMultiplayer(Store store) { + private SleepMultiplayer createSleepMultiplayer(@Nonnull Store store) { World world = store.getExternalData().getWorld(); List playerRefs = new ArrayList<>(world.getPlayerRefs()); + playerRefs.removeIf(playerRefx -> playerRefx.getReference() == null); if (playerRefs.size() <= 1) { return null; } else { diff --git a/src/com/hypixel/hytale/builtin/beds/sleep/systems/player/WakeUpOnDismountSystem.java b/src/com/hypixel/hytale/builtin/beds/sleep/systems/player/WakeUpOnDismountSystem.java index 8568c44..05e4fb9 100644 --- a/src/com/hypixel/hytale/builtin/beds/sleep/systems/player/WakeUpOnDismountSystem.java +++ b/src/com/hypixel/hytale/builtin/beds/sleep/systems/player/WakeUpOnDismountSystem.java @@ -10,13 +10,10 @@ import com.hypixel.hytale.component.query.Query; import com.hypixel.hytale.component.system.RefChangeSystem; import com.hypixel.hytale.protocol.BlockMountType; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; public class WakeUpOnDismountSystem extends RefChangeSystem { - public WakeUpOnDismountSystem() { - } - @Override public ComponentType componentType() { return MountedComponent.getComponentType(); @@ -28,27 +25,21 @@ public class WakeUpOnDismountSystem extends RefChangeSystem ref, - @NonNullDecl MountedComponent component, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, @Nonnull MountedComponent component, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { } public void onComponentSet( - @NonNullDecl Ref ref, - @NullableDecl MountedComponent oldComponent, - @NonNullDecl MountedComponent newComponent, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, + @Nullable MountedComponent oldComponent, + @Nonnull MountedComponent newComponent, + @Nonnull Store store, + @Nonnull CommandBuffer commandBuffer ) { } public void onComponentRemoved( - @NonNullDecl Ref ref, - @NonNullDecl MountedComponent component, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, @Nonnull MountedComponent component, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { if (component.getBlockMountType() == BlockMountType.Bed) { commandBuffer.putComponent(ref, PlayerSomnolence.getComponentType(), PlayerSomnolence.AWAKE); diff --git a/src/com/hypixel/hytale/builtin/beds/sleep/systems/world/CanSleepInWorld.java b/src/com/hypixel/hytale/builtin/beds/sleep/systems/world/CanSleepInWorld.java index ee31769..fb8bb96 100644 --- a/src/com/hypixel/hytale/builtin/beds/sleep/systems/world/CanSleepInWorld.java +++ b/src/com/hypixel/hytale/builtin/beds/sleep/systems/world/CanSleepInWorld.java @@ -8,9 +8,6 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import java.time.LocalDateTime; public final class CanSleepInWorld { - public CanSleepInWorld() { - } - public static CanSleepInWorld.Result check(World world) { if (world.getWorldConfig().isGameTimePaused()) { return CanSleepInWorld.Status.GAME_TIME_PAUSED; @@ -39,9 +36,6 @@ public final class CanSleepInWorld { CAN_SLEEP, GAME_TIME_PAUSED; - private Status() { - } - @Override public boolean isNegative() { return this != CAN_SLEEP; diff --git a/src/com/hypixel/hytale/builtin/beds/sleep/systems/world/StartSlumberSystem.java b/src/com/hypixel/hytale/builtin/beds/sleep/systems/world/StartSlumberSystem.java index 916eab3..d996248 100644 --- a/src/com/hypixel/hytale/builtin/beds/sleep/systems/world/StartSlumberSystem.java +++ b/src/com/hypixel/hytale/builtin/beds/sleep/systems/world/StartSlumberSystem.java @@ -19,7 +19,7 @@ import java.time.LocalDateTime; import java.time.ZoneOffset; import java.util.Collection; import java.util.concurrent.TimeUnit; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; +import javax.annotation.Nonnull; public class StartSlumberSystem extends DelayedSystem { public static final Duration NODDING_OFF_DURATION = Duration.ofMillis(3200L); @@ -30,7 +30,7 @@ public class StartSlumberSystem extends DelayedSystem { } @Override - public void delayedTick(float dt, int systemIndex, @NonNullDecl Store store) { + public void delayedTick(float dt, int systemIndex, @Nonnull Store store) { this.checkIfEveryoneIsReadyToSleep(store); } @@ -40,15 +40,15 @@ public class StartSlumberSystem extends DelayedSystem { if (!playerRefs.isEmpty()) { if (!CanSleepInWorld.check(world).isNegative()) { float wakeUpHour = world.getGameplayConfig().getWorldConfig().getSleepConfig().getWakeUpHour(); - WorldSomnolence worldSomnolence = store.getResource(WorldSomnolence.getResourceType()); - WorldSleep worldState = worldSomnolence.getState(); + WorldSomnolence worldSomnolenceResource = store.getResource(WorldSomnolence.getResourceType()); + WorldSleep worldState = worldSomnolenceResource.getState(); if (worldState == WorldSleep.Awake.INSTANCE) { if (this.isEveryoneReadyToSleep(store)) { WorldTimeResource timeResource = store.getResource(WorldTimeResource.getResourceType()); Instant now = timeResource.getGameTime(); Instant target = this.computeWakeupInstant(now, wakeUpHour); float irlSeconds = computeIrlSeconds(now, target); - worldSomnolence.setState(new WorldSlumber(now, target, irlSeconds)); + worldSomnolenceResource.setState(new WorldSlumber(now, target, irlSeconds)); store.forEachEntityParallel(PlayerSomnolence.getComponentType(), (index, archetypeChunk, commandBuffer) -> { Ref ref = archetypeChunk.getReferenceTo(index); commandBuffer.putComponent(ref, PlayerSomnolence.getComponentType(), PlayerSleep.Slumber.createComponent(timeResource)); @@ -59,7 +59,7 @@ public class StartSlumberSystem extends DelayedSystem { } } - private Instant computeWakeupInstant(Instant now, float wakeUpHour) { + private Instant computeWakeupInstant(@Nonnull Instant now, float wakeUpHour) { LocalDateTime ldt = LocalDateTime.ofInstant(now, ZoneOffset.UTC); int hours = (int)wakeUpHour; float fractionalHour = wakeUpHour - hours; diff --git a/src/com/hypixel/hytale/builtin/beds/sleep/systems/world/UpdateWorldSlumberSystem.java b/src/com/hypixel/hytale/builtin/beds/sleep/systems/world/UpdateWorldSlumberSystem.java index 244d0a9..c32e76f 100644 --- a/src/com/hypixel/hytale/builtin/beds/sleep/systems/world/UpdateWorldSlumberSystem.java +++ b/src/com/hypixel/hytale/builtin/beds/sleep/systems/world/UpdateWorldSlumberSystem.java @@ -17,14 +17,11 @@ import java.time.Duration; import java.time.Instant; import java.util.Collection; import java.util.Iterator; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; +import javax.annotation.Nonnull; public class UpdateWorldSlumberSystem extends TickingSystem { - public UpdateWorldSlumberSystem() { - } - @Override - public void tick(float dt, int systemIndex, @NonNullDecl Store store) { + public void tick(float dt, int systemIndex, @Nonnull Store store) { World world = store.getExternalData().getWorld(); WorldSomnolence worldSomnolence = store.getResource(WorldSomnolence.getResourceType()); if (worldSomnolence.getState() instanceof WorldSlumber slumber) { @@ -36,8 +33,11 @@ public class UpdateWorldSlumberSystem extends TickingSystem { Instant wakeUpTime = computeWakeupTime(slumber); timeResource.setGameTime(wakeUpTime, world, store); store.forEachEntityParallel(PlayerSomnolence.getComponentType(), (index, archetypeChunk, commandBuffer) -> { - PlayerSomnolence somnolence = archetypeChunk.getComponent(index, PlayerSomnolence.getComponentType()); - if (somnolence.getSleepState() instanceof PlayerSleep.Slumber) { + PlayerSomnolence somnolenceComponent = archetypeChunk.getComponent(index, PlayerSomnolence.getComponentType()); + + assert somnolenceComponent != null; + + if (somnolenceComponent.getSleepState() instanceof PlayerSleep.Slumber) { Ref ref = archetypeChunk.getReferenceTo(index); commandBuffer.putComponent(ref, PlayerSomnolence.getComponentType(), PlayerSleep.MorningWakeUp.createComponent(timeResource)); } @@ -46,14 +46,14 @@ public class UpdateWorldSlumberSystem extends TickingSystem { } } - private static Instant computeWakeupTime(WorldSlumber slumber) { + private static Instant computeWakeupTime(@Nonnull WorldSlumber slumber) { float progress = slumber.getProgressSeconds() / slumber.getIrlDurationSeconds(); long totalNanos = Duration.between(slumber.getStartInstant(), slumber.getTargetInstant()).toNanos(); long progressNanos = (long)((float)totalNanos * progress); return slumber.getStartInstant().plusNanos(progressNanos); } - private static boolean isSomeoneAwake(ComponentAccessor store) { + private static boolean isSomeoneAwake(@Nonnull ComponentAccessor store) { World world = store.getExternalData().getWorld(); Collection playerRefs = world.getPlayerRefs(); if (playerRefs.isEmpty()) { @@ -62,11 +62,11 @@ public class UpdateWorldSlumberSystem extends TickingSystem { Iterator var3 = playerRefs.iterator(); if (var3.hasNext()) { PlayerRef playerRef = (PlayerRef)var3.next(); - PlayerSomnolence somnolence = store.getComponent(playerRef.getReference(), PlayerSomnolence.getComponentType()); - if (somnolence == null) { + PlayerSomnolence somnolenceComponent = store.getComponent(playerRef.getReference(), PlayerSomnolence.getComponentType()); + if (somnolenceComponent == null) { return true; } else { - PlayerSleep sleepState = somnolence.getSleepState(); + PlayerSleep sleepState = somnolenceComponent.getSleepState(); return sleepState instanceof PlayerSleep.FullyAwake; } } else { diff --git a/src/com/hypixel/hytale/builtin/blockphysics/BlockPhysicsSystems.java b/src/com/hypixel/hytale/builtin/blockphysics/BlockPhysicsSystems.java index f960761..755e971 100644 --- a/src/com/hypixel/hytale/builtin/blockphysics/BlockPhysicsSystems.java +++ b/src/com/hypixel/hytale/builtin/blockphysics/BlockPhysicsSystems.java @@ -33,9 +33,6 @@ public class BlockPhysicsSystems { private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); public static final int MAX_SUPPORT_RADIUS = 14; - public BlockPhysicsSystems() { - } - public static class CachedAccessor extends AbstractCachedAccessor { private static final ThreadLocal THREAD_LOCAL = ThreadLocal.withInitial(BlockPhysicsSystems.CachedAccessor::new); private static final int PHYSICS_COMPONENT = 0; @@ -135,9 +132,6 @@ public class BlockPhysicsSystems { new SystemDependency<>(Order.AFTER, ChunkBlockTickSystem.PreTick.class), new SystemDependency<>(Order.BEFORE, ChunkBlockTickSystem.Ticking.class) ); - public Ticking() { - } - @Nonnull @Override public Query getQuery() { diff --git a/src/com/hypixel/hytale/builtin/blockphysics/BlockPhysicsUtil.java b/src/com/hypixel/hytale/builtin/blockphysics/BlockPhysicsUtil.java index 9ef5c32..9787212 100644 --- a/src/com/hypixel/hytale/builtin/blockphysics/BlockPhysicsUtil.java +++ b/src/com/hypixel/hytale/builtin/blockphysics/BlockPhysicsUtil.java @@ -32,9 +32,6 @@ public class BlockPhysicsUtil { public static final int SATISFIES_SUPPORT = -2; public static final int WAITING_CHUNK = -3; - public BlockPhysicsUtil() { - } - @Nonnull public static BlockPhysicsUtil.Result applyBlockPhysics( @Nullable ComponentAccessor commandBuffer, @@ -447,8 +444,5 @@ public class BlockPhysicsUtil { INVALID, VALID, WAITING_CHUNK; - - private Result() { - } } } diff --git a/src/com/hypixel/hytale/builtin/blockphysics/PrefabBufferValidator.java b/src/com/hypixel/hytale/builtin/blockphysics/PrefabBufferValidator.java index 91b4144..bf8be09 100644 --- a/src/com/hypixel/hytale/builtin/blockphysics/PrefabBufferValidator.java +++ b/src/com/hypixel/hytale/builtin/blockphysics/PrefabBufferValidator.java @@ -4,11 +4,15 @@ import com.hypixel.hytale.common.util.ExceptionUtil; import com.hypixel.hytale.component.ComponentType; import com.hypixel.hytale.component.Holder; import com.hypixel.hytale.component.data.unknown.UnknownComponents; +import com.hypixel.hytale.event.IEvent; +import com.hypixel.hytale.event.IEventDispatcher; +import com.hypixel.hytale.server.core.HytaleServer; import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType; import com.hypixel.hytale.server.core.prefab.PrefabStore; import com.hypixel.hytale.server.core.prefab.selection.buffer.PrefabBufferUtil; import com.hypixel.hytale.server.core.prefab.selection.buffer.impl.IPrefabBuffer; import com.hypixel.hytale.server.core.universe.world.ValidationOption; +import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import com.hypixel.hytale.server.core.util.FillerBlockUtil; import com.hypixel.hytale.server.core.util.io.FileUtil; @@ -41,9 +45,6 @@ public class PrefabBufferValidator { } }; - public PrefabBufferValidator() { - } - @Nonnull public static List validateAllPrefabs(@Nonnull List list) { Set options = !list.isEmpty() @@ -105,6 +106,13 @@ public class PrefabBufferValidator { IPrefabBuffer.iterateAllColumns(), (x, y, z, mask, blockId, chance, holder, supportValue, rotation, filler, o) -> { legacyValidator.accept(x, y, z, mask, blockId, chance, holder, supportValue, rotation, filler, o); + IEventDispatcher dispatch = HytaleServer.get() + .getEventBus() + .dispatchFor(PrefabBufferValidator.ValidateBlockEvent.class); + if (dispatch.hasListener()) { + dispatch.dispatch(new PrefabBufferValidator.ValidateBlockEvent(x, y, z, blockId, supportValue, rotation, filler, holder, sb)); + } + if (options.contains(ValidationOption.BLOCK_FILLER)) { FillerBlockUtil.ValidationResult fillerResult = FillerBlockUtil.validateBlock(x, y, z, blockId, rotation, filler, prefab, null, FILLER_FETCHER); switch (fillerResult) { @@ -158,4 +166,9 @@ public class PrefabBufferValidator { ); return !sb.isEmpty() ? sb.toString() : null; } + + public record ValidateBlockEvent( + int x, int y, int z, int blockId, int support, int rotation, int filler, @Nullable Holder holder, StringBuilder reason + ) implements IEvent { + } } diff --git a/src/com/hypixel/hytale/builtin/blockphysics/WorldValidationUtil.java b/src/com/hypixel/hytale/builtin/blockphysics/WorldValidationUtil.java index 94ac636..713abc7 100644 --- a/src/com/hypixel/hytale/builtin/blockphysics/WorldValidationUtil.java +++ b/src/com/hypixel/hytale/builtin/blockphysics/WorldValidationUtil.java @@ -9,9 +9,6 @@ import java.util.Set; import javax.annotation.Nonnull; public class WorldValidationUtil { - public WorldValidationUtil() { - } - @Nonnull public static IPrefabBuffer.RawBlockConsumer blockValidator(@Nonnull StringBuilder sb, @Nonnull Set options) { return blockValidator(0, 0, 0, sb, options); @@ -43,7 +40,15 @@ public class WorldValidationUtil { if (options.contains(ValidationOption.BLOCK_STATES) && holder != null) { UnknownComponents unknownComponents = holder.getComponent(ChunkStore.REGISTRY.getUnknownComponentType()); if (unknownComponents != null && !unknownComponents.getUnknownComponents().isEmpty()) { - sb.append("\tUnknown Components: ").append(holder).append("\n"); + sb.append("\tUnknown Components at (") + .append(x + offsetX) + .append(',') + .append(y + offsetY) + .append(',') + .append(z + offsetZ) + .append("): ") + .append(unknownComponents.getUnknownComponents().keySet()) + .append("\n"); } } }; diff --git a/src/com/hypixel/hytale/builtin/blockspawner/BlockSpawnerEntry.java b/src/com/hypixel/hytale/builtin/blockspawner/BlockSpawnerEntry.java index aae0375..c2cdd81 100644 --- a/src/com/hypixel/hytale/builtin/blockspawner/BlockSpawnerEntry.java +++ b/src/com/hypixel/hytale/builtin/blockspawner/BlockSpawnerEntry.java @@ -41,9 +41,6 @@ public class BlockSpawnerEntry implements IWeightedElement { private double weight; private BlockSpawnerEntry.RotationMode rotationMode = BlockSpawnerEntry.RotationMode.INHERIT; - public BlockSpawnerEntry() { - } - public String getBlockName() { return this.blockName; } @@ -67,8 +64,5 @@ public class BlockSpawnerEntry implements IWeightedElement { INHERIT; public static final Codec CODEC = new EnumCodec<>(BlockSpawnerEntry.RotationMode.class); - - private RotationMode() { - } } } diff --git a/src/com/hypixel/hytale/builtin/blockspawner/BlockSpawnerPlugin.java b/src/com/hypixel/hytale/builtin/blockspawner/BlockSpawnerPlugin.java index 81b214e..7216dab 100644 --- a/src/com/hypixel/hytale/builtin/blockspawner/BlockSpawnerPlugin.java +++ b/src/com/hypixel/hytale/builtin/blockspawner/BlockSpawnerPlugin.java @@ -2,6 +2,7 @@ package com.hypixel.hytale.builtin.blockspawner; import com.hypixel.hytale.assetstore.AssetRegistry; import com.hypixel.hytale.assetstore.map.DefaultAssetMap; +import com.hypixel.hytale.builtin.blockphysics.PrefabBufferValidator; import com.hypixel.hytale.builtin.blockspawner.command.BlockSpawnerCommand; import com.hypixel.hytale.builtin.blockspawner.state.BlockSpawner; import com.hypixel.hytale.component.AddReason; @@ -66,6 +67,48 @@ public class BlockSpawnerPlugin extends JavaPlugin { this.blockSpawnerComponentType = this.getChunkStoreRegistry().registerComponent(BlockSpawner.class, "BlockSpawner", BlockSpawner.CODEC); this.getChunkStoreRegistry().registerSystem(new BlockSpawnerPlugin.BlockSpawnerSystem()); this.getChunkStoreRegistry().registerSystem(new BlockSpawnerPlugin.MigrateBlockSpawner()); + this.getEventRegistry().registerGlobal(PrefabBufferValidator.ValidateBlockEvent.class, BlockSpawnerPlugin::validatePrefabBlock); + } + + private static void validatePrefabBlock(PrefabBufferValidator.ValidateBlockEvent validateBlockEvent) { + Holder holder = validateBlockEvent.holder(); + if (holder != null) { + BlockSpawner spawner = holder.getComponent(BlockSpawner.getComponentType()); + if (spawner != null) { + BlockType blockType = BlockType.getAssetMap().getAsset(validateBlockEvent.blockId()); + if (blockType != null) { + if (spawner.getBlockSpawnerId() == null) { + validateBlockEvent.reason() + .append("\t Block ") + .append(blockType.getId()) + .append(" at ") + .append(validateBlockEvent.x()) + .append(", ") + .append(validateBlockEvent.y()) + .append(", ") + .append(validateBlockEvent.z()) + .append(" has no defined block spawner id") + .append('\n'); + } else { + BlockSpawnerTable blockSpawner = BlockSpawnerTable.getAssetMap().getAsset(spawner.getBlockSpawnerId()); + if (blockSpawner == null) { + validateBlockEvent.reason() + .append("\t Block ") + .append(blockType.getId()) + .append(" at ") + .append(validateBlockEvent.x()) + .append(", ") + .append(validateBlockEvent.y()) + .append(", ") + .append(validateBlockEvent.z()) + .append(" has an invalid spawner id ") + .append(spawner.getBlockSpawnerId()) + .append('\n'); + } + } + } + } + } } public ComponentType getBlockSpawnerComponentType() { @@ -173,9 +216,6 @@ public class BlockSpawnerPlugin extends JavaPlugin { @Deprecated(forRemoval = true) public static class MigrateBlockSpawner extends BlockModule.MigrationSystem { - public MigrateBlockSpawner() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { UnknownComponents unknown = holder.getComponent(ChunkStore.REGISTRY.getUnknownComponentType()); diff --git a/src/com/hypixel/hytale/builtin/blocktick/system/ChunkBlockTickSystem.java b/src/com/hypixel/hytale/builtin/blocktick/system/ChunkBlockTickSystem.java index e7d6449..e02dfa9 100644 --- a/src/com/hypixel/hytale/builtin/blocktick/system/ChunkBlockTickSystem.java +++ b/src/com/hypixel/hytale/builtin/blocktick/system/ChunkBlockTickSystem.java @@ -29,15 +29,9 @@ import javax.annotation.Nonnull; public class ChunkBlockTickSystem { protected static final HytaleLogger LOGGER = BlockTickPlugin.get().getLogger(); - public ChunkBlockTickSystem() { - } - public static class PreTick extends EntityTickingSystem { private static final ComponentType COMPONENT_TYPE = BlockChunk.getComponentType(); - public PreTick() { - } - @Override public Query getQuery() { return COMPONENT_TYPE; @@ -73,9 +67,6 @@ public class ChunkBlockTickSystem { private static final ComponentType COMPONENT_TYPE = WorldChunk.getComponentType(); private static final Set> DEPENDENCIES = Set.of(new SystemDependency<>(Order.AFTER, ChunkBlockTickSystem.PreTick.class)); - public Ticking() { - } - @Override public Query getQuery() { return COMPONENT_TYPE; diff --git a/src/com/hypixel/hytale/builtin/blocktick/system/MergeWaitingBlocksSystem.java b/src/com/hypixel/hytale/builtin/blocktick/system/MergeWaitingBlocksSystem.java index 9ec4142..362fb77 100644 --- a/src/com/hypixel/hytale/builtin/blocktick/system/MergeWaitingBlocksSystem.java +++ b/src/com/hypixel/hytale/builtin/blocktick/system/MergeWaitingBlocksSystem.java @@ -17,9 +17,6 @@ import javax.annotation.Nonnull; public class MergeWaitingBlocksSystem extends RefSystem { private static final ComponentType COMPONENT_TYPE = WorldChunk.getComponentType(); - public MergeWaitingBlocksSystem() { - } - @Override public Query getQuery() { return COMPONENT_TYPE; diff --git a/src/com/hypixel/hytale/builtin/buildertools/BlockColorIndex.java b/src/com/hypixel/hytale/builtin/buildertools/BlockColorIndex.java index 5028a65..c638513 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/BlockColorIndex.java +++ b/src/com/hypixel/hytale/builtin/buildertools/BlockColorIndex.java @@ -18,9 +18,6 @@ public final class BlockColorIndex { private final List entries = new ArrayList<>(); private boolean initialized = false; - public BlockColorIndex() { - } - private void ensureInitialized() { if (!this.initialized) { BlockTypeAssetMap assetMap = BlockType.getAssetMap(); diff --git a/src/com/hypixel/hytale/builtin/buildertools/BuilderToolsPacketHandler.java b/src/com/hypixel/hytale/builtin/buildertools/BuilderToolsPacketHandler.java index aa36388..e26ff51 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/BuilderToolsPacketHandler.java +++ b/src/com/hypixel/hytale/builtin/buildertools/BuilderToolsPacketHandler.java @@ -215,19 +215,24 @@ public class BuilderToolsPacketHandler implements SubPacketHandler { if (entityReference == null) { playerComponent.sendMessage(Message.translation("server.general.entityNotFound").param("id", entityId)); } else { - LOGGER.at(Level.INFO).log("%s: %s", this.packetHandler.getIdentifier(), packet); - switch (packet.action) { - case Freeze: - UUIDComponent uuidComponent = store.getComponent(entityReference, UUIDComponent.getComponentType()); - if (uuidComponent != null) { - CommandManager.get().handleCommand(playerComponent, "npc freeze --toggle --entity " + uuidComponent.getUuid()); - } - break; - case Clone: - world.execute(() -> EntityCloneCommand.cloneEntity(playerComponent, entityReference, store)); - break; - case Remove: - world.execute(() -> EntityRemoveCommand.removeEntity(ref, entityReference, store)); + Player targetPlayerComponent = store.getComponent(entityReference, Player.getComponentType()); + if (targetPlayerComponent != null) { + playerComponent.sendMessage(Message.translation("server.builderTools.entityTool.cannotTargetPlayer")); + } else { + LOGGER.at(Level.INFO).log("%s: %s", this.packetHandler.getIdentifier(), packet); + switch (packet.action) { + case Freeze: + UUIDComponent uuidComponent = store.getComponent(entityReference, UUIDComponent.getComponentType()); + if (uuidComponent != null) { + CommandManager.get().handleCommand(playerComponent, "npc freeze --toggle --entity " + uuidComponent.getUuid()); + } + break; + case Clone: + world.execute(() -> EntityCloneCommand.cloneEntity(playerComponent, entityReference, store)); + break; + case Remove: + world.execute(() -> EntityRemoveCommand.removeEntity(ref, entityReference, store)); + } } } } @@ -401,6 +406,16 @@ public class BuilderToolsPacketHandler implements SubPacketHandler { Player playerComponent = store.getComponent(ref, Player.getComponentType()); if (hasPermission(playerComponent, "hytale.editor.selection.clipboard")) { LOGGER.at(Level.INFO).log("%s: %s", this.packetHandler.getIdentifier(), packet); + boolean keepEmptyBlocks = true; + BuilderTool builderTool = BuilderTool.getActiveBuilderTool(playerComponent); + if (builderTool != null && builderTool.getId().equals("Selection")) { + BuilderTool.ArgData args = builderTool.getItemArgData(playerComponent.getInventory().getItemInHand()); + if (args != null && args.tool() != null) { + keepEmptyBlocks = (Boolean)args.tool().getOrDefault("KeepEmptyBlocks", true); + } + } + + boolean finalKeepEmptyBlocks = keepEmptyBlocks; float[] tmx = new float[16]; for (int i = 0; i < packet.transformationMatrix.length; i++) { @@ -489,6 +504,7 @@ public class BuilderToolsPacketHandler implements SubPacketHandler { transformationMatrix, rotationOrigin, blockChangeOffsetOrigin, + finalKeepEmptyBlocks, componentAccessor ); s.select(initialSelectionMin, initialSelectionMax, "SelectionTranslatePacket", componentAccessor); diff --git a/src/com/hypixel/hytale/builtin/buildertools/BuilderToolsPlugin.java b/src/com/hypixel/hytale/builtin/buildertools/BuilderToolsPlugin.java index a527706..68f6ac2 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/BuilderToolsPlugin.java +++ b/src/com/hypixel/hytale/builtin/buildertools/BuilderToolsPlugin.java @@ -886,9 +886,6 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, UPDATE_SELECTION, WALLS, HOLLOW; - - private Action() { - } } public static class ActionEntry { @@ -2058,7 +2055,9 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, } } - public void tint(int x, int y, int z, int color, @Nonnull BrushShape shape, int shapeRange, ComponentAccessor componentAccessor) { + public void tint( + int x, int y, int z, int color, @Nonnull BrushShape shape, int shapeRange, int shapeHeight, ComponentAccessor componentAccessor + ) { if (y >= 0 && y < 320) { World world = componentAccessor.getExternalData().getWorld(); LongSet dirtyChunks = new LongOpenHashSet(); @@ -2079,11 +2078,12 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, case Cube: case Pyramid: case InvertedPyramid: - label33: + case Diamond: + label55: for (int px = -radiusXZ; px <= radiusXZ; px++) { - for (int pz = -radiusXZ; pz <= radiusXZ; pz++) { - if (!tintBlock.test(x + px, y, z + pz, null)) { - break label33; + for (int pzx = -radiusXZ; pzx <= radiusXZ; pzx++) { + if (!tintBlock.test(x + px, y, z + pzx, null)) { + break label55; } } } @@ -2092,8 +2092,26 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, case Cylinder: case Cone: case InvertedCone: + case Dome: + case InvertedDome: BlockSphereUtil.forEachBlock(x, y, z, radiusXZ, 1, radiusXZ, null, tintBlock); break; + case Torus: + int minorRadius = Math.max(1, shapeHeight / 4); + int majorRadius = Math.max(1, radiusXZ - minorRadius); + int sizeXZ = majorRadius + minorRadius; + float minorRadiusAdjusted = minorRadius + 0.5F; + + for (int px = -sizeXZ; px <= sizeXZ; px++) { + for (int pz = -sizeXZ; pz <= sizeXZ; pz++) { + double distFromCenter = Math.sqrt(px * px + pz * pz); + double distFromRing = Math.abs(distFromCenter - majorRadius); + if (distFromRing <= minorRadiusAdjusted) { + tintBlock.test(x + px, y, z + pz, null); + } + } + } + break; default: this.sendFeedback(Message.translation("server.builderTools.errorWithUsedShape"), componentAccessor); return; @@ -2142,6 +2160,21 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, int zMax, int settings, @Nonnull ComponentAccessor componentAccessor + ) throws PrefabCopyException { + return this.copyOrCut(ref, xMin, yMin, zMin, xMax, yMax, zMax, settings, null, componentAccessor); + } + + public int copyOrCut( + @Nonnull Ref ref, + int xMin, + int yMin, + int zMin, + int xMax, + int yMax, + int zMax, + int settings, + @Nullable Vector3i playerAnchor, + @Nonnull ComponentAccessor componentAccessor ) throws PrefabCopyException { World world = componentAccessor.getExternalData().getWorld(); long start = System.nanoTime(); @@ -2224,7 +2257,7 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, after.addEmptyAtWorldPos(x, y, z); } - if (block == editorBlockPrefabAnchor && !keepAnchors) { + if (block == editorBlockPrefabAnchor && !keepAnchors && playerAnchor == null) { anchors.add(new Vector3i(x, y, z)); this.selection.setAnchorAtWorldPos(x, y, z); if (blocks) { @@ -2253,7 +2286,7 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, } } - if (anchors.size() > 1) { + if (anchors.size() > 1 && playerAnchor == null) { StringBuilder sb = new StringBuilder("Anchors: "); boolean first = true; @@ -2268,6 +2301,10 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, throw new PrefabCopyException("Prefab has multiple anchor blocks!\n" + sb); } else { + if (playerAnchor != null) { + this.selection.setAnchorAtWorldPos(playerAnchor.getX(), playerAnchor.getY(), playerAnchor.getZ()); + } + if (entities) { Store store = world.getEntityStore().getStore(); ArrayList> entitiesToRemove = cut ? new ArrayList<>() : null; @@ -2421,10 +2458,13 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, @Nonnull Matrix4d transformationMatrix, @Nonnull Vector3f rotationOrigin, @Nonnull Vector3i initialPastePoint, + boolean keepEmptyBlocks, ComponentAccessor componentAccessor ) { World world = componentAccessor.getExternalData().getWorld(); long start = System.nanoTime(); + BlockTypeAssetMap assetMap = BlockType.getAssetMap(); + int editorBlockPrefabAir = keepEmptyBlocks ? assetMap.getIndex("Editor_Empty") : 0; int yOffsetOutOfGround = 0; for (BlockChange blockChange : blockChanges) { @@ -2479,10 +2519,16 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, byte originalFluidLevel = currentChunk.getFluidLevel(rotatedLocation.x, rotatedLocation.y, rotatedLocation.z); before.addFluidAtWorldPos(rotatedLocation.x, rotatedLocation.y, rotatedLocation.z, originalFluidId, originalFluidLevel); int newRotation = transformRotation(RotationTuple.get(blockChangex.rotation), transformationMatrix).index(); - BlockType blockType = BlockType.getAssetMap().getAsset(blockChangex.block); + int blockIdToPlace = blockChangex.block; + if (blockChangex.block == 0 && keepEmptyBlocks) { + blockIdToPlace = editorBlockPrefabAir; + } + + BlockType blockType = assetMap.getAsset(blockIdToPlace); if (blockType != null) { BlockBoundingBoxes hitbox = BlockBoundingBoxes.getAssetMap().getAsset(blockType.getHitboxTypeIndex()); if (hitbox != null) { + int finalBlockIdToPlace = blockIdToPlace; if (hitbox.protrudesUnitBox()) { FillerBlockUtil.forEachFillerBlock( hitbox.get(newRotation), @@ -2490,7 +2536,7 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, rotatedLocation.x + x, rotatedLocation.y + y, rotatedLocation.z + z, - blockChange.block, + finalBlockIdToPlace, newRotation, FillerBlockUtil.pack(x, y, z), 0, @@ -2498,7 +2544,7 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, ) ); } else { - after.addBlockAtWorldPos(rotatedLocation.x, rotatedLocation.y, rotatedLocation.z, blockChangex.block, newRotation, 0, 0, holder); + after.addBlockAtWorldPos(rotatedLocation.x, rotatedLocation.y, rotatedLocation.z, blockIdToPlace, newRotation, 0, 0, holder); } } } @@ -2514,12 +2560,12 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, 1.0 ); transformationMatrix.multiply(mutable4d); - Vector3i rotatedLocation = new Vector3i( + Vector3i rotatedLocationx = new Vector3i( (int)Math.floor(mutable4d.x + 0.1 + rotationOrigin.x - 0.5), (int)Math.floor(mutable4d.y + 0.1 + rotationOrigin.y - 0.5), (int)Math.floor(mutable4d.z + 0.1 + rotationOrigin.z - 0.5) ); - after.addFluidAtWorldPos(rotatedLocation.x, rotatedLocation.y, rotatedLocation.z, fluidChange.fluidId(), fluidChange.fluidLevel()); + after.addFluidAtWorldPos(rotatedLocationx.x, rotatedLocationx.y, rotatedLocationx.z, fluidChange.fluidId(), fluidChange.fluidLevel()); } } @@ -2562,6 +2608,10 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, } public int paste(@Nonnull Ref ref, int x, int y, int z, @Nonnull ComponentAccessor componentAccessor) { + return this.paste(ref, x, y, z, false, componentAccessor); + } + + public int paste(@Nonnull Ref ref, int x, int y, int z, boolean technicalPaste, @Nonnull ComponentAccessor componentAccessor) { World world = componentAccessor.getExternalData().getWorld(); if (this.selection != null) { long start = System.nanoTime(); @@ -2575,31 +2625,36 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, int offsetZ = z - origPosZ; Vector3i pasteMin = new Vector3i(selMin.x + offsetX, selMin.y + offsetY, selMin.z + offsetZ); Vector3i pasteMax = new Vector3i(selMax.x + offsetX, selMax.y + offsetY, selMax.z + offsetZ); - this.selection.setPosition(x, y, z); + BlockSelection selectionToPlace = this.selection; + if (technicalPaste) { + selectionToPlace = this.convertEmptyBlocksToEditorEmpty(this.selection); + } + + selectionToPlace.setPosition(x, y, z); int prefabId = PrefabUtil.getNextPrefabId(); - this.selection.setPrefabId(prefabId); + selectionToPlace.setPrefabId(prefabId); if (!BuilderToolsPlugin.onPasteStart(prefabId, componentAccessor)) { this.sendErrorFeedback(ref, Message.translation("server.builderTools.pasteCancelledByEvent"), componentAccessor); return 0; } else { - int entityCount = this.selection.getEntityCount(); + int entityCount = selectionToPlace.getEntityCount(); List> snapshots = new ObjectArrayList<>(entityCount + 1); Consumer> collector = BlockSelection.DEFAULT_ENTITY_CONSUMER; if (entityCount > 0) { collector = e -> snapshots.add(new EntityAddSnapshot(e)); } - BlockSelection before = this.selection.place(this.player, world, Vector3i.ZERO, this.globalMask, collector); + BlockSelection before = selectionToPlace.place(this.player, world, Vector3i.ZERO, this.globalMask, collector); before.setSelectionArea(pasteMin, pasteMax); snapshots.add(new BlockSelectionSnapshot(before)); this.pushHistory(BuilderToolsPlugin.Action.PASTE, snapshots); BuilderToolsPlugin.invalidateWorldMapForBounds(pasteMin, pasteMax, world); BuilderToolsPlugin.get().onPasteEnd(prefabId, componentAccessor); - this.selection.setPrefabId(-1); - this.selection.setPosition(0, 0, 0); + selectionToPlace.setPrefabId(-1); + selectionToPlace.setPosition(0, 0, 0); long end = System.nanoTime(); long diff = end - start; - int size = this.selection.getBlockCount(); + int size = selectionToPlace.getBlockCount(); BuilderToolsPlugin.get() .getLogger() .at(Level.FINE) @@ -2613,6 +2668,26 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, } } + private BlockSelection convertEmptyBlocksToEditorEmpty(@Nonnull BlockSelection original) { + BlockTypeAssetMap assetMap = BlockType.getAssetMap(); + int editorBlockPrefabAir = assetMap.getIndex("Editor_Empty"); + if (editorBlockPrefabAir == Integer.MIN_VALUE) { + return original; + } else { + BlockSelection converted = new BlockSelection(original.getBlockCount(), original.getEntityCount()); + converted.setPosition(original.getX(), original.getY(), original.getZ()); + converted.setAnchor(original.getAnchorX(), original.getAnchorY(), original.getAnchorZ()); + converted.setSelectionArea(original.getSelectionMin(), original.getSelectionMax()); + original.forEachBlock((x, y, z, block) -> { + int blockId = block.blockId() == 0 ? editorBlockPrefabAir : block.blockId(); + converted.addBlockAtLocalPos(x, y, z, blockId, block.rotation(), block.filler(), block.supportValue(), block.holder()); + }); + original.forEachFluid((x, y, z, fluidId, fluidLevel) -> converted.addFluidAtLocalPos(x, y, z, fluidId, fluidLevel)); + original.forEachEntity(holder -> converted.addEntityHolderRaw(holder.clone())); + return converted; + } + } + public void rotate(@Nonnull Ref ref, @Nonnull Axis axis, int angle, @Nonnull ComponentAccessor componentAccessor) { if (this.selection != null) { long start = System.nanoTime(); @@ -3264,12 +3339,11 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, } } - public void replace(@Nonnull Ref ref, @Nullable IntPredicate doReplace, int to, @Nonnull ComponentAccessor componentAccessor) { - this.replace(ref, doReplace, new int[]{to}, componentAccessor); - } - public void replace( - @Nonnull Ref ref, @Nullable IntPredicate doReplace, @Nonnull int[] toBlockIds, @Nonnull ComponentAccessor componentAccessor + @Nonnull Ref ref, + @Nullable IntPredicate doReplace, + @Nonnull BlockPattern toPattern, + @Nonnull ComponentAccessor componentAccessor ) { if (this.selection == null) { this.sendErrorFeedback(ref, Message.translation("server.builderTools.noSelection"), componentAccessor); @@ -3311,14 +3385,16 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, int block = chunk.getBlock(x, y, z); if (doReplace == null && block != 0 || doReplace != null && doReplace.test(block)) { Holder holder = chunk.getBlockComponentHolder(x, y, z); - int newBlockId = toBlockIds.length == 1 ? toBlockIds[0] : toBlockIds[this.random.nextInt(toBlockIds.length)]; + Material material = Material.fromPattern(toPattern, this.random); + int newBlockId = material.getBlockId(); + int newRotation = material.hasRotation() ? material.getRotation() : chunk.getRotationIndex(x, y, z); Holder newHolder = BuilderToolsPlugin.createBlockComponent(chunk, x, y, z, newBlockId, block, holder, true); int rotationIndex = chunk.getRotationIndex(x, y, z); before.addBlockAtWorldPos( x, y, z, block, rotationIndex, filler, chunk.getSupportValue(x, y, z), chunk.getBlockComponentHolder(x, y, z) ); - after.addBlockAtWorldPos(x, y, z, newBlockId, rotationIndex, 0, 0, newHolder); - this.replaceMultiBlockStructure(x, y, z, block, newBlockId, rotationIndex, accessor, before, after); + after.addBlockAtWorldPos(x, y, z, newBlockId, newRotation, 0, 0, newHolder); + this.replaceMultiBlockStructure(x, y, z, block, newBlockId, newRotation, accessor, before, after); if (newBlockId == 0) { int fluidId = chunk.getFluidId(x, y, z); byte fluidLevel = chunk.getFluidLevel(x, y, z); @@ -4087,6 +4163,19 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, boolean includeEntities, boolean includeEmpty, @Nonnull ComponentAccessor componentAccessor + ) { + this.saveFromSelection(ref, name, relativize, overwrite, includeEntities, includeEmpty, null, componentAccessor); + } + + public void saveFromSelection( + @Nonnull Ref ref, + @Nonnull String name, + boolean relativize, + boolean overwrite, + boolean includeEntities, + boolean includeEmpty, + @Nullable Vector3i playerAnchor, + @Nonnull ComponentAccessor componentAccessor ) { if (this.selection != null && (!this.selection.getSelectionMin().equals(Vector3i.ZERO) || !this.selection.getSelectionMax().equals(Vector3i.ZERO))) { World world = componentAccessor.getExternalData().getWorld(); @@ -4146,7 +4235,7 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, } } - if (block == editorBlockPrefabAnchor) { + if (block == editorBlockPrefabAnchor && playerAnchor == null) { tempSelection.setAnchorAtWorldPos(x, y, z); int id = BuilderToolsPlugin.getNonEmptyNeighbourBlock(accessor, x, y, z); if (id > 0 && id != editorBlockPrefabAir) { @@ -4169,6 +4258,10 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, } } + if (playerAnchor != null) { + tempSelection.setAnchorAtWorldPos(playerAnchor.getX(), playerAnchor.getY(), playerAnchor.getZ()); + } + if (includeEntities) { Store entityStore = world.getEntityStore().getStore(); BuilderToolsPlugin.forEachCopyableInSelection(world, xMin, yMin, zMin, width, height, depth, e -> { @@ -4181,12 +4274,12 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, BlockSelection postClone = relativize ? tempSelection.relativize() : tempSelection.cloneSelection(); prefabStore.saveServerPrefab(name, postClone, overwrite); this.sendFeedback(Message.translation("server.builderTools.savedSelectionToPrefab").param("name", name), componentAccessor); - } catch (PrefabSaveException var46) { - switch (var46.getType()) { + } catch (PrefabSaveException var47) { + switch (var47.getType()) { case ERROR: - BuilderToolsPlugin.get().getLogger().at(Level.WARNING).withCause(var46).log("Exception saving prefab %s", name); + BuilderToolsPlugin.get().getLogger().at(Level.WARNING).withCause(var47).log("Exception saving prefab %s", name); this.sendFeedback( - Message.translation("server.builderTools.errorSavingPrefab").param("name", name).param("message", var46.getCause().getMessage()), + Message.translation("server.builderTools.errorSavingPrefab").param("name", name).param("message", var47.getCause().getMessage()), componentAccessor ); break; @@ -4372,9 +4465,6 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, public int mainBlockCount = 0; public int mainBlockNotAir = 0; public int mainBlockNotAirCount = 0; - - public BlocksSampleData() { - } } public static class SmoothSampleData { @@ -4383,9 +4473,6 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, public int solidBlockCount = 0; public int fillerBlock = 0; public int fillerBlockCount = 0; - - public SmoothSampleData() { - } } } @@ -4405,9 +4492,6 @@ public class BuilderToolsPlugin extends JavaPlugin implements SelectionProvider, .build(); private int historyCount = 50; private long toolExpireTime = 3600L; - - public BuilderToolsConfig() { - } } public static class CachedAccessor extends AbstractCachedAccessor { diff --git a/src/com/hypixel/hytale/builtin/buildertools/BuilderToolsSystems.java b/src/com/hypixel/hytale/builtin/buildertools/BuilderToolsSystems.java index 5966a25..d058f3a 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/BuilderToolsSystems.java +++ b/src/com/hypixel/hytale/builtin/buildertools/BuilderToolsSystems.java @@ -19,16 +19,10 @@ import java.util.Map; import javax.annotation.Nonnull; public class BuilderToolsSystems { - public BuilderToolsSystems() { - } - public static class EnsureBuilderTools extends HolderSystem { @Nonnull private static final ComponentType PLAYER_COMPONENT_TYPE = Player.getComponentType(); - public EnsureBuilderTools() { - } - @Nonnull @Override public Query getQuery() { diff --git a/src/com/hypixel/hytale/builtin/buildertools/BuilderToolsUserData.java b/src/com/hypixel/hytale/builtin/buildertools/BuilderToolsUserData.java index c157f7c..b818218 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/BuilderToolsUserData.java +++ b/src/com/hypixel/hytale/builtin/buildertools/BuilderToolsUserData.java @@ -37,9 +37,6 @@ public class BuilderToolsUserData implements Component { return BuilderToolsPlugin.get().getUserDataComponentType(); } - public BuilderToolsUserData() { - } - public boolean isRecordingSelectionHistory() { return this.selectionHistory; } diff --git a/src/com/hypixel/hytale/builtin/buildertools/BuilderToolsUserDataSystem.java b/src/com/hypixel/hytale/builtin/buildertools/BuilderToolsUserDataSystem.java index e5b8ed8..ea0dba2 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/BuilderToolsUserDataSystem.java +++ b/src/com/hypixel/hytale/builtin/buildertools/BuilderToolsUserDataSystem.java @@ -13,9 +13,6 @@ import javax.annotation.Nonnull; public class BuilderToolsUserDataSystem extends HolderSystem { private static final Query QUERY = Query.and(Player.getComponentType(), Query.not(BuilderToolsUserData.getComponentType())); - public BuilderToolsUserDataSystem() { - } - @Nonnull @Override public Query getQuery() { diff --git a/src/com/hypixel/hytale/builtin/buildertools/CopyCutSettings.java b/src/com/hypixel/hytale/builtin/buildertools/CopyCutSettings.java index 47160b0..83daf36 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/CopyCutSettings.java +++ b/src/com/hypixel/hytale/builtin/buildertools/CopyCutSettings.java @@ -9,7 +9,4 @@ public class CopyCutSettings { public static final int TINT_MAP = 32; public static final int KEEP_ANCHORS = 64; public static final int FLUIDS = 128; - - public CopyCutSettings() { - } } diff --git a/src/com/hypixel/hytale/builtin/buildertools/commands/ClearBlocksCommand.java b/src/com/hypixel/hytale/builtin/buildertools/commands/ClearBlocksCommand.java index acd7f25..4190457 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/commands/ClearBlocksCommand.java +++ b/src/com/hypixel/hytale/builtin/buildertools/commands/ClearBlocksCommand.java @@ -25,6 +25,8 @@ import javax.annotation.Nonnull; public class ClearBlocksCommand extends AbstractPlayerCommand { @Nonnull private static final Message MESSAGE_COMMANDS_CLEAR_NO_SELECTION = Message.translation("server.commands.clear.noSelection"); + @Nonnull + private static final Message MESSAGE_COMMANDS_CLEAR_SUCCESS = Message.translation("server.commands.clear.success"); public ClearBlocksCommand() { super("clearBlocks", "server.commands.clear.desc"); @@ -69,6 +71,7 @@ public class ClearBlocksCommand extends AbstractPlayerCommand { BuilderToolsPlugin.addToQueue( playerComponent, playerRef, (r, s, componentAccessor) -> s.clear(min.x, min.y, min.z, max.x, max.y, max.z, componentAccessor) ); + playerRef.sendMessage(ClearBlocksCommand.MESSAGE_COMMANDS_CLEAR_SUCCESS); } } } @@ -89,6 +92,7 @@ public class ClearBlocksCommand extends AbstractPlayerCommand { playerRef.sendMessage(MESSAGE_COMMANDS_CLEAR_NO_SELECTION); } else { BuilderToolsPlugin.addToQueue(playerComponent, playerRef, (r, s, componentAccessor) -> s.set(BlockPattern.EMPTY, componentAccessor)); + playerRef.sendMessage(MESSAGE_COMMANDS_CLEAR_SUCCESS); } } } diff --git a/src/com/hypixel/hytale/builtin/buildertools/commands/ClearEntitiesCommand.java b/src/com/hypixel/hytale/builtin/buildertools/commands/ClearEntitiesCommand.java index 31bac75..52992e3 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/commands/ClearEntitiesCommand.java +++ b/src/com/hypixel/hytale/builtin/buildertools/commands/ClearEntitiesCommand.java @@ -21,8 +21,6 @@ import javax.annotation.Nonnull; public class ClearEntitiesCommand extends AbstractPlayerCommand { @Nonnull private static final Message MESSAGE_NO_SELECTION = Message.translation("server.commands.clearEntities.noSelection"); - @Nonnull - private static final Message MESSAGE_CLEARED = Message.translation("server.commands.clearEntities.cleared"); public ClearEntitiesCommand() { super("clearEntities", "server.commands.clearEntities.desc"); @@ -57,7 +55,7 @@ public class ClearEntitiesCommand extends AbstractPlayerCommand { entityStore.removeEntity(entityRef, RemoveReason.REMOVE); } - context.sendMessage(MESSAGE_CLEARED.param("count", entitiesToRemove.size())); + context.sendMessage(Message.translation("server.commands.clearEntities.cleared").param("count", entitiesToRemove.size())); } } } diff --git a/src/com/hypixel/hytale/builtin/buildertools/commands/CopyCommand.java b/src/com/hypixel/hytale/builtin/buildertools/commands/CopyCommand.java index e679760..43d81c6 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/commands/CopyCommand.java +++ b/src/com/hypixel/hytale/builtin/buildertools/commands/CopyCommand.java @@ -6,6 +6,8 @@ import com.hypixel.hytale.builtin.buildertools.PrototypePlayerBuilderToolSetting import com.hypixel.hytale.component.ComponentAccessor; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.Store; +import com.hypixel.hytale.math.util.MathUtil; +import com.hypixel.hytale.math.vector.Vector3d; import com.hypixel.hytale.math.vector.Vector3i; import com.hypixel.hytale.protocol.GameMode; import com.hypixel.hytale.protocol.SoundCategory; @@ -16,6 +18,7 @@ import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredAr import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes; import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand; import com.hypixel.hytale.server.core.entity.entities.Player; +import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent; import com.hypixel.hytale.server.core.prefab.selection.standard.BlockSelection; import com.hypixel.hytale.server.core.universe.PlayerRef; import com.hypixel.hytale.server.core.universe.world.SoundUtil; @@ -23,6 +26,7 @@ import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import com.hypixel.hytale.server.core.util.TempAssetIdUtil; import javax.annotation.Nonnull; +import javax.annotation.Nullable; public class CopyCommand extends AbstractPlayerCommand { @Nonnull @@ -35,6 +39,8 @@ public class CopyCommand extends AbstractPlayerCommand { private final FlagArg emptyFlag = this.withFlagArg("empty", "server.commands.copy.empty.desc"); @Nonnull private final FlagArg keepAnchorsFlag = this.withFlagArg("keepanchors", "server.commands.copy.keepanchors.desc"); + @Nonnull + private final FlagArg playerAnchorFlag = this.withFlagArg("playerAnchor", "server.commands.copy.playerAnchor.desc"); public CopyCommand() { super("copy", "server.commands.copy.desc"); @@ -73,21 +79,43 @@ public class CopyCommand extends AbstractPlayerCommand { } int settingsFinal = settings; - BuilderToolsPlugin.addToQueue(playerComponent, playerRef, (r, s, componentAccessor) -> { - try { - BlockSelection selection = builderState.getSelection(); - if (selection == null || !selection.hasSelectionBounds()) { - context.sendMessage(MESSAGE_BUILDER_TOOLS_COPY_CUT_NO_SELECTION); - return; - } + Vector3i playerAnchor = getPlayerAnchor(ref, store, this.playerAnchorFlag.get(context)); + BuilderToolsPlugin.addToQueue( + playerComponent, + playerRef, + (r, s, componentAccessor) -> { + try { + BlockSelection selection = builderState.getSelection(); + if (selection == null || !selection.hasSelectionBounds()) { + context.sendMessage(MESSAGE_BUILDER_TOOLS_COPY_CUT_NO_SELECTION); + return; + } - Vector3i min = selection.getSelectionMin(); - Vector3i max = selection.getSelectionMax(); - builderState.copyOrCut(r, min.getX(), min.getY(), min.getZ(), max.getX(), max.getY(), max.getZ(), settingsFinal, componentAccessor); - } catch (PrefabCopyException var9x) { - context.sendMessage(Message.translation("server.builderTools.copycut.copyFailedReason").param("reason", var9x.getMessage())); + Vector3i min = selection.getSelectionMin(); + Vector3i max = selection.getSelectionMax(); + builderState.copyOrCut( + r, min.getX(), min.getY(), min.getZ(), max.getX(), max.getY(), max.getZ(), settingsFinal, playerAnchor, componentAccessor + ); + } catch (PrefabCopyException var10x) { + context.sendMessage(Message.translation("server.builderTools.copycut.copyFailedReason").param("reason", var10x.getMessage())); + } } - }); + ); + } + } + + @Nullable + private static Vector3i getPlayerAnchor(@Nonnull Ref ref, @Nonnull Store store, boolean usePlayerAnchor) { + if (!usePlayerAnchor) { + return null; + } else { + TransformComponent transformComponent = store.getComponent(ref, TransformComponent.getComponentType()); + if (transformComponent == null) { + return null; + } else { + Vector3d position = transformComponent.getPosition(); + return new Vector3i(MathUtil.floor(position.getX()), MathUtil.floor(position.getY()), MathUtil.floor(position.getZ())); + } } } @@ -155,6 +183,8 @@ public class CopyCommand extends AbstractPlayerCommand { private final FlagArg emptyFlag = this.withFlagArg("empty", "server.commands.copy.empty.desc"); @Nonnull private final FlagArg keepAnchorsFlag = this.withFlagArg("keepanchors", "server.commands.copy.keepanchors.desc"); + @Nonnull + private final FlagArg playerAnchorFlag = this.withFlagArg("playerAnchor", "server.commands.copy.playerAnchor.desc"); public CopyRegionCommand() { super("server.commands.copy.desc"); @@ -196,11 +226,12 @@ public class CopyCommand extends AbstractPlayerCommand { int yMax = this.yMaxArg.get(context); int zMax = this.zMaxArg.get(context); int copySettings = settings; + Vector3i playerAnchor = CopyCommand.getPlayerAnchor(ref, store, this.playerAnchorFlag.get(context)); BuilderToolsPlugin.addToQueue(playerComponent, playerRef, (r, s, componentAccessor) -> { try { - builderState.copyOrCut(r, xMin, yMin, zMin, xMax, yMax, zMax, copySettings, componentAccessor); - } catch (PrefabCopyException var13x) { - context.sendMessage(Message.translation("server.builderTools.copycut.copyFailedReason").param("reason", var13x.getMessage())); + builderState.copyOrCut(r, xMin, yMin, zMin, xMax, yMax, zMax, copySettings, playerAnchor, componentAccessor); + } catch (PrefabCopyException var14x) { + context.sendMessage(Message.translation("server.builderTools.copycut.copyFailedReason").param("reason", var14x.getMessage())); SoundUtil.playSoundEvent2d(r, TempAssetIdUtil.getSoundEventIndex("CREATE_ERROR"), SoundCategory.UI, componentAccessor); } }); diff --git a/src/com/hypixel/hytale/builtin/buildertools/commands/PasteCommand.java b/src/com/hypixel/hytale/builtin/buildertools/commands/PasteCommand.java index db2e3c4..63cd79b 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/commands/PasteCommand.java +++ b/src/com/hypixel/hytale/builtin/buildertools/commands/PasteCommand.java @@ -8,6 +8,7 @@ import com.hypixel.hytale.math.vector.Vector3d; import com.hypixel.hytale.math.vector.Vector3i; import com.hypixel.hytale.protocol.GameMode; import com.hypixel.hytale.server.core.command.system.CommandContext; +import com.hypixel.hytale.server.core.command.system.arguments.system.FlagArg; import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg; import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes; import com.hypixel.hytale.server.core.command.system.arguments.types.RelativeIntPosition; @@ -21,6 +22,9 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class PasteCommand extends AbstractPlayerCommand { + @Nonnull + private final FlagArg technicalFlag = this.withFlagArg("technical", "server.commands.paste.technical.desc"); + public PasteCommand() { super("paste", "server.commands.paste.desc"); this.setPermissionGroup(GameMode.Creative); @@ -45,7 +49,8 @@ public class PasteCommand extends AbstractPlayerCommand { int x = MathUtil.floor(position.x); int y = MathUtil.floor(position.y); int z = MathUtil.floor(position.z); - BuilderToolsPlugin.addToQueue(playerComponent, playerRef, (r, s, componentAccessor) -> s.paste(r, x, y, z, componentAccessor)); + boolean technical = this.technicalFlag.get(context); + BuilderToolsPlugin.addToQueue(playerComponent, playerRef, (r, s, componentAccessor) -> s.paste(r, x, y, z, technical, componentAccessor)); } private static class PasteAtPositionCommand extends AbstractPlayerCommand { @@ -53,6 +58,8 @@ public class PasteCommand extends AbstractPlayerCommand { private final RequiredArg positionArg = this.withRequiredArg( "position", "server.commands.paste.position.desc", ArgTypes.RELATIVE_BLOCK_POSITION ); + @Nonnull + private final FlagArg technicalFlag = this.withFlagArg("technical", "server.commands.paste.technical.desc"); public PasteAtPositionCommand() { super("server.commands.paste.desc"); @@ -74,8 +81,9 @@ public class PasteCommand extends AbstractPlayerCommand { Vector3d position = transformComponent.getPosition(); RelativeIntPosition relativePos = this.positionArg.get(context); Vector3i blockPos = relativePos.getBlockPosition(position, chunkStore); + boolean technical = this.technicalFlag.get(context); BuilderToolsPlugin.addToQueue( - playerComponent, playerRef, (r, s, componentAccessor) -> s.paste(r, blockPos.x, blockPos.y, blockPos.z, componentAccessor) + playerComponent, playerRef, (r, s, componentAccessor) -> s.paste(r, blockPos.x, blockPos.y, blockPos.z, technical, componentAccessor) ); } } diff --git a/src/com/hypixel/hytale/builtin/buildertools/commands/PrefabCommand.java b/src/com/hypixel/hytale/builtin/buildertools/commands/PrefabCommand.java index 1a252da..d2ff071 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/commands/PrefabCommand.java +++ b/src/com/hypixel/hytale/builtin/buildertools/commands/PrefabCommand.java @@ -7,6 +7,9 @@ import com.hypixel.hytale.builtin.buildertools.utils.RecursivePrefabLoader; import com.hypixel.hytale.common.util.PathUtil; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.Store; +import com.hypixel.hytale.math.util.MathUtil; +import com.hypixel.hytale.math.vector.Vector3d; +import com.hypixel.hytale.math.vector.Vector3i; import com.hypixel.hytale.protocol.GameMode; import com.hypixel.hytale.server.core.Message; import com.hypixel.hytale.server.core.command.system.CommandContext; @@ -18,6 +21,7 @@ import com.hypixel.hytale.server.core.command.system.basecommands.AbstractComman import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand; import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase; import com.hypixel.hytale.server.core.entity.entities.Player; +import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent; import com.hypixel.hytale.server.core.modules.singleplayer.SingleplayerModule; import com.hypixel.hytale.server.core.prefab.PrefabStore; import com.hypixel.hytale.server.core.prefab.selection.standard.BlockSelection; @@ -38,6 +42,7 @@ import java.util.Random; import java.util.function.BiFunction; import java.util.function.Function; import javax.annotation.Nonnull; +import javax.annotation.Nullable; public class PrefabCommand extends AbstractCommandCollection { public PrefabCommand() { @@ -290,6 +295,7 @@ public class PrefabCommand extends AbstractCommandCollection { public PrefabSaveCommand() { super("save", "server.commands.prefab.save.desc"); this.requirePermission("hytale.editor.prefab.manage"); + this.addUsageVariant(new PrefabCommand.PrefabSaveDirectCommand()); } @Override @@ -300,8 +306,59 @@ public class PrefabCommand extends AbstractCommandCollection { assert playerComponent != null; - BuilderToolsPlugin.BuilderState builderState = BuilderToolsPlugin.getState(playerComponent, playerRef); playerComponent.getPageManager().openCustomPage(ref, store, new PrefabSavePage(playerRef)); } } + + private static class PrefabSaveDirectCommand extends AbstractPlayerCommand { + @Nonnull + private final RequiredArg nameArg = this.withRequiredArg("name", "server.commands.prefab.save.name.desc", ArgTypes.STRING); + @Nonnull + private final FlagArg overwriteFlag = this.withFlagArg("overwrite", "server.commands.prefab.save.overwrite.desc"); + @Nonnull + private final FlagArg entitiesFlag = this.withFlagArg("entities", "server.commands.prefab.save.entities.desc"); + @Nonnull + private final FlagArg emptyFlag = this.withFlagArg("empty", "server.commands.prefab.save.empty.desc"); + @Nonnull + private final FlagArg playerAnchorFlag = this.withFlagArg("playerAnchor", "server.commands.prefab.save.playerAnchor.desc"); + + public PrefabSaveDirectCommand() { + super("server.commands.prefab.save.desc"); + } + + @Override + protected void execute( + @Nonnull CommandContext context, @Nonnull Store store, @Nonnull Ref ref, @Nonnull PlayerRef playerRef, @Nonnull World world + ) { + Player playerComponent = store.getComponent(ref, Player.getComponentType()); + + assert playerComponent != null; + + String name = this.nameArg.get(context); + boolean overwrite = this.overwriteFlag.get(context); + boolean entities = this.entitiesFlag.get(context); + boolean empty = this.emptyFlag.get(context); + Vector3i playerAnchor = this.getPlayerAnchor(ref, store, this.playerAnchorFlag.get(context)); + BuilderToolsPlugin.addToQueue( + playerComponent, + playerRef, + (r, s, componentAccessor) -> s.saveFromSelection(r, name, true, overwrite, entities, empty, playerAnchor, componentAccessor) + ); + } + + @Nullable + private Vector3i getPlayerAnchor(@Nonnull Ref ref, @Nonnull Store store, boolean usePlayerAnchor) { + if (!usePlayerAnchor) { + return null; + } else { + TransformComponent transformComponent = store.getComponent(ref, TransformComponent.getComponentType()); + if (transformComponent == null) { + return null; + } else { + Vector3d position = transformComponent.getPosition(); + return new Vector3i(MathUtil.floor(position.getX()), MathUtil.floor(position.getY()), MathUtil.floor(position.getZ())); + } + } + } + } } diff --git a/src/com/hypixel/hytale/builtin/buildertools/commands/ReplaceCommand.java b/src/com/hypixel/hytale/builtin/buildertools/commands/ReplaceCommand.java index 3e09600..39ec5cf 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/commands/ReplaceCommand.java +++ b/src/com/hypixel/hytale/builtin/buildertools/commands/ReplaceCommand.java @@ -20,6 +20,7 @@ import com.hypixel.hytale.server.core.universe.PlayerRef; import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import it.unimi.dsi.fastutil.ints.Int2IntArrayMap; +import java.util.concurrent.ThreadLocalRandom; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; import javax.annotation.Nonnull; @@ -63,54 +64,51 @@ public class ReplaceCommand extends AbstractPlayerCommand { if (PrototypePlayerBuilderToolSettings.isOkayToDoCommandsOnSelection(ref, playerComponent, store)) { if (toPattern != null && !toPattern.isEmpty()) { String toValue = toPattern.toString(); - Integer[] toBlockIds = toPattern.getResolvedKeys(); Material fromMaterial = fromValue != null ? Material.fromKey(fromValue) : null; - if (fromMaterial != null && fromMaterial.isFluid()) { - Material toMaterial = Material.fromKey(toValue); - if (toMaterial == null) { - context.sendMessage(Message.translation("server.builderTools.invalidBlockType").param("name", toValue).param("key", toValue)); + Material toMaterial = Material.fromPattern(toPattern, ThreadLocalRandom.current()); + if (toMaterial.isFluid() && !substringSwap && !regex) { + if (fromMaterial == null) { + context.sendMessage(Message.translation("server.commands.replace.fromRequired")); } else { BuilderToolsPlugin.addToQueue( playerComponent, playerRef, (r, s, componentAccessor) -> s.replace(r, fromMaterial, toMaterial, componentAccessor) ); context.sendMessage(Message.translation("server.builderTools.replace.replacementBlockDone").param("from", fromValue).param("to", toValue)); } + } else if (fromMaterial != null && fromMaterial.isFluid()) { + BuilderToolsPlugin.addToQueue(playerComponent, playerRef, (r, s, componentAccessor) -> s.replace(r, fromMaterial, toMaterial, componentAccessor)); + context.sendMessage(Message.translation("server.builderTools.replace.replacementBlockDone").param("from", fromValue).param("to", toValue)); } else { BlockTypeAssetMap assetMap = BlockType.getAssetMap(); if (fromValue == null && !substringSwap && !regex) { - int[] toIds = toIntArray(toBlockIds); - BuilderToolsPlugin.addToQueue(playerComponent, playerRef, (r, s, componentAccessor) -> s.replace(r, null, toIds, componentAccessor)); + BuilderToolsPlugin.addToQueue(playerComponent, playerRef, (r, s, componentAccessor) -> s.replace(r, null, toPattern, componentAccessor)); context.sendMessage(Message.translation("server.builderTools.replace.replacementAllDone").param("to", toValue)); } else if (fromValue == null) { context.sendMessage(Message.translation("server.commands.replace.fromRequired")); + } else if (regex) { + Pattern pattern; + try { + pattern = Pattern.compile(fromValue); + } catch (PatternSyntaxException var24) { + context.sendMessage(Message.translation("server.commands.replace.invalidRegex").param("error", var24.getMessage())); + return; + } + + BuilderToolsPlugin.addToQueue(playerComponent, playerRef, (r, s, componentAccessor) -> { + s.replace(r, value -> { + String valueKey = assetMap.getAsset(value).getId(); + return pattern.matcher(valueKey).matches(); + }, toPattern, componentAccessor); + context.sendMessage(Message.translation("server.commands.replace.success").param("regex", fromValue).param("replacement", toValue)); + }); } else if (fromMaterial == null) { context.sendMessage(Message.translation("server.builderTools.invalidBlockType").param("name", fromValue).param("key", fromValue)); } else if (!substringSwap) { - if (regex) { - Pattern pattern; - try { - pattern = Pattern.compile(fromValue); - } catch (PatternSyntaxException var24) { - context.sendMessage(Message.translation("server.commands.replace.invalidRegex").param("error", var24.getMessage())); - return; - } - - int[] toIds = toIntArray(toBlockIds); - BuilderToolsPlugin.addToQueue(playerComponent, playerRef, (r, s, componentAccessor) -> { - s.replace(r, value -> { - String valueKey = assetMap.getAsset(value).getId(); - return pattern.matcher(valueKey).matches(); - }, toIds, componentAccessor); - context.sendMessage(Message.translation("server.commands.replace.success").param("regex", fromValue).param("to", toValue)); - }); - } else { - int[] toIds = toIntArray(toBlockIds); - int fromBlockId = fromMaterial.getBlockId(); - BuilderToolsPlugin.addToQueue( - playerComponent, playerRef, (r, s, componentAccessor) -> s.replace(r, block -> block == fromBlockId, toIds, componentAccessor) - ); - context.sendMessage(Message.translation("server.builderTools.replace.replacementBlockDone").param("from", fromValue).param("to", toValue)); - } + int fromBlockId = fromMaterial.getBlockId(); + BuilderToolsPlugin.addToQueue( + playerComponent, playerRef, (r, s, componentAccessor) -> s.replace(r, block -> block == fromBlockId, toPattern, componentAccessor) + ); + context.sendMessage(Message.translation("server.builderTools.replace.replacementBlockDone").param("from", fromValue).param("to", toValue)); } else { String[] blockKeys = fromValue.split(","); Int2IntArrayMap swapMap = new Int2IntArrayMap(); @@ -153,16 +151,6 @@ public class ReplaceCommand extends AbstractPlayerCommand { } } - private static int[] toIntArray(Integer[] arr) { - int[] result = new int[arr.length]; - - for (int i = 0; i < arr.length; i++) { - result[i] = arr[i]; - } - - return result; - } - private static class ReplaceFromToCommand extends AbstractPlayerCommand { @Nonnull private final RequiredArg fromArg = this.withRequiredArg("from", "server.commands.replace.from.desc", ArgTypes.STRING); diff --git a/src/com/hypixel/hytale/builtin/buildertools/imageimport/ImageImportPage.java b/src/com/hypixel/hytale/builtin/buildertools/imageimport/ImageImportPage.java index c7f190a..428a1c1 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/imageimport/ImageImportPage.java +++ b/src/com/hypixel/hytale/builtin/buildertools/imageimport/ImageImportPage.java @@ -2,6 +2,7 @@ package com.hypixel.hytale.builtin.buildertools.imageimport; import com.hypixel.hytale.builtin.buildertools.BlockColorIndex; import com.hypixel.hytale.builtin.buildertools.BuilderToolsPlugin; +import com.hypixel.hytale.builtin.buildertools.utils.PasteToolUtil; import com.hypixel.hytale.codec.Codec; import com.hypixel.hytale.codec.KeyedCodec; import com.hypixel.hytale.codec.builder.BuilderCodec; @@ -12,18 +13,14 @@ import com.hypixel.hytale.math.vector.Vector3i; import com.hypixel.hytale.protocol.packets.interface_.CustomPageLifetime; import com.hypixel.hytale.protocol.packets.interface_.CustomUIEventBindingType; import com.hypixel.hytale.protocol.packets.interface_.Page; -import com.hypixel.hytale.protocol.packets.inventory.SetActiveSlot; import com.hypixel.hytale.server.core.Message; import com.hypixel.hytale.server.core.entity.entities.Player; import com.hypixel.hytale.server.core.entity.entities.player.pages.InteractiveCustomUIPage; -import com.hypixel.hytale.server.core.inventory.Inventory; -import com.hypixel.hytale.server.core.inventory.ItemStack; -import com.hypixel.hytale.server.core.inventory.container.ItemContainer; -import com.hypixel.hytale.server.core.modules.singleplayer.SingleplayerModule; import com.hypixel.hytale.server.core.prefab.selection.standard.BlockSelection; import com.hypixel.hytale.server.core.ui.DropdownEntryInfo; import com.hypixel.hytale.server.core.ui.LocalizableString; import com.hypixel.hytale.server.core.ui.browser.FileBrowserConfig; +import com.hypixel.hytale.server.core.ui.browser.FileBrowserEventData; import com.hypixel.hytale.server.core.ui.browser.ServerFileBrowser; import com.hypixel.hytale.server.core.ui.builder.EventData; import com.hypixel.hytale.server.core.ui.builder.UICommandBuilder; @@ -31,7 +28,6 @@ import com.hypixel.hytale.server.core.ui.builder.UIEventBuilder; import com.hypixel.hytale.server.core.universe.PlayerRef; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import java.awt.image.BufferedImage; -import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -46,8 +42,7 @@ public class ImageImportPage extends InteractiveCustomUIPage ref, @Nonnull Store store, @Nonnull ImageImportPage.PageData data) { - boolean needsUpdate = false; if (data.browse != null && data.browse) { this.showBrowser = true; this.rebuild(); @@ -165,60 +153,10 @@ public class ImageImportPage extends InteractiveCustomUIPage ImageImportPage.Orientation.VERTICAL_XZ; case "floor", "horizontal", "horizontal_xz" -> ImageImportPage.Orientation.HORIZONTAL_XZ; default -> ImageImportPage.Orientation.VERTICAL_XY; @@ -244,9 +182,9 @@ public class ImageImportPage extends InteractiveCustomUIPage ImageImportPage.Origin.BOTTOM_FRONT_LEFT; case "center" -> ImageImportPage.Origin.CENTER; case "top_center" -> ImageImportPage.Origin.TOP_CENTER; @@ -265,20 +203,62 @@ public class ImageImportPage extends InteractiveCustomUIPage ref, @Nonnull Store store) { if (this.imagePath.isEmpty()) { this.setError("Please enter a path to an image file"); } else { Path path = Paths.get(this.imagePath); - if (!SingleplayerModule.isOwner(this.playerRef)) { - Path normalizedPath = path.toAbsolutePath().normalize(); - Path normalizedImports = IMPORTS_DIR.toAbsolutePath().normalize(); - if (!normalizedPath.startsWith(normalizedImports)) { - this.setError("Files must be in the server's imports/images directory"); - return; - } - } - if (!Files.exists(path)) { this.setError("File not found: " + this.imagePath); } else { @@ -434,7 +414,7 @@ public class ImageImportPage extends InteractiveCustomUIPage CODEC = BuilderCodec.builder(ImageImportPage.PageData.class, ImageImportPage.PageData::new) - .addField(new KeyedCodec<>("@ImagePath", Codec.STRING), (entry, s) -> entry.imagePath = s, entry -> entry.imagePath) - .addField(new KeyedCodec<>("@MaxSize", Codec.INTEGER), (entry, i) -> entry.maxSize = i, entry -> entry.maxSize) - .addField(new KeyedCodec<>("@Orientation", Codec.STRING), (entry, s) -> entry.orientation = s, entry -> entry.orientation) - .addField(new KeyedCodec<>("@Origin", Codec.STRING), (entry, s) -> entry.origin = s, entry -> entry.origin) + .addField(new KeyedCodec<>("@ImagePath", Codec.STRING), (e, s) -> e.imagePath = s, e -> e.imagePath) + .addField(new KeyedCodec<>("@MaxSize", Codec.INTEGER), (e, i) -> e.maxSize = i, e -> e.maxSize) + .addField(new KeyedCodec<>("@Orientation", Codec.STRING), (e, s) -> e.orientation = s, e -> e.orientation) + .addField(new KeyedCodec<>("@Origin", Codec.STRING), (e, s) -> e.origin = s, e -> e.origin) .addField( - new KeyedCodec<>("Import", Codec.STRING), - (entry, s) -> entry.doImport = "true".equalsIgnoreCase(s), - entry -> entry.doImport != null && entry.doImport ? "true" : null - ) - .addField( - new KeyedCodec<>("Browse", Codec.STRING), - (entry, s) -> entry.browse = "true".equalsIgnoreCase(s), - entry -> entry.browse != null && entry.browse ? "true" : null + new KeyedCodec<>("Import", Codec.STRING), (e, s) -> e.doImport = "true".equalsIgnoreCase(s), e -> e.doImport != null && e.doImport ? "true" : null ) + .addField(new KeyedCodec<>("Browse", Codec.STRING), (e, s) -> e.browse = "true".equalsIgnoreCase(s), e -> e.browse != null && e.browse ? "true" : null) .addField( new KeyedCodec<>("BrowserSelect", Codec.STRING), - (entry, s) -> entry.browserSelect = "true".equalsIgnoreCase(s), - entry -> entry.browserSelect != null && entry.browserSelect ? "true" : null + (e, s) -> e.browserSelect = "true".equalsIgnoreCase(s), + e -> e.browserSelect != null && e.browserSelect ? "true" : null ) .addField( new KeyedCodec<>("BrowserCancel", Codec.STRING), - (entry, s) -> entry.browserCancel = "true".equalsIgnoreCase(s), - entry -> entry.browserCancel != null && entry.browserCancel ? "true" : null + (e, s) -> e.browserCancel = "true".equalsIgnoreCase(s), + e -> e.browserCancel != null && e.browserCancel ? "true" : null ) - .addField(new KeyedCodec<>("File", Codec.STRING), (entry, s) -> entry.file = s, entry -> entry.file) - .addField(new KeyedCodec<>("@SearchQuery", Codec.STRING), (entry, s) -> entry.searchQuery = s, entry -> entry.searchQuery) - .addField(new KeyedCodec<>("SearchResult", Codec.STRING), (entry, s) -> entry.searchResult = s, entry -> entry.searchResult) + .addField(new KeyedCodec<>("File", Codec.STRING), (e, s) -> e.file = s, e -> e.file) + .addField(new KeyedCodec<>("@SearchQuery", Codec.STRING), (e, s) -> e.searchQuery = s, e -> e.searchQuery) + .addField(new KeyedCodec<>("SearchResult", Codec.STRING), (e, s) -> e.searchResult = s, e -> e.searchResult) .build(); @Nullable private String imagePath; @@ -582,8 +495,5 @@ public class ImageImportPage extends InteractiveCustomUIPage ref, @Nonnull Store store, @Nonnull ObjImportPage.PageData data) { - boolean needsUpdate = false; if (data.browse != null && data.browse) { this.showBrowser = true; this.rebuild(); @@ -216,60 +205,10 @@ public class ObjImportPage extends InteractiveCustomUIPage ObjImportPage.Origin.BOTTOM_FRONT_LEFT; case "center" -> ObjImportPage.Origin.CENTER; case "top_center" -> ObjImportPage.Origin.TOP_CENTER; @@ -325,9 +264,9 @@ public class ObjImportPage extends InteractiveCustomUIPage ObjImportPage.MeshRotation.Z_UP_TO_Y_UP; case "x_up" -> ObjImportPage.MeshRotation.X_UP_TO_Y_UP; default -> ObjImportPage.MeshRotation.NONE; @@ -346,6 +285,57 @@ public class ObjImportPage extends InteractiveCustomUIPage parseBlockPattern(@Nonnull String pattern) { List result = new ArrayList<>(); @@ -413,15 +403,6 @@ public class ObjImportPage extends InteractiveCustomUIPage CODEC = BuilderCodec.builder(ObjImportPage.PageData.class, ObjImportPage.PageData::new) - .addField(new KeyedCodec<>("@ObjPath", Codec.STRING), (entry, s) -> entry.objPath = s, entry -> entry.objPath) - .addField(new KeyedCodec<>("@Height", Codec.INTEGER), (entry, i) -> entry.height = i, entry -> entry.height) - .addField(new KeyedCodec<>("@Scale", Codec.FLOAT), (entry, f) -> entry.scale = f, entry -> entry.scale) - .addField(new KeyedCodec<>("SizeMode", Codec.STRING), (entry, s) -> entry.sizeMode = s, entry -> entry.sizeMode) - .addField(new KeyedCodec<>("@BlockPattern", Codec.STRING), (entry, s) -> entry.blockPattern = s, entry -> entry.blockPattern) - .addField(new KeyedCodec<>("@FillSolid", Codec.BOOLEAN), (entry, b) -> entry.fillSolid = b, entry -> entry.fillSolid) - .addField(new KeyedCodec<>("@UseMaterials", Codec.BOOLEAN), (entry, b) -> entry.useMaterials = b, entry -> entry.useMaterials) - .addField(new KeyedCodec<>("@AutoDetectTextures", Codec.BOOLEAN), (entry, b) -> entry.autoDetectTextures = b, entry -> entry.autoDetectTextures) - .addField(new KeyedCodec<>("@Origin", Codec.STRING), (entry, s) -> entry.origin = s, entry -> entry.origin) - .addField(new KeyedCodec<>("@Rotation", Codec.STRING), (entry, s) -> entry.rotation = s, entry -> entry.rotation) + .addField(new KeyedCodec<>("@ObjPath", Codec.STRING), (e, s) -> e.objPath = s, e -> e.objPath) + .addField(new KeyedCodec<>("@Height", Codec.INTEGER), (e, i) -> e.height = i, e -> e.height) + .addField(new KeyedCodec<>("@Scale", Codec.FLOAT), (e, f) -> e.scale = f, e -> e.scale) + .addField(new KeyedCodec<>("SizeMode", Codec.STRING), (e, s) -> e.sizeMode = s, e -> e.sizeMode) + .addField(new KeyedCodec<>("@BlockPattern", Codec.STRING), (e, s) -> e.blockPattern = s, e -> e.blockPattern) + .addField(new KeyedCodec<>("@FillSolid", Codec.BOOLEAN), (e, b) -> e.fillSolid = b, e -> e.fillSolid) + .addField(new KeyedCodec<>("@UseMaterials", Codec.BOOLEAN), (e, b) -> e.useMaterials = b, e -> e.useMaterials) + .addField(new KeyedCodec<>("@AutoDetectTextures", Codec.BOOLEAN), (e, b) -> e.autoDetectTextures = b, e -> e.autoDetectTextures) + .addField(new KeyedCodec<>("@Origin", Codec.STRING), (e, s) -> e.origin = s, e -> e.origin) + .addField(new KeyedCodec<>("@Rotation", Codec.STRING), (e, s) -> e.rotation = s, e -> e.rotation) .addField( - new KeyedCodec<>("Import", Codec.STRING), - (entry, s) -> entry.doImport = "true".equalsIgnoreCase(s), - entry -> entry.doImport != null && entry.doImport ? "true" : null - ) - .addField( - new KeyedCodec<>("Browse", Codec.STRING), - (entry, s) -> entry.browse = "true".equalsIgnoreCase(s), - entry -> entry.browse != null && entry.browse ? "true" : null + new KeyedCodec<>("Import", Codec.STRING), (e, s) -> e.doImport = "true".equalsIgnoreCase(s), e -> e.doImport != null && e.doImport ? "true" : null ) + .addField(new KeyedCodec<>("Browse", Codec.STRING), (e, s) -> e.browse = "true".equalsIgnoreCase(s), e -> e.browse != null && e.browse ? "true" : null) .addField( new KeyedCodec<>("BrowserSelect", Codec.STRING), - (entry, s) -> entry.browserSelect = "true".equalsIgnoreCase(s), - entry -> entry.browserSelect != null && entry.browserSelect ? "true" : null + (e, s) -> e.browserSelect = "true".equalsIgnoreCase(s), + e -> e.browserSelect != null && e.browserSelect ? "true" : null ) .addField( new KeyedCodec<>("BrowserCancel", Codec.STRING), - (entry, s) -> entry.browserCancel = "true".equalsIgnoreCase(s), - entry -> entry.browserCancel != null && entry.browserCancel ? "true" : null + (e, s) -> e.browserCancel = "true".equalsIgnoreCase(s), + e -> e.browserCancel != null && e.browserCancel ? "true" : null ) - .addField(new KeyedCodec<>("File", Codec.STRING), (entry, s) -> entry.file = s, entry -> entry.file) - .addField(new KeyedCodec<>("@SearchQuery", Codec.STRING), (entry, s) -> entry.searchQuery = s, entry -> entry.searchQuery) - .addField(new KeyedCodec<>("SearchResult", Codec.STRING), (entry, s) -> entry.searchResult = s, entry -> entry.searchResult) + .addField(new KeyedCodec<>("File", Codec.STRING), (e, s) -> e.file = s, e -> e.file) + .addField(new KeyedCodec<>("@SearchQuery", Codec.STRING), (e, s) -> e.searchQuery = s, e -> e.searchQuery) + .addField(new KeyedCodec<>("SearchResult", Codec.STRING), (e, s) -> e.searchResult = s, e -> e.searchResult) .build(); @Nullable private String objPath; @@ -809,9 +723,6 @@ public class ObjImportPage extends InteractiveCustomUIPage { - Teleport teleportComponent = new Teleport(targetWorld, new Transform(spawnPoint)); + Teleport teleportComponent = Teleport.createForPlayer(targetWorld, new Transform(spawnPoint)); componentAccessor.putComponent(ref, Teleport.getComponentType(), teleportComponent); }, sourceWorld); } @@ -934,11 +934,8 @@ public class PrefabEditSessionManager { returnLocation = returnWorld.getWorldConfig().getSpawnProvider().getSpawnPoint(ref, componentAccessor); } - World finalReturnWorld = returnWorld; - Transform finalReturnLocation = returnLocation; - return CompletableFuture.runAsync( - () -> componentAccessor.putComponent(ref, Teleport.getComponentType(), new Teleport(finalReturnWorld, finalReturnLocation)), world - ) + Teleport teleportComponent = Teleport.createForPlayer(returnWorld, returnLocation); + return CompletableFuture.runAsync(() -> componentAccessor.putComponent(ref, Teleport.getComponentType(), teleportComponent), world) .thenRunAsync(() -> { World worldToRemove = Universe.get().getWorld(prefabEditSession.getWorldName()); if (worldToRemove != null) { diff --git a/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/PrefabLoadingState.java b/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/PrefabLoadingState.java index ee81fee..881b19a 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/PrefabLoadingState.java +++ b/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/PrefabLoadingState.java @@ -21,9 +21,6 @@ public class PrefabLoadingState { private long lastUpdateTimeNanos = this.startTimeNanos; private long lastNotifyTimeNanos; - public PrefabLoadingState() { - } - public void setTotalPrefabs(int totalPrefabs) { this.totalPrefabs = totalPrefabs; this.lastUpdateTimeNanos = System.nanoTime(); diff --git a/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/PrefabMarkerProvider.java b/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/PrefabMarkerProvider.java index 2fc8dc1..5751f6e 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/PrefabMarkerProvider.java +++ b/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/PrefabMarkerProvider.java @@ -2,23 +2,17 @@ package com.hypixel.hytale.builtin.buildertools.prefabeditor; import com.hypixel.hytale.builtin.buildertools.BuilderToolsPlugin; import com.hypixel.hytale.protocol.packets.worldmap.MapMarker; -import com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig; import com.hypixel.hytale.server.core.entity.entities.Player; import com.hypixel.hytale.server.core.universe.world.World; -import com.hypixel.hytale.server.core.universe.world.WorldMapTracker; import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager; +import com.hypixel.hytale.server.core.universe.world.worldmap.markers.MapMarkerTracker; import javax.annotation.Nonnull; public class PrefabMarkerProvider implements WorldMapManager.MarkerProvider { public static final PrefabMarkerProvider INSTANCE = new PrefabMarkerProvider(); - public PrefabMarkerProvider() { - } - @Override - public void update( - @Nonnull World world, @Nonnull GameplayConfig gameplayConfig, @Nonnull WorldMapTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ - ) { + public void update(@Nonnull World world, @Nonnull MapMarkerTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ) { PrefabEditSessionManager sessionManager = BuilderToolsPlugin.get().getPrefabEditSessionManager(); Player player = tracker.getPlayer(); PrefabEditSession session = sessionManager.getPrefabEditSession(player.getUuid()); diff --git a/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/PrefabSelectionInteraction.java b/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/PrefabSelectionInteraction.java index d6c7af7..bb8fb09 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/PrefabSelectionInteraction.java +++ b/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/PrefabSelectionInteraction.java @@ -40,9 +40,6 @@ public class PrefabSelectionInteraction extends SimpleInstantInteraction { .documentation("Interaction that handles the selection functionally for the prefab selection tool.") .build(); - public PrefabSelectionInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { CommandBuffer commandBuffer = context.getCommandBuffer(); diff --git a/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/PrefabSetAnchorInteraction.java b/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/PrefabSetAnchorInteraction.java index 2c0fdd2..6eb4274 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/PrefabSetAnchorInteraction.java +++ b/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/PrefabSetAnchorInteraction.java @@ -38,9 +38,6 @@ public class PrefabSetAnchorInteraction extends SimpleInstantInteraction { .documentation("Sets the prefab anchor.") .build(); - public PrefabSetAnchorInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { CommandBuffer commandBuffer = context.getCommandBuffer(); diff --git a/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/enums/PrefabStackingAxis.java b/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/enums/PrefabStackingAxis.java index ead8107..a3347c5 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/enums/PrefabStackingAxis.java +++ b/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/enums/PrefabStackingAxis.java @@ -3,7 +3,4 @@ package com.hypixel.hytale.builtin.buildertools.prefabeditor.enums; public enum PrefabStackingAxis { X, Z; - - private PrefabStackingAxis() { - } } diff --git a/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/saving/PrefabSaver.java b/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/saving/PrefabSaver.java index 4254a47..ca44c8e 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/saving/PrefabSaver.java +++ b/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/saving/PrefabSaver.java @@ -2,20 +2,29 @@ package com.hypixel.hytale.builtin.buildertools.prefabeditor.saving; import com.hypixel.hytale.assetstore.map.BlockTypeAssetMap; import com.hypixel.hytale.builtin.buildertools.BuilderToolsPlugin; +import com.hypixel.hytale.component.ComponentRegistry; +import com.hypixel.hytale.component.ComponentType; import com.hypixel.hytale.component.Holder; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.Store; import com.hypixel.hytale.math.util.ChunkUtil; +import com.hypixel.hytale.math.vector.Vector3d; import com.hypixel.hytale.math.vector.Vector3i; +import com.hypixel.hytale.math.vector.VectorBoxUtil; import com.hypixel.hytale.server.core.Message; import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType; import com.hypixel.hytale.server.core.blocktype.component.BlockPhysics; import com.hypixel.hytale.server.core.command.system.CommandSender; +import com.hypixel.hytale.server.core.entity.UUIDComponent; +import com.hypixel.hytale.server.core.entity.entities.BlockEntity; +import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent; +import com.hypixel.hytale.server.core.prefab.PrefabCopyableComponent; import com.hypixel.hytale.server.core.prefab.PrefabSaveException; import com.hypixel.hytale.server.core.prefab.PrefabStore; import com.hypixel.hytale.server.core.prefab.selection.standard.BlockSelection; import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.chunk.ChunkColumn; +import com.hypixel.hytale.server.core.universe.world.chunk.EntityChunk; import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk; import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection; import com.hypixel.hytale.server.core.universe.world.chunk.section.FluidSection; @@ -28,6 +37,11 @@ import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import it.unimi.dsi.fastutil.longs.LongSet; import java.nio.file.FileSystems; import java.nio.file.Path; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -39,9 +53,6 @@ public class PrefabSaver { protected static final String EDITOR_BLOCK_PREFAB_AIR = "Editor_Empty"; protected static final String EDITOR_BLOCK_PREFAB_ANCHOR = "Editor_Anchor"; - public PrefabSaver() { - } - @Nonnull public static CompletableFuture savePrefab( @Nonnull CommandSender sender, @@ -54,14 +65,12 @@ public class PrefabSaver { @Nonnull Vector3i originalFileAnchor, @Nonnull PrefabSaverSettings settings ) { - return CompletableFuture.supplyAsync(() -> { - BlockSelection blockSelection = copyBlocks(sender, world, anchorPoint, minPoint, maxPoint, pastePosition, originalFileAnchor, settings); - return blockSelection == null ? false : save(sender, blockSelection, pathToSave, settings); - }, world); + return copyBlocksAsync(sender, world, anchorPoint, minPoint, maxPoint, pastePosition, originalFileAnchor, settings) + .thenApplyAsync(blockSelection -> blockSelection == null ? false : save(sender, blockSelection, pathToSave, settings), world); } - @Nullable - private static BlockSelection copyBlocks( + @Nonnull + private static CompletableFuture copyBlocksAsync( @Nonnull CommandSender sender, @Nonnull World world, @Nonnull Vector3i anchorPoint, @@ -72,134 +81,228 @@ public class PrefabSaver { @Nonnull PrefabSaverSettings settings ) { ChunkStore chunkStore = world.getChunkStore(); - long start = System.nanoTime(); - int width = maxPoint.x - minPoint.x; - int height = maxPoint.y - minPoint.y; - int depth = maxPoint.z - minPoint.z; BlockTypeAssetMap assetMap = BlockType.getAssetMap(); int editorBlock = assetMap.getIndex("Editor_Block"); if (editorBlock == Integer.MIN_VALUE) { sender.sendMessage(Message.translation("server.commands.editprefab.save.error.unknownBlockIdKey").param("key", "Editor_Block".toString())); - return null; + return CompletableFuture.completedFuture(null); } else { int editorBlockPrefabAir = assetMap.getIndex("Editor_Empty"); if (editorBlockPrefabAir == Integer.MIN_VALUE) { sender.sendMessage(Message.translation("server.commands.editprefab.save.error.unknownBlockIdKey").param("key", "Editor_Empty".toString())); - return null; + return CompletableFuture.completedFuture(null); } else { int editorBlockPrefabAnchor = assetMap.getIndex("Editor_Anchor"); if (editorBlockPrefabAnchor == Integer.MIN_VALUE) { sender.sendMessage(Message.translation("server.commands.editprefab.save.error.unknownBlockIdKey").param("key", "Editor_Anchor".toString())); - return null; + return CompletableFuture.completedFuture(null); } else { - int newAnchorX = anchorPoint.x - pastePosition.x; - int newAnchorY = anchorPoint.y - pastePosition.y; - int newAnchorZ = anchorPoint.z - pastePosition.z; - BlockSelection selection = new BlockSelection(); - selection.setPosition(pastePosition.x - originalFileAnchor.x, pastePosition.y - originalFileAnchor.y, pastePosition.z - originalFileAnchor.z); - selection.setSelectionArea(minPoint, maxPoint); - selection.setAnchor(newAnchorX, newAnchorY, newAnchorZ); - int blockCount = 0; - int fluidCount = 0; - int top = Math.max(minPoint.y, maxPoint.y); - int bottom = Math.min(minPoint.y, maxPoint.y); - Long2ObjectMap> loadedChunks = preloadChunksInSelection(world, chunkStore, minPoint, maxPoint); - - for (int x = minPoint.x; x <= maxPoint.x; x++) { - for (int z = minPoint.z; z <= maxPoint.z; z++) { - long chunkIndex = ChunkUtil.indexChunkFromBlock(x, z); - Ref chunkRef = loadedChunks.get(chunkIndex); - if (chunkRef != null && chunkRef.isValid()) { - WorldChunk worldChunkComponent = chunkStore.getStore().getComponent(chunkRef, WorldChunk.getComponentType()); - - assert worldChunkComponent != null; - - ChunkColumn chunkColumnComponent = chunkStore.getStore().getComponent(chunkRef, ChunkColumn.getComponentType()); - - assert chunkColumnComponent != null; - - for (int y = top; y >= bottom; y--) { - int sectionIndex = ChunkUtil.indexSection(y); - Ref sectionRef = chunkColumnComponent.getSection(sectionIndex); - if (sectionRef != null && sectionRef.isValid()) { - BlockSection sectionComponent = chunkStore.getStore().getComponent(sectionRef, BlockSection.getComponentType()); - - assert sectionComponent != null; - - BlockPhysics blockPhysicsComponent = chunkStore.getStore().getComponent(sectionRef, BlockPhysics.getComponentType()); - int block = sectionComponent.get(x, y, z); - if (settings.isBlocks() && (block != 0 || settings.isEmpty()) && block != editorBlock) { - if (block == editorBlockPrefabAir) { - block = 0; - } - - Holder holder = worldChunkComponent.getBlockComponentHolder(x, y, z); - if (holder != null) { - holder = holder.clone(); - BlockState blockState = BlockState.getBlockState(holder); - if (blockState != null) { - int localX = x - pastePosition.x; - int localY = y - pastePosition.y; - int localZ = z - pastePosition.z; - Vector3i position = blockState.__internal_getPosition(); - if (position != null) { - position.assign(localX, localY, localZ); - } - } - } - - selection.addBlockAtWorldPos( - x, - y, - z, - block, - sectionComponent.getRotationIndex(x, y, z), - sectionComponent.getFiller(x, y, z), - blockPhysicsComponent != null ? blockPhysicsComponent.get(x, y, z) : 0, - holder - ); - blockCount++; - } - - FluidSection fluidSectionComponent = chunkStore.getStore().getComponent(sectionRef, FluidSection.getComponentType()); - - assert fluidSectionComponent != null; - - int fluid = fluidSectionComponent.getFluidId(x, y, z); - if (settings.isBlocks() && (fluid != 0 || settings.isEmpty())) { - byte fluidLevel = fluidSectionComponent.getFluidLevel(x, y, z); - selection.addFluidAtWorldPos(x, y, z, fluid, fluidLevel); - fluidCount++; - } - } - } - } - } - } - - if (settings.isEntities()) { - Store store = world.getEntityStore().getStore(); - BuilderToolsPlugin.forEachCopyableInSelection(world, minPoint.x, minPoint.y, minPoint.z, width, height, depth, e -> { - Holder holder = store.copyEntity(e); - selection.addEntityFromWorld(holder); - }); - } - - long end = System.nanoTime(); - long diff = end - start; - BuilderToolsPlugin.get() - .getLogger() - .at(Level.FINE) - .log("Took: %dns (%dms) to execute copy of %d blocks, %d fluids", diff, TimeUnit.NANOSECONDS.toMillis(diff), blockCount, fluidCount); - return selection; + return preloadChunksInSelectionAsync(chunkStore, minPoint, maxPoint) + .thenApplyAsync( + loadedChunks -> copyBlocksWithLoadedChunks( + sender, + world, + anchorPoint, + minPoint, + maxPoint, + pastePosition, + originalFileAnchor, + settings, + (Long2ObjectMap>)loadedChunks, + editorBlock, + editorBlockPrefabAir, + editorBlockPrefabAnchor + ), + world + ); } } } } + @Nullable + private static BlockSelection copyBlocksWithLoadedChunks( + @Nonnull CommandSender sender, + @Nonnull World world, + @Nonnull Vector3i anchorPoint, + @Nonnull Vector3i minPoint, + @Nonnull Vector3i maxPoint, + @Nonnull Vector3i pastePosition, + @Nonnull Vector3i originalFileAnchor, + @Nonnull PrefabSaverSettings settings, + @Nonnull Long2ObjectMap> loadedChunks, + int editorBlock, + int editorBlockPrefabAir, + int editorBlockPrefabAnchor + ) { + ChunkStore chunkStore = world.getChunkStore(); + long start = System.nanoTime(); + int width = maxPoint.x - minPoint.x; + int height = maxPoint.y - minPoint.y; + int depth = maxPoint.z - minPoint.z; + int newAnchorX = anchorPoint.x - pastePosition.x; + int newAnchorY = anchorPoint.y - pastePosition.y; + int newAnchorZ = anchorPoint.z - pastePosition.z; + BlockSelection selection = new BlockSelection(); + selection.setPosition(pastePosition.x - originalFileAnchor.x, pastePosition.y - originalFileAnchor.y, pastePosition.z - originalFileAnchor.z); + selection.setSelectionArea(minPoint, maxPoint); + selection.setAnchor(newAnchorX, newAnchorY, newAnchorZ); + int blockCount = 0; + int fluidCount = 0; + int top = Math.max(minPoint.y, maxPoint.y); + int bottom = Math.min(minPoint.y, maxPoint.y); + + for (int x = minPoint.x; x <= maxPoint.x; x++) { + for (int z = minPoint.z; z <= maxPoint.z; z++) { + long chunkIndex = ChunkUtil.indexChunkFromBlock(x, z); + Ref chunkRef = loadedChunks.get(chunkIndex); + if (chunkRef != null && chunkRef.isValid()) { + WorldChunk worldChunkComponent = chunkStore.getStore().getComponent(chunkRef, WorldChunk.getComponentType()); + + assert worldChunkComponent != null; + + ChunkColumn chunkColumnComponent = chunkStore.getStore().getComponent(chunkRef, ChunkColumn.getComponentType()); + + assert chunkColumnComponent != null; + + for (int y = top; y >= bottom; y--) { + int sectionIndex = ChunkUtil.indexSection(y); + Ref sectionRef = chunkColumnComponent.getSection(sectionIndex); + if (sectionRef != null && sectionRef.isValid()) { + BlockSection sectionComponent = chunkStore.getStore().getComponent(sectionRef, BlockSection.getComponentType()); + + assert sectionComponent != null; + + BlockPhysics blockPhysicsComponent = chunkStore.getStore().getComponent(sectionRef, BlockPhysics.getComponentType()); + int block = sectionComponent.get(x, y, z); + int filler = sectionComponent.getFiller(x, y, z); + if (settings.isBlocks() && (block != 0 || settings.isEmpty()) && block != editorBlock) { + if (block == editorBlockPrefabAir) { + block = 0; + } + + Holder holder = worldChunkComponent.getBlockComponentHolder(x, y, z); + if (holder != null) { + holder = holder.clone(); + BlockState blockState = BlockState.getBlockState(holder); + if (blockState != null) { + blockState.clearPositionForSerialization(); + } + } + + selection.addBlockAtWorldPos( + x, + y, + z, + block, + sectionComponent.getRotationIndex(x, y, z), + filler, + blockPhysicsComponent != null ? blockPhysicsComponent.get(x, y, z) : 0, + holder + ); + blockCount++; + } + + FluidSection fluidSectionComponent = chunkStore.getStore().getComponent(sectionRef, FluidSection.getComponentType()); + + assert fluidSectionComponent != null; + + int fluid = fluidSectionComponent.getFluidId(x, y, z); + if (settings.isBlocks() && (fluid != 0 || settings.isEmpty())) { + byte fluidLevel = fluidSectionComponent.getFluidLevel(x, y, z); + selection.addFluidAtWorldPos(x, y, z, fluid, fluidLevel); + fluidCount++; + } + } + } + } + } + } + + if (settings.isEntities()) { + Store store = world.getEntityStore().getStore(); + ComponentType blockEntityType = BlockEntity.getComponentType(); + Set addedEntityUuids = new HashSet<>(); + ComponentRegistry.Data data = EntityStore.REGISTRY.getData(); + ComponentType prefabCopyableType = PrefabCopyableComponent.getComponentType(); + ComponentType transformType = TransformComponent.getComponentType(); + BuilderToolsPlugin.forEachCopyableInSelection(world, minPoint.x, minPoint.y, minPoint.z, width, height, depth, e -> { + BlockEntity blockEntityx = store.getComponent(e, blockEntityType); + if (blockEntityx != null) { + String key = blockEntityx.getBlockTypeKey(); + if (key != null && (key.equals("Editor_Block") || key.equals("Editor_Empty") || key.equals("Editor_Anchor"))) { + return; + } + } + + Holder holderx = store.copyEntity(e); + UUIDComponent uuidCompx = holderx.getComponent(UUIDComponent.getComponentType()); + if (uuidCompx != null) { + addedEntityUuids.add(uuidCompx.getUuid()); + } + + TransformComponent transformx = holderx.getComponent(transformType); + if (transformx != null && transformx.getPosition() != null) { + transformx.getPosition().subtract(selection.getX(), selection.getY(), selection.getZ()); + } + + selection.addEntityHolderRaw(holderx); + }); + + for (Ref chunkRef : loadedChunks.values()) { + EntityChunk entityChunk = chunkStore.getStore().getComponent(chunkRef, EntityChunk.getComponentType()); + if (entityChunk != null) { + for (Holder holder : entityChunk.getEntityHolders()) { + UUIDComponent uuidComp = holder.getComponent(UUIDComponent.getComponentType()); + TransformComponent transform = holder.getComponent(transformType); + Vector3d position = transform != null ? transform.getPosition() : null; + boolean hasPrefabCopyable = holder.getArchetype().contains(prefabCopyableType); + boolean hasSerializable = holder.hasSerializableComponents(data); + if (hasPrefabCopyable && hasSerializable) { + BlockEntity blockEntity = holder.getComponent(blockEntityType); + if (blockEntity != null) { + String key = blockEntity.getBlockTypeKey(); + if (key != null && (key.equals("Editor_Block") || key.equals("Editor_Empty") || key.equals("Editor_Anchor"))) { + continue; + } + } + + if (transform != null + && position != null + && VectorBoxUtil.isInside(minPoint.x, minPoint.y, minPoint.z, 0.0, 0.0, 0.0, width + 1, height + 1, depth + 1, position) + && (uuidComp == null || !addedEntityUuids.contains(uuidComp.getUuid()))) { + if (uuidComp != null) { + addedEntityUuids.add(uuidComp.getUuid()); + } + + Holder clonedHolder = holder.clone(); + TransformComponent clonedTransform = clonedHolder.getComponent(transformType); + if (clonedTransform != null && clonedTransform.getPosition() != null) { + clonedTransform.getPosition().subtract(selection.getX(), selection.getY(), selection.getZ()); + } + + selection.addEntityHolderRaw(clonedHolder); + } + } + } + } + } + + selection.sortEntitiesByPosition(); + } + + long end = System.nanoTime(); + long diff = end - start; + BuilderToolsPlugin.get() + .getLogger() + .at(Level.FINE) + .log("Took: %dns (%dms) to execute copy of %d blocks, %d fluids", diff, TimeUnit.NANOSECONDS.toMillis(diff), blockCount, fluidCount); + return selection; + } + @Nonnull - private static Long2ObjectMap> preloadChunksInSelection( - @Nonnull World world, @Nonnull ChunkStore chunkStore, @Nonnull Vector3i minPoint, @Nonnull Vector3i maxPoint + private static CompletableFuture>> preloadChunksInSelectionAsync( + @Nonnull ChunkStore chunkStore, @Nonnull Vector3i minPoint, @Nonnull Vector3i maxPoint ) { LongSet chunkIndices = new LongOpenHashSet(); int minChunkX = minPoint.x >> 5; @@ -214,21 +317,20 @@ public class PrefabSaver { } Long2ObjectMap> loadedChunks = new Long2ObjectOpenHashMap<>(chunkIndices.size()); + List> chunkFutures = new ArrayList<>(chunkIndices.size()); for (long chunkIndex : chunkIndices) { - CompletableFuture> future = chunkStore.getChunkReferenceAsync(chunkIndex); - - while (!future.isDone()) { - world.consumeTaskQueue(); - } - - Ref reference = future.join(); - if (reference != null && reference.isValid()) { - loadedChunks.put(chunkIndex, reference); - } + CompletableFuture future = chunkStore.getChunkReferenceAsync(chunkIndex).thenAccept(reference -> { + if (reference != null && reference.isValid()) { + synchronized (loadedChunks) { + loadedChunks.put(chunkIndex, (Ref)reference); + } + } + }); + chunkFutures.add(future); } - return loadedChunks; + return CompletableFuture.allOf(chunkFutures.toArray(CompletableFuture[]::new)).thenApply(v -> loadedChunks); } private static boolean save( diff --git a/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/saving/PrefabSaverSettings.java b/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/saving/PrefabSaverSettings.java index 4df9d7a..d207fbb 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/saving/PrefabSaverSettings.java +++ b/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/saving/PrefabSaverSettings.java @@ -8,9 +8,6 @@ public class PrefabSaverSettings { private boolean entities; private boolean keepAnchors; - public PrefabSaverSettings() { - } - public boolean isRelativize() { return this.relativize; } diff --git a/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/ui/PrefabEditorExitConfirmPage.java b/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/ui/PrefabEditorExitConfirmPage.java index f333ca6..77bdbe8 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/ui/PrefabEditorExitConfirmPage.java +++ b/src/com/hypixel/hytale/builtin/buildertools/prefabeditor/ui/PrefabEditorExitConfirmPage.java @@ -57,7 +57,7 @@ public class PrefabEditorExitConfirmPage extends InteractiveCustomUIPage 1 ? "/" + parts[1] : ""; + if ("HytaleAssets".equals(packName)) { + displayPath = packName + subPath; + } else { + displayPath = "Mods/" + packName + subPath; + } + } + commandBuilder.set("#BrowserPage #CurrentPath.Text", displayPath); List entries = this.assetProvider.getFiles(this.assetsCurrentDir, this.browserSearchQuery); int buttonIndex = 0; @@ -832,7 +845,7 @@ public class PrefabEditorLoadSettingsPage extends InteractiveCustomUIPage selectedPrefabUuids = new HashSet<>(); @@ -201,10 +204,11 @@ public class PrefabEditorSaveSettingsPage extends InteractiveCustomUIPage[] saveFutures = new CompletableFuture[totalPrefabs]; + AtomicInteger completedCount = new AtomicInteger(0); + this.lastProgressUpdateTime = 0L; for (int i = 0; i < totalPrefabs; i++) { PrefabEditingMetadata metadataxxx = prefabsToSave.get(i); - int index = i; Path savePath = this.getWritableSavePath(metadataxxx); saveFutures[i] = PrefabSaver.savePrefab( playerComponent, @@ -219,14 +223,20 @@ public class PrefabEditorSaveSettingsPage extends InteractiveCustomUIPage { - float progress = (float)(index + 1) / totalPrefabs; - UICommandBuilder progressBuilder = new UICommandBuilder(); - progressBuilder.set("#SavingPage #ProgressBar.Value", progress); - progressBuilder.set( - "#SavingPage #StatusText.TextSpans", - Message.translation("server.commands.editprefab.save.progress").param("current", index + 1).param("total", totalPrefabs) - ); - this.sendUpdate(progressBuilder); + int completed = completedCount.incrementAndGet(); + long now = System.currentTimeMillis(); + if (now - this.lastProgressUpdateTime >= 100L || completed == totalPrefabs) { + this.lastProgressUpdateTime = now; + float progress = (float)completed / totalPrefabs; + UICommandBuilder progressBuilder = new UICommandBuilder(); + progressBuilder.set("#SavingPage #ProgressBar.Value", progress); + progressBuilder.set( + "#SavingPage #StatusText.TextSpans", + Message.translation("server.commands.editprefab.save.progress").param("current", completed).param("total", totalPrefabs) + ); + this.sendUpdate(progressBuilder); + } + return (Boolean)success; } ); @@ -262,6 +272,7 @@ public class PrefabEditorSaveSettingsPage extends InteractiveCustomUIPage { this.isSaving = false; + LOGGER.atWarning().withCause(throwable).log("Error saving prefabs"); this.onSavingFailed(Message.raw(throwable.getMessage() != null ? throwable.getMessage() : "Unknown error")); return null; }); @@ -478,9 +489,6 @@ public class PrefabEditorSaveSettingsPage extends InteractiveCustomUIPage { + boolean aIsBase = "HytaleAssets".equals(a.displayName()); + boolean bIsBase = "HytaleAssets".equals(b.displayName()); + if (aIsBase != bIsBase) { + return aIsBase ? -1 : 1; + } else { + return a.displayName().compareToIgnoreCase(b.displayName()); + } + }); return entries; } @@ -122,7 +128,7 @@ public class AssetPrefabFileProvider implements FileListProvider { for (int i = 0; i < Math.min(allResults.size(), 50); i++) { AssetPrefabFileProvider.SearchResult result = allResults.get(i); - entries.add(new FileListProvider.FileEntry(result.relativePath(), result.displayName(), false, result.score())); + entries.add(new FileListProvider.FileEntry(result.relativePath(), result.displayName(), false, false, result.score())); } return entries; diff --git a/src/com/hypixel/hytale/builtin/buildertools/prefablist/PrefabPage.java b/src/com/hypixel/hytale/builtin/buildertools/prefablist/PrefabPage.java index 3f72feb..ded7eb1 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/prefablist/PrefabPage.java +++ b/src/com/hypixel/hytale/builtin/buildertools/prefablist/PrefabPage.java @@ -1,18 +1,15 @@ package com.hypixel.hytale.builtin.buildertools.prefablist; import com.hypixel.hytale.builtin.buildertools.BuilderToolsPlugin; +import com.hypixel.hytale.builtin.buildertools.utils.PasteToolUtil; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.Store; import com.hypixel.hytale.protocol.GameMode; import com.hypixel.hytale.protocol.packets.interface_.CustomPageLifetime; import com.hypixel.hytale.protocol.packets.interface_.CustomUIEventBindingType; import com.hypixel.hytale.protocol.packets.interface_.Page; -import com.hypixel.hytale.protocol.packets.inventory.SetActiveSlot; import com.hypixel.hytale.server.core.entity.entities.Player; import com.hypixel.hytale.server.core.entity.entities.player.pages.InteractiveCustomUIPage; -import com.hypixel.hytale.server.core.inventory.Inventory; -import com.hypixel.hytale.server.core.inventory.ItemStack; -import com.hypixel.hytale.server.core.inventory.container.ItemContainer; import com.hypixel.hytale.server.core.prefab.PrefabStore; import com.hypixel.hytale.server.core.prefab.selection.standard.BlockSelection; import com.hypixel.hytale.server.core.ui.Value; @@ -33,7 +30,6 @@ import java.util.List; import javax.annotation.Nonnull; public class PrefabPage extends InteractiveCustomUIPage { - private static final String PASTE_TOOL_ID = "EditorTool_Paste"; private static final String ASSETS_ROOT_KEY = "Assets"; @Nonnull private final ServerFileBrowser browser; @@ -195,7 +191,7 @@ public class PrefabPage extends InteractiveCustomUIPage { playerComponent.getPageManager().setPage(ref, store, Page.None); BlockSelection prefab = PrefabStore.get().getPrefab(file); BuilderToolsPlugin.addToQueue(playerComponent, playerRefComponent, (r, s, componentAccessor) -> s.load(displayPath, prefab, componentAccessor)); - this.switchToPasteTool(playerComponent, playerRefComponent); + PasteToolUtil.switchToPasteTool(playerComponent, playerRefComponent); } } @@ -203,7 +199,18 @@ public class PrefabPage extends InteractiveCustomUIPage { String displayPath; if (this.inAssetsRoot) { String currentDirStr = this.assetsCurrentDir.toString().replace('\\', '/'); - displayPath = currentDirStr.isEmpty() ? "Assets" : "Assets/" + currentDirStr; + if (currentDirStr.isEmpty()) { + displayPath = "Assets"; + } else { + String[] parts = currentDirStr.split("/", 2); + String packName = parts[0]; + String subPath = parts.length > 1 ? "/" + parts[1] : ""; + if ("HytaleAssets".equals(packName)) { + displayPath = packName + subPath; + } else { + displayPath = "Mods/" + packName + subPath; + } + } } else { Path root = this.browser.getRoot(); String rootDisplay = this.getRootDisplayName(root); @@ -261,59 +268,4 @@ public class PrefabPage extends InteractiveCustomUIPage { buttonIndex++; } } - - private void switchToPasteTool(@Nonnull Player playerComponent, @Nonnull PlayerRef playerRef) { - Inventory inventory = playerComponent.getInventory(); - ItemContainer hotbar = inventory.getHotbar(); - ItemContainer storage = inventory.getStorage(); - ItemContainer tools = inventory.getTools(); - int hotbarSize = hotbar.getCapacity(); - - for (short slot = 0; slot < hotbarSize; slot++) { - ItemStack itemStack = hotbar.getItemStack(slot); - if (itemStack != null && !itemStack.isEmpty() && "EditorTool_Paste".equals(itemStack.getItemId())) { - inventory.setActiveHotbarSlot((byte)slot); - playerRef.getPacketHandler().writeNoCache(new SetActiveSlot(-1, (byte)slot)); - return; - } - } - - short emptySlot = -1; - - for (short slotx = 0; slotx < hotbarSize; slotx++) { - ItemStack itemStack = hotbar.getItemStack(slotx); - if (itemStack == null || itemStack.isEmpty()) { - emptySlot = slotx; - break; - } - } - - if (emptySlot != -1) { - for (short slotxx = 0; slotxx < storage.getCapacity(); slotxx++) { - ItemStack itemStack = storage.getItemStack(slotxx); - if (itemStack != null && !itemStack.isEmpty() && "EditorTool_Paste".equals(itemStack.getItemId())) { - storage.moveItemStackFromSlotToSlot(slotxx, 1, hotbar, emptySlot); - inventory.setActiveHotbarSlot((byte)emptySlot); - playerRef.getPacketHandler().writeNoCache(new SetActiveSlot(-1, (byte)emptySlot)); - return; - } - } - - ItemStack pasteToolStack = null; - - for (short slotxxx = 0; slotxxx < tools.getCapacity(); slotxxx++) { - ItemStack itemStack = tools.getItemStack(slotxxx); - if (itemStack != null && !itemStack.isEmpty() && "EditorTool_Paste".equals(itemStack.getItemId())) { - pasteToolStack = itemStack; - break; - } - } - - if (pasteToolStack != null) { - hotbar.setItemStackForSlot(emptySlot, new ItemStack(pasteToolStack.getItemId())); - inventory.setActiveHotbarSlot((byte)emptySlot); - playerRef.getPacketHandler().writeNoCache(new SetActiveSlot(-1, (byte)emptySlot)); - } - } - } } diff --git a/src/com/hypixel/hytale/builtin/buildertools/prefablist/PrefabSavePage.java b/src/com/hypixel/hytale/builtin/buildertools/prefablist/PrefabSavePage.java index 9f755db..ef1583f 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/prefablist/PrefabSavePage.java +++ b/src/com/hypixel/hytale/builtin/buildertools/prefablist/PrefabSavePage.java @@ -7,18 +7,23 @@ import com.hypixel.hytale.codec.builder.BuilderCodec; import com.hypixel.hytale.codec.codecs.EnumCodec; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.Store; +import com.hypixel.hytale.math.util.MathUtil; +import com.hypixel.hytale.math.vector.Vector3d; +import com.hypixel.hytale.math.vector.Vector3i; import com.hypixel.hytale.protocol.packets.interface_.CustomPageLifetime; import com.hypixel.hytale.protocol.packets.interface_.CustomUIEventBindingType; import com.hypixel.hytale.protocol.packets.interface_.Page; import com.hypixel.hytale.server.core.Message; import com.hypixel.hytale.server.core.entity.entities.Player; import com.hypixel.hytale.server.core.entity.entities.player.pages.InteractiveCustomUIPage; +import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent; import com.hypixel.hytale.server.core.ui.builder.EventData; import com.hypixel.hytale.server.core.ui.builder.UICommandBuilder; import com.hypixel.hytale.server.core.ui.builder.UIEventBuilder; import com.hypixel.hytale.server.core.universe.PlayerRef; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; +import javax.annotation.Nullable; public class PrefabSavePage extends InteractiveCustomUIPage { @Nonnull @@ -37,6 +42,7 @@ public class PrefabSavePage extends InteractiveCustomUIPage { if (data.fromClipboard) { s.save(r, data.name, true, data.overwrite, componentAccessor); } else { - s.saveFromSelection(r, data.name, true, data.overwrite, data.entities, data.empty, componentAccessor); + s.saveFromSelection(r, data.name, true, data.overwrite, data.entities, data.empty, playerAnchor, componentAccessor); } }); break; @@ -78,12 +86,24 @@ public class PrefabSavePage extends InteractiveCustomUIPage ref, @Nonnull Store store, boolean usePlayerAnchor) { + if (!usePlayerAnchor) { + return null; + } else { + TransformComponent transformComponent = store.getComponent(ref, TransformComponent.getComponentType()); + if (transformComponent == null) { + return null; + } else { + Vector3d position = transformComponent.getPosition(); + return new Vector3i(MathUtil.floor(position.getX()), MathUtil.floor(position.getY()), MathUtil.floor(position.getZ())); + } + } + } + public static enum Action { Save, Cancel; - - private Action() { - } } protected static class PageData { @@ -92,6 +112,7 @@ public class PrefabSavePage extends InteractiveCustomUIPage CODEC = BuilderCodec.builder(PrefabSavePage.PageData.class, PrefabSavePage.PageData::new) .append( new KeyedCodec<>("Action", new EnumCodec<>(PrefabSavePage.Action.class, EnumCodec.EnumStyle.LEGACY)), @@ -109,6 +130,8 @@ public class PrefabSavePage extends InteractiveCustomUIPage("@FromClipboard", Codec.BOOLEAN), (o, fromClipboard) -> o.fromClipboard = fromClipboard, o -> o.fromClipboard) .add() + .append(new KeyedCodec<>("@UsePlayerAnchor", Codec.BOOLEAN), (o, usePlayerAnchor) -> o.usePlayerAnchor = usePlayerAnchor, o -> o.usePlayerAnchor) + .add() .build(); public PrefabSavePage.Action action; public String name; @@ -116,6 +139,7 @@ public class PrefabSavePage extends InteractiveCustomUIPage= 0) { edit.setBlock(x, y, z, blockId); diff --git a/src/com/hypixel/hytale/builtin/buildertools/scriptedbrushes/operations/sequential/LayerOperation.java b/src/com/hypixel/hytale/builtin/buildertools/scriptedbrushes/operations/sequential/LayerOperation.java index 0b083cb..192066c 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/scriptedbrushes/operations/sequential/LayerOperation.java +++ b/src/com/hypixel/hytale/builtin/buildertools/scriptedbrushes/operations/sequential/LayerOperation.java @@ -69,6 +69,10 @@ public class LayerOperation extends SequenceBrushOperation { for (LayerEntryCodec entry : this.layerArgs) { depthTestingAt += entry.getDepth(); if (depth < depthTestingAt) { + if (entry.isSkip()) { + return true; + } + int blockId = this.resolveBlockId(entry, toolArgs, brushConfig); if (blockId >= 0) { edit.setBlock(x, y, z, blockId); diff --git a/src/com/hypixel/hytale/builtin/buildertools/scriptedbrushes/operations/sequential/flowcontrol/JumpIfBlockTypeOperation.java b/src/com/hypixel/hytale/builtin/buildertools/scriptedbrushes/operations/sequential/flowcontrol/JumpIfBlockTypeOperation.java index 5975f3d..33ddfa2 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/scriptedbrushes/operations/sequential/flowcontrol/JumpIfBlockTypeOperation.java +++ b/src/com/hypixel/hytale/builtin/buildertools/scriptedbrushes/operations/sequential/flowcontrol/JumpIfBlockTypeOperation.java @@ -6,27 +6,16 @@ import com.hypixel.hytale.builtin.buildertools.scriptedbrushes.operations.system import com.hypixel.hytale.codec.Codec; import com.hypixel.hytale.codec.KeyedCodec; import com.hypixel.hytale.codec.builder.BuilderCodec; -import com.hypixel.hytale.codec.codecs.array.ArrayCodec; import com.hypixel.hytale.component.ComponentAccessor; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.math.vector.Vector3i; -import com.hypixel.hytale.server.core.command.system.arguments.types.RelativeVector3i; import com.hypixel.hytale.server.core.prefab.selection.mask.BlockMask; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; -import java.util.Arrays; -import java.util.List; import javax.annotation.Nonnull; public class JumpIfBlockTypeOperation extends SequenceBrushOperation { public static final BuilderCodec CODEC = BuilderCodec.builder(JumpIfBlockTypeOperation.class, JumpIfBlockTypeOperation::new) - .append( - new KeyedCodec<>("Offset", new ArrayCodec<>(RelativeVector3i.CODEC, RelativeVector3i[]::new)), - (op, val) -> op.offsetListArg = val != null ? Arrays.asList(val) : List.of(), - op -> op.offsetListArg.toArray(new RelativeVector3i[0]) - ) - .documentation("The offset(s) to compare from. In 3 dimensions. Each value is optionally relative by prefixing it with a tilde.") - .add() - .append(new KeyedCodec<>("Mask", BlockMask.CODEC), (op, val) -> op.blockMaskArg = val, op -> op.blockMaskArg) + .append(new KeyedCodec<>("Mask", BlockMask.CODEC), (op, val) -> op.blockMaskArg = val, op -> op.blockMaskArg) .documentation("The block mask for the comparison.") .add() .append(new KeyedCodec<>("StoredIndexName", Codec.STRING), (op, val) -> op.indexVariableNameArg = val, op -> op.indexVariableNameArg) @@ -35,8 +24,6 @@ public class JumpIfBlockTypeOperation extends SequenceBrushOperation { .documentation("Jump the execution of the stack based on a block type comparison") .build(); @Nonnull - public List offsetListArg = List.of(); - @Nonnull public BlockMask blockMaskArg = BlockMask.EMPTY; @Nonnull public String indexVariableNameArg = "Undefined"; @@ -52,28 +39,24 @@ public class JumpIfBlockTypeOperation extends SequenceBrushOperation { @Nonnull BrushConfigCommandExecutor brushConfigCommandExecutor, @Nonnull ComponentAccessor componentAccessor ) { - Vector3i currentBrushOrigin = brushConfig.getOriginAfterOffset(); + Vector3i currentBrushOrigin = brushConfig.getOrigin(); if (currentBrushOrigin == null) { brushConfig.setErrorFlag("Could not find the origin for the operation."); } else { - for (RelativeVector3i offset : this.offsetListArg) { - Vector3i brushOriginAfterOffset = offset.resolve(currentBrushOrigin); - int targetBlockId = brushConfigCommandExecutor.getEdit().getBlock(brushOriginAfterOffset.x, brushOriginAfterOffset.y, brushOriginAfterOffset.z); - int targetFluidId = brushConfigCommandExecutor.getEdit().getFluid(brushOriginAfterOffset.x, brushOriginAfterOffset.y, brushOriginAfterOffset.z); - if (!this.blockMaskArg - .isExcluded( - brushConfigCommandExecutor.getEdit().getAccessor(), - brushOriginAfterOffset.x, - brushOriginAfterOffset.y, - brushOriginAfterOffset.z, - null, - null, - targetBlockId, - targetFluidId - )) { - brushConfigCommandExecutor.loadOperatingIndex(this.indexVariableNameArg); - return; - } + int targetBlockId = brushConfigCommandExecutor.getEdit().getBlock(currentBrushOrigin.x, currentBrushOrigin.y, currentBrushOrigin.z); + int targetFluidId = brushConfigCommandExecutor.getEdit().getFluid(currentBrushOrigin.x, currentBrushOrigin.y, currentBrushOrigin.z); + if (!this.blockMaskArg + .isExcluded( + brushConfigCommandExecutor.getEdit().getAccessor(), + currentBrushOrigin.x, + currentBrushOrigin.y, + currentBrushOrigin.z, + null, + null, + targetBlockId, + targetFluidId + )) { + brushConfigCommandExecutor.loadOperatingIndex(this.indexVariableNameArg); } } } diff --git a/src/com/hypixel/hytale/builtin/buildertools/scriptedbrushes/operations/sequential/flowcontrol/JumpIfClickType.java b/src/com/hypixel/hytale/builtin/buildertools/scriptedbrushes/operations/sequential/flowcontrol/JumpIfClickType.java index 3e4f0c6..aad9fce 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/scriptedbrushes/operations/sequential/flowcontrol/JumpIfClickType.java +++ b/src/com/hypixel/hytale/builtin/buildertools/scriptedbrushes/operations/sequential/flowcontrol/JumpIfClickType.java @@ -51,8 +51,5 @@ public class JumpIfClickType extends SequenceBrushOperation { public static enum ClickType { Left, Right; - - private ClickType() { - } } } diff --git a/src/com/hypixel/hytale/builtin/buildertools/scriptedbrushes/operations/sequential/flowcontrol/JumpIfToolArgOperation.java b/src/com/hypixel/hytale/builtin/buildertools/scriptedbrushes/operations/sequential/flowcontrol/JumpIfToolArgOperation.java index 8da06b4..5b3d532 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/scriptedbrushes/operations/sequential/flowcontrol/JumpIfToolArgOperation.java +++ b/src/com/hypixel/hytale/builtin/buildertools/scriptedbrushes/operations/sequential/flowcontrol/JumpIfToolArgOperation.java @@ -122,8 +122,5 @@ public class JumpIfToolArgOperation extends SequenceBrushOperation { Equals, NotEquals, Contains; - - private ComparisonType() { - } } } diff --git a/src/com/hypixel/hytale/builtin/buildertools/scriptedbrushes/ui/ScriptedBrushPage.java b/src/com/hypixel/hytale/builtin/buildertools/scriptedbrushes/ui/ScriptedBrushPage.java index 88037b3..24b2de9 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/scriptedbrushes/ui/ScriptedBrushPage.java +++ b/src/com/hypixel/hytale/builtin/buildertools/scriptedbrushes/ui/ScriptedBrushPage.java @@ -31,9 +31,6 @@ import java.util.stream.Collectors; import javax.annotation.Nonnull; public class ScriptedBrushPage extends InteractiveCustomUIPage { - private static final Message MESSAGE_BRUSH_LOADED = Message.translation("server.commands.brushConfig.loaded"); - private static final Message MESSAGE_BRUSH_NOT_FOUND = Message.translation("server.commands.brushConfig.load.error.notFound"); - private static final Message MESSAGE_BRUSH_LOAD_ERROR = Message.translation("server.commands.brushConfig.load.error.loadFailed"); @Nonnull private final ServerFileBrowser browser; @@ -86,7 +83,7 @@ public class ScriptedBrushPage extends InteractiveCustomUIPage getFiles(@Nonnull Path currentDir, @Nonnull String searchQuery) { @@ -124,7 +120,7 @@ public class ScriptedBrushPage extends InteractiveCustomUIPage 0) { - results.add(new FileListProvider.FileEntry(name, name, false, score)); + results.add(new FileListProvider.FileEntry(name, name, false, false, score)); } } diff --git a/src/com/hypixel/hytale/builtin/buildertools/tooloperations/LayersOperation.java b/src/com/hypixel/hytale/builtin/buildertools/tooloperations/LayersOperation.java index a4d3231..53bbd6f 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/tooloperations/LayersOperation.java +++ b/src/com/hypixel/hytale/builtin/buildertools/tooloperations/LayersOperation.java @@ -26,6 +26,9 @@ public class LayersOperation extends ToolOperation { private boolean failed; private final int layerTwoDepthEnd; private final int layerThreeDepthEnd; + private final boolean skipLayerOne; + private final boolean skipLayerTwo; + private final boolean skipLayerThree; public LayersOperation( @Nonnull Ref ref, @@ -74,6 +77,9 @@ public class LayersOperation extends ToolOperation { this.layerThreeBlockPattern = (BlockPattern)this.args.tool().get("iLayerThreeMaterial"); this.enableLayerTwo = (Boolean)this.args.tool().get("dEnableLayerTwo"); this.enableLayerThree = (Boolean)this.args.tool().get("gEnableLayerThree"); + this.skipLayerOne = (Boolean)this.args.tool().getOrDefault("kSkipLayerOne", false); + this.skipLayerTwo = (Boolean)this.args.tool().getOrDefault("lSkipLayerTwo", false); + this.skipLayerThree = (Boolean)this.args.tool().getOrDefault("mSkipLayerThree", false); this.maxDepthNecessary = this.layerOneLength + (this.enableLayerTwo ? this.layerTwoLength : 0) + (this.enableLayerThree ? this.layerThreeLength : 0); this.layerTwoDepthEnd = this.layerOneLength + this.layerTwoLength; this.layerThreeDepthEnd = this.layerTwoDepthEnd + this.layerThreeLength; @@ -139,13 +145,22 @@ public class LayersOperation extends ToolOperation { public boolean attemptSetBlock(int x, int y, int z, int depth) { if (depth < this.layerOneLength) { - this.edit.setBlock(x, y, z, this.layerOneBlockPattern.nextBlock(this.random)); + if (!this.skipLayerOne) { + this.edit.setBlock(x, y, z, this.layerOneBlockPattern.nextBlock(this.random)); + } + return true; - } else if (this.enableLayerTwo && depth < this.layerTwoDepthEnd && !this.layerThreeBlockPattern.isEmpty()) { - this.edit.setBlock(x, y, z, this.layerTwoBlockPattern.nextBlock(this.random)); + } else if (this.enableLayerTwo && depth < this.layerTwoDepthEnd) { + if (!this.skipLayerTwo && !this.layerTwoBlockPattern.isEmpty()) { + this.edit.setBlock(x, y, z, this.layerTwoBlockPattern.nextBlock(this.random)); + } + return true; - } else if (this.enableLayerThree && depth < this.layerThreeDepthEnd && !this.layerThreeBlockPattern.isEmpty()) { - this.edit.setBlock(x, y, z, this.layerThreeBlockPattern.nextBlock(this.random)); + } else if (this.enableLayerThree && depth < this.layerThreeDepthEnd) { + if (!this.skipLayerThree && !this.layerThreeBlockPattern.isEmpty()) { + this.edit.setBlock(x, y, z, this.layerThreeBlockPattern.nextBlock(this.random)); + } + return true; } else { return false; diff --git a/src/com/hypixel/hytale/builtin/buildertools/tooloperations/TintOperation.java b/src/com/hypixel/hytale/builtin/buildertools/tooloperations/TintOperation.java index 498bbbe..6f62b32 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/tooloperations/TintOperation.java +++ b/src/com/hypixel/hytale/builtin/buildertools/tooloperations/TintOperation.java @@ -31,7 +31,12 @@ public class TintOperation extends ToolOperation { @Override public void execute(ComponentAccessor componentAccessor) { - this.builderState.tint(this.x, this.y, this.z, this.tintColor, this.shape, this.shapeRange, componentAccessor); + this.builderState.tint(this.x, this.y, this.z, this.tintColor, this.shape, this.shapeRange, this.shapeHeight, componentAccessor); + } + + @Override + public void executeAt(int posX, int posY, int posZ, ComponentAccessor componentAccessor) { + this.builderState.tint(posX, posY, posZ, this.tintColor, this.shape, this.shapeRange, this.shapeHeight, componentAccessor); } @Override diff --git a/src/com/hypixel/hytale/builtin/buildertools/utils/PasteToolUtil.java b/src/com/hypixel/hytale/builtin/buildertools/utils/PasteToolUtil.java new file mode 100644 index 0000000..2b3e367 --- /dev/null +++ b/src/com/hypixel/hytale/builtin/buildertools/utils/PasteToolUtil.java @@ -0,0 +1,71 @@ +package com.hypixel.hytale.builtin.buildertools.utils; + +import com.hypixel.hytale.protocol.packets.inventory.SetActiveSlot; +import com.hypixel.hytale.server.core.entity.entities.Player; +import com.hypixel.hytale.server.core.inventory.Inventory; +import com.hypixel.hytale.server.core.inventory.ItemStack; +import com.hypixel.hytale.server.core.inventory.container.ItemContainer; +import com.hypixel.hytale.server.core.universe.PlayerRef; +import javax.annotation.Nonnull; + +public final class PasteToolUtil { + private static final String PASTE_TOOL_ID = "EditorTool_Paste"; + + private PasteToolUtil() { + } + + public static void switchToPasteTool(@Nonnull Player player, @Nonnull PlayerRef playerRef) { + Inventory inventory = player.getInventory(); + ItemContainer hotbar = inventory.getHotbar(); + ItemContainer storage = inventory.getStorage(); + ItemContainer tools = inventory.getTools(); + int hotbarSize = hotbar.getCapacity(); + + for (short slot = 0; slot < hotbarSize; slot++) { + ItemStack itemStack = hotbar.getItemStack(slot); + if (itemStack != null && !itemStack.isEmpty() && "EditorTool_Paste".equals(itemStack.getItemId())) { + inventory.setActiveHotbarSlot((byte)slot); + playerRef.getPacketHandler().writeNoCache(new SetActiveSlot(-1, (byte)slot)); + return; + } + } + + short emptySlot = -1; + + for (short slotx = 0; slotx < hotbarSize; slotx++) { + ItemStack itemStack = hotbar.getItemStack(slotx); + if (itemStack == null || itemStack.isEmpty()) { + emptySlot = slotx; + break; + } + } + + if (emptySlot != -1) { + for (short slotxx = 0; slotxx < storage.getCapacity(); slotxx++) { + ItemStack itemStack = storage.getItemStack(slotxx); + if (itemStack != null && !itemStack.isEmpty() && "EditorTool_Paste".equals(itemStack.getItemId())) { + storage.moveItemStackFromSlotToSlot(slotxx, 1, hotbar, emptySlot); + inventory.setActiveHotbarSlot((byte)emptySlot); + playerRef.getPacketHandler().writeNoCache(new SetActiveSlot(-1, (byte)emptySlot)); + return; + } + } + + ItemStack pasteToolStack = null; + + for (short slotxxx = 0; slotxxx < tools.getCapacity(); slotxxx++) { + ItemStack itemStack = tools.getItemStack(slotxxx); + if (itemStack != null && !itemStack.isEmpty() && "EditorTool_Paste".equals(itemStack.getItemId())) { + pasteToolStack = itemStack; + break; + } + } + + if (pasteToolStack != null) { + hotbar.setItemStackForSlot(emptySlot, new ItemStack(pasteToolStack.getItemId())); + inventory.setActiveHotbarSlot((byte)emptySlot); + playerRef.getPacketHandler().writeNoCache(new SetActiveSlot(-1, (byte)emptySlot)); + } + } + } +} diff --git a/src/com/hypixel/hytale/builtin/buildertools/utils/RecursivePrefabLoader.java b/src/com/hypixel/hytale/builtin/buildertools/utils/RecursivePrefabLoader.java index 7b6d3e6..9eeaa06 100644 --- a/src/com/hypixel/hytale/builtin/buildertools/utils/RecursivePrefabLoader.java +++ b/src/com/hypixel/hytale/builtin/buildertools/utils/RecursivePrefabLoader.java @@ -171,9 +171,6 @@ public abstract class RecursivePrefabLoader implements BiFunction extends ArrayList implements Consumer { - protected DistinctCollector() { - } - @Override public void accept(T t) { if (!this.contains(t)) { diff --git a/src/com/hypixel/hytale/builtin/commandmacro/MacroCommandBuilder.java b/src/com/hypixel/hytale/builtin/commandmacro/MacroCommandBuilder.java index 6b98e79..affae38 100644 --- a/src/com/hypixel/hytale/builtin/commandmacro/MacroCommandBuilder.java +++ b/src/com/hypixel/hytale/builtin/commandmacro/MacroCommandBuilder.java @@ -44,9 +44,6 @@ public class MacroCommandBuilder implements JsonAssetWithMap entityStoreRegistry = this.getEntityStoreRegistry(); this.craftingManagerComponentType = entityStoreRegistry.registerComponent(CraftingManager.class, CraftingManager::new); - entityStoreRegistry.registerSystem(new PlayerCraftingSystems.PlayerCraftingSystem(this.craftingManagerComponentType)); - entityStoreRegistry.registerSystem(new PlayerCraftingSystems.CraftingManagerAddSystem(this.craftingManagerComponentType)); + entityStoreRegistry.registerSystem(new PlayerCraftingSystems.CraftingTickingSystem(this.craftingManagerComponentType)); + entityStoreRegistry.registerSystem(new PlayerCraftingSystems.CraftingHolderSystem(this.craftingManagerComponentType)); + entityStoreRegistry.registerSystem(new PlayerCraftingSystems.CraftingRefSystem(this.craftingManagerComponentType)); this.getCodecRegistry(Interaction.CODEC) .register("OpenBenchPage", OpenBenchPageInteraction.class, OpenBenchPageInteraction.CODEC) .register("OpenProcessingBench", OpenProcessingBenchInteraction.class, OpenProcessingBenchInteraction.CODEC); @@ -323,9 +324,6 @@ public class CraftingPlugin extends JavaPlugin { public static class PlayerAddedSystem extends RefSystem { private static final Query QUERY = Archetype.of(Player.getComponentType(), PlayerRef.getComponentType()); - public PlayerAddedSystem() { - } - @Override public Query getQuery() { return QUERY; diff --git a/src/com/hypixel/hytale/builtin/crafting/component/CraftingManager.java b/src/com/hypixel/hytale/builtin/crafting/component/CraftingManager.java index 45eae1a..ab29b79 100644 --- a/src/com/hypixel/hytale/builtin/crafting/component/CraftingManager.java +++ b/src/com/hypixel/hytale/builtin/crafting/component/CraftingManager.java @@ -37,6 +37,7 @@ import com.hypixel.hytale.server.core.entity.entities.player.data.PlayerConfigDa import com.hypixel.hytale.server.core.entity.entities.player.windows.MaterialExtraResourcesSection; import com.hypixel.hytale.server.core.event.events.ecs.CraftRecipeEvent; import com.hypixel.hytale.server.core.event.events.player.PlayerCraftEvent; +import com.hypixel.hytale.server.core.inventory.Inventory; import com.hypixel.hytale.server.core.inventory.ItemStack; import com.hypixel.hytale.server.core.inventory.MaterialQuantity; import com.hypixel.hytale.server.core.inventory.container.CombinedItemContainer; @@ -129,8 +130,8 @@ public class CraftingManager implements Component { } } - public boolean clearBench(@Nonnull Ref ref, @Nonnull Store store) { - boolean result = this.cancelAllCrafting(ref, store); + public boolean clearBench(@Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor) { + boolean result = this.cancelAllCrafting(ref, componentAccessor); this.x = 0; this.y = 0; this.z = 0; @@ -141,7 +142,7 @@ public class CraftingManager implements Component { public boolean craftItem( @Nonnull Ref ref, - @Nonnull ComponentAccessor store, + @Nonnull ComponentAccessor componentAccessor, @Nonnull CraftingRecipe recipe, int quantity, @Nonnull ItemContainer itemContainer @@ -151,37 +152,40 @@ public class CraftingManager implements Component { } else { Objects.requireNonNull(recipe, "Recipe can't be null"); CraftRecipeEvent.Pre preEvent = new CraftRecipeEvent.Pre(recipe, quantity); - store.invoke(ref, preEvent); + componentAccessor.invoke(ref, preEvent); if (preEvent.isCancelled()) { return false; - } else if (!this.isValidBenchForRecipe(ref, store, recipe)) { + } else if (!this.isValidBenchForRecipe(ref, componentAccessor, recipe)) { return false; } else { - World world = store.getExternalData().getWorld(); - Player playerComponent = store.getComponent(ref, Player.getComponentType()); + World world = componentAccessor.getExternalData().getWorld(); + Player playerComponent = componentAccessor.getComponent(ref, Player.getComponentType()); assert playerComponent != null; if (playerComponent.getGameMode() != GameMode.Creative && !removeInputFromInventory(itemContainer, recipe, quantity)) { - PlayerRef playerRefComponent = store.getComponent(ref, PlayerRef.getComponentType()); + PlayerRef playerRefComponent = componentAccessor.getComponent(ref, PlayerRef.getComponentType()); assert playerRefComponent != null; String translationKey = getRecipeOutputTranslationKey(recipe); - NotificationUtil.sendNotification( - playerRefComponent.getPacketHandler(), - Message.translation("server.general.crafting.missingIngredient").param("item", Message.translation(translationKey)), - NotificationStyle.Danger - ); + if (translationKey != null) { + NotificationUtil.sendNotification( + playerRefComponent.getPacketHandler(), + Message.translation("server.general.crafting.missingIngredient").param("item", Message.translation(translationKey)), + NotificationStyle.Danger + ); + } + LOGGER.at(Level.FINE).log("Missing items required to craft the item: %s", recipe); return false; } else { CraftRecipeEvent.Post postEvent = new CraftRecipeEvent.Post(recipe, quantity); - store.invoke(ref, postEvent); + componentAccessor.invoke(ref, postEvent); if (postEvent.isCancelled()) { return true; } else { - giveOutput(ref, store, recipe, quantity); + giveOutput(ref, componentAccessor, recipe, quantity); IEventDispatcher dispatcher = HytaleServer.get() .getEventBus() .dispatchFor(PlayerCraftEvent.class, world.getName()); @@ -196,15 +200,20 @@ public class CraftingManager implements Component { } } - private static String getRecipeOutputTranslationKey(CraftingRecipe recipe) { + @Nullable + private static String getRecipeOutputTranslationKey(@Nonnull CraftingRecipe recipe) { String itemId = recipe.getPrimaryOutput().getItemId(); - Item item = Item.getAssetMap().getAsset(itemId); - return item != null ? item.getTranslationKey() : null; + if (itemId == null) { + return null; + } else { + Item itemAsset = Item.getAssetMap().getAsset(itemId); + return itemAsset != null ? itemAsset.getTranslationKey() : null; + } } public boolean queueCraft( @Nonnull Ref ref, - @Nonnull ComponentAccessor store, + @Nonnull ComponentAccessor componentAccessor, @Nonnull CraftingWindow window, int transactionId, @Nonnull CraftingRecipe recipe, @@ -216,12 +225,12 @@ public class CraftingManager implements Component { return false; } else { Objects.requireNonNull(recipe, "Recipe can't be null"); - if (!this.isValidBenchForRecipe(ref, store, recipe)) { + if (!this.isValidBenchForRecipe(ref, componentAccessor, recipe)) { return false; } else { float recipeTime = recipe.getTimeSeconds(); if (recipeTime > 0.0F) { - int level = this.getBenchTierLevel(store); + int level = this.getBenchTierLevel(componentAccessor); if (level > 1) { BenchTierLevel tierLevelData = this.getBenchTierLevelData(level); if (tierLevelData != null) { @@ -237,7 +246,7 @@ public class CraftingManager implements Component { } } - public void tick(@Nonnull Ref ref, @Nonnull ComponentAccessor store, float dt) { + public void tick(@Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor, float dt) { if (this.upgradingJob != null) { if (dt > 0.0F) { this.upgradingJob.timeSecondsCompleted += dt; @@ -245,15 +254,15 @@ public class CraftingManager implements Component { this.upgradingJob.window.updateBenchUpgradeJob(this.upgradingJob.computeLoadingPercent()); if (this.upgradingJob.timeSecondsCompleted >= this.upgradingJob.timeSeconds) { - this.upgradingJob.window.updateBenchTierLevel(this.finishTierUpgrade(ref, store)); + this.upgradingJob.window.updateBenchTierLevel(this.finishTierUpgrade(ref, componentAccessor)); this.upgradingJob = null; } } else { - Player playerComponent = store.getComponent(ref, Player.getComponentType()); + Player playerComponent = componentAccessor.getComponent(ref, Player.getComponentType()); assert playerComponent != null; - PlayerRef playerRefComponent = store.getComponent(ref, PlayerRef.getComponentType()); + PlayerRef playerRefComponent = componentAccessor.getComponent(ref, PlayerRef.getComponentType()); assert playerRefComponent != null; @@ -265,11 +274,14 @@ public class CraftingManager implements Component { int currentItemId = currentJob.quantityStarted++; if (!isCreativeMode && !removeInputFromInventory(currentJob, currentItemId)) { String translationKey = getRecipeOutputTranslationKey(currentJob.recipe); - NotificationUtil.sendNotification( - playerRefComponent.getPacketHandler(), - Message.translation("server.general.crafting.missingIngredient").param("item", Message.translation(translationKey)), - NotificationStyle.Danger - ); + if (translationKey != null) { + NotificationUtil.sendNotification( + playerRefComponent.getPacketHandler(), + Message.translation("server.general.crafting.missingIngredient").param("item", Message.translation(translationKey)), + NotificationStyle.Danger + ); + } + LOGGER.at(Level.FINE).log("Missing items required to craft the item: %s", currentJob); currentJob = null; this.queuedCraftingJobs.poll(); @@ -306,7 +318,7 @@ public class CraftingManager implements Component { currentJob.timeSecondsCompleted = 0.0F; LOGGER.at(Level.FINE).log("Crafted 1 Quantity: %s", currentJob); if (currentJob.quantityCompleted == currentJob.quantity) { - giveOutput(ref, store, currentJob, currentCompletedItemId); + giveOutput(ref, componentAccessor, currentJob, currentCompletedItemId); LOGGER.at(Level.FINE).log("Crafting Finished: %s", currentJob); this.queuedCraftingJobs.poll(); } else { @@ -315,11 +327,11 @@ public class CraftingManager implements Component { throw new RuntimeException("QuantityCompleted is greater than the Quality! " + currentJob); } - giveOutput(ref, store, currentJob, currentCompletedItemId); + giveOutput(ref, componentAccessor, currentJob, currentCompletedItemId); } if (this.queuedCraftingJobs.isEmpty()) { - currentJob.window.setBlockInteractionState("default", store.getExternalData().getWorld(), 6); + currentJob.window.setBlockInteractionState("default", componentAccessor.getExternalData().getWorld()); } } } @@ -327,29 +339,31 @@ public class CraftingManager implements Component { } } - public boolean cancelAllCrafting(@Nonnull Ref ref, @Nonnull ComponentAccessor store) { + public boolean cancelAllCrafting(@Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor) { LOGGER.at(Level.FINE).log("Cancel Crafting!"); ObjectList oldJobs = new ObjectArrayList<>(this.queuedCraftingJobs.size()); this.queuedCraftingJobs.drainTo(oldJobs); if (!oldJobs.isEmpty()) { CraftingManager.CraftingJob currentJob = oldJobs.getFirst(); LOGGER.at(Level.FINE).log("Refunding Items for: %s", currentJob); - refundInputToInventory(ref, store, currentJob, currentJob.quantityStarted - 1); + refundInputToInventory(ref, componentAccessor, currentJob, currentJob.quantityStarted - 1); return true; } else { return false; } } - private boolean isValidBenchForRecipe(@Nonnull Ref ref, @Nonnull ComponentAccessor store, @Nonnull CraftingRecipe recipe) { - Player playerComponent = store.getComponent(ref, Player.getComponentType()); + private boolean isValidBenchForRecipe( + @Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor, @Nonnull CraftingRecipe recipe + ) { + Player playerComponent = componentAccessor.getComponent(ref, Player.getComponentType()); assert playerComponent != null; PlayerConfigData playerConfigData = playerComponent.getPlayerConfigData(); String primaryOutputItemId = recipe.getPrimaryOutput() != null ? recipe.getPrimaryOutput().getItemId() : null; if (!recipe.isKnowledgeRequired() || primaryOutputItemId != null && playerConfigData.getKnownRecipes().contains(primaryOutputItemId)) { - World world = store.getExternalData().getWorld(); + World world = componentAccessor.getExternalData().getWorld(); if (recipe.getRequiredMemoriesLevel() > 1 && MemoriesPlugin.get().getMemoriesLevel(world.getGameplayConfig()) < recipe.getRequiredMemoriesLevel()) { LOGGER.at(Level.WARNING).log("Attempted to craft %s but doesn't have the required world memories level!", recipe.getId()); return false; @@ -387,7 +401,7 @@ public class CraftingManager implements Component { } private static void giveOutput( - @Nonnull Ref ref, @Nonnull ComponentAccessor store, @Nonnull CraftingManager.CraftingJob job, int currentItemId + @Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor, @Nonnull CraftingManager.CraftingJob job, int currentItemId ) { job.removedItems.remove(currentItemId); String recipeId = job.recipe.getId(); @@ -395,16 +409,21 @@ public class CraftingManager implements Component { if (recipeAsset == null) { throw new RuntimeException("A non-existent item ID was provided! " + recipeId); } else { - giveOutput(ref, store, recipeAsset, 1); + giveOutput(ref, componentAccessor, recipeAsset, 1); } } private static void giveOutput( - @Nonnull Ref ref, @Nonnull ComponentAccessor store, @Nonnull CraftingRecipe craftingRecipe, int quantity + @Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor, @Nonnull CraftingRecipe craftingRecipe, int quantity ) { - Player player = store.getComponent(ref, Player.getComponentType()); - List itemStacks = getOutputItemStacks(craftingRecipe, quantity); - SimpleItemContainer.addOrDropItemStacks(store, ref, player.getInventory().getCombinedArmorHotbarStorage(), itemStacks); + Player playerComponent = componentAccessor.getComponent(ref, Player.getComponentType()); + if (playerComponent == null) { + LOGGER.at(Level.WARNING).log("Attempted to give output to a non-player entity: %s", ref); + } else { + List itemStacks = getOutputItemStacks(craftingRecipe, quantity); + Inventory inventory = playerComponent.getInventory(); + SimpleItemContainer.addOrDropItemStacks(componentAccessor, ref, inventory.getCombinedArmorHotbarStorage(), itemStacks); + } } private static boolean removeInputFromInventory(@Nonnull CraftingManager.CraftingJob job, int currentItemId) { @@ -464,13 +483,16 @@ public class CraftingManager implements Component { } private static void refundInputToInventory( - @Nonnull Ref ref, @Nonnull ComponentAccessor store, @Nonnull CraftingManager.CraftingJob job, int currentItemId + @Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor, @Nonnull CraftingManager.CraftingJob job, int currentItemId ) { Objects.requireNonNull(job, "Job can't be null!"); List itemStacks = job.removedItems.get(currentItemId); if (itemStacks != null) { - Player player = store.getComponent(ref, Player.getComponentType()); - SimpleItemContainer.addOrDropItemStacks(store, ref, player.getInventory().getCombinedHotbarFirst(), itemStacks); + Player playerComponent = componentAccessor.getComponent(ref, Player.getComponentType()); + + assert playerComponent != null; + + SimpleItemContainer.addOrDropItemStacks(componentAccessor, ref, playerComponent.getInventory().getCombinedHotbarFirst(), itemStacks); } } @@ -489,23 +511,30 @@ public class CraftingManager implements Component { ObjectList outputItemStacks = new ObjectArrayList<>(); for (MaterialQuantity outputMaterial : output) { - outputItemStacks.add(getOutputItemStack(outputMaterial, quantity)); + ItemStack outputItemStack = getOutputItemStack(outputMaterial, quantity); + if (outputItemStack != null) { + outputItemStacks.add(outputItemStack); + } } return outputItemStacks; } } - @Nonnull + @Nullable public static ItemStack getOutputItemStack(@Nonnull MaterialQuantity outputMaterial, @Nonnull String id) { return getOutputItemStack(outputMaterial, 1); } - @Nonnull + @Nullable public static ItemStack getOutputItemStack(@Nonnull MaterialQuantity outputMaterial, int quantity) { String itemId = outputMaterial.getItemId(); - int materialQuantity = outputMaterial.getQuantity() <= 0 ? 1 : outputMaterial.getQuantity(); - return new ItemStack(itemId, materialQuantity * quantity, outputMaterial.getMetadata()); + if (itemId == null) { + return null; + } else { + int materialQuantity = outputMaterial.getQuantity() <= 0 ? 1 : outputMaterial.getQuantity(); + return new ItemStack(itemId, materialQuantity * quantity, outputMaterial.getMetadata()); + } } @Nonnull @@ -547,7 +576,7 @@ public class CraftingManager implements Component { String resourceTypeId = craftingMaterial.getResourceTypeId(); if (resourceTypeId != null && itemStack.getItem().getResourceTypes() != null) { for (ItemResourceType itemResourceType : itemStack.getItem().getResourceTypes()) { - if (itemResourceType.id.equals(resourceTypeId)) { + if (resourceTypeId.equals(itemResourceType.id)) { return true; } } @@ -583,7 +612,7 @@ public class CraftingManager implements Component { if (slotCraftingMaterial.getResourceTypeId() != null && slotItemStack.getItem().getResourceTypes() != null) { for (ItemResourceType itemResourceType : slotItemStack.getItem().getResourceTypes()) { - if (itemResourceType.id.equals(slotCraftingMaterial.getResourceTypeId())) { + if (slotCraftingMaterial.getResourceTypeId().equals(itemResourceType.id)) { return true; } } @@ -594,11 +623,11 @@ public class CraftingManager implements Component { return false; } - public boolean startTierUpgrade(Ref ref, ComponentAccessor store, @Nonnull BenchWindow window) { + public boolean startTierUpgrade(@Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor, @Nonnull BenchWindow window) { if (this.upgradingJob != null) { return false; } else { - BenchUpgradeRequirement requirements = this.getBenchUpgradeRequierement(this.getBenchTierLevel(store)); + BenchUpgradeRequirement requirements = this.getBenchUpgradeRequirement(this.getBenchTierLevel(componentAccessor)); if (requirements == null) { return false; } else { @@ -606,10 +635,13 @@ public class CraftingManager implements Component { if (input.isEmpty()) { return false; } else { - Player player = store.getComponent(ref, Player.getComponentType()); - if (player.getGameMode() != GameMode.Creative) { + Player playerComponent = componentAccessor.getComponent(ref, Player.getComponentType()); + + assert playerComponent != null; + + if (playerComponent.getGameMode() != GameMode.Creative) { CombinedItemContainer combined = new CombinedItemContainer( - player.getInventory().getCombinedBackpackStorageHotbar(), window.getExtraResourcesSection().getItemContainer() + playerComponent.getInventory().getCombinedBackpackStorageHotbar(), window.getExtraResourcesSection().getItemContainer() ); if (!combined.canRemoveMaterials(input)) { return false; @@ -617,21 +649,22 @@ public class CraftingManager implements Component { } this.upgradingJob = new CraftingManager.BenchUpgradingJob(window, requirements.getTimeSeconds()); - this.cancelAllCrafting(ref, store); + this.cancelAllCrafting(ref, componentAccessor); return true; } } } } - private int finishTierUpgrade(Ref ref, ComponentAccessor store) { + private int finishTierUpgrade(@Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor) { if (this.upgradingJob == null) { return 0; } else { - BlockState state = store.getExternalData().getWorld().getState(this.x, this.y, this.z, true); + World world = componentAccessor.getExternalData().getWorld(); + BlockState state = world.getState(this.x, this.y, this.z, true); BenchState benchState = state instanceof BenchState ? (BenchState)state : null; if (benchState != null && benchState.getTierLevel() != 0) { - BenchUpgradeRequirement requirements = this.getBenchUpgradeRequierement(benchState.getTierLevel()); + BenchUpgradeRequirement requirements = this.getBenchUpgradeRequirement(benchState.getTierLevel()); if (requirements == null) { return benchState.getTierLevel(); } else { @@ -639,11 +672,15 @@ public class CraftingManager implements Component { if (input.isEmpty()) { return benchState.getTierLevel(); } else { - Player player = store.getComponent(ref, Player.getComponentType()); - boolean canUpgrade = player.getGameMode() == GameMode.Creative; + Player playerComponent = componentAccessor.getComponent(ref, Player.getComponentType()); + + assert playerComponent != null; + + boolean canUpgrade = playerComponent.getGameMode() == GameMode.Creative; if (!canUpgrade) { CombinedItemContainer combined = new CombinedItemContainer( - player.getInventory().getCombinedBackpackStorageHotbar(), this.upgradingJob.window.getExtraResourcesSection().getItemContainer() + playerComponent.getInventory().getCombinedBackpackStorageHotbar(), + this.upgradingJob.window.getExtraResourcesSection().getItemContainer() ); combined = new CombinedItemContainer(combined, this.upgradingJob.window.getExtraResourcesSection().getItemContainer()); ListTransaction materialTransactions = combined.removeMaterials(input); @@ -665,7 +702,12 @@ public class CraftingManager implements Component { benchState.setTierLevel(benchState.getTierLevel() + 1); if (benchState.getBench().getBenchUpgradeCompletedSoundEventIndex() != 0) { SoundUtil.playSoundEvent3d( - benchState.getBench().getBenchUpgradeCompletedSoundEventIndex(), SoundCategory.SFX, this.x + 0.5, this.y + 0.5, this.z + 0.5, store + benchState.getBench().getBenchUpgradeCompletedSoundEventIndex(), + SoundCategory.SFX, + this.x + 0.5, + this.y + 0.5, + this.z + 0.5, + componentAccessor ); } } @@ -679,6 +721,7 @@ public class CraftingManager implements Component { } } + @Nullable private BenchTierLevel getBenchTierLevelData(int level) { if (this.blockType == null) { return null; @@ -688,61 +731,22 @@ public class CraftingManager implements Component { } } - private BenchUpgradeRequirement getBenchUpgradeRequierement(int tierLevel) { + @Nullable + private BenchUpgradeRequirement getBenchUpgradeRequirement(int tierLevel) { BenchTierLevel tierData = this.getBenchTierLevelData(tierLevel); return tierData == null ? null : tierData.getUpgradeRequirement(); } - private int getBenchTierLevel(ComponentAccessor store) { - BlockState state = store.getExternalData().getWorld().getState(this.x, this.y, this.z, true); + private int getBenchTierLevel(@Nonnull ComponentAccessor componentAccessor) { + World world = componentAccessor.getExternalData().getWorld(); + BlockState state = world.getState(this.x, this.y, this.z, true); return state instanceof BenchState ? ((BenchState)state).getTierLevel() : 0; } - protected static List getContainersAroundBench(@Nonnull BenchState benchState) { - List containers = new ObjectArrayList<>(); - World world = benchState.getChunk().getWorld(); - Store store = world.getChunkStore().getStore(); - int limit = world.getGameplayConfig().getCraftingConfig().getBenchMaterialChestLimit(); - double horizontalRadius = world.getGameplayConfig().getCraftingConfig().getBenchMaterialHorizontalChestSearchRadius(); - double verticalRadius = world.getGameplayConfig().getCraftingConfig().getBenchMaterialVerticalChestSearchRadius(); - Vector3d blockPos = benchState.getBlockPosition().toVector3d(); - BlockBoundingBoxes hitboxAsset = BlockBoundingBoxes.getAssetMap().getAsset(benchState.getBlockType().getHitboxTypeIndex()); - BlockBoundingBoxes.RotatedVariantBoxes rotatedHitbox = hitboxAsset.get(benchState.getRotationIndex()); - Box boundingBox = rotatedHitbox.getBoundingBox(); - double benchWidth = boundingBox.width(); - double benchHeight = boundingBox.height(); - double benchDepth = boundingBox.depth(); - double extraSearchRadius = Math.max(benchWidth, Math.max(benchDepth, benchHeight)) - 1.0; - SpatialResource, ChunkStore> blockStateSpatialStructure = store.getResource(BlockStateModule.get().getItemContainerSpatialResourceType()); - ObjectList> results = SpatialResource.getThreadLocalReferenceList(); - blockStateSpatialStructure.getSpatialStructure() - .ordered3DAxis(blockPos, horizontalRadius + extraSearchRadius, verticalRadius + extraSearchRadius, horizontalRadius + extraSearchRadius, results); - if (!results.isEmpty()) { - double minX = blockPos.x + boundingBox.min.x - horizontalRadius; - double minY = blockPos.y + boundingBox.min.y - verticalRadius; - double minZ = blockPos.z + boundingBox.min.z - horizontalRadius; - double maxX = blockPos.x + boundingBox.max.x + horizontalRadius; - double maxY = blockPos.y + boundingBox.max.y + verticalRadius; - double maxZ = blockPos.z + boundingBox.max.z + horizontalRadius; - - for (Ref ref : results) { - if (BlockState.getBlockState(ref, ref.getStore()) instanceof ItemContainerState chest) { - Vector3d chestPos = chest.getCenteredBlockPosition(); - if (chestPos.x >= minX && chestPos.x <= maxX && chestPos.y >= minY && chestPos.y <= maxY && chestPos.z >= minZ && chestPos.z <= maxZ) { - containers.add(chest.getItemContainer()); - if (containers.size() >= limit) { - break; - } - } - } - } - } - - return containers; - } - - public static void feedExtraResourcesSection(BenchState benchState, MaterialExtraResourcesSection extraResourcesSection) { - List chests = getContainersAroundBench(benchState); + public static int feedExtraResourcesSection(@Nonnull BenchState benchState, @Nonnull MaterialExtraResourcesSection extraResourcesSection) { + CraftingManager.ChestLookupResult result = getContainersAroundBench(benchState); + List chests = result.containers; + List chestStates = result.states; ItemContainer itemContainer = EmptyItemContainer.INSTANCE; if (!chests.isEmpty()) { itemContainer = new CombinedItemContainer(chests.stream().map(container -> { @@ -766,6 +770,72 @@ public class CraftingManager implements Component { extraResourcesSection.setItemContainer(itemContainer); extraResourcesSection.setExtraMaterials(materials.values().toArray(new ItemQuantity[0])); extraResourcesSection.setValid(true); + return chestStates.size(); + } + + @Nonnull + protected static CraftingManager.ChestLookupResult getContainersAroundBench(@Nonnull BenchState benchState) { + List containers = new ObjectArrayList<>(); + List states = new ObjectArrayList<>(); + List spatialResults = new ObjectArrayList<>(); + List filteredOut = new ObjectArrayList<>(); + World world = benchState.getChunk().getWorld(); + Store store = world.getChunkStore().getStore(); + int limit = world.getGameplayConfig().getCraftingConfig().getBenchMaterialChestLimit(); + double horizontalRadius = world.getGameplayConfig().getCraftingConfig().getBenchMaterialHorizontalChestSearchRadius(); + double verticalRadius = world.getGameplayConfig().getCraftingConfig().getBenchMaterialVerticalChestSearchRadius(); + Vector3d blockPos = benchState.getBlockPosition().toVector3d(); + BlockBoundingBoxes hitboxAsset = BlockBoundingBoxes.getAssetMap().getAsset(benchState.getBlockType().getHitboxTypeIndex()); + BlockBoundingBoxes.RotatedVariantBoxes rotatedHitbox = hitboxAsset.get(benchState.getRotationIndex()); + Box boundingBox = rotatedHitbox.getBoundingBox(); + double benchWidth = boundingBox.width(); + double benchHeight = boundingBox.height(); + double benchDepth = boundingBox.depth(); + double extraSearchRadius = Math.max(benchWidth, Math.max(benchDepth, benchHeight)) - 1.0; + SpatialResource, ChunkStore> blockStateSpatialStructure = store.getResource(BlockStateModule.get().getItemContainerSpatialResourceType()); + ObjectList> results = SpatialResource.getThreadLocalReferenceList(); + blockStateSpatialStructure.getSpatialStructure() + .ordered3DAxis(blockPos, horizontalRadius + extraSearchRadius, verticalRadius + extraSearchRadius, horizontalRadius + extraSearchRadius, results); + if (!results.isEmpty()) { + int benchMinBlockX = (int)Math.floor(boundingBox.min.x); + int benchMinBlockY = (int)Math.floor(boundingBox.min.y); + int benchMinBlockZ = (int)Math.floor(boundingBox.min.z); + int benchMaxBlockX = (int)Math.ceil(boundingBox.max.x) - 1; + int benchMaxBlockY = (int)Math.ceil(boundingBox.max.y) - 1; + int benchMaxBlockZ = (int)Math.ceil(boundingBox.max.z) - 1; + double minX = blockPos.x + benchMinBlockX - horizontalRadius; + double minY = blockPos.y + benchMinBlockY - verticalRadius; + double minZ = blockPos.z + benchMinBlockZ - horizontalRadius; + double maxX = blockPos.x + benchMaxBlockX + horizontalRadius; + double maxY = blockPos.y + benchMaxBlockY + verticalRadius; + double maxZ = blockPos.z + benchMaxBlockZ + horizontalRadius; + + for (Ref ref : results) { + if (BlockState.getBlockState(ref, ref.getStore()) instanceof ItemContainerState chest) { + spatialResults.add(chest); + } + } + + for (ItemContainerState chest : spatialResults) { + Vector3d chestBlockPos = chest.getBlockPosition().toVector3d(); + if (chestBlockPos.x >= minX + && chestBlockPos.x <= maxX + && chestBlockPos.y >= minY + && chestBlockPos.y <= maxY + && chestBlockPos.z >= minZ + && chestBlockPos.z <= maxZ) { + containers.add(chest.getItemContainer()); + states.add(chest); + if (containers.size() >= limit) { + break; + } + } else { + filteredOut.add(chest); + } + } + } + + return new CraftingManager.ChestLookupResult(containers, states, spatialResults, filteredOut, blockPos); } @Nonnull @@ -812,6 +882,15 @@ public class CraftingManager implements Component { } } + protected record ChestLookupResult( + List containers, + List states, + List spatialResults, + List filteredOut, + Vector3d benchCenteredPos + ) { + } + private static class CraftingJob { @Nonnull private final CraftingWindow window; @@ -880,8 +959,5 @@ public class CraftingManager implements Component { public static enum InputRemovalType { NORMAL, ORDERED; - - private InputRemovalType() { - } } } diff --git a/src/com/hypixel/hytale/builtin/crafting/interaction/LearnRecipeInteraction.java b/src/com/hypixel/hytale/builtin/crafting/interaction/LearnRecipeInteraction.java index d026f55..e9f4f74 100644 --- a/src/com/hypixel/hytale/builtin/crafting/interaction/LearnRecipeInteraction.java +++ b/src/com/hypixel/hytale/builtin/crafting/interaction/LearnRecipeInteraction.java @@ -39,9 +39,6 @@ public class LearnRecipeInteraction extends SimpleInstantInteraction { @Nullable protected String itemId; - public LearnRecipeInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { diff --git a/src/com/hypixel/hytale/builtin/crafting/interaction/OpenBenchPageInteraction.java b/src/com/hypixel/hytale/builtin/crafting/interaction/OpenBenchPageInteraction.java index 5f64f08..3035294 100644 --- a/src/com/hypixel/hytale/builtin/crafting/interaction/OpenBenchPageInteraction.java +++ b/src/com/hypixel/hytale/builtin/crafting/interaction/OpenBenchPageInteraction.java @@ -2,6 +2,7 @@ package com.hypixel.hytale.builtin.crafting.interaction; import com.hypixel.hytale.builtin.crafting.component.CraftingManager; import com.hypixel.hytale.builtin.crafting.state.BenchState; +import com.hypixel.hytale.builtin.crafting.window.BenchWindow; import com.hypixel.hytale.builtin.crafting.window.DiagramCraftingWindow; import com.hypixel.hytale.builtin.crafting.window.SimpleCraftingWindow; import com.hypixel.hytale.builtin.crafting.window.StructuralCraftingWindow; @@ -16,14 +17,15 @@ import com.hypixel.hytale.math.vector.Vector3i; import com.hypixel.hytale.protocol.InteractionType; import com.hypixel.hytale.protocol.packets.interface_.Page; import com.hypixel.hytale.server.core.entity.InteractionContext; +import com.hypixel.hytale.server.core.entity.UUIDComponent; import com.hypixel.hytale.server.core.entity.entities.Player; -import com.hypixel.hytale.server.core.entity.entities.player.windows.Window; import com.hypixel.hytale.server.core.inventory.ItemStack; import com.hypixel.hytale.server.core.modules.interaction.interaction.CooldownHandler; import com.hypixel.hytale.server.core.modules.interaction.interaction.config.RootInteraction; import com.hypixel.hytale.server.core.modules.interaction.interaction.config.client.SimpleBlockInteraction; import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; +import java.util.UUID; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -85,11 +87,21 @@ public class OpenBenchPageInteraction extends SimpleBlockInteraction { if (!craftingManagerComponent.hasBenchSet()) { if (world.getState(targetBlock.x, targetBlock.y, targetBlock.z, true) instanceof BenchState benchState) { - playerComponent.getPageManager().setPageWithWindows(ref, store, Page.Bench, true, (Window)(switch (this.pageType) { + BenchWindow benchWindow = (BenchWindow)(switch (this.pageType) { case SIMPLE_CRAFTING -> new SimpleCraftingWindow(benchState); - case DIAGRAM_CRAFTING -> new DiagramCraftingWindow(commandBuffer, benchState); + case DIAGRAM_CRAFTING -> new DiagramCraftingWindow(ref, commandBuffer, benchState); case STRUCTURAL_CRAFTING -> new StructuralCraftingWindow(benchState); - })); + }); + UUIDComponent uuidComponent = commandBuffer.getComponent(ref, UUIDComponent.getComponentType()); + + assert uuidComponent != null; + + UUID uuid = uuidComponent.getUuid(); + if (benchState.getWindows().putIfAbsent(uuid, benchWindow) == null) { + benchWindow.registerCloseEvent(event -> benchState.getWindows().remove(uuid, benchWindow)); + } + + playerComponent.getPageManager().setPageWithWindows(ref, store, Page.Bench, true, benchWindow); } } } @@ -105,8 +117,5 @@ public class OpenBenchPageInteraction extends SimpleBlockInteraction { SIMPLE_CRAFTING, DIAGRAM_CRAFTING, STRUCTURAL_CRAFTING; - - private PageType() { - } } } diff --git a/src/com/hypixel/hytale/builtin/crafting/interaction/OpenProcessingBenchInteraction.java b/src/com/hypixel/hytale/builtin/crafting/interaction/OpenProcessingBenchInteraction.java index 0f6a051..7596b7c 100644 --- a/src/com/hypixel/hytale/builtin/crafting/interaction/OpenProcessingBenchInteraction.java +++ b/src/com/hypixel/hytale/builtin/crafting/interaction/OpenProcessingBenchInteraction.java @@ -1,6 +1,7 @@ package com.hypixel.hytale.builtin.crafting.interaction; import com.hypixel.hytale.builtin.crafting.state.ProcessingBenchState; +import com.hypixel.hytale.builtin.crafting.window.BenchWindow; import com.hypixel.hytale.builtin.crafting.window.ProcessingBenchWindow; import com.hypixel.hytale.codec.builder.BuilderCodec; import com.hypixel.hytale.component.CommandBuffer; @@ -38,9 +39,6 @@ public class OpenProcessingBenchInteraction extends SimpleBlockInteraction { .documentation("Opens the processing bench page.") .build(); - public OpenProcessingBenchInteraction() { - } - @Override protected void interactWithBlock( @Nonnull World world, @@ -77,7 +75,7 @@ public class OpenProcessingBenchInteraction extends SimpleBlockInteraction { UUID uuid = uuidComponent.getUuid(); ProcessingBenchWindow window = new ProcessingBenchWindow(benchState); - Map windows = benchState.getWindows(); + Map windows = benchState.getWindows(); if (windows.putIfAbsent(uuid, window) == null) { benchState.updateFuelValues(); if (playerComponent.getPageManager().setPageWithWindows(ref, store, Page.Bench, true, window)) { diff --git a/src/com/hypixel/hytale/builtin/crafting/state/BenchState.java b/src/com/hypixel/hytale/builtin/crafting/state/BenchState.java index 28af2a3..dc92c06 100644 --- a/src/com/hypixel/hytale/builtin/crafting/state/BenchState.java +++ b/src/com/hypixel/hytale/builtin/crafting/state/BenchState.java @@ -1,5 +1,6 @@ package com.hypixel.hytale.builtin.crafting.state; +import com.hypixel.hytale.builtin.crafting.window.BenchWindow; import com.hypixel.hytale.codec.Codec; import com.hypixel.hytale.codec.KeyedCodec; import com.hypixel.hytale.codec.builder.BuilderCodec; @@ -12,6 +13,7 @@ import com.hypixel.hytale.math.vector.Vector3f; import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType; import com.hypixel.hytale.server.core.asset.type.blocktype.config.bench.Bench; import com.hypixel.hytale.server.core.asset.type.blocktype.config.bench.BenchUpgradeRequirement; +import com.hypixel.hytale.server.core.entity.entities.player.windows.WindowManager; import com.hypixel.hytale.server.core.inventory.ItemStack; import com.hypixel.hytale.server.core.modules.entity.item.ItemComponent; import com.hypixel.hytale.server.core.universe.world.World; @@ -20,6 +22,9 @@ import com.hypixel.hytale.server.core.universe.world.meta.state.DestroyableBlock import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import java.util.Arrays; import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; import javax.annotation.Nonnull; public class BenchState extends BlockState implements DestroyableBlockState { @@ -42,9 +47,7 @@ public class BenchState extends BlockState implements DestroyableBlockState { private int tierLevel = 1; protected ItemStack[] upgradeItems = ItemStack.EMPTY_ARRAY; protected Bench bench; - - public BenchState() { - } + protected final Map windows = new ConcurrentHashMap<>(); public int getTierLevel() { return this.tierLevel; @@ -125,6 +128,12 @@ public class BenchState extends BlockState implements DestroyableBlockState { @Override public void onDestroy() { + WindowManager.closeAndRemoveAll(this.windows); this.dropUpgradeItems(); } + + @Nonnull + public Map getWindows() { + return this.windows; + } } diff --git a/src/com/hypixel/hytale/builtin/crafting/state/ProcessingBenchState.java b/src/com/hypixel/hytale/builtin/crafting/state/ProcessingBenchState.java index 331df03..726d4f3 100644 --- a/src/com/hypixel/hytale/builtin/crafting/state/ProcessingBenchState.java +++ b/src/com/hypixel/hytale/builtin/crafting/state/ProcessingBenchState.java @@ -31,7 +31,6 @@ import com.hypixel.hytale.server.core.asset.type.blocktype.config.bench.Processi import com.hypixel.hytale.server.core.asset.type.item.config.CraftingRecipe; import com.hypixel.hytale.server.core.asset.type.item.config.Item; import com.hypixel.hytale.server.core.entity.entities.Player; -import com.hypixel.hytale.server.core.entity.entities.player.windows.WindowManager; import com.hypixel.hytale.server.core.inventory.ItemStack; import com.hypixel.hytale.server.core.inventory.MaterialQuantity; import com.hypixel.hytale.server.core.inventory.ResourceQuantity; @@ -69,11 +68,9 @@ import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; import java.util.logging.Level; import javax.annotation.Nonnull; @@ -115,7 +112,6 @@ public class ProcessingBenchState public static final String PROCESSING = "Processing"; public static final String PROCESS_COMPLETED = "ProcessCompleted"; protected WorldMapManager.MarkerReference marker; - private final Map windows = new ConcurrentHashMap<>(); private ProcessingBench processingBench; private ItemContainer inputContainer; private ItemContainer fuelContainer; @@ -133,9 +129,6 @@ public class ProcessingBenchState private CraftingRecipe recipe; private boolean active = false; - public ProcessingBenchState() { - } - @Override public boolean initialize(@Nonnull BlockType blockType) { if (!super.initialize(blockType)) { @@ -588,15 +581,15 @@ public class ProcessingBenchState } private void sendProgress(float progress) { - this.windows.forEach((uuid, window) -> window.setProgress(progress)); + this.windows.forEach((uuid, window) -> ((ProcessingBenchWindow)window).setProgress(progress)); } private void sendProcessingSlots() { - this.windows.forEach((uuid, window) -> window.setProcessingSlots(this.processingSlots)); + this.windows.forEach((uuid, window) -> ((ProcessingBenchWindow)window).setProcessingSlots(this.processingSlots)); } private void sendProcessingFuelSlots() { - this.windows.forEach((uuid, window) -> window.setProcessingFuelSlots(this.processingFuelSlots)); + this.windows.forEach((uuid, window) -> ((ProcessingBenchWindow)window).setProcessingFuelSlots(this.processingFuelSlots)); } public boolean isActive() { @@ -617,7 +610,7 @@ public class ProcessingBenchState } this.updateRecipe(); - this.windows.forEach((uuid, window) -> window.setActive(active)); + this.windows.forEach((uuid, window) -> ((ProcessingBenchWindow)window).setActive(active)); this.markNeedsSave(); return true; } @@ -633,16 +626,16 @@ public class ProcessingBenchState float fuelPercent = this.lastConsumedFuelTotal > 0 ? this.fuelTime / this.lastConsumedFuelTotal : 0.0F; this.windows.forEach((uuid, window) -> { - window.setFuelTime(fuelPercent); - window.setMaxFuel(this.lastConsumedFuelTotal); - window.setProcessingFuelSlots(this.processingFuelSlots); + ProcessingBenchWindow processingBenchWindow = (ProcessingBenchWindow)window; + processingBenchWindow.setFuelTime(fuelPercent); + processingBenchWindow.setMaxFuel(this.lastConsumedFuelTotal); + processingBenchWindow.setProcessingFuelSlots(this.processingFuelSlots); }); } @Override public void onDestroy() { super.onDestroy(); - WindowManager.closeAndRemoveAll(this.windows); if (this.combinedItemContainer != null) { List itemStacks = this.combinedItemContainer.dropAllItemStacks(); this.dropFuelItems(itemStacks); @@ -770,11 +763,6 @@ public class ProcessingBenchState return this.recipe; } - @Nonnull - public Map getWindows() { - return this.windows; - } - public float getInputProgress() { return this.inputProgress; } diff --git a/src/com/hypixel/hytale/builtin/crafting/system/PlayerCraftingSystems.java b/src/com/hypixel/hytale/builtin/crafting/system/PlayerCraftingSystems.java index 5bd80e2..5ecc8c8 100644 --- a/src/com/hypixel/hytale/builtin/crafting/system/PlayerCraftingSystems.java +++ b/src/com/hypixel/hytale/builtin/crafting/system/PlayerCraftingSystems.java @@ -11,6 +11,7 @@ import com.hypixel.hytale.component.RemoveReason; import com.hypixel.hytale.component.Store; import com.hypixel.hytale.component.query.Query; import com.hypixel.hytale.component.system.HolderSystem; +import com.hypixel.hytale.component.system.RefSystem; import com.hypixel.hytale.component.system.tick.EntityTickingSystem; import com.hypixel.hytale.server.core.entity.entities.Player; import com.hypixel.hytale.server.core.universe.world.World; @@ -18,42 +19,30 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class PlayerCraftingSystems { - public PlayerCraftingSystems() { - } - - public static class CraftingManagerAddSystem extends HolderSystem { + public static class CraftingHolderSystem extends HolderSystem { + @Nonnull private final ComponentType playerComponentType = Player.getComponentType(); + @Nonnull private final ComponentType craftingManagerComponentType; - public CraftingManagerAddSystem(ComponentType craftingManagerComponentType) { + public CraftingHolderSystem(@Nonnull ComponentType craftingManagerComponentType) { this.craftingManagerComponentType = craftingManagerComponentType; } @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { - Player player = holder.getComponent(Player.getComponentType()); - if (player == null) { - throw new UnsupportedOperationException("Cannot have null player component during crafting system creation"); - } else { - holder.ensureComponent(this.craftingManagerComponentType); - } + holder.ensureComponent(this.craftingManagerComponentType); } @Override public void onEntityRemoved(@Nonnull Holder holder, @Nonnull RemoveReason reason, @Nonnull Store store) { - CraftingManager craftingManager = holder.getComponent(this.craftingManagerComponentType); - if (craftingManager != null) { - Player player = holder.getComponent(this.playerComponentType); + World world = store.getExternalData().getWorld(); + if (world.getWorldConfig().isSavingPlayers()) { + Player playerComponent = holder.getComponent(this.playerComponentType); - try { - Ref ref = player.getReference(); - craftingManager.cancelAllCrafting(ref, store); - } finally { - World world = store.getExternalData().getWorld(); - if (world.getWorldConfig().isSavingPlayers() && player != null) { - player.saveConfig(world, holder); - } - } + assert playerComponent != null; + + playerComponent.saveConfig(world, holder); } } @@ -64,10 +53,45 @@ public class PlayerCraftingSystems { } } - public static class PlayerCraftingSystem extends EntityTickingSystem { + public static class CraftingRefSystem extends RefSystem { + @Nonnull + private final ComponentType playerComponentType = Player.getComponentType(); + @Nonnull private final ComponentType craftingManagerComponentType; - public PlayerCraftingSystem(ComponentType craftingManagerComponentType) { + public CraftingRefSystem(@Nonnull ComponentType craftingManagerComponentType) { + this.craftingManagerComponentType = craftingManagerComponentType; + } + + @Nonnull + @Override + public Query getQuery() { + return Query.and(this.playerComponentType, this.craftingManagerComponentType); + } + + @Override + public void onEntityAdded( + @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer + ) { + } + + @Override + public void onEntityRemove( + @Nonnull Ref ref, @Nonnull RemoveReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer + ) { + CraftingManager craftingManagerComponent = commandBuffer.getComponent(ref, CraftingManager.getComponentType()); + + assert craftingManagerComponent != null; + + craftingManagerComponent.cancelAllCrafting(ref, store); + } + } + + public static class CraftingTickingSystem extends EntityTickingSystem { + @Nonnull + private final ComponentType craftingManagerComponentType; + + public CraftingTickingSystem(@Nonnull ComponentType craftingManagerComponentType) { this.craftingManagerComponentType = craftingManagerComponentType; } @@ -89,8 +113,11 @@ public class PlayerCraftingSystems { @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { - Ref ref = archetypeChunk.getReferenceTo(index); CraftingManager craftingManagerComponent = archetypeChunk.getComponent(index, this.craftingManagerComponentType); + + assert craftingManagerComponent != null; + + Ref ref = archetypeChunk.getReferenceTo(index); craftingManagerComponent.tick(ref, commandBuffer, dt); } } diff --git a/src/com/hypixel/hytale/builtin/crafting/window/BenchWindow.java b/src/com/hypixel/hytale/builtin/crafting/window/BenchWindow.java index cba3c37..e409ee9 100644 --- a/src/com/hypixel/hytale/builtin/crafting/window/BenchWindow.java +++ b/src/com/hypixel/hytale/builtin/crafting/window/BenchWindow.java @@ -4,16 +4,17 @@ import com.google.gson.JsonObject; import com.hypixel.hytale.builtin.adventure.memories.MemoriesPlugin; import com.hypixel.hytale.builtin.crafting.component.CraftingManager; import com.hypixel.hytale.builtin.crafting.state.BenchState; +import com.hypixel.hytale.component.ComponentAccessor; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.Store; import com.hypixel.hytale.protocol.SoundCategory; import com.hypixel.hytale.protocol.packets.window.WindowType; import com.hypixel.hytale.server.core.asset.type.blocktype.config.bench.Bench; +import com.hypixel.hytale.server.core.asset.type.gameplay.CraftingConfig; import com.hypixel.hytale.server.core.asset.type.item.config.Item; import com.hypixel.hytale.server.core.entity.entities.player.windows.BlockWindow; import com.hypixel.hytale.server.core.entity.entities.player.windows.MaterialContainerWindow; import com.hypixel.hytale.server.core.entity.entities.player.windows.MaterialExtraResourcesSection; -import com.hypixel.hytale.server.core.universe.PlayerRef; import com.hypixel.hytale.server.core.universe.world.SoundUtil; import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; @@ -29,18 +30,22 @@ public abstract class BenchWindow extends BlockWindow implements MaterialContain protected final BenchState benchState; protected final JsonObject windowData = new JsonObject(); @Nonnull - private MaterialExtraResourcesSection extraResourcesSection = new MaterialExtraResourcesSection(); + private final MaterialExtraResourcesSection extraResourcesSection = new MaterialExtraResourcesSection(); public BenchWindow(@Nonnull WindowType windowType, @Nonnull BenchState benchState) { super(windowType, benchState.getBlockX(), benchState.getBlockY(), benchState.getBlockZ(), benchState.getRotationIndex(), benchState.getBlockType()); this.bench = this.blockType.getBench(); this.benchState = benchState; Item item = this.blockType.getItem(); - this.windowData.addProperty("type", this.bench.getType().ordinal()); - this.windowData.addProperty("id", this.bench.getId()); - this.windowData.addProperty("name", item.getTranslationKey()); - this.windowData.addProperty("blockItemId", item.getId()); - this.windowData.addProperty("tierLevel", this.getBenchTierLevel()); + if (item == null) { + throw new IllegalStateException("Bench block type " + this.blockType.getId() + " does not have an associated item!"); + } else { + this.windowData.addProperty("type", this.bench.getType().ordinal()); + this.windowData.addProperty("id", this.bench.getId()); + this.windowData.addProperty("name", item.getTranslationKey()); + this.windowData.addProperty("blockItemId", item.getId()); + this.windowData.addProperty("tierLevel", this.getBenchTierLevel()); + } } @Nonnull @@ -50,15 +55,26 @@ public abstract class BenchWindow extends BlockWindow implements MaterialContain } @Override - protected boolean onOpen0() { - PlayerRef playerRef = this.getPlayerRef(); - Ref ref = playerRef.getReference(); - Store store = ref.getStore(); - CraftingManager craftingManager = store.getComponent(ref, CraftingManager.getComponentType()); - craftingManager.setBench(this.x, this.y, this.z, this.blockType); - World world = store.getExternalData().getWorld(); - this.windowData.addProperty("worldMemoriesLevel", MemoriesPlugin.get().getMemoriesLevel(world.getGameplayConfig())); - return true; + protected boolean onOpen0(@Nonnull Ref ref, @Nonnull Store store) { + CraftingManager craftingManagerComponent = store.getComponent(ref, CraftingManager.getComponentType()); + if (craftingManagerComponent == null) { + return false; + } else { + craftingManagerComponent.setBench(this.x, this.y, this.z, this.blockType); + World world = store.getExternalData().getWorld(); + int memoriesLevel = MemoriesPlugin.get().getMemoriesLevel(world.getGameplayConfig()); + this.windowData.addProperty("worldMemoriesLevel", memoriesLevel); + int chestCount = CraftingManager.feedExtraResourcesSection(this.benchState, this.extraResourcesSection); + CraftingConfig craftingConfig = world.getGameplayConfig().getCraftingConfig(); + int maxChestCount = craftingConfig.getBenchMaterialChestLimit(); + int horizontalRadius = craftingConfig.getBenchMaterialHorizontalChestSearchRadius(); + int verticalRadius = craftingConfig.getBenchMaterialVerticalChestSearchRadius(); + this.windowData.addProperty("nearbyChestCount", chestCount); + this.windowData.addProperty("maxChestCount", maxChestCount); + this.windowData.addProperty("chestHorizontalRadius", horizontalRadius); + this.windowData.addProperty("chestVerticalRadius", verticalRadius); + return true; + } } protected int getBenchTierLevel() { @@ -66,16 +82,12 @@ public abstract class BenchWindow extends BlockWindow implements MaterialContain } @Override - public void onClose0() { - PlayerRef playerRef = this.getPlayerRef(); - Ref ref = playerRef.getReference(); - Store store = ref.getStore(); - CraftingManager craftingManagerComponent = store.getComponent(ref, CraftingManager.getComponentType()); - - assert craftingManagerComponent != null; - - if (craftingManagerComponent.clearBench(ref, store) && this.bench.getFailedSoundEventIndex() != 0) { - SoundUtil.playSoundEvent2d(ref, this.bench.getFailedSoundEventIndex(), SoundCategory.UI, store); + public void onClose0(@Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor) { + CraftingManager craftingManagerComponent = componentAccessor.getComponent(ref, CraftingManager.getComponentType()); + if (craftingManagerComponent != null) { + if (craftingManagerComponent.clearBench(ref, componentAccessor) && this.bench.getFailedSoundEventIndex() != 0) { + SoundUtil.playSoundEvent2d(ref, this.bench.getFailedSoundEventIndex(), SoundCategory.UI, componentAccessor); + } } } diff --git a/src/com/hypixel/hytale/builtin/crafting/window/CraftingWindow.java b/src/com/hypixel/hytale/builtin/crafting/window/CraftingWindow.java index f08ee25..303305a 100644 --- a/src/com/hypixel/hytale/builtin/crafting/window/CraftingWindow.java +++ b/src/com/hypixel/hytale/builtin/crafting/window/CraftingWindow.java @@ -6,6 +6,7 @@ import com.hypixel.hytale.builtin.adventure.memories.MemoriesGameplayConfig; import com.hypixel.hytale.builtin.crafting.CraftingPlugin; import com.hypixel.hytale.builtin.crafting.component.CraftingManager; import com.hypixel.hytale.builtin.crafting.state.BenchState; +import com.hypixel.hytale.component.ComponentAccessor; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.Store; import com.hypixel.hytale.math.util.ChunkUtil; @@ -26,11 +27,12 @@ import java.util.Set; import javax.annotation.Nonnull; public abstract class CraftingWindow extends BenchWindow { - public static final int SET_BLOCK_SETTINGS = 6; + @Nonnull protected static final String CRAFT_COMPLETED = "CraftCompleted"; + @Nonnull protected static final String CRAFT_COMPLETED_INSTANT = "CraftCompletedInstant"; - public CraftingWindow(@Nonnull WindowType windowType, BenchState benchState) { + public CraftingWindow(@Nonnull WindowType windowType, @Nonnull BenchState benchState) { super(windowType, benchState); JsonArray categories = new JsonArray(); if (this.bench instanceof CraftingBench craftingBench) { @@ -73,11 +75,8 @@ public abstract class CraftingWindow extends BenchWindow { } @Override - protected boolean onOpen0() { - super.onOpen0(); - PlayerRef playerRef = this.getPlayerRef(); - Ref ref = playerRef.getReference(); - Store store = ref.getStore(); + protected boolean onOpen0(@Nonnull Ref ref, @Nonnull Store store) { + super.onOpen0(ref, store); GameplayConfig gameplayConfig = store.getExternalData().getWorld().getGameplayConfig(); MemoriesGameplayConfig memoriesConfig = MemoriesGameplayConfig.get(gameplayConfig); if (memoriesConfig != null) { @@ -101,22 +100,23 @@ public abstract class CraftingWindow extends BenchWindow { } @Override - public void onClose0() { - super.onClose0(); - PlayerRef playerRef = this.getPlayerRef(); - Ref ref = playerRef.getReference(); - Store store = ref.getStore(); - World world = store.getExternalData().getWorld(); - this.setBlockInteractionState(this.benchState.getTierStateName(), world, 6); + public void onClose0(@Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor) { + super.onClose0(ref, componentAccessor); + World world = componentAccessor.getExternalData().getWorld(); + this.setBlockInteractionState(this.benchState.getTierStateName(), world); if (this.bench.getLocalCloseSoundEventIndex() != 0) { - SoundUtil.playSoundEvent2d(ref, this.bench.getLocalCloseSoundEventIndex(), SoundCategory.UI, store); + SoundUtil.playSoundEvent2d(ref, this.bench.getLocalCloseSoundEventIndex(), SoundCategory.UI, componentAccessor); } } - public void setBlockInteractionState(@Nonnull String state, @Nonnull World world, int setBlockSettings) { + public void setBlockInteractionState(@Nonnull String state, @Nonnull World world) { WorldChunk worldChunk = world.getChunk(ChunkUtil.indexChunkFromBlock(this.x, this.z)); - BlockType blockType = worldChunk.getBlockType(this.x, this.y, this.z); - worldChunk.setBlockInteractionState(this.x, this.y, this.z, blockType, state, true); + if (worldChunk != null) { + BlockType blockType = worldChunk.getBlockType(this.x, this.y, this.z); + if (blockType != null) { + worldChunk.setBlockInteractionState(this.x, this.y, this.z, blockType, state, true); + } + } } public static boolean craftSimpleItem( @@ -130,11 +130,17 @@ public abstract class CraftingWindow extends BenchWindow { CraftingRecipe recipe = CraftingRecipe.getAssetMap().getAsset(recipeId); if (recipe == null) { PlayerRef playerRef = store.getComponent(ref, PlayerRef.getComponentType()); + + assert playerRef != null; + playerRef.getPacketHandler().disconnect("Attempted to craft unknown recipe!"); return false; } else { - Player player = store.getComponent(ref, Player.getComponentType()); - craftingManager.craftItem(ref, store, recipe, quantity, player.getInventory().getCombinedBackpackStorageHotbar()); + Player playerComponent = store.getComponent(ref, Player.getComponentType()); + + assert playerComponent != null; + + craftingManager.craftItem(ref, store, recipe, quantity, playerComponent.getInventory().getCombinedBackpackStorageHotbar()); return true; } } diff --git a/src/com/hypixel/hytale/builtin/crafting/window/DiagramCraftingWindow.java b/src/com/hypixel/hytale/builtin/crafting/window/DiagramCraftingWindow.java index 619fe68..f2ff8ae 100644 --- a/src/com/hypixel/hytale/builtin/crafting/window/DiagramCraftingWindow.java +++ b/src/com/hypixel/hytale/builtin/crafting/window/DiagramCraftingWindow.java @@ -47,15 +47,16 @@ public class DiagramCraftingWindow extends CraftingWindow implements ItemContain private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); private String category; private String itemCategory; + @Nullable private CraftingBench.BenchItemCategory benchItemCategory; private SimpleItemContainer inputPrimaryContainer; private SimpleItemContainer inputSecondaryContainer; private CombinedItemContainer combinedInputItemContainer; private SimpleItemContainer outputContainer; private CombinedItemContainer combinedItemContainer; - private EventRegistration inventoryRegistration; + private EventRegistration inventoryRegistration; - public DiagramCraftingWindow(@Nonnull ComponentAccessor store, BenchState benchState) { + public DiagramCraftingWindow(@Nonnull Ref ref, @Nonnull ComponentAccessor store, @Nonnull BenchState benchState) { super(WindowType.DiagramCrafting, benchState); DiagramCraftingBench bench = (DiagramCraftingBench)this.bench; if (bench.getCategories() != null && bench.getCategories().length > 0) { @@ -70,7 +71,7 @@ public class DiagramCraftingWindow extends CraftingWindow implements ItemContain if (this.benchItemCategory == null) { throw new IllegalArgumentException("Failed to get category!"); } else { - this.updateInventory(store, this.benchItemCategory); + this.updateInventory(ref, store, this.benchItemCategory); } } @@ -82,14 +83,14 @@ public class DiagramCraftingWindow extends CraftingWindow implements ItemContain } @Override - public boolean onOpen0() { - boolean result = super.onOpen0(); - PlayerRef playerRef = this.getPlayerRef(); - Ref ref = playerRef.getReference(); - Store store = ref.getStore(); - Player player = store.getComponent(ref, Player.getComponentType()); - Inventory inventory = player.getInventory(); - this.updateInput((ItemContainer)null); + public boolean onOpen0(@Nonnull Ref ref, @Nonnull Store store) { + boolean result = super.onOpen0(ref, store); + Player playerComponent = store.getComponent(ref, Player.getComponentType()); + + assert playerComponent != null; + + Inventory inventory = playerComponent.getInventory(); + this.updateInput(null, ref, store); this.inventoryRegistration = inventory.getCombinedHotbarFirst().registerChangeEvent(event -> { ObjectList recipes = new ObjectArrayList<>(); this.windowData.add("slots", this.generateSlots(inventory.getCombinedHotbarFirst(), recipes)); @@ -99,66 +100,75 @@ public class DiagramCraftingWindow extends CraftingWindow implements ItemContain } @Override - public void onClose0() { - PlayerRef playerRef = this.getPlayerRef(); - Ref ref = playerRef.getReference(); - Store store = ref.getStore(); - Player player = store.getComponent(ref, Player.getComponentType()); + public void onClose0(@Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor) { + Player playerComponent = componentAccessor.getComponent(ref, Player.getComponentType()); + + assert playerComponent != null; + List itemStacks = this.combinedInputItemContainer.dropAllItemStacks(); - SimpleItemContainer.addOrDropItemStacks(store, ref, player.getInventory().getCombinedHotbarFirst(), itemStacks); - CraftingManager craftingManager = store.getComponent(ref, CraftingManager.getComponentType()); - craftingManager.cancelAllCrafting(ref, store); + SimpleItemContainer.addOrDropItemStacks(componentAccessor, ref, playerComponent.getInventory().getCombinedHotbarFirst(), itemStacks); + CraftingManager craftingManagerComponent = componentAccessor.getComponent(ref, CraftingManager.getComponentType()); + + assert craftingManagerComponent != null; + + craftingManagerComponent.cancelAllCrafting(ref, componentAccessor); this.inventoryRegistration.unregister(); - super.onClose0(); + super.onClose0(ref, componentAccessor); } @Override public void handleAction(@Nonnull Ref ref, @Nonnull Store store, @Nonnull WindowAction action) { World world = store.getExternalData().getWorld(); - PlayerRef playerRef = this.getPlayerRef(); - CraftingManager craftingManager = store.getComponent(ref, CraftingManager.getComponentType()); + PlayerRef playerRefComponent = store.getComponent(ref, PlayerRef.getComponentType()); + + assert playerRefComponent != null; + + CraftingManager craftingManagerComponent = store.getComponent(ref, CraftingManager.getComponentType()); + + assert craftingManagerComponent != null; + switch (action) { case CancelCraftingAction ignored: - craftingManager.cancelAllCrafting(ref, store); + craftingManagerComponent.cancelAllCrafting(ref, store); break; case UpdateCategoryAction updateAction: this.category = updateAction.category; this.itemCategory = updateAction.itemCategory; this.benchItemCategory = this.getBenchItemCategory(this.category, this.itemCategory); if (this.benchItemCategory != null) { - this.updateInventory(store, this.benchItemCategory); + this.updateInventory(ref, store, this.benchItemCategory); } else { - this.getPlayerRef().sendMessage(Message.translation("server.ui.diagramcraftingwindow.invalidCategory")); - this.close(); + playerRefComponent.sendMessage(Message.translation("server.ui.diagramcraftingwindow.invalidCategory")); + this.close(ref, store); } break; case CraftItemAction ignoredx: - label45: { + label59: { ItemStack itemStack = this.outputContainer.getItemStack((short)0); if (itemStack == null || itemStack.isEmpty()) { - playerRef.sendMessage(Message.translation("server.ui.diagramcraftingwindow.noOutputItem")); + playerRefComponent.sendMessage(Message.translation("server.ui.diagramcraftingwindow.noOutputItem")); return; } ObjectList recipes = new ObjectArrayList<>(); - boolean allSlotsFull = this.collectRecipes(recipes); + boolean allSlotsFull = this.collectRecipes(ref, recipes, store); if (recipes.size() != 1 || !allSlotsFull) { - playerRef.sendMessage(Message.translation("server.ui.diagramcraftingwindow.failedVerifyRecipy")); + playerRefComponent.sendMessage(Message.translation("server.ui.diagramcraftingwindow.failedVerifyRecipy")); return; } CraftingRecipe recipe = recipes.getFirst(); - craftingManager.queueCraft(ref, store, this, 0, recipe, 1, this.combinedInputItemContainer, CraftingManager.InputRemovalType.ORDERED); + craftingManagerComponent.queueCraft(ref, store, this, 0, recipe, 1, this.combinedInputItemContainer, CraftingManager.InputRemovalType.ORDERED); String completedState = recipe.getTimeSeconds() > 0.0F ? "CraftCompleted" : "CraftCompletedInstant"; - this.setBlockInteractionState(completedState, world, 70); + this.setBlockInteractionState(completedState, world); if (this.bench.getCompletedSoundEventIndex() != 0) { SoundUtil.playSoundEvent3d(this.bench.getCompletedSoundEventIndex(), SoundCategory.SFX, this.x + 0.5, this.y + 0.5, this.z + 0.5, store); } if (CraftingPlugin.learnRecipe(ref, recipe.getId(), store)) { - this.updateInput(this.outputContainer); + this.updateInput(this.outputContainer, ref, store); } - break label45; + break label59; } default: } @@ -170,6 +180,7 @@ public class DiagramCraftingWindow extends CraftingWindow implements ItemContain return this.combinedItemContainer; } + @Nullable private CraftingBench.BenchItemCategory getBenchItemCategory(@Nullable String category, @Nullable String itemCategory) { if (category != null && itemCategory != null) { DiagramCraftingBench craftingBench = (DiagramCraftingBench)this.bench; @@ -190,13 +201,16 @@ public class DiagramCraftingWindow extends CraftingWindow implements ItemContain } } - private void updateInventory(@Nonnull ComponentAccessor store, @Nonnull CraftingBench.BenchItemCategory benchItemCategory) { + private void updateInventory( + @Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor, @Nonnull CraftingBench.BenchItemCategory benchItemCategory + ) { if (this.combinedInputItemContainer != null) { - PlayerRef playerRef = this.getPlayerRef(); - Ref ref = playerRef.getReference(); - Player playerComponent = store.getComponent(ref, Player.getComponentType()); + Player playerComponent = componentAccessor.getComponent(ref, Player.getComponentType()); + + assert playerComponent != null; + List itemStacks = this.combinedInputItemContainer.dropAllItemStacks(); - SimpleItemContainer.addOrDropItemStacks(store, ref, playerComponent.getInventory().getCombinedHotbarFirst(), itemStacks); + SimpleItemContainer.addOrDropItemStacks(componentAccessor, ref, playerComponent.getInventory().getCombinedHotbarFirst(), itemStacks); } this.inputPrimaryContainer = new SimpleItemContainer((short)1); @@ -210,16 +224,23 @@ public class DiagramCraftingWindow extends CraftingWindow implements ItemContain } private void updateInput(@Nonnull ItemContainer.ItemContainerChangeEvent event) { - this.updateInput(event.container()); + PlayerRef playerRef = this.getPlayerRef(); + if (playerRef != null) { + Ref ref = playerRef.getReference(); + if (ref != null && ref.isValid()) { + Store store = ref.getStore(); + this.updateInput(event.container(), ref, store); + } + } } - private void updateInput(@Nullable ItemContainer container) { - PlayerRef playerRef = this.getPlayerRef(); - Ref ref = playerRef.getReference(); - Store store = ref.getStore(); - Player player = store.getComponent(ref, Player.getComponentType()); + private void updateInput(@Nullable ItemContainer container, @Nonnull Ref ref, @Nonnull Store store) { + Player playerComponent = store.getComponent(ref, Player.getComponentType()); + + assert playerComponent != null; + ItemStack primaryItemStack = this.inputPrimaryContainer.getItemStack((short)0); - CombinedItemContainer combinedStorage = player.getInventory().getCombinedHotbarFirst(); + CombinedItemContainer combinedStorage = playerComponent.getInventory().getCombinedHotbarFirst(); if (primaryItemStack != null && !primaryItemStack.isEmpty()) { this.inputSecondaryContainer.setGlobalFilter(FilterType.ALLOW_ALL); boolean needsDropSlot = true; @@ -244,12 +265,12 @@ public class DiagramCraftingWindow extends CraftingWindow implements ItemContain } List recipes = new ObjectArrayList<>(); - boolean allSlotsFull = this.collectRecipes(recipes); + boolean allSlotsFull = this.collectRecipes(ref, recipes, store); this.windowData.add("slots", this.generateSlots(combinedStorage, recipes)); if (recipes.size() == 1 && allSlotsFull) { CraftingRecipe recipe = recipes.getFirst(); ItemStack output = CraftingManager.getOutputItemStacks(recipe).getFirst(); - if (player.getPlayerConfigData().getKnownRecipes().contains(recipe.getId())) { + if (playerComponent.getPlayerConfigData().getKnownRecipes().contains(recipe.getId())) { this.outputContainer.setItemStackForSlot((short)0, output); } else { this.outputContainer.setItemStackForSlot((short)0, new ItemStack("Unknown", 1)); @@ -265,18 +286,20 @@ public class DiagramCraftingWindow extends CraftingWindow implements ItemContain this.invalidate(); } - private boolean collectRecipes(@Nonnull List recipes) { + private boolean collectRecipes(@Nonnull Ref ref, @Nonnull List recipes, @Nonnull Store store) { + assert this.benchItemCategory != null; + ItemStack primaryItemStack = this.inputPrimaryContainer.getItemStack((short)0); if (primaryItemStack != null && !primaryItemStack.isEmpty()) { - PlayerRef playerRef = this.getPlayerRef(); - Ref ref = playerRef.getReference(); - Store store = ref.getStore(); - Player player = store.getComponent(ref, Player.getComponentType()); - Set knownRecipes = player.getPlayerConfigData().getKnownRecipes(); + Player playerComponent = store.getComponent(ref, Player.getComponentType()); + + assert playerComponent != null; + + Set knownRecipes = playerComponent.getPlayerConfigData().getKnownRecipes(); short inputCapacity = this.combinedInputItemContainer.getCapacity(); boolean allSlotsFull = true; - label54: + label65: for (CraftingRecipe recipe : this.getBenchRecipes()) { if (recipe.getInput().length != inputCapacity && (!this.benchItemCategory.isSpecialSlot() || recipe.getInput().length != inputCapacity - 1)) { LOGGER.at(Level.WARNING) @@ -293,7 +316,7 @@ public class DiagramCraftingWindow extends CraftingWindow implements ItemContain ItemStack itemStack = this.combinedInputItemContainer.getItemStack(i); if (itemStack != null && !itemStack.isEmpty()) { if (!CraftingManager.matches(recipe.getInput()[i], itemStack)) { - continue label54; + continue label65; } } else if (!this.benchItemCategory.isSpecialSlot() && i == inputCapacity - 1) { allSlotsFull = false; diff --git a/src/com/hypixel/hytale/builtin/crafting/window/FieldCraftingWindow.java b/src/com/hypixel/hytale/builtin/crafting/window/FieldCraftingWindow.java index 6aaeb1d..40aabd1 100644 --- a/src/com/hypixel/hytale/builtin/crafting/window/FieldCraftingWindow.java +++ b/src/com/hypixel/hytale/builtin/crafting/window/FieldCraftingWindow.java @@ -5,6 +5,7 @@ import com.google.gson.JsonObject; import com.hypixel.hytale.builtin.adventure.memories.MemoriesPlugin; import com.hypixel.hytale.builtin.crafting.CraftingPlugin; import com.hypixel.hytale.builtin.crafting.component.CraftingManager; +import com.hypixel.hytale.component.ComponentAccessor; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.Store; import com.hypixel.hytale.protocol.BenchType; @@ -14,7 +15,6 @@ import com.hypixel.hytale.protocol.packets.window.WindowAction; import com.hypixel.hytale.protocol.packets.window.WindowType; import com.hypixel.hytale.server.core.asset.type.item.config.FieldcraftCategory; import com.hypixel.hytale.server.core.entity.entities.player.windows.Window; -import com.hypixel.hytale.server.core.universe.PlayerRef; import com.hypixel.hytale.server.core.universe.world.SoundUtil; import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; @@ -60,10 +60,7 @@ public class FieldCraftingWindow extends Window { } @Override - public boolean onOpen0() { - PlayerRef playerRef = this.getPlayerRef(); - Ref ref = playerRef.getReference(); - Store store = ref.getStore(); + public boolean onOpen0(@Nonnull Ref ref, @Nonnull Store store) { World world = store.getExternalData().getWorld(); this.windowData.addProperty("worldMemoriesLevel", MemoriesPlugin.get().getMemoriesLevel(world.getGameplayConfig())); this.invalidate(); @@ -71,7 +68,7 @@ public class FieldCraftingWindow extends Window { } @Override - public void onClose0() { + public void onClose0(@Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor) { } @Override diff --git a/src/com/hypixel/hytale/builtin/crafting/window/ProcessingBenchWindow.java b/src/com/hypixel/hytale/builtin/crafting/window/ProcessingBenchWindow.java index b9f467d..c5c7c37 100644 --- a/src/com/hypixel/hytale/builtin/crafting/window/ProcessingBenchWindow.java +++ b/src/com/hypixel/hytale/builtin/crafting/window/ProcessingBenchWindow.java @@ -5,6 +5,7 @@ import com.google.gson.JsonObject; import com.hypixel.hytale.builtin.crafting.CraftingPlugin; import com.hypixel.hytale.builtin.crafting.component.CraftingManager; import com.hypixel.hytale.builtin.crafting.state.ProcessingBenchState; +import com.hypixel.hytale.component.ComponentAccessor; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.Store; import com.hypixel.hytale.event.EventRegistration; @@ -21,7 +22,6 @@ import com.hypixel.hytale.server.core.entity.entities.Player; import com.hypixel.hytale.server.core.entity.entities.player.windows.ItemContainerWindow; import com.hypixel.hytale.server.core.inventory.Inventory; import com.hypixel.hytale.server.core.inventory.container.CombinedItemContainer; -import com.hypixel.hytale.server.core.universe.PlayerRef; import com.hypixel.hytale.server.core.universe.world.SoundUtil; import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; @@ -190,13 +190,13 @@ public class ProcessingBenchWindow extends BenchWindow implements ItemContainerW } @Override - protected boolean onOpen0() { - super.onOpen0(); - PlayerRef playerRef = this.getPlayerRef(); - Ref ref = playerRef.getReference(); - Store store = ref.getStore(); - Player player = store.getComponent(ref, Player.getComponentType()); - Inventory inventory = player.getInventory(); + protected boolean onOpen0(@Nonnull Ref ref, @Nonnull Store store) { + super.onOpen0(ref, store); + Player playerComponent = store.getComponent(ref, Player.getComponentType()); + + assert playerComponent != null; + + Inventory inventory = playerComponent.getInventory(); this.inventoryRegistration = inventory.getCombinedHotbarFirst().registerChangeEvent(event -> { this.windowData.add("inventoryHints", generateInventoryHints(this.bench, inventory.getCombinedHotbarFirst())); this.invalidate(); @@ -237,8 +237,8 @@ public class ProcessingBenchWindow extends BenchWindow implements ItemContainerW } @Override - public void onClose0() { - super.onClose0(); + public void onClose0(@Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor) { + super.onClose0(ref, componentAccessor); if (this.inventoryRegistration != null) { this.inventoryRegistration.unregister(); this.inventoryRegistration = null; diff --git a/src/com/hypixel/hytale/builtin/crafting/window/SimpleCraftingWindow.java b/src/com/hypixel/hytale/builtin/crafting/window/SimpleCraftingWindow.java index 0f375ef..58b7b92 100644 --- a/src/com/hypixel/hytale/builtin/crafting/window/SimpleCraftingWindow.java +++ b/src/com/hypixel/hytale/builtin/crafting/window/SimpleCraftingWindow.java @@ -61,7 +61,7 @@ public class SimpleCraftingWindow extends CraftingWindow implements MaterialCont this.invalidateExtraResources(); if (accepted) { String completedState = craftRecipe.getTimeSeconds() > 0.0F ? "CraftCompleted" : "CraftCompletedInstant"; - this.setBlockInteractionState(completedState, world, 70); + this.setBlockInteractionState(completedState, world); if (this.bench.getCompletedSoundEventIndex() != 0) { Vector3d pos = new Vector3d(); this.blockType.getBlockCenter(this.rotationIndex, pos); @@ -70,7 +70,7 @@ public class SimpleCraftingWindow extends CraftingWindow implements MaterialCont } } } else if (action instanceof TierUpgradeAction && craftingManager.startTierUpgrade(ref, store, this)) { - this.setBlockInteractionState("BenchUpgrading", world, 70); + this.setBlockInteractionState("BenchUpgrading", world); if (this.bench.getBenchUpgradeSoundEventIndex() != 0) { Vector3d pos = new Vector3d(); this.blockType.getBlockCenter(this.rotationIndex, pos); diff --git a/src/com/hypixel/hytale/builtin/crafting/window/StructuralCraftingWindow.java b/src/com/hypixel/hytale/builtin/crafting/window/StructuralCraftingWindow.java index b4e1c56..64b029e 100644 --- a/src/com/hypixel/hytale/builtin/crafting/window/StructuralCraftingWindow.java +++ b/src/com/hypixel/hytale/builtin/crafting/window/StructuralCraftingWindow.java @@ -4,6 +4,7 @@ import com.google.gson.JsonArray; import com.hypixel.hytale.builtin.crafting.CraftingPlugin; import com.hypixel.hytale.builtin.crafting.component.CraftingManager; import com.hypixel.hytale.builtin.crafting.state.BenchState; +import com.hypixel.hytale.component.ComponentAccessor; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.Store; import com.hypixel.hytale.event.EventRegistration; @@ -32,7 +33,6 @@ import com.hypixel.hytale.server.core.inventory.container.ItemContainer; import com.hypixel.hytale.server.core.inventory.container.SimpleItemContainer; import com.hypixel.hytale.server.core.inventory.container.filter.FilterActionType; import com.hypixel.hytale.server.core.inventory.container.filter.FilterType; -import com.hypixel.hytale.server.core.universe.PlayerRef; import com.hypixel.hytale.server.core.universe.world.SoundUtil; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; @@ -42,7 +42,6 @@ import it.unimi.dsi.fastutil.objects.ObjectList; import java.util.List; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; public class StructuralCraftingWindow extends CraftingWindow implements ItemContainerWindow { private static final int MAX_OPTIONS = 64; @@ -222,13 +221,13 @@ public class StructuralCraftingWindow extends CraftingWindow implements ItemCont } @Override - public boolean onOpen0() { - super.onOpen0(); - PlayerRef playerRef = this.getPlayerRef(); - Ref ref = playerRef.getReference(); - Store store = ref.getStore(); - Player player = store.getComponent(ref, Player.getComponentType()); - Inventory inventory = player.getInventory(); + public boolean onOpen0(@Nonnull Ref ref, @Nonnull Store store) { + super.onOpen0(ref, store); + Player playerComponent = store.getComponent(ref, Player.getComponentType()); + + assert playerComponent != null; + + Inventory inventory = playerComponent.getInventory(); this.inventoryRegistration = inventory.getCombinedHotbarFirst() .registerChangeEvent( event -> { @@ -246,16 +245,19 @@ public class StructuralCraftingWindow extends CraftingWindow implements ItemCont } @Override - public void onClose0() { - super.onClose0(); - PlayerRef playerRef = this.getPlayerRef(); - Ref ref = playerRef.getReference(); - Store store = ref.getStore(); - Player player = store.getComponent(ref, Player.getComponentType()); + public void onClose0(@Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor) { + super.onClose0(ref, componentAccessor); + Player playerComponent = componentAccessor.getComponent(ref, Player.getComponentType()); + + assert playerComponent != null; + List itemStacks = this.inputContainer.dropAllItemStacks(); - SimpleItemContainer.addOrDropItemStacks(store, ref, player.getInventory().getCombinedHotbarFirst(), itemStacks); - CraftingManager craftingManager = store.getComponent(ref, CraftingManager.getComponentType()); - craftingManager.cancelAllCrafting(ref, store); + SimpleItemContainer.addOrDropItemStacks(componentAccessor, ref, playerComponent.getInventory().getCombinedHotbarFirst(), itemStacks); + CraftingManager craftingManagerComponent = componentAccessor.getComponent(ref, CraftingManager.getComponentType()); + + assert craftingManagerComponent != null; + + craftingManagerComponent.cancelAllCrafting(ref, componentAccessor); if (this.inventoryRegistration != null) { this.inventoryRegistration.unregister(); this.inventoryRegistration = null; @@ -311,7 +313,7 @@ public class StructuralCraftingWindow extends CraftingWindow implements ItemCont } } - @NullableDecl + @Nullable private ObjectList getMatchingRecipes(@Nullable ItemStack inputStack) { if (inputStack == null) { return null; diff --git a/src/com/hypixel/hytale/builtin/creativehub/config/CreativeHubEntityConfig.java b/src/com/hypixel/hytale/builtin/creativehub/config/CreativeHubEntityConfig.java index fd1cd33..c1c8e0f 100644 --- a/src/com/hypixel/hytale/builtin/creativehub/config/CreativeHubEntityConfig.java +++ b/src/com/hypixel/hytale/builtin/creativehub/config/CreativeHubEntityConfig.java @@ -44,9 +44,6 @@ public class CreativeHubEntityConfig implements Component { return holder.getComponent(type); } - public CreativeHubEntityConfig() { - } - @Nullable public UUID getParentHubWorldUuid() { return this.parentHubWorldUuid; diff --git a/src/com/hypixel/hytale/builtin/creativehub/config/CreativeHubWorldConfig.java b/src/com/hypixel/hytale/builtin/creativehub/config/CreativeHubWorldConfig.java index cea27cc..87e3cd5 100644 --- a/src/com/hypixel/hytale/builtin/creativehub/config/CreativeHubWorldConfig.java +++ b/src/com/hypixel/hytale/builtin/creativehub/config/CreativeHubWorldConfig.java @@ -18,9 +18,6 @@ public class CreativeHubWorldConfig { @Nullable private String startupInstance; - public CreativeHubWorldConfig() { - } - @Nullable public static CreativeHubWorldConfig get(@Nonnull WorldConfig config) { return config.getPluginConfig().get(CreativeHubWorldConfig.class); diff --git a/src/com/hypixel/hytale/builtin/creativehub/interactions/HubPortalInteraction.java b/src/com/hypixel/hytale/builtin/creativehub/interactions/HubPortalInteraction.java index 9663f8d..7233ef0 100644 --- a/src/com/hypixel/hytale/builtin/creativehub/interactions/HubPortalInteraction.java +++ b/src/com/hypixel/hytale/builtin/creativehub/interactions/HubPortalInteraction.java @@ -37,7 +37,6 @@ import java.util.concurrent.TimeUnit; import java.util.logging.Level; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class HubPortalInteraction extends SimpleInstantInteraction { private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); @@ -68,10 +67,7 @@ public class HubPortalInteraction extends SimpleInstantInteraction { @Nullable private String instanceTemplate; - public HubPortalInteraction() { - } - - @NonNullDecl + @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { return WaitForDataFrom.Server; @@ -131,7 +127,8 @@ public class HubPortalInteraction extends SimpleInstantInteraction { spawnPoint = spawnProvider != null ? spawnProvider.getSpawnPoint(targetWorld, uuidComponent.getUuid()) : new Transform(); } - componentAccessor.addComponent(playerRef, Teleport.getComponentType(), new Teleport(targetWorld, spawnPoint)); + Teleport teleportComponent = Teleport.createForPlayer(targetWorld, spawnPoint); + componentAccessor.addComponent(playerRef, Teleport.getComponentType(), teleportComponent); } private void teleportToLoadingWorld( diff --git a/src/com/hypixel/hytale/builtin/deployables/DeployablesUtils.java b/src/com/hypixel/hytale/builtin/deployables/DeployablesUtils.java index a3248cd..4b066ca 100644 --- a/src/com/hypixel/hytale/builtin/deployables/DeployablesUtils.java +++ b/src/com/hypixel/hytale/builtin/deployables/DeployablesUtils.java @@ -49,9 +49,6 @@ import javax.annotation.Nullable; public class DeployablesUtils { private static final String DEPLOYABLE_MAX_STAT_MODIFIER = "DEPLOYABLE_MAX"; - public DeployablesUtils() { - } - @Nonnull public static Ref spawnDeployable( @Nonnull CommandBuffer commandBuffer, diff --git a/src/com/hypixel/hytale/builtin/deployables/component/DeployableComponent.java b/src/com/hypixel/hytale/builtin/deployables/component/DeployableComponent.java index 43b1aae..ccb639b 100644 --- a/src/com/hypixel/hytale/builtin/deployables/component/DeployableComponent.java +++ b/src/com/hypixel/hytale/builtin/deployables/component/DeployableComponent.java @@ -30,9 +30,6 @@ public class DeployableComponent implements Component { private boolean firstTickRan; private String spawnFace; - public DeployableComponent() { - } - @Nonnull public static ComponentType getComponentType() { return DeployablesPlugin.get().getDeployableComponentType(); @@ -130,8 +127,5 @@ public class DeployableComponent implements Component { LIVE, BURST_SHOTS, TRIGGERED; - - private DeployableFlag() { - } } } diff --git a/src/com/hypixel/hytale/builtin/deployables/component/DeployableOwnerComponent.java b/src/com/hypixel/hytale/builtin/deployables/component/DeployableOwnerComponent.java index c3788c4..3a37322 100644 --- a/src/com/hypixel/hytale/builtin/deployables/component/DeployableOwnerComponent.java +++ b/src/com/hypixel/hytale/builtin/deployables/component/DeployableOwnerComponent.java @@ -30,9 +30,6 @@ public class DeployableOwnerComponent implements Component { private final List> deployablesForDestruction = new ObjectArrayList<>(); private final List>> tempDestructionList = new ObjectArrayList<>(); - public DeployableOwnerComponent() { - } - @Nonnull public static ComponentType getComponentType() { return DeployablesPlugin.get().getDeployableOwnerComponentType(); diff --git a/src/com/hypixel/hytale/builtin/deployables/component/DeployableProjectileShooterComponent.java b/src/com/hypixel/hytale/builtin/deployables/component/DeployableProjectileShooterComponent.java index 133a5c9..e56dab9 100644 --- a/src/com/hypixel/hytale/builtin/deployables/component/DeployableProjectileShooterComponent.java +++ b/src/com/hypixel/hytale/builtin/deployables/component/DeployableProjectileShooterComponent.java @@ -18,9 +18,6 @@ public class DeployableProjectileShooterComponent implements Component> projectilesForRemoval = new ObjectArrayList<>(); protected Ref activeTarget; - public DeployableProjectileShooterComponent() { - } - public static ComponentType getComponentType() { return DeployablesPlugin.get().getDeployableProjectileShooterComponentType(); } diff --git a/src/com/hypixel/hytale/builtin/deployables/config/DeployableAoeConfig.java b/src/com/hypixel/hytale/builtin/deployables/config/DeployableAoeConfig.java index fe907a3..7644729 100644 --- a/src/com/hypixel/hytale/builtin/deployables/config/DeployableAoeConfig.java +++ b/src/com/hypixel/hytale/builtin/deployables/config/DeployableAoeConfig.java @@ -266,8 +266,5 @@ public class DeployableAoeConfig extends DeployableConfig { public static enum Shape { Sphere, Cylinder; - - private Shape() { - } } } diff --git a/src/com/hypixel/hytale/builtin/deployables/config/DeployableTrapSpawnerConfig.java b/src/com/hypixel/hytale/builtin/deployables/config/DeployableTrapSpawnerConfig.java index 8b5a0e4..cfd70aa 100644 --- a/src/com/hypixel/hytale/builtin/deployables/config/DeployableTrapSpawnerConfig.java +++ b/src/com/hypixel/hytale/builtin/deployables/config/DeployableTrapSpawnerConfig.java @@ -49,9 +49,6 @@ public class DeployableTrapSpawnerConfig extends DeployableTrapConfig { private String[] deployableSpawnerIds; private DeployableSpawner[] deployableSpawners; - public DeployableTrapSpawnerConfig() { - } - @Override public void tick( @Nonnull DeployableComponent deployableComponent, diff --git a/src/com/hypixel/hytale/builtin/deployables/config/DeployableTurretConfig.java b/src/com/hypixel/hytale/builtin/deployables/config/DeployableTurretConfig.java index 4bd9a51..66838cd 100644 --- a/src/com/hypixel/hytale/builtin/deployables/config/DeployableTurretConfig.java +++ b/src/com/hypixel/hytale/builtin/deployables/config/DeployableTurretConfig.java @@ -191,9 +191,6 @@ public class DeployableTurretConfig extends DeployableConfig { protected boolean respectTeams = true; protected Map projectileSpawnOffsets = new Object2ObjectOpenHashMap<>(); - public DeployableTurretConfig() { - } - protected void processConfig() { if (this.projectileHitWorldSoundEventId != null) { this.projectileHitWorldSoundEventIndex = this.projectileHitLocalSoundEventIndex = SoundEvent.getAssetMap() diff --git a/src/com/hypixel/hytale/builtin/deployables/interaction/SpawnDeployableAtHitLocationInteraction.java b/src/com/hypixel/hytale/builtin/deployables/interaction/SpawnDeployableAtHitLocationInteraction.java index e317abf..1e196cb 100644 --- a/src/com/hypixel/hytale/builtin/deployables/interaction/SpawnDeployableAtHitLocationInteraction.java +++ b/src/com/hypixel/hytale/builtin/deployables/interaction/SpawnDeployableAtHitLocationInteraction.java @@ -17,7 +17,6 @@ import com.hypixel.hytale.server.core.modules.interaction.interaction.CooldownHa import com.hypixel.hytale.server.core.modules.interaction.interaction.config.SimpleInstantInteraction; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class SpawnDeployableAtHitLocationInteraction extends SimpleInstantInteraction { @Nonnull @@ -30,16 +29,13 @@ public class SpawnDeployableAtHitLocationInteraction extends SimpleInstantIntera .build(); private DeployableConfig config; - public SpawnDeployableAtHitLocationInteraction() { - } - @Override public boolean needsRemoteSync() { return false; } @Override - protected void firstRun(@NonNullDecl InteractionType type, @NonNullDecl InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler) { + protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { InteractionChain contextChain = context.getChain(); assert contextChain != null; diff --git a/src/com/hypixel/hytale/builtin/deployables/interaction/SpawnDeployableFromRaycastInteraction.java b/src/com/hypixel/hytale/builtin/deployables/interaction/SpawnDeployableFromRaycastInteraction.java index 8491a3f..a64af8a 100644 --- a/src/com/hypixel/hytale/builtin/deployables/interaction/SpawnDeployableFromRaycastInteraction.java +++ b/src/com/hypixel/hytale/builtin/deployables/interaction/SpawnDeployableFromRaycastInteraction.java @@ -34,7 +34,6 @@ import it.unimi.dsi.fastutil.ints.Int2FloatMap.Entry; import it.unimi.dsi.fastutil.objects.Object2FloatMap; import it.unimi.dsi.fastutil.objects.Object2FloatOpenHashMap; import javax.annotation.Nonnull; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class SpawnDeployableFromRaycastInteraction extends SimpleInstantInteraction { @Nonnull @@ -67,9 +66,6 @@ public class SpawnDeployableFromRaycastInteraction extends SimpleInstantInteract protected float maxPlacementDistance; private DeployableConfig config; - public SpawnDeployableFromRaycastInteraction() { - } - private void processConfig() { if (this.unknownEntityStats != null) { this.entityStats = EntityStatsModule.resolveEntityStats(this.unknownEntityStats); @@ -85,7 +81,7 @@ public class SpawnDeployableFromRaycastInteraction extends SimpleInstantInteract return true; } - @NonNullDecl + @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { return WaitForDataFrom.Client; @@ -154,7 +150,7 @@ public class SpawnDeployableFromRaycastInteraction extends SimpleInstantInteract } } - @NonNullDecl + @Nonnull @Override protected Interaction generatePacket() { return new com.hypixel.hytale.protocol.SpawnDeployableFromRaycastInteraction(); diff --git a/src/com/hypixel/hytale/builtin/deployables/system/DeployablesSystem.java b/src/com/hypixel/hytale/builtin/deployables/system/DeployablesSystem.java index aa1d8e4..15f1670 100644 --- a/src/com/hypixel/hytale/builtin/deployables/system/DeployablesSystem.java +++ b/src/com/hypixel/hytale/builtin/deployables/system/DeployablesSystem.java @@ -29,9 +29,6 @@ import it.unimi.dsi.fastutil.objects.ObjectList; import javax.annotation.Nonnull; public class DeployablesSystem { - public DeployablesSystem() { - } - private static void spawnParticleEffect(Ref sourceRef, CommandBuffer commandBuffer, Vector3d position, ModelParticle particle) { Vector3f particlePositionOffset = particle.getPositionOffset(); Direction particleRotationOffset = particle.getRotationOffset(); @@ -63,9 +60,6 @@ public class DeployablesSystem { } public static class DeployableOwnerTicker extends EntityTickingSystem { - public DeployableOwnerTicker() { - } - @Override public Query getQuery() { return Query.and(DeployableOwnerComponent.getComponentType()); @@ -79,9 +73,6 @@ public class DeployablesSystem { } public static class DeployableRegisterer extends RefSystem { - public DeployableRegisterer() { - } - private static void deregisterOwner( @Nonnull Ref ref, @Nonnull DeployableComponent deployableComponent, @Nonnull DeployableConfig deployableConfig ) { @@ -155,9 +146,6 @@ public class DeployablesSystem { } public static class DeployableTicker extends EntityTickingSystem { - public DeployableTicker() { - } - @Override public Query getQuery() { return Query.and(DeployableComponent.getComponentType()); diff --git a/src/com/hypixel/hytale/builtin/fluid/FluidSystems.java b/src/com/hypixel/hytale/builtin/fluid/FluidSystems.java index 11a4a77..58f91fd 100644 --- a/src/com/hypixel/hytale/builtin/fluid/FluidSystems.java +++ b/src/com/hypixel/hytale/builtin/fluid/FluidSystems.java @@ -54,16 +54,10 @@ public class FluidSystems { private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); private static final int MAX_CHANGES_PER_PACKET = 1024; - public FluidSystems() { - } - public static class EnsureFluidSection extends HolderSystem { @Nonnull private static final Query QUERY = Query.and(ChunkSection.getComponentType(), Query.not(FluidSection.getComponentType())); - public EnsureFluidSection() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { holder.addComponent(FluidSection.getComponentType(), new FluidSection()); @@ -87,9 +81,6 @@ public class FluidSystems { } public static class LoadPacketGenerator extends ChunkStore.LoadFuturePacketDataQuerySystem { - public LoadPacketGenerator() { - } - public void fetch( int index, @Nonnull ArchetypeChunk archetypeChunk, @@ -128,9 +119,6 @@ public class FluidSystems { @Nonnull private final Set> DEPENDENCIES = Set.of(new SystemDependency<>(Order.BEFORE, LegacyModule.MigrateLegacySections.class)); - public MigrateFromColumn() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { ChunkColumn chunkColumnComponent = holder.getComponent(ChunkColumn.getComponentType()); @@ -179,9 +167,6 @@ public class FluidSystems { @Nonnull private static final Query QUERY = Query.and(ChunkSection.getComponentType(), FluidSection.getComponentType()); - public ReplicateChanges() { - } - @Override public boolean isParallel(int archetypeChunkSize, int taskCount) { return EntityTickingSystem.maybeUseParallel(archetypeChunkSize, taskCount); @@ -307,9 +292,6 @@ public class FluidSystems { @Nonnull private static final Set> DEPENDENCIES = Set.of(new SystemDependency<>(Order.AFTER, FluidSystems.MigrateFromColumn.class)); - public SetupSection() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { ChunkSection chunkSectionComponent = holder.getComponent(ChunkSection.getComponentType()); @@ -348,9 +330,6 @@ public class FluidSystems { new SystemDependency<>(Order.AFTER, ChunkBlockTickSystem.PreTick.class), new SystemDependency<>(Order.BEFORE, ChunkBlockTickSystem.Ticking.class) ); - public Ticking() { - } - @Override public boolean isParallel(int archetypeChunkSize, int taskCount) { return EntityTickingSystem.useParallel(archetypeChunkSize, taskCount); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/ArrayUtil.java b/src/com/hypixel/hytale/builtin/hytalegenerator/ArrayUtil.java index 53d744f..5d8a4ce 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/ArrayUtil.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/ArrayUtil.java @@ -7,9 +7,6 @@ import java.util.function.BiFunction; import javax.annotation.Nonnull; public class ArrayUtil { - public ArrayUtil() { - } - @Nonnull public static T[] brokenCopyOf(@Nonnull T[] a) { T[] copy = (T[])(new Object[a.length]); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/BlockMask.java b/src/com/hypixel/hytale/builtin/hytalegenerator/BlockMask.java index ff642cd..ba12538 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/BlockMask.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/BlockMask.java @@ -11,9 +11,6 @@ public class BlockMask { private final List sourceBlocks = new ArrayList<>(0); private final List destinationBlocks = new ArrayList<>(0); - public BlockMask() { - } - public boolean canPlace(@Nonnull Material material) { return !this.skippedBlocks.test(material); } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/FutureUtils.java b/src/com/hypixel/hytale/builtin/hytalegenerator/FutureUtils.java index e7c9894..91be0d0 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/FutureUtils.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/FutureUtils.java @@ -5,9 +5,6 @@ import java.util.concurrent.CompletableFuture; import javax.annotation.Nonnull; public class FutureUtils { - public FutureUtils() { - } - public static CompletableFuture allOf(@Nonnull List> tasks) { return CompletableFuture.allOf(tasks.toArray(new CompletableFuture[tasks.size()])); } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/Indexer.java b/src/com/hypixel/hytale/builtin/hytalegenerator/Indexer.java index fe66b45..99ed4a1 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/Indexer.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/Indexer.java @@ -6,9 +6,6 @@ import java.util.Map; public class Indexer { private Map ids = new HashMap<>(); - public Indexer() { - } - public int getIdFor(Object o) { return this.ids.computeIfAbsent(o, k -> this.ids.size()); } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/LoggerUtil.java b/src/com/hypixel/hytale/builtin/hytalegenerator/LoggerUtil.java index 3fbd982..f9be9a8 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/LoggerUtil.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/LoggerUtil.java @@ -7,9 +7,6 @@ import javax.annotation.Nonnull; public class LoggerUtil { public static final String HYTALE_GENERATOR_NAME = "HytaleGenerator"; - public LoggerUtil() { - } - public static Logger getLogger() { return Logger.getLogger("HytaleGenerator"); } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/VectorUtil.java b/src/com/hypixel/hytale/builtin/hytalegenerator/VectorUtil.java index e054009..c736224 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/VectorUtil.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/VectorUtil.java @@ -13,9 +13,6 @@ import java.util.List; import javax.annotation.Nonnull; public class VectorUtil { - public VectorUtil() { - } - public static boolean areasOverlap(@Nonnull Vector3d minA, @Nonnull Vector3d maxA, @Nonnull Vector3d minB, @Nonnull Vector3d maxB) { return isAnyGreater(maxA, minB) && isAnySmaller(minA, maxB); } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/AssetManager.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/AssetManager.java index 142c4d8..1c95744 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/AssetManager.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/AssetManager.java @@ -170,9 +170,9 @@ import com.hypixel.hytale.builtin.hytalegenerator.assets.positionproviders.Mesh2 import com.hypixel.hytale.builtin.hytalegenerator.assets.positionproviders.Mesh3DPositionProviderAsset; import com.hypixel.hytale.builtin.hytalegenerator.assets.positionproviders.OffsetPositionProviderAsset; import com.hypixel.hytale.builtin.hytalegenerator.assets.positionproviders.PositionProviderAsset; +import com.hypixel.hytale.builtin.hytalegenerator.assets.positionproviders.SimpleHorizontalPositionProviderAsset; import com.hypixel.hytale.builtin.hytalegenerator.assets.positionproviders.SpherePositionProviderAsset; import com.hypixel.hytale.builtin.hytalegenerator.assets.positionproviders.UnionPositionProviderAsset; -import com.hypixel.hytale.builtin.hytalegenerator.assets.positionproviders.VerticalEliminatorPositionProviderAsset; import com.hypixel.hytale.builtin.hytalegenerator.assets.propassignments.AssignmentsAsset; import com.hypixel.hytale.builtin.hytalegenerator.assets.propassignments.ConstantAssignmentsAsset; import com.hypixel.hytale.builtin.hytalegenerator.assets.propassignments.FieldFunctionAssignmentsAsset; @@ -184,10 +184,12 @@ import com.hypixel.hytale.builtin.hytalegenerator.assets.props.ClusterPropAsset; import com.hypixel.hytale.builtin.hytalegenerator.assets.props.ColumnPropAsset; import com.hypixel.hytale.builtin.hytalegenerator.assets.props.DensityPropAsset; import com.hypixel.hytale.builtin.hytalegenerator.assets.props.ImportedPropAsset; +import com.hypixel.hytale.builtin.hytalegenerator.assets.props.OffsetPropAsset; import com.hypixel.hytale.builtin.hytalegenerator.assets.props.PondFillerPropAsset; import com.hypixel.hytale.builtin.hytalegenerator.assets.props.PropAsset; import com.hypixel.hytale.builtin.hytalegenerator.assets.props.QueuePropAsset; import com.hypixel.hytale.builtin.hytalegenerator.assets.props.UnionPropAsset; +import com.hypixel.hytale.builtin.hytalegenerator.assets.props.WeightedPropAsset; import com.hypixel.hytale.builtin.hytalegenerator.assets.props.prefabprop.PrefabPropAsset; import com.hypixel.hytale.builtin.hytalegenerator.assets.props.prefabprop.directionality.DirectionalityAsset; import com.hypixel.hytale.builtin.hytalegenerator.assets.props.prefabprop.directionality.ImportedDirectionalityAsset; @@ -498,7 +500,7 @@ public class AssetManager { .register("Occurrence", FieldFunctionOccurrencePositionProviderAsset.class, FieldFunctionOccurrencePositionProviderAsset.CODEC); PositionProviderAsset.CODEC.register("Offset", OffsetPositionProviderAsset.class, OffsetPositionProviderAsset.CODEC); PositionProviderAsset.CODEC.register("Union", UnionPositionProviderAsset.class, UnionPositionProviderAsset.CODEC); - PositionProviderAsset.CODEC.register("VerticalEliminator", VerticalEliminatorPositionProviderAsset.class, VerticalEliminatorPositionProviderAsset.CODEC); + PositionProviderAsset.CODEC.register("SimpleHorizontal", SimpleHorizontalPositionProviderAsset.class, SimpleHorizontalPositionProviderAsset.CODEC); PositionProviderAsset.CODEC.register("Cache", CachedPositionProviderAsset.class, CachedPositionProviderAsset.CODEC); PositionProviderAsset.CODEC.register("BaseHeight", BaseHeightPositionProviderAsset.class, BaseHeightPositionProviderAsset.CODEC); PositionProviderAsset.CODEC.register("Imported", ImportedPositionProviderAsset.class, ImportedPositionProviderAsset.CODEC); @@ -519,6 +521,8 @@ public class AssetManager { PropAsset.CODEC.register("Prefab", PrefabPropAsset.class, PrefabPropAsset.CODEC); PropAsset.CODEC.register("PondFiller", PondFillerPropAsset.class, PondFillerPropAsset.CODEC); PropAsset.CODEC.register("Density", DensityPropAsset.class, DensityPropAsset.CODEC); + PropAsset.CODEC.register("Offset", OffsetPropAsset.class, OffsetPropAsset.CODEC); + PropAsset.CODEC.register("Weighted", WeightedPropAsset.class, WeightedPropAsset.CODEC); DirectionalityAsset.CODEC.register("Imported", ImportedDirectionalityAsset.class, ImportedDirectionalityAsset.CODEC); DirectionalityAsset.CODEC.register("Static", StaticDirectionalityAsset.class, StaticDirectionalityAsset.CODEC); DirectionalityAsset.CODEC.register("Random", RandomDirectionalityAsset.class, RandomDirectionalityAsset.CODEC); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/ValidatorUtil.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/ValidatorUtil.java index 7b2e35d..e688ecc 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/ValidatorUtil.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/ValidatorUtil.java @@ -5,9 +5,6 @@ import com.hypixel.hytale.codec.validation.ValidationResults; import javax.annotation.Nonnull; public class ValidatorUtil { - public ValidatorUtil() { - } - @Nonnull public static LegacyValidator validEnumValue(@Nonnull final T[] values) { return new LegacyValidator() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/blockmask/BlockMaskAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/blockmask/BlockMaskAsset.java index b420016..084830e 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/blockmask/BlockMaskAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/blockmask/BlockMaskAsset.java @@ -63,9 +63,6 @@ public class BlockMaskAsset implements JsonAssetWithMap materials = new ArrayList<>(this.materialAssets.length); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/CeilingCurveAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/CeilingCurveAsset.java index 04eaeb9..e37d921 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/CeilingCurveAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/CeilingCurveAsset.java @@ -16,9 +16,6 @@ public class CeilingCurveAsset extends CurveAsset { private CurveAsset curveAsset = new ConstantCurveAsset(); private double limit = 0.0; - public CeilingCurveAsset() { - } - @Nonnull @Override public Double2DoubleFunction build() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/ClampCurveAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/ClampCurveAsset.java index 90e844e..516b5e5 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/ClampCurveAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/ClampCurveAsset.java @@ -20,9 +20,6 @@ public class ClampCurveAsset extends CurveAsset { private double wallA = 1.0; private double wallB = -1.0; - public ClampCurveAsset() { - } - @Nonnull @Override public Double2DoubleFunction build() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/DistanceExponentialCurveAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/DistanceExponentialCurveAsset.java index ae50dbb..d2bf961 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/DistanceExponentialCurveAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/DistanceExponentialCurveAsset.java @@ -21,9 +21,6 @@ public class DistanceExponentialCurveAsset extends CurveAsset { private double exponent = 1.0; private double range = 1.0; - public DistanceExponentialCurveAsset() { - } - @Nonnull @Override public Double2DoubleFunction build() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/DistanceSCurveAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/DistanceSCurveAsset.java index 469dfb9..030563c 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/DistanceSCurveAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/DistanceSCurveAsset.java @@ -34,9 +34,6 @@ public class DistanceSCurveAsset extends CurveAsset { private double transition = 1.0; private double transitionSmooth = 1.0; - public DistanceSCurveAsset() { - } - @Nonnull @Override public Double2DoubleFunction build() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/FloorCurveAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/FloorCurveAsset.java index 331a63f..a5e22c7 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/FloorCurveAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/FloorCurveAsset.java @@ -16,9 +16,6 @@ public class FloorCurveAsset extends CurveAsset { private CurveAsset curveAsset = new ConstantCurveAsset(); private double limit = 0.0; - public FloorCurveAsset() { - } - @Nonnull @Override public Double2DoubleFunction build() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/ImportedCurveAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/ImportedCurveAsset.java index b3afd2c..2e37c43 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/ImportedCurveAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/ImportedCurveAsset.java @@ -15,9 +15,6 @@ public class ImportedCurveAsset extends CurveAsset { .build(); private String name; - public ImportedCurveAsset() { - } - @Override public Double2DoubleFunction build() { if (this.name != null && !this.name.isEmpty()) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/InverterCurveAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/InverterCurveAsset.java index 972ecfb..0853e16 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/InverterCurveAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/InverterCurveAsset.java @@ -14,9 +14,6 @@ public class InverterCurveAsset extends CurveAsset { .build(); private CurveAsset curveAsset = new ConstantCurveAsset(); - public InverterCurveAsset() { - } - @Nonnull @Override public Double2DoubleFunction build() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/MaxCurveAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/MaxCurveAsset.java index 50c350f..0771e4e 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/MaxCurveAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/MaxCurveAsset.java @@ -13,9 +13,6 @@ public class MaxCurveAsset extends CurveAsset { .build(); private CurveAsset[] curveAssets = new CurveAsset[0]; - public MaxCurveAsset() { - } - @Nonnull @Override public Double2DoubleFunction build() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/MinCurveAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/MinCurveAsset.java index 655ffe3..fb0f161 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/MinCurveAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/MinCurveAsset.java @@ -13,9 +13,6 @@ public class MinCurveAsset extends CurveAsset { .build(); private CurveAsset[] curveAssets = new CurveAsset[0]; - public MinCurveAsset() { - } - @Nonnull @Override public Double2DoubleFunction build() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/MultiplierCurveAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/MultiplierCurveAsset.java index d22964e..c691c0d 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/MultiplierCurveAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/MultiplierCurveAsset.java @@ -15,9 +15,6 @@ public class MultiplierCurveAsset extends CurveAsset { .build(); private CurveAsset[] curveAssets = new CurveAsset[0]; - public MultiplierCurveAsset() { - } - @Nonnull @Override public Double2DoubleFunction build() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/NotCurveAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/NotCurveAsset.java index bd08ba5..87c9475 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/NotCurveAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/NotCurveAsset.java @@ -12,9 +12,6 @@ public class NotCurveAsset extends CurveAsset { .build(); private CurveAsset curveAsset = new ConstantCurveAsset(); - public NotCurveAsset() { - } - @Nonnull @Override public Double2DoubleFunction build() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/SmoothCeilingCurveAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/SmoothCeilingCurveAsset.java index af63bce..0a2db0b 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/SmoothCeilingCurveAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/SmoothCeilingCurveAsset.java @@ -24,9 +24,6 @@ public class SmoothCeilingCurveAsset extends CurveAsset { private double range = 0.0; private double limit = 0.0; - public SmoothCeilingCurveAsset() { - } - @Nonnull @Override public Double2DoubleFunction build() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/SmoothClampCurveAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/SmoothClampCurveAsset.java index 6113c76..8681225 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/SmoothClampCurveAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/SmoothClampCurveAsset.java @@ -27,9 +27,6 @@ public class SmoothClampCurveAsset extends CurveAsset { private double wallB = -1.0; private double range = 0.0; - public SmoothClampCurveAsset() { - } - @Nonnull @Override public Double2DoubleFunction build() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/SmoothFloorCurveAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/SmoothFloorCurveAsset.java index 0b0d9e2..f550c72 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/SmoothFloorCurveAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/SmoothFloorCurveAsset.java @@ -24,9 +24,6 @@ public class SmoothFloorCurveAsset extends CurveAsset { private double range = 0.0; private double limit = 0.0; - public SmoothFloorCurveAsset() { - } - @Nonnull @Override public Double2DoubleFunction build() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/SmoothMaxCurveAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/SmoothMaxCurveAsset.java index 02ea892..adc71a6 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/SmoothMaxCurveAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/SmoothMaxCurveAsset.java @@ -24,9 +24,6 @@ public class SmoothMaxCurveAsset extends CurveAsset { private CurveAsset curveBAsset = new ConstantCurveAsset(); private double range = 0.0; - public SmoothMaxCurveAsset() { - } - @Nonnull @Override public Double2DoubleFunction build() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/SmoothMinCurveAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/SmoothMinCurveAsset.java index 3398946..8e7245c 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/SmoothMinCurveAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/SmoothMinCurveAsset.java @@ -24,9 +24,6 @@ public class SmoothMinCurveAsset extends CurveAsset { private CurveAsset curveBAsset = new ConstantCurveAsset(); private double range = 0.0; - public SmoothMinCurveAsset() { - } - @Nonnull @Override public Double2DoubleFunction build() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/SumCurveAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/SumCurveAsset.java index fe2cce8..c3fd5b1 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/SumCurveAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/SumCurveAsset.java @@ -13,9 +13,6 @@ public class SumCurveAsset extends CurveAsset { .build(); private CurveAsset[] curveAssets = new CurveAsset[0]; - public SumCurveAsset() { - } - @Nonnull @Override public Double2DoubleFunction build() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/legacy/NodeFunctionYOutAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/legacy/NodeFunctionYOutAsset.java index 1dcae9f..6855ca2 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/legacy/NodeFunctionYOutAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/curves/legacy/NodeFunctionYOutAsset.java @@ -43,9 +43,6 @@ public class NodeFunctionYOutAsset implements JsonAssetWithMap CODEC = BuilderCodec.builder(AbsDensityAsset.class, AbsDensityAsset::new, DensityAsset.ABSTRACT_CODEC) .build(); - public AbsDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/AmplitudeConstantAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/AmplitudeConstantAsset.java index bdd7e84..478878d 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/AmplitudeConstantAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/AmplitudeConstantAsset.java @@ -17,9 +17,6 @@ public class AmplitudeConstantAsset extends DensityAsset { .build(); private double value = 0.0; - public AmplitudeConstantAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/AmplitudeDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/AmplitudeDensityAsset.java index 5ea0094..4c48813 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/AmplitudeDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/AmplitudeDensityAsset.java @@ -17,9 +17,6 @@ public class AmplitudeDensityAsset extends DensityAsset { .build(); private NodeFunctionYOutAsset nodeFunctionYOutAsset = new NodeFunctionYOutAsset(); - public AmplitudeDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/AnchorDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/AnchorDensityAsset.java index ac2c9ea..cdd51a3 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/AnchorDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/AnchorDensityAsset.java @@ -17,9 +17,6 @@ public class AnchorDensityAsset extends DensityAsset { .build(); private boolean isReversed = false; - public AnchorDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/AngleDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/AngleDensityAsset.java index d846c13..4346a22 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/AngleDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/AngleDensityAsset.java @@ -31,9 +31,6 @@ public class AngleDensityAsset extends DensityAsset { private Vector3d vector = new Vector3d(); private boolean isAxis = false; - public AngleDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/AxisDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/AxisDensityAsset.java index df29a24..64badeb 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/AxisDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/AxisDensityAsset.java @@ -30,9 +30,6 @@ public class AxisDensityAsset extends DensityAsset { private Vector3d axis = new Vector3d(0.0, 1.0, 0.0); private boolean isAnchored = false; - public AxisDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/BaseHeightDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/BaseHeightDensityAsset.java index a569bd0..43fe007 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/BaseHeightDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/BaseHeightDensityAsset.java @@ -23,9 +23,6 @@ public class BaseHeightDensityAsset extends DensityAsset { private String baseHeightName = ""; private boolean isDistance = false; - public BaseHeightDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/Cache2dDensityAsset_Deprecated.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/Cache2dDensityAsset_Deprecated.java index 7cab7b3..5749702 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/Cache2dDensityAsset_Deprecated.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/Cache2dDensityAsset_Deprecated.java @@ -18,9 +18,6 @@ public class Cache2dDensityAsset_Deprecated extends DensityAsset { .build(); private double y = 0.0; - public Cache2dDensityAsset_Deprecated() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CacheDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CacheDensityAsset.java index c22ff74..3e24e37 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CacheDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CacheDensityAsset.java @@ -20,9 +20,6 @@ public class CacheDensityAsset extends DensityAsset { public static int DEFAULT_CAPACITY = 3; private int capacity = DEFAULT_CAPACITY; - public CacheDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CeilingDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CeilingDensityAsset.java index a05faea..38a1918 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CeilingDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CeilingDensityAsset.java @@ -17,9 +17,6 @@ public class CeilingDensityAsset extends DensityAsset { .build(); private double limit = 0.0; - public CeilingDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CellNoise2DDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CellNoise2DDensityAsset.java index 745aec7..ff07756 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CellNoise2DDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CellNoise2DDensityAsset.java @@ -26,9 +26,6 @@ public class CellNoise2DDensityAsset extends DensityAsset { private String seedKey = "A"; private FastNoiseLite.CellularReturnType cellType = FastNoiseLite.CellularReturnType.CellValue; - public CellNoise2DDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CellNoise3DDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CellNoise3DDensityAsset.java index 1482c2c..76c8479 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CellNoise3DDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CellNoise3DDensityAsset.java @@ -45,9 +45,6 @@ public class CellNoise3DDensityAsset extends DensityAsset { private String seedKey = "A"; private FastNoiseLite.CellularReturnType cellType = FastNoiseLite.CellularReturnType.CellValue; - public CellNoise3DDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CellWallDistanceDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CellWallDistanceDensityAsset.java index 89c1abf..952ed0c 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CellWallDistanceDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CellWallDistanceDensityAsset.java @@ -12,9 +12,6 @@ public class CellWallDistanceDensityAsset extends DensityAsset { ) .build(); - public CellWallDistanceDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ClampDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ClampDensityAsset.java index aabd719..059fa0f 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ClampDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ClampDensityAsset.java @@ -20,9 +20,6 @@ public class ClampDensityAsset extends DensityAsset { private double wallA = 0.0; private double wallB = 0.0; - public ClampDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ConstantDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ConstantDensityAsset.java index 2e59217..a17ef09 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ConstantDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ConstantDensityAsset.java @@ -16,9 +16,6 @@ public class ConstantDensityAsset extends DensityAsset { .build(); private double value = 0.0; - public ConstantDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CubeDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CubeDensityAsset.java index f830754..04b9ee1 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CubeDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CubeDensityAsset.java @@ -16,9 +16,6 @@ public class CubeDensityAsset extends DensityAsset { .build(); private CurveAsset densityCurveAsset = new ConstantCurveAsset(); - public CubeDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CuboidDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CuboidDensityAsset.java index d002f89..bdd54f8 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CuboidDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CuboidDensityAsset.java @@ -42,9 +42,6 @@ public class CuboidDensityAsset extends DensityAsset { private Vector3d newYAxis = new Vector3d(0.0, 1.0, 0.0); private double spinAngle = 0.0; - public CuboidDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CurveMapperDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CurveMapperDensityAsset.java index 11d9d7b..e07e33a 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CurveMapperDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CurveMapperDensityAsset.java @@ -18,9 +18,6 @@ public class CurveMapperDensityAsset extends DensityAsset { .build(); private CurveAsset curveAsset = new ConstantCurveAsset(); - public CurveMapperDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CylinderDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CylinderDensityAsset.java index 2bc46ee..0efa814 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CylinderDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/CylinderDensityAsset.java @@ -35,9 +35,6 @@ public class CylinderDensityAsset extends DensityAsset { private Vector3d newYAxis = new Vector3d(0.0, 1.0, 0.0); private double spinAngle = 0.0; - public CylinderDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/DensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/DensityAsset.java index a5f2dab..93de92d 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/DensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/DensityAsset.java @@ -229,8 +229,5 @@ public abstract class DensityAsset implements JsonAssetWithMap("YFor2D", Codec.DOUBLE, false), (t, k) -> t.y2d = k, t -> t.y2d) .add() - .append(new KeyedCodec<>("CacheSizeFor2D", Codec.INTEGER, false), (t, k) -> t._2dCacheSize = k, t -> t._2dCacheSize) - .add() .build(); private double sampleRange = 1.0; private double warpFactor = 1.0; private boolean is2d = false; private double y2d = 0.0; - private int _2dCacheSize = 16; - - public GradientWarpDensityAsset() { - } @Nonnull @Override diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ImportedDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ImportedDensityAsset.java index ffc2516..4260a55 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ImportedDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ImportedDensityAsset.java @@ -17,9 +17,6 @@ public class ImportedDensityAsset extends DensityAsset { .build(); private String importedNodeName = ""; - public ImportedDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/InverterDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/InverterDensityAsset.java index a3a74d8..da48a5f 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/InverterDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/InverterDensityAsset.java @@ -12,9 +12,6 @@ public class InverterDensityAsset extends DensityAsset { ) .build(); - public InverterDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/MaxDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/MaxDensityAsset.java index 8ce768c..ef39eef 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/MaxDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/MaxDensityAsset.java @@ -10,9 +10,6 @@ public class MaxDensityAsset extends DensityAsset { public static final BuilderCodec CODEC = BuilderCodec.builder(MaxDensityAsset.class, MaxDensityAsset::new, DensityAsset.ABSTRACT_CODEC) .build(); - public MaxDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/MinDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/MinDensityAsset.java index 43118d2..63d0714 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/MinDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/MinDensityAsset.java @@ -10,9 +10,6 @@ public class MinDensityAsset extends DensityAsset { public static final BuilderCodec CODEC = BuilderCodec.builder(MinDensityAsset.class, MinDensityAsset::new, DensityAsset.ABSTRACT_CODEC) .build(); - public MinDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/MixDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/MixDensityAsset.java index 7d9b126..2450567 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/MixDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/MixDensityAsset.java @@ -11,9 +11,6 @@ public class MixDensityAsset extends DensityAsset { public static final BuilderCodec CODEC = BuilderCodec.builder(MixDensityAsset.class, MixDensityAsset::new, DensityAsset.ABSTRACT_CODEC) .build(); - public MixDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/MultiMixDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/MultiMixDensityAsset.java index 7eb208f..9ed9615 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/MultiMixDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/MultiMixDensityAsset.java @@ -29,9 +29,6 @@ public class MultiMixDensityAsset extends DensityAsset { .build(); private MultiMixDensityAsset.KeyAsset[] keyAssets = new MultiMixDensityAsset.KeyAsset[0]; - public MultiMixDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { @@ -130,9 +127,6 @@ public class MultiMixDensityAsset extends DensityAsset { private double value = 0.0; private int densityIndex = 0; - public KeyAsset() { - } - public String getId() { return this.id; } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/MultiplierDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/MultiplierDensityAsset.java index 21d0eaa..543b7c5 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/MultiplierDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/MultiplierDensityAsset.java @@ -12,9 +12,6 @@ public class MultiplierDensityAsset extends DensityAsset { ) .build(); - public MultiplierDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/NormalizerDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/NormalizerDensityAsset.java index f39021d..86692c8 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/NormalizerDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/NormalizerDensityAsset.java @@ -26,9 +26,6 @@ public class NormalizerDensityAsset extends DensityAsset { private double toMin = 0.0; private double toMax = 1.0; - public NormalizerDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/OffsetConstantAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/OffsetConstantAsset.java index 69b1f95..ba70899 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/OffsetConstantAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/OffsetConstantAsset.java @@ -17,9 +17,6 @@ public class OffsetConstantAsset extends DensityAsset { .build(); private double value = 0.0; - public OffsetConstantAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/OffsetDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/OffsetDensityAsset.java index 3873446..df72d7b 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/OffsetDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/OffsetDensityAsset.java @@ -17,9 +17,6 @@ public class OffsetDensityAsset extends DensityAsset { .build(); private NodeFunctionYOutAsset nodeFunctionYOutAsset = new NodeFunctionYOutAsset(); - public OffsetDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/PipelineDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/PipelineDensityAsset.java index 1588cdb..854894c 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/PipelineDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/PipelineDensityAsset.java @@ -17,9 +17,6 @@ public class PipelineDensityAsset extends DensityAsset { .build(); private DensityAsset[] pipeline = new DensityAsset[0]; - public PipelineDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/PlaneDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/PlaneDensityAsset.java index 4dc4be5..82f4336 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/PlaneDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/PlaneDensityAsset.java @@ -32,9 +32,6 @@ public class PlaneDensityAsset extends DensityAsset { private Vector3d planeNormal = new Vector3d(0.0, 1.0, 0.0); private boolean isAnchored = false; - public PlaneDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/PositionsPinchDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/PositionsPinchDensityAsset.java index 4fdc959..fd15b13 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/PositionsPinchDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/PositionsPinchDensityAsset.java @@ -44,9 +44,6 @@ public class PositionsPinchDensityAsset extends DensityAsset { private double positionsMinY = 0.0; private double positionsMaxY = 1.0E-6; - public PositionsPinchDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/PositionsTwistDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/PositionsTwistDensityAsset.java index 48d4143..15d20c4 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/PositionsTwistDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/PositionsTwistDensityAsset.java @@ -41,9 +41,6 @@ public class PositionsTwistDensityAsset extends DensityAsset { private boolean normalizeDistance = false; private boolean zeroPositionsY = false; - public PositionsTwistDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/PowDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/PowDensityAsset.java index 0a7ea38..d15a6aa 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/PowDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/PowDensityAsset.java @@ -15,9 +15,6 @@ public class PowDensityAsset extends DensityAsset { .build(); private double exponent = 1.0; - public PowDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/RotatorDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/RotatorDensityAsset.java index 3ef99aa..62f0cb6 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/RotatorDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/RotatorDensityAsset.java @@ -21,9 +21,6 @@ public class RotatorDensityAsset extends DensityAsset { private Vector3d newYAxis = new Vector3d(); private double spinAngle = 0.0; - public RotatorDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ScaleDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ScaleDensityAsset.java index 3131e3d..0aa2be6 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ScaleDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ScaleDensityAsset.java @@ -23,9 +23,6 @@ public class ScaleDensityAsset extends DensityAsset { private double scaleY = 1.0; private double scaleZ = 1.0; - public ScaleDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SelectorDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SelectorDensityAsset.java index b8f3f81..f22e282 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SelectorDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SelectorDensityAsset.java @@ -31,9 +31,6 @@ public class SelectorDensityAsset extends DensityAsset { private double toMax = 1.0; private double smoothRange = 0.0; - public SelectorDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ShellDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ShellDensityAsset.java index 1574fd5..b95bb98 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ShellDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ShellDensityAsset.java @@ -29,9 +29,6 @@ public class ShellDensityAsset extends DensityAsset { private CurveAsset angleCurveAsset = new ConstantCurveAsset(); private CurveAsset distanceCurveAsset = new ConstantCurveAsset(); - public ShellDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SimplexNoise2dDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SimplexNoise2dDensityAsset.java index 40a81cc..72905b3 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SimplexNoise2dDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SimplexNoise2dDensityAsset.java @@ -38,9 +38,6 @@ public class SimplexNoise2dDensityAsset extends DensityAsset { private int octaves = 1; private String seedKey = "A"; - public SimplexNoise2dDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SimplexNoise3DDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SimplexNoise3DDensityAsset.java index 665e46c..6bd4235 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SimplexNoise3DDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SimplexNoise3DDensityAsset.java @@ -40,9 +40,6 @@ public class SimplexNoise3DDensityAsset extends DensityAsset { private int octaves = 1; private String seedKey = "A"; - public SimplexNoise3DDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SliderDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SliderDensityAsset.java index f81130a..0af5a8f 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SliderDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SliderDensityAsset.java @@ -23,9 +23,6 @@ public class SliderDensityAsset extends DensityAsset { private double slideY = 0.0; private double slideZ = 0.0; - public SliderDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SmoothCeilingDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SmoothCeilingDensityAsset.java index de43683..df625a6 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SmoothCeilingDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SmoothCeilingDensityAsset.java @@ -22,9 +22,6 @@ public class SmoothCeilingDensityAsset extends DensityAsset { private double smoothRange = 1.0; private double limit = 0.0; - public SmoothCeilingDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SmoothClampDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SmoothClampDensityAsset.java index de276cb..29cfec0 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SmoothClampDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SmoothClampDensityAsset.java @@ -26,9 +26,6 @@ public class SmoothClampDensityAsset extends DensityAsset { private double wallB = 1.0; private double range = 0.01; - public SmoothClampDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SmoothFloorDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SmoothFloorDensityAsset.java index 1d27d18..0e5a82e 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SmoothFloorDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SmoothFloorDensityAsset.java @@ -22,9 +22,6 @@ public class SmoothFloorDensityAsset extends DensityAsset { private double smoothRange = 1.0; private double limit = 0.0; - public SmoothFloorDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SmoothMaxDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SmoothMaxDensityAsset.java index 011dee9..3e9d78a 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SmoothMaxDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SmoothMaxDensityAsset.java @@ -19,9 +19,6 @@ public class SmoothMaxDensityAsset extends DensityAsset { .build(); private double range = 1.0; - public SmoothMaxDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SmoothMinDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SmoothMinDensityAsset.java index 5d04c3e..4e27fcf 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SmoothMinDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SmoothMinDensityAsset.java @@ -19,9 +19,6 @@ public class SmoothMinDensityAsset extends DensityAsset { .build(); private double range = 1.0; - public SmoothMinDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SqrtDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SqrtDensityAsset.java index ac1c25b..97b4c95 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SqrtDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SqrtDensityAsset.java @@ -10,9 +10,6 @@ public class SqrtDensityAsset extends DensityAsset { public static final BuilderCodec CODEC = BuilderCodec.builder(SqrtDensityAsset.class, SqrtDensityAsset::new, DensityAsset.ABSTRACT_CODEC) .build(); - public SqrtDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SumDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SumDensityAsset.java index d8a4688..1051b8f 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SumDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SumDensityAsset.java @@ -10,9 +10,6 @@ public class SumDensityAsset extends DensityAsset { public static final BuilderCodec CODEC = BuilderCodec.builder(SumDensityAsset.class, SumDensityAsset::new, DensityAsset.ABSTRACT_CODEC) .build(); - public SumDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SwitchDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SwitchDensityAsset.java index 1b64e13..9eebbfb 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SwitchDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SwitchDensityAsset.java @@ -31,9 +31,6 @@ public class SwitchDensityAsset extends DensityAsset { public static final int DEFAULT_STATE_HASH = 0; private SwitchDensityAsset.SwitchCaseAsset[] switchCaseAssets = new SwitchDensityAsset.SwitchCaseAsset[0]; - public SwitchDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { @@ -90,9 +87,6 @@ public class SwitchDensityAsset extends DensityAsset { private String caseState = ""; private DensityAsset densityAsset; - public SwitchCaseAsset() { - } - public String getId() { return this.id; } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SwitchStateDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SwitchStateDensityAsset.java index 7be8d83..2c2d3cc 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SwitchStateDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/SwitchStateDensityAsset.java @@ -18,9 +18,6 @@ public class SwitchStateDensityAsset extends DensityAsset { .build(); private String switchState = ""; - public SwitchStateDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/TerrainDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/TerrainDensityAsset.java index 09cfb67..5dc50ec 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/TerrainDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/TerrainDensityAsset.java @@ -12,9 +12,6 @@ public class TerrainDensityAsset extends DensityAsset { ) .build(); - public TerrainDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/VectorWarpDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/VectorWarpDensityAsset.java index 99b1aa3..7b23d63 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/VectorWarpDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/VectorWarpDensityAsset.java @@ -21,9 +21,6 @@ public class VectorWarpDensityAsset extends DensityAsset { private double warpFactor = 1.0; private Vector3d warpVector = new Vector3d(); - public VectorWarpDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/XOverrideDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/XOverrideDensityAsset.java index b72091a..add1fdd 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/XOverrideDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/XOverrideDensityAsset.java @@ -17,9 +17,6 @@ public class XOverrideDensityAsset extends DensityAsset { .build(); private double value = 0.0; - public XOverrideDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/XValueDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/XValueDensityAsset.java index d4da081..c1cb50a 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/XValueDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/XValueDensityAsset.java @@ -12,9 +12,6 @@ public class XValueDensityAsset extends DensityAsset { ) .build(); - public XValueDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/YOverrideDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/YOverrideDensityAsset.java index 1249a51..e7085a6 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/YOverrideDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/YOverrideDensityAsset.java @@ -17,9 +17,6 @@ public class YOverrideDensityAsset extends DensityAsset { .build(); private double value = 0.0; - public YOverrideDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/YValueDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/YValueDensityAsset.java index 74dbe9b..323bbd3 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/YValueDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/YValueDensityAsset.java @@ -12,9 +12,6 @@ public class YValueDensityAsset extends DensityAsset { ) .build(); - public YValueDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ZOverrideDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ZOverrideDensityAsset.java index d6ea6c9..dfb93d0 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ZOverrideDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ZOverrideDensityAsset.java @@ -17,9 +17,6 @@ public class ZOverrideDensityAsset extends DensityAsset { .build(); private double value = 0.0; - public ZOverrideDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ZValueDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ZValueDensityAsset.java index 7c00620..8eafd57 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ZValueDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/ZValueDensityAsset.java @@ -12,9 +12,6 @@ public class ZValueDensityAsset extends DensityAsset { ) .build(); - public ZValueDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/Positions3DDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/Positions3DDensityAsset.java index dec75fc..a8450c0 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/Positions3DDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/Positions3DDensityAsset.java @@ -36,9 +36,6 @@ public class Positions3DDensityAsset extends DensityAsset { private CurveAsset curveAsset = new ConstantCurveAsset(); private double maxDistance = 0.0; - public Positions3DDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/PositionsCellNoiseDensityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/PositionsCellNoiseDensityAsset.java index 100ce80..6ac5df3 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/PositionsCellNoiseDensityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/PositionsCellNoiseDensityAsset.java @@ -44,9 +44,6 @@ public class PositionsCellNoiseDensityAsset extends DensityAsset { private DistanceFunctionAsset distanceFunctionAsset = new EuclideanDistanceFunctionAsset(); private double maxDistance = 0.0; - public PositionsCellNoiseDensityAsset() { - } - @Nonnull @Override public Density build(@Nonnull DensityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/distancefunctions/EuclideanDistanceFunctionAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/distancefunctions/EuclideanDistanceFunctionAsset.java index efaab68..739f287 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/distancefunctions/EuclideanDistanceFunctionAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/distancefunctions/EuclideanDistanceFunctionAsset.java @@ -12,9 +12,6 @@ public class EuclideanDistanceFunctionAsset extends DistanceFunctionAsset { ) .build(); - public EuclideanDistanceFunctionAsset() { - } - @Nonnull @Override public DistanceFunction build(@Nonnull SeedBox parentSeed, double maxDistance) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/distancefunctions/ManhattanDistanceFunctionAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/distancefunctions/ManhattanDistanceFunctionAsset.java index d9e0108..05e4472 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/distancefunctions/ManhattanDistanceFunctionAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/distancefunctions/ManhattanDistanceFunctionAsset.java @@ -12,9 +12,6 @@ public class ManhattanDistanceFunctionAsset extends DistanceFunctionAsset { ) .build(); - public ManhattanDistanceFunctionAsset() { - } - @Nonnull @Override public DistanceFunction build(@Nonnull SeedBox parentSeed, double maxDistance) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/CellValueReturnTypeAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/CellValueReturnTypeAsset.java index d285ce9..8dd7b05 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/CellValueReturnTypeAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/CellValueReturnTypeAsset.java @@ -27,9 +27,6 @@ public class CellValueReturnTypeAsset extends ReturnTypeAsset { private DensityAsset densityAsset = new ConstantDensityAsset(); private double defaultValue = 0.0; - public CellValueReturnTypeAsset() { - } - @Nonnull @Override public ReturnType build(@Nonnull SeedBox parentSeed, @Nonnull ReferenceBundle referenceBundle, @Nonnull WorkerIndexer workerIndexer) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/CurveReturnTypeAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/CurveReturnTypeAsset.java index 2645907..bc0d4db 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/CurveReturnTypeAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/CurveReturnTypeAsset.java @@ -21,9 +21,6 @@ public class CurveReturnTypeAsset extends ReturnTypeAsset { .build(); private CurveAsset curveAsset = new ConstantCurveAsset(); - public CurveReturnTypeAsset() { - } - @Nonnull @Override public ReturnType build(@Nonnull SeedBox parentSeed, @Nonnull ReferenceBundle referenceBundle, @Nonnull WorkerIndexer workerIndexer) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/DensityReturnTypeAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/DensityReturnTypeAsset.java index da70f44..f803454 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/DensityReturnTypeAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/DensityReturnTypeAsset.java @@ -42,9 +42,6 @@ public class DensityReturnTypeAsset extends ReturnTypeAsset { private DensityReturnTypeAsset.DelimiterAsset[] delimiterAssets = new DensityReturnTypeAsset.DelimiterAsset[0]; private double defaultValue = 0.0; - public DensityReturnTypeAsset() { - } - @Nonnull @Override public ReturnType build(@Nonnull SeedBox parentSeed, @Nonnull ReferenceBundle referenceBundle, @Nonnull WorkerIndexer workerIndexer) { @@ -83,9 +80,6 @@ public class DensityReturnTypeAsset extends ReturnTypeAsset { private double to = 0.0; private DensityAsset densityAsset = new ConstantDensityAsset(); - public DelimiterAsset() { - } - public String getId() { return this.id; } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/Distance2AddReturnTypeAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/Distance2AddReturnTypeAsset.java index f2ce8c1..2313572 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/Distance2AddReturnTypeAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/Distance2AddReturnTypeAsset.java @@ -14,9 +14,6 @@ public class Distance2AddReturnTypeAsset extends ReturnTypeAsset { ) .build(); - public Distance2AddReturnTypeAsset() { - } - @Nonnull @Override public ReturnType build(@Nonnull SeedBox parentSeed, @Nonnull ReferenceBundle referenceBundle, @Nonnull WorkerIndexer workerIndexer) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/Distance2DivReturnTypeAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/Distance2DivReturnTypeAsset.java index 85a9b69..9ff6a0d 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/Distance2DivReturnTypeAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/Distance2DivReturnTypeAsset.java @@ -14,9 +14,6 @@ public class Distance2DivReturnTypeAsset extends ReturnTypeAsset { ) .build(); - public Distance2DivReturnTypeAsset() { - } - @Nonnull @Override public ReturnType build(@Nonnull SeedBox parentSeed, @Nonnull ReferenceBundle referenceBundle, @Nonnull WorkerIndexer workerIndexer) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/Distance2MulReturnTypeAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/Distance2MulReturnTypeAsset.java index 6519b41..68e9361 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/Distance2MulReturnTypeAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/Distance2MulReturnTypeAsset.java @@ -14,9 +14,6 @@ public class Distance2MulReturnTypeAsset extends ReturnTypeAsset { ) .build(); - public Distance2MulReturnTypeAsset() { - } - @Nonnull @Override public ReturnType build(@Nonnull SeedBox parentSeed, @Nonnull ReferenceBundle referenceBundle, @Nonnull WorkerIndexer workerIndexer) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/Distance2ReturnTypeAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/Distance2ReturnTypeAsset.java index 6acdbfe..39a20aa 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/Distance2ReturnTypeAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/Distance2ReturnTypeAsset.java @@ -14,9 +14,6 @@ public class Distance2ReturnTypeAsset extends ReturnTypeAsset { ) .build(); - public Distance2ReturnTypeAsset() { - } - @Nonnull @Override public ReturnType build(@Nonnull SeedBox parentSeed, @Nonnull ReferenceBundle referenceBundle, @Nonnull WorkerIndexer workerIndexer) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/Distance2SubReturnTypeAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/Distance2SubReturnTypeAsset.java index 83917cd..c86360d 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/Distance2SubReturnTypeAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/Distance2SubReturnTypeAsset.java @@ -14,9 +14,6 @@ public class Distance2SubReturnTypeAsset extends ReturnTypeAsset { ) .build(); - public Distance2SubReturnTypeAsset() { - } - @Nonnull @Override public ReturnType build(@Nonnull SeedBox parentSeed, @Nonnull ReferenceBundle referenceBundle, @Nonnull WorkerIndexer workerIndexer) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/DistanceReturnTypeAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/DistanceReturnTypeAsset.java index 11d3f16..9258cef 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/DistanceReturnTypeAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/DistanceReturnTypeAsset.java @@ -14,9 +14,6 @@ public class DistanceReturnTypeAsset extends ReturnTypeAsset { ) .build(); - public DistanceReturnTypeAsset() { - } - @Nonnull @Override public ReturnType build(@Nonnull SeedBox parentSeed, @Nonnull ReferenceBundle referenceBundle, @Nonnull WorkerIndexer workerIndexer) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/ImportedReturnTypeAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/ImportedReturnTypeAsset.java index 5c845c0..8923cdf 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/ImportedReturnTypeAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/density/positions/returntypes/ImportedReturnTypeAsset.java @@ -22,9 +22,6 @@ public class ImportedReturnTypeAsset extends ReturnTypeAsset { .build(); private String importedAssetName = ""; - public ImportedReturnTypeAsset() { - } - @Override public ReturnType build(@Nonnull SeedBox parentSeed, @Nonnull ReferenceBundle referenceBundle, @Nonnull WorkerIndexer workerIndexer) { ReturnTypeAsset asset = getExportedAsset(this.importedAssetName); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/environmentproviders/ConstantEnvironmentProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/environmentproviders/ConstantEnvironmentProviderAsset.java index 27b4259..fe3ffd1 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/environmentproviders/ConstantEnvironmentProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/environmentproviders/ConstantEnvironmentProviderAsset.java @@ -17,9 +17,6 @@ public class ConstantEnvironmentProviderAsset extends EnvironmentProviderAsset { .build(); private String environment = "Unknown"; - public ConstantEnvironmentProviderAsset() { - } - @Nonnull @Override public EnvironmentProvider build(@Nonnull EnvironmentProviderAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/environmentproviders/DensityDelimitedEnvironmentProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/environmentproviders/DensityDelimitedEnvironmentProviderAsset.java index 994a864..f8cf206 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/environmentproviders/DensityDelimitedEnvironmentProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/environmentproviders/DensityDelimitedEnvironmentProviderAsset.java @@ -40,9 +40,6 @@ public class DensityDelimitedEnvironmentProviderAsset extends EnvironmentProvide private DensityDelimitedEnvironmentProviderAsset.DelimiterAsset[] delimiterAssets = new DensityDelimitedEnvironmentProviderAsset.DelimiterAsset[0]; private DensityAsset densityAsset = DensityAsset.getFallbackAsset(); - public DensityDelimitedEnvironmentProviderAsset() { - } - @Nonnull @Override public EnvironmentProvider build(@Nonnull EnvironmentProviderAsset.Argument argument) { @@ -95,9 +92,6 @@ public class DensityDelimitedEnvironmentProviderAsset extends EnvironmentProvide private RangeDoubleAsset rangeAsset = new RangeDoubleAsset(); private EnvironmentProviderAsset environmentProviderAsset = EnvironmentProviderAsset.getFallbackAsset(); - public DelimiterAsset() { - } - @Nonnull public DelimiterDouble build(@Nonnull EnvironmentProviderAsset.Argument argument) { RangeDouble range = this.rangeAsset.build(); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/ConstantMaterialProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/ConstantMaterialProviderAsset.java index c1e1eca..7050a5c 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/ConstantMaterialProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/ConstantMaterialProviderAsset.java @@ -17,9 +17,6 @@ public class ConstantMaterialProviderAsset extends MaterialProviderAsset { .build(); private MaterialAsset materialAsset = new MaterialAsset(); - public ConstantMaterialProviderAsset() { - } - @Nonnull @Override public MaterialProvider build(@Nonnull MaterialProviderAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/DownwardDepthMaterialProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/DownwardDepthMaterialProviderAsset.java index 276e766..23fd516 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/DownwardDepthMaterialProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/DownwardDepthMaterialProviderAsset.java @@ -20,9 +20,6 @@ public class DownwardDepthMaterialProviderAsset extends MaterialProviderAsset { private int depth = 0; private MaterialProviderAsset materialProviderAsset = new ConstantMaterialProviderAsset(); - public DownwardDepthMaterialProviderAsset() { - } - @Nonnull @Override public MaterialProvider build(@Nonnull MaterialProviderAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/DownwardSpaceMaterialProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/DownwardSpaceMaterialProviderAsset.java index 59b289d..19bdc30 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/DownwardSpaceMaterialProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/DownwardSpaceMaterialProviderAsset.java @@ -20,9 +20,6 @@ public class DownwardSpaceMaterialProviderAsset extends MaterialProviderAsset { private int space = 0; private MaterialProviderAsset materialProviderAsset = new ConstantMaterialProviderAsset(); - public DownwardSpaceMaterialProviderAsset() { - } - @Nonnull @Override public MaterialProvider build(@Nonnull MaterialProviderAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/FieldFunctionMaterialProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/FieldFunctionMaterialProviderAsset.java index 43d132a..683d062 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/FieldFunctionMaterialProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/FieldFunctionMaterialProviderAsset.java @@ -38,9 +38,6 @@ public class FieldFunctionMaterialProviderAsset extends MaterialProviderAsset { private DensityAsset densityAsset = new ConstantDensityAsset(); private FieldFunctionMaterialProviderAsset.DelimiterAsset[] delimiterAssets = new FieldFunctionMaterialProviderAsset.DelimiterAsset[0]; - public FieldFunctionMaterialProviderAsset() { - } - @Nonnull @Override public MaterialProvider build(@Nonnull MaterialProviderAsset.Argument argument) { @@ -96,9 +93,6 @@ public class FieldFunctionMaterialProviderAsset extends MaterialProviderAsset { private double to = 0.0; private MaterialProviderAsset materialProviderAsset = new ConstantMaterialProviderAsset(); - public DelimiterAsset() { - } - public String getId() { return this.id; } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/ImportedMaterialProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/ImportedMaterialProviderAsset.java index 8481824..475c8cb 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/ImportedMaterialProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/ImportedMaterialProviderAsset.java @@ -17,9 +17,6 @@ public class ImportedMaterialProviderAsset extends MaterialProviderAsset { .build(); private String name = ""; - public ImportedMaterialProviderAsset() { - } - @Override public MaterialProvider build(@Nonnull MaterialProviderAsset.Argument argument) { if (super.skip()) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/QueueMaterialProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/QueueMaterialProviderAsset.java index b0752b9..1b3b5aa 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/QueueMaterialProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/QueueMaterialProviderAsset.java @@ -19,9 +19,6 @@ public class QueueMaterialProviderAsset extends MaterialProviderAsset { .build(); private MaterialProviderAsset[] queue = new MaterialProviderAsset[0]; - public QueueMaterialProviderAsset() { - } - @Nonnull @Override public MaterialProvider build(@Nonnull MaterialProviderAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/SimpleHorizontalMaterialProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/SimpleHorizontalMaterialProviderAsset.java index 4346c14..a438a2c 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/SimpleHorizontalMaterialProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/SimpleHorizontalMaterialProviderAsset.java @@ -32,9 +32,6 @@ public class SimpleHorizontalMaterialProviderAsset extends MaterialProviderAsset private String topBaseHeightName = ""; private String bottomBaseHeightName = ""; - public SimpleHorizontalMaterialProviderAsset() { - } - @Nonnull @Override public MaterialProvider build(@Nonnull MaterialProviderAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/SolidityMaterialProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/SolidityMaterialProviderAsset.java index 868ac3a..a1c775c 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/SolidityMaterialProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/SolidityMaterialProviderAsset.java @@ -19,9 +19,6 @@ public class SolidityMaterialProviderAsset extends MaterialProviderAsset { private MaterialProviderAsset solidMaterialProvider = new ConstantMaterialProviderAsset(); private MaterialProviderAsset emptyMaterialProvider = new ConstantMaterialProviderAsset(); - public SolidityMaterialProviderAsset() { - } - @Nonnull @Override public MaterialProvider build(@Nonnull MaterialProviderAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/StripedMaterialProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/StripedMaterialProviderAsset.java index 238b531..15841b5 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/StripedMaterialProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/StripedMaterialProviderAsset.java @@ -31,9 +31,6 @@ public class StripedMaterialProviderAsset extends MaterialProviderAsset { private StripedMaterialProviderAsset.StripeAsset[] stripeAssets = new StripedMaterialProviderAsset.StripeAsset[0]; private MaterialProviderAsset materialProviderAsset = new ConstantMaterialProviderAsset(); - public StripedMaterialProviderAsset() { - } - @Nonnull @Override public MaterialProvider build(@Nonnull MaterialProviderAsset.Argument argument) { @@ -81,9 +78,6 @@ public class StripedMaterialProviderAsset extends MaterialProviderAsset { private int topY; private int bottomY; - public StripeAsset() { - } - public String getId() { return this.id; } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/TerrainDensityMaterialProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/TerrainDensityMaterialProviderAsset.java index 0ae9cbe..e5edae7 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/TerrainDensityMaterialProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/TerrainDensityMaterialProviderAsset.java @@ -32,9 +32,6 @@ public class TerrainDensityMaterialProviderAsset extends MaterialProviderAsset { .build(); private TerrainDensityMaterialProviderAsset.DelimiterAsset[] delimiterAssets = new TerrainDensityMaterialProviderAsset.DelimiterAsset[0]; - public TerrainDensityMaterialProviderAsset() { - } - @Nonnull @Override public MaterialProvider build(@Nonnull MaterialProviderAsset.Argument argument) { @@ -87,9 +84,6 @@ public class TerrainDensityMaterialProviderAsset extends MaterialProviderAsset { private double to = 0.0; private MaterialProviderAsset materialProviderAsset = new ConstantMaterialProviderAsset(); - public DelimiterAsset() { - } - public String getId() { return this.id; } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/UpwardDepthMaterialProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/UpwardDepthMaterialProviderAsset.java index 32f3ac7..41995bc 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/UpwardDepthMaterialProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/UpwardDepthMaterialProviderAsset.java @@ -20,9 +20,6 @@ public class UpwardDepthMaterialProviderAsset extends MaterialProviderAsset { private int depth = 0; private MaterialProviderAsset materialProviderAsset = new ConstantMaterialProviderAsset(); - public UpwardDepthMaterialProviderAsset() { - } - @Nonnull @Override public MaterialProvider build(@Nonnull MaterialProviderAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/UpwardSpaceMaterialProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/UpwardSpaceMaterialProviderAsset.java index dbdbed5..baf1fc2 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/UpwardSpaceMaterialProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/UpwardSpaceMaterialProviderAsset.java @@ -20,9 +20,6 @@ public class UpwardSpaceMaterialProviderAsset extends MaterialProviderAsset { private int space = 0; private MaterialProviderAsset materialProviderAsset = new ConstantMaterialProviderAsset(); - public UpwardSpaceMaterialProviderAsset() { - } - @Nonnull @Override public MaterialProvider build(@Nonnull MaterialProviderAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/WeightedMaterialProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/WeightedMaterialProviderAsset.java index 642ec23..6b0cf8b 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/WeightedMaterialProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/WeightedMaterialProviderAsset.java @@ -39,9 +39,6 @@ public class WeightedMaterialProviderAsset extends MaterialProviderAsset { private double skipChance = 0.0; private String seed = ""; - public WeightedMaterialProviderAsset() { - } - @Nonnull @Override public MaterialProvider build(@Nonnull MaterialProviderAsset.Argument argument) { @@ -88,9 +85,6 @@ public class WeightedMaterialProviderAsset extends MaterialProviderAsset { private double weight = 1.0; private MaterialProviderAsset materialProviderAsset; - public WeightedMaterialAsset() { - } - public String getId() { return this.id; } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/SpaceAndDepthMaterialProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/SpaceAndDepthMaterialProviderAsset.java index 4165ae5..e907547 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/SpaceAndDepthMaterialProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/SpaceAndDepthMaterialProviderAsset.java @@ -37,9 +37,6 @@ public class SpaceAndDepthMaterialProviderAsset extends MaterialProviderAsset { private ConditionAsset conditionAsset = new AlwaysTrueConditionAsset(); private LayerAsset[] layerAssets = new LayerAsset[0]; - public SpaceAndDepthMaterialProviderAsset() { - } - @Nonnull @Override public MaterialProvider build(@Nonnull MaterialProviderAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/AlwaysTrueConditionAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/AlwaysTrueConditionAsset.java index 2a482bb..bb3d6b7 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/AlwaysTrueConditionAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/AlwaysTrueConditionAsset.java @@ -11,9 +11,6 @@ public class AlwaysTrueConditionAsset extends ConditionAsset { ) .build(); - public AlwaysTrueConditionAsset() { - } - @Nonnull @Override public SpaceAndDepthMaterialProvider.Condition build() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/AndConditionAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/AndConditionAsset.java index 1266cfa..35b1619 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/AndConditionAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/AndConditionAsset.java @@ -24,9 +24,6 @@ public class AndConditionAsset extends ConditionAsset { .build(); private ConditionAsset[] conditionAssets = new ConditionAsset[0]; - public AndConditionAsset() { - } - @Nonnull @Override public SpaceAndDepthMaterialProvider.Condition build() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/EqualsConditionAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/EqualsConditionAsset.java index 7a60699..e337b53 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/EqualsConditionAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/EqualsConditionAsset.java @@ -20,9 +20,6 @@ public class EqualsConditionAsset extends ConditionAsset { private ConditionParameter parameter = ConditionParameter.SPACE_ABOVE_FLOOR; private int value = 0; - public EqualsConditionAsset() { - } - @Nonnull @Override public SpaceAndDepthMaterialProvider.Condition build() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/GreaterThanConditionAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/GreaterThanConditionAsset.java index 1485cb2..0749e24 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/GreaterThanConditionAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/GreaterThanConditionAsset.java @@ -20,9 +20,6 @@ public class GreaterThanConditionAsset extends ConditionAsset { private ConditionParameter parameter = ConditionParameter.SPACE_ABOVE_FLOOR; private int threshold = 0; - public GreaterThanConditionAsset() { - } - @Nonnull @Override public SpaceAndDepthMaterialProvider.Condition build() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/NotConditionAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/NotConditionAsset.java index 0611584..fd3db55 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/NotConditionAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/NotConditionAsset.java @@ -15,9 +15,6 @@ public class NotConditionAsset extends ConditionAsset { .build(); private ConditionAsset conditionAsset = new AlwaysTrueConditionAsset(); - public NotConditionAsset() { - } - @Nonnull @Override public SpaceAndDepthMaterialProvider.Condition build() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/OrConditionAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/OrConditionAsset.java index 89b37dc..cd0f3f4 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/OrConditionAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/OrConditionAsset.java @@ -22,9 +22,6 @@ public class OrConditionAsset extends ConditionAsset { .build(); private ConditionAsset[] conditionAssets = new ConditionAsset[0]; - public OrConditionAsset() { - } - @Nonnull @Override public SpaceAndDepthMaterialProvider.Condition build() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/SmallerThanConditionAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/SmallerThanConditionAsset.java index ab95c85..b784a5b 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/SmallerThanConditionAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/conditionassets/SmallerThanConditionAsset.java @@ -20,9 +20,6 @@ public class SmallerThanConditionAsset extends ConditionAsset { private ConditionParameter parameter = ConditionParameter.SPACE_ABOVE_FLOOR; private int threshold = 0; - public SmallerThanConditionAsset() { - } - @Nonnull @Override public SpaceAndDepthMaterialProvider.Condition build() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/layerassets/ConstantThicknessLayerAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/layerassets/ConstantThicknessLayerAsset.java index 013a4d5..c3e2442 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/layerassets/ConstantThicknessLayerAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/layerassets/ConstantThicknessLayerAsset.java @@ -24,9 +24,6 @@ public class ConstantThicknessLayerAsset extends LayerAsset { private int thickness = 0; private MaterialProviderAsset materialProviderAsset = new ConstantMaterialProviderAsset(); - public ConstantThicknessLayerAsset() { - } - @Nonnull @Override public SpaceAndDepthMaterialProvider.Layer build(@Nonnull MaterialProviderAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/layerassets/NoiseThicknessAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/layerassets/NoiseThicknessAsset.java index 4356a4d..7209eca 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/layerassets/NoiseThicknessAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/layerassets/NoiseThicknessAsset.java @@ -25,9 +25,6 @@ public class NoiseThicknessAsset extends LayerAsset { private DensityAsset densityAsset = new ConstantDensityAsset(); private MaterialProviderAsset materialProviderAsset = new ConstantMaterialProviderAsset(); - public NoiseThicknessAsset() { - } - @Nonnull @Override public SpaceAndDepthMaterialProvider.Layer build(@Nonnull MaterialProviderAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/layerassets/RangeThicknessAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/layerassets/RangeThicknessAsset.java index b1620c3..061e262 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/layerassets/RangeThicknessAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/layerassets/RangeThicknessAsset.java @@ -30,9 +30,6 @@ public class RangeThicknessAsset extends LayerAsset { private int rangeMin = 0; private int rangeMax = 0; - public RangeThicknessAsset() { - } - @Nonnull @Override public SpaceAndDepthMaterialProvider.Layer build(@Nonnull MaterialProviderAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/layerassets/WeightedThicknessLayerAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/layerassets/WeightedThicknessLayerAsset.java index cfe0fe3..73e1495 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/layerassets/WeightedThicknessLayerAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/materialproviders/spaceanddepth/layerassets/WeightedThicknessLayerAsset.java @@ -41,9 +41,6 @@ public class WeightedThicknessLayerAsset extends LayerAsset { private String seed = ""; private WeightedThicknessLayerAsset.WeightedThicknessAsset[] possibleThicknessAssets = new WeightedThicknessLayerAsset.WeightedThicknessAsset[0]; - public WeightedThicknessLayerAsset() { - } - @Nonnull @Override public SpaceAndDepthMaterialProvider.Layer build(@Nonnull MaterialProviderAsset.Argument argument) { @@ -81,9 +78,6 @@ public class WeightedThicknessLayerAsset extends LayerAsset { private double weight; private int thickness; - public WeightedThicknessAsset() { - } - public String getId() { return this.id; } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/noisegenerators/CellNoiseAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/noisegenerators/CellNoiseAsset.java index b9b6c7f..5293d49 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/noisegenerators/CellNoiseAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/noisegenerators/CellNoiseAsset.java @@ -24,9 +24,6 @@ public class CellNoiseAsset extends NoiseAsset { @Nonnull private FastNoiseLite.CellularReturnType cellType = FastNoiseLite.CellularReturnType.CellValue; - public CellNoiseAsset() { - } - @Nonnull public CellNoiseField build(@Nonnull SeedBox parentSeed) { SeedBox childSeed = parentSeed.child(this.seedKey); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/noisegenerators/SimplexNoiseAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/noisegenerators/SimplexNoiseAsset.java index b884f89..39f77f0 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/noisegenerators/SimplexNoiseAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/noisegenerators/SimplexNoiseAsset.java @@ -31,9 +31,6 @@ public class SimplexNoiseAsset extends NoiseAsset { private int octaves = 1; private String seedKey = "A"; - public SimplexNoiseAsset() { - } - @Nonnull public SimplexNoiseField build(@Nonnull SeedBox parentSeed) { SeedBox childSeed = parentSeed.child(this.seedKey); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/AndPatternAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/AndPatternAsset.java index 373603c..bde6fcb 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/AndPatternAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/AndPatternAsset.java @@ -17,9 +17,6 @@ public class AndPatternAsset extends PatternAsset { .build(); private PatternAsset[] patternAssets = new PatternAsset[0]; - public AndPatternAsset() { - } - @Nonnull @Override public Pattern build(@Nonnull PatternAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/BlockSetPatternAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/BlockSetPatternAsset.java index 3f6b712..bf3ffda 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/BlockSetPatternAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/BlockSetPatternAsset.java @@ -17,9 +17,6 @@ public class BlockSetPatternAsset extends PatternAsset { .build(); private MaterialSetAsset materialSetAsset = new MaterialSetAsset(); - public BlockSetPatternAsset() { - } - @Nonnull @Override public Pattern build(@Nonnull PatternAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/CeilingPatternAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/CeilingPatternAsset.java index a5f04a8..e99150b 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/CeilingPatternAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/CeilingPatternAsset.java @@ -18,9 +18,6 @@ public class CeilingPatternAsset extends PatternAsset { private PatternAsset ceiling = new ConstantPatternAsset(); private PatternAsset origin = new ConstantPatternAsset(); - public CeilingPatternAsset() { - } - @Nonnull @Override public Pattern build(@Nonnull PatternAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/ConstantPatternAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/ConstantPatternAsset.java index 8ebe7a6..274ef30 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/ConstantPatternAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/ConstantPatternAsset.java @@ -16,9 +16,6 @@ public class ConstantPatternAsset extends PatternAsset { .build(); private boolean value = false; - public ConstantPatternAsset() { - } - @Override public Pattern build(@Nonnull PatternAsset.Argument argument) { return super.isSkipped() ? Pattern.noPattern() : new Pattern() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/CuboidPatternAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/CuboidPatternAsset.java index 7994ef2..ac92b7c 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/CuboidPatternAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/CuboidPatternAsset.java @@ -22,9 +22,6 @@ public class CuboidPatternAsset extends PatternAsset { private Vector3i min = new Vector3i(); private Vector3i max = new Vector3i(); - public CuboidPatternAsset() { - } - @Nonnull @Override public Pattern build(@Nonnull PatternAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/DensityPatternAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/DensityPatternAsset.java index ccd83e9..84256ac 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/DensityPatternAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/DensityPatternAsset.java @@ -31,9 +31,6 @@ public class DensityPatternAsset extends PatternAsset { private DensityPatternAsset.DelimiterAsset[] delimiterAssets = new DensityPatternAsset.DelimiterAsset[0]; private DensityAsset densityAsset = new ConstantDensityAsset(); - public DensityPatternAsset() { - } - @Nonnull @Override public Pattern build(@Nonnull PatternAsset.Argument argument) { @@ -76,9 +73,6 @@ public class DensityPatternAsset extends PatternAsset { private double min; private double max; - public DelimiterAsset() { - } - public String getId() { return this.id; } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/FloorPatternAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/FloorPatternAsset.java index 637f99d..853f7d4 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/FloorPatternAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/FloorPatternAsset.java @@ -18,9 +18,6 @@ public class FloorPatternAsset extends PatternAsset { private PatternAsset floor = new ConstantPatternAsset(); private PatternAsset origin = new ConstantPatternAsset(); - public FloorPatternAsset() { - } - @Nonnull @Override public Pattern build(@Nonnull PatternAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/GapPatternAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/GapPatternAsset.java index b1cb97e..dc0143c 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/GapPatternAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/GapPatternAsset.java @@ -43,9 +43,6 @@ public class GapPatternAsset extends PatternAsset { private int depthUp = 0; private Float[] angles = new Float[0]; - public GapPatternAsset() { - } - @Nonnull @Override public Pattern build(@Nonnull PatternAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/ImportedPatternAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/ImportedPatternAsset.java index a9159ea..e98d0ef 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/ImportedPatternAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/ImportedPatternAsset.java @@ -16,9 +16,6 @@ public class ImportedPatternAsset extends PatternAsset { .build(); private String name = ""; - public ImportedPatternAsset() { - } - @Override public Pattern build(@Nonnull PatternAsset.Argument argument) { if (super.isSkipped()) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/MaterialPatternAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/MaterialPatternAsset.java index f7fbe0f..27a880d 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/MaterialPatternAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/MaterialPatternAsset.java @@ -17,9 +17,6 @@ public class MaterialPatternAsset extends PatternAsset { .build(); private MaterialAsset materialAsset = new MaterialAsset(); - public MaterialPatternAsset() { - } - @Override public Pattern build(@Nonnull PatternAsset.Argument argument) { if (super.isSkipped()) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/NotPatternAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/NotPatternAsset.java index 8f6f8a4..f6b634c 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/NotPatternAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/NotPatternAsset.java @@ -13,9 +13,6 @@ public class NotPatternAsset extends PatternAsset { .build(); private PatternAsset patternAsset = new ConstantPatternAsset(); - public NotPatternAsset() { - } - @Nonnull @Override public Pattern build(@Nonnull PatternAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/OffsetPatternAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/OffsetPatternAsset.java index 4cfff31..8c43960 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/OffsetPatternAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/OffsetPatternAsset.java @@ -19,9 +19,6 @@ public class OffsetPatternAsset extends PatternAsset { private PatternAsset patternAsset = new ConstantPatternAsset(); private Vector3i offset = new Vector3i(); - public OffsetPatternAsset() { - } - @Nonnull @Override public Pattern build(@Nonnull PatternAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/OrPatternAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/OrPatternAsset.java index b7d9f9a..2b33028 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/OrPatternAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/OrPatternAsset.java @@ -17,9 +17,6 @@ public class OrPatternAsset extends PatternAsset { .build(); private PatternAsset[] patternAssets = new PatternAsset[0]; - public OrPatternAsset() { - } - @Nonnull @Override public Pattern build(@Nonnull PatternAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/SurfacePatternAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/SurfacePatternAsset.java index faa91a9..f79c23e 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/SurfacePatternAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/SurfacePatternAsset.java @@ -50,9 +50,6 @@ public class SurfacePatternAsset extends PatternAsset { private SurfacePattern.Facing[] facings = new SurfacePattern.Facing[0]; private boolean requireAllFacings = false; - public SurfacePatternAsset() { - } - @Nonnull @Override public Pattern build(@Nonnull PatternAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/WallPatternAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/WallPatternAsset.java index cdf50f9..98d3c2f 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/WallPatternAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/patterns/WallPatternAsset.java @@ -29,9 +29,6 @@ public class WallPatternAsset extends PatternAsset { private WallPattern.WallDirection[] directions = new WallPattern.WallDirection[0]; private boolean matchAll = false; - public WallPatternAsset() { - } - @Nonnull @Override public Pattern build(@Nonnull PatternAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/pointgenerators/MeshPointGeneratorAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/pointgenerators/MeshPointGeneratorAsset.java index e87a6d9..a952b5d 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/pointgenerators/MeshPointGeneratorAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/pointgenerators/MeshPointGeneratorAsset.java @@ -34,9 +34,6 @@ public class MeshPointGeneratorAsset extends PointGeneratorAsset { private double scaleZ = 1.0; private String seedKey = "A"; - public MeshPointGeneratorAsset() { - } - @Override public PointProvider build(@Nonnull SeedBox parentSeed) { SeedBox childSeed = parentSeed.child(this.seedKey); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/pointgenerators/NoPointGeneratorAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/pointgenerators/NoPointGeneratorAsset.java index dc4aa6d..e05291c 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/pointgenerators/NoPointGeneratorAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/pointgenerators/NoPointGeneratorAsset.java @@ -17,9 +17,6 @@ public class NoPointGeneratorAsset extends PointGeneratorAsset { ) .build(); - public NoPointGeneratorAsset() { - } - @Override public PointProvider build(@Nonnull SeedBox parentSeed) { return new PointProvider() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/AnchorPositionProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/AnchorPositionProviderAsset.java index 28d09e4..74fdb59 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/AnchorPositionProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/AnchorPositionProviderAsset.java @@ -19,9 +19,6 @@ public class AnchorPositionProviderAsset extends PositionProviderAsset { private boolean isReversed = false; private PositionProviderAsset positionProviderAsset = new ListPositionProviderAsset(); - public AnchorPositionProviderAsset() { - } - @Nonnull @Override public PositionProvider build(@Nonnull PositionProviderAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/BaseHeightPositionProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/BaseHeightPositionProviderAsset.java index 1374f34..d2723e4 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/BaseHeightPositionProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/BaseHeightPositionProviderAsset.java @@ -30,9 +30,6 @@ public class BaseHeightPositionProviderAsset extends PositionProviderAsset { private String bedName = ""; private PositionProviderAsset positionProviderAsset = new ListPositionProviderAsset(); - public BaseHeightPositionProviderAsset() { - } - @Nonnull @Override public PositionProvider build(@Nonnull PositionProviderAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/CachedPositionProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/CachedPositionProviderAsset.java index 69ca574..eefef21 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/CachedPositionProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/CachedPositionProviderAsset.java @@ -25,9 +25,6 @@ public class CachedPositionProviderAsset extends PositionProviderAsset { private int sectionSize = 32; private int cacheSize = 100; - public CachedPositionProviderAsset() { - } - @Nonnull @Override public PositionProvider build(@Nonnull PositionProviderAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/FieldFunctionOccurrencePositionProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/FieldFunctionOccurrencePositionProviderAsset.java index dc6b0b0..60c0ab8 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/FieldFunctionOccurrencePositionProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/FieldFunctionOccurrencePositionProviderAsset.java @@ -27,9 +27,6 @@ public class FieldFunctionOccurrencePositionProviderAsset extends PositionProvid private DensityAsset densityAsset = new ConstantDensityAsset(); private PositionProviderAsset positionProviderAsset = new ListPositionProviderAsset(); - public FieldFunctionOccurrencePositionProviderAsset() { - } - @Nonnull @Override public PositionProvider build(@Nonnull PositionProviderAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/FieldFunctionPositionProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/FieldFunctionPositionProviderAsset.java index f336a7e..2866afe 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/FieldFunctionPositionProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/FieldFunctionPositionProviderAsset.java @@ -41,9 +41,6 @@ public class FieldFunctionPositionProviderAsset extends PositionProviderAsset { private DensityAsset densityAsset = new ConstantDensityAsset(); private PositionProviderAsset positionProviderAsset = new ListPositionProviderAsset(); - public FieldFunctionPositionProviderAsset() { - } - @Nonnull @Override public PositionProvider build(@Nonnull PositionProviderAsset.Argument argument) { @@ -88,9 +85,6 @@ public class FieldFunctionPositionProviderAsset extends PositionProviderAsset { private double min = 0.0; private double max = 0.0; - public DelimiterAsset() { - } - public String getId() { return this.id; } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/ImportedPositionProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/ImportedPositionProviderAsset.java index b66eb54..f465282 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/ImportedPositionProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/ImportedPositionProviderAsset.java @@ -16,9 +16,6 @@ public class ImportedPositionProviderAsset extends PositionProviderAsset { .build(); private String name = ""; - public ImportedPositionProviderAsset() { - } - @Override public PositionProvider build(@Nonnull PositionProviderAsset.Argument argument) { if (super.skip()) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/ListPositionProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/ListPositionProviderAsset.java index 41c43f3..4c04dd1 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/ListPositionProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/ListPositionProviderAsset.java @@ -27,9 +27,6 @@ public class ListPositionProviderAsset extends PositionProviderAsset { .build(); private ListPositionProviderAsset.PositionAsset[] positions = new ListPositionProviderAsset.PositionAsset[0]; - public ListPositionProviderAsset() { - } - @Nonnull @Override public PositionProvider build(@Nonnull PositionProviderAsset.Argument argument) { @@ -70,9 +67,6 @@ public class ListPositionProviderAsset extends PositionProviderAsset { private int y; private int z; - public PositionAsset() { - } - public String getId() { return this.id; } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/Mesh2DPositionProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/Mesh2DPositionProviderAsset.java index c412e45..7909f93 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/Mesh2DPositionProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/Mesh2DPositionProviderAsset.java @@ -23,9 +23,6 @@ public class Mesh2DPositionProviderAsset extends PositionProviderAsset { private PointGeneratorAsset pointGeneratorAsset = new NoPointGeneratorAsset(); private int y = 0; - public Mesh2DPositionProviderAsset() { - } - @Nonnull @Override public PositionProvider build(@Nonnull PositionProviderAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/Mesh3DPositionProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/Mesh3DPositionProviderAsset.java index ee6ed7b..2fa191d 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/Mesh3DPositionProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/Mesh3DPositionProviderAsset.java @@ -19,9 +19,6 @@ public class Mesh3DPositionProviderAsset extends PositionProviderAsset { .build(); private PointGeneratorAsset pointGeneratorAsset = new NoPointGeneratorAsset(); - public Mesh3DPositionProviderAsset() { - } - @Nonnull @Override public PositionProvider build(@Nonnull PositionProviderAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/OffsetPositionProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/OffsetPositionProviderAsset.java index 56d2a6a..7ce681e 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/OffsetPositionProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/OffsetPositionProviderAsset.java @@ -28,9 +28,6 @@ public class OffsetPositionProviderAsset extends PositionProviderAsset { private int offsetZ = 0; private PositionProviderAsset positionProviderAsset = new ListPositionProviderAsset(); - public OffsetPositionProviderAsset() { - } - @Nonnull @Override public PositionProvider build(@Nonnull PositionProviderAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/VerticalEliminatorPositionProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/SimpleHorizontalPositionProviderAsset.java similarity index 55% rename from src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/VerticalEliminatorPositionProviderAsset.java rename to src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/SimpleHorizontalPositionProviderAsset.java index 8e4a3cb..98b92b3 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/VerticalEliminatorPositionProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/SimpleHorizontalPositionProviderAsset.java @@ -1,32 +1,26 @@ package com.hypixel.hytale.builtin.hytalegenerator.assets.positionproviders; +import com.hypixel.hytale.builtin.hytalegenerator.assets.delimiters.RangeDoubleAsset; import com.hypixel.hytale.builtin.hytalegenerator.positionproviders.PositionProvider; -import com.hypixel.hytale.builtin.hytalegenerator.positionproviders.VerticalEliminatorPositionProvider; -import com.hypixel.hytale.codec.Codec; +import com.hypixel.hytale.builtin.hytalegenerator.positionproviders.SimpleHorizontalPositionProvider; import com.hypixel.hytale.codec.KeyedCodec; import com.hypixel.hytale.codec.builder.BuilderCodec; import javax.annotation.Nonnull; -public class VerticalEliminatorPositionProviderAsset extends PositionProviderAsset { - public static final BuilderCodec CODEC = BuilderCodec.builder( - VerticalEliminatorPositionProviderAsset.class, VerticalEliminatorPositionProviderAsset::new, PositionProviderAsset.ABSTRACT_CODEC +public class SimpleHorizontalPositionProviderAsset extends PositionProviderAsset { + public static final BuilderCodec CODEC = BuilderCodec.builder( + SimpleHorizontalPositionProviderAsset.class, SimpleHorizontalPositionProviderAsset::new, PositionProviderAsset.ABSTRACT_CODEC ) - .append(new KeyedCodec<>("MaxY", Codec.INTEGER, true), (asset, v) -> asset.maxY = v, asset -> asset.maxY) - .add() - .append(new KeyedCodec<>("MinY", Codec.INTEGER, true), (asset, v) -> asset.minY = v, asset -> asset.minY) + .append(new KeyedCodec<>("RangeY", RangeDoubleAsset.CODEC, true), (asset, value) -> asset.rangeYAsset = value, asset -> asset.rangeYAsset) .add() .append( new KeyedCodec<>("Positions", PositionProviderAsset.CODEC, true), (asset, v) -> asset.positionProviderAsset = v, asset -> asset.positionProviderAsset ) .add() .build(); - private int maxY = 0; - private int minY = 0; + private RangeDoubleAsset rangeYAsset = new RangeDoubleAsset(); private PositionProviderAsset positionProviderAsset = new ListPositionProviderAsset(); - public VerticalEliminatorPositionProviderAsset() { - } - @Nonnull @Override public PositionProvider build(@Nonnull PositionProviderAsset.Argument argument) { @@ -34,7 +28,7 @@ public class VerticalEliminatorPositionProviderAsset extends PositionProviderAss return PositionProvider.noPositionProvider(); } else { PositionProvider positionProvider = this.positionProviderAsset.build(argument); - return new VerticalEliminatorPositionProvider(this.minY, this.maxY, positionProvider); + return new SimpleHorizontalPositionProvider(this.rangeYAsset.build(), positionProvider); } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/SpherePositionProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/SpherePositionProviderAsset.java index f8ba70f..e37892c 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/SpherePositionProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/SpherePositionProviderAsset.java @@ -19,9 +19,6 @@ public class SpherePositionProviderAsset extends PositionProviderAsset { private double range = 0.0; private PositionProviderAsset positionProviderAsset = new ListPositionProviderAsset(); - public SpherePositionProviderAsset() { - } - @Nonnull @Override public PositionProvider build(@Nonnull PositionProviderAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/UnionPositionProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/UnionPositionProviderAsset.java index 802850d..57c405f 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/UnionPositionProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/positionproviders/UnionPositionProviderAsset.java @@ -21,9 +21,6 @@ public class UnionPositionProviderAsset extends PositionProviderAsset { .build(); private PositionProviderAsset[] positionProviderAssets = new PositionProviderAsset[0]; - public UnionPositionProviderAsset() { - } - @Nonnull @Override public PositionProvider build(@Nonnull PositionProviderAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/propassignments/ConstantAssignmentsAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/propassignments/ConstantAssignmentsAsset.java index 69bc5d9..1adbf52 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/propassignments/ConstantAssignmentsAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/propassignments/ConstantAssignmentsAsset.java @@ -18,9 +18,6 @@ public class ConstantAssignmentsAsset extends AssignmentsAsset { .build(); private PropAsset propAsset = new NoPropAsset(); - public ConstantAssignmentsAsset() { - } - @Nonnull @Override public Assignments build(@Nonnull AssignmentsAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/propassignments/FieldFunctionAssignmentsAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/propassignments/FieldFunctionAssignmentsAsset.java index 3c0c985..6791e57 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/propassignments/FieldFunctionAssignmentsAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/propassignments/FieldFunctionAssignmentsAsset.java @@ -35,9 +35,6 @@ public class FieldFunctionAssignmentsAsset extends AssignmentsAsset { private FieldFunctionAssignmentsAsset.DelimiterAsset[] delimiterAssets = new FieldFunctionAssignmentsAsset.DelimiterAsset[0]; private DensityAsset densityAsset = new ConstantDensityAsset(); - public FieldFunctionAssignmentsAsset() { - } - @Nonnull @Override public Assignments build(@Nonnull AssignmentsAsset.Argument argument) { @@ -85,9 +82,6 @@ public class FieldFunctionAssignmentsAsset extends AssignmentsAsset { private double max; private AssignmentsAsset assignmentsAsset = new ConstantAssignmentsAsset(); - public DelimiterAsset() { - } - public String getId() { return this.id; } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/propassignments/ImportedAssignmentsAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/propassignments/ImportedAssignmentsAsset.java index 5c5aa76..ae8f3f9 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/propassignments/ImportedAssignmentsAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/propassignments/ImportedAssignmentsAsset.java @@ -16,9 +16,6 @@ public class ImportedAssignmentsAsset extends AssignmentsAsset { .build(); private String name = ""; - public ImportedAssignmentsAsset() { - } - @Override public Assignments build(@Nonnull AssignmentsAsset.Argument argument) { if (super.skip()) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/propassignments/SandwichAssignmentsAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/propassignments/SandwichAssignmentsAsset.java index 600ba67..bf53896 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/propassignments/SandwichAssignmentsAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/propassignments/SandwichAssignmentsAsset.java @@ -27,9 +27,6 @@ public class SandwichAssignmentsAsset extends AssignmentsAsset { .build(); private SandwichAssignmentsAsset.DelimiterAsset[] delimiterAssets = new SandwichAssignmentsAsset.DelimiterAsset[0]; - public SandwichAssignmentsAsset() { - } - @Nonnull @Override public Assignments build(@Nonnull AssignmentsAsset.Argument argument) { @@ -78,9 +75,6 @@ public class SandwichAssignmentsAsset extends AssignmentsAsset { private double max; private AssignmentsAsset assignmentsAsset = new ConstantAssignmentsAsset(); - public DelimiterAsset() { - } - public String getId() { return this.id; } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/propassignments/WeightedAssignmentsAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/propassignments/WeightedAssignmentsAsset.java index a049535..91a5847 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/propassignments/WeightedAssignmentsAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/propassignments/WeightedAssignmentsAsset.java @@ -36,9 +36,6 @@ public class WeightedAssignmentsAsset extends AssignmentsAsset { private String seed = ""; private double skipChance = 0.0; - public WeightedAssignmentsAsset() { - } - @Nonnull @Override public Assignments build(@Nonnull AssignmentsAsset.Argument argument) { @@ -83,9 +80,6 @@ public class WeightedAssignmentsAsset extends AssignmentsAsset { private double weight = 1.0; private AssignmentsAsset assignmentsAsset = new ConstantAssignmentsAsset(); - public WeightedAssets() { - } - public String getId() { return this.id; } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/BoxPropAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/BoxPropAsset.java index 01a5dee..4f68c49 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/BoxPropAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/BoxPropAsset.java @@ -29,9 +29,6 @@ public class BoxPropAsset extends PropAsset { private PatternAsset patternAsset = new ConstantPatternAsset(); private ScannerAsset scannerAsset = new OriginScannerAsset(); - public BoxPropAsset() { - } - @Nonnull @Override public Prop build(@Nonnull PropAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/ClusterPropAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/ClusterPropAsset.java index a385516..4c7f042 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/ClusterPropAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/ClusterPropAsset.java @@ -4,6 +4,7 @@ import com.hypixel.hytale.assetstore.AssetExtraInfo; import com.hypixel.hytale.assetstore.codec.AssetBuilderCodec; import com.hypixel.hytale.assetstore.map.DefaultAssetMap; import com.hypixel.hytale.assetstore.map.JsonAssetWithMap; +import com.hypixel.hytale.builtin.hytalegenerator.LoggerUtil; import com.hypixel.hytale.builtin.hytalegenerator.assets.Cleanable; import com.hypixel.hytale.builtin.hytalegenerator.assets.curves.ConstantCurveAsset; import com.hypixel.hytale.builtin.hytalegenerator.assets.curves.CurveAsset; @@ -22,6 +23,8 @@ import com.hypixel.hytale.codec.KeyedCodec; import com.hypixel.hytale.codec.builder.BuilderCodec; import com.hypixel.hytale.codec.codecs.array.ArrayCodec; import com.hypixel.hytale.codec.validation.Validators; +import com.hypixel.hytale.math.vector.Vector3i; +import java.util.logging.Level; import javax.annotation.Nonnull; public class ClusterPropAsset extends PropAsset { @@ -51,9 +54,6 @@ public class ClusterPropAsset extends PropAsset { private PatternAsset patternAsset = new ConstantPatternAsset(); private ScannerAsset scannerAsset = new OriginScannerAsset(); - public ClusterPropAsset() { - } - @Nonnull @Override public Prop build(@Nonnull PropAsset.Argument argument) { @@ -63,7 +63,16 @@ public class ClusterPropAsset extends PropAsset { WeightedMap weightedMap = new WeightedMap<>(); for (ClusterPropAsset.WeightedPropAsset entry : this.weightedPropAssets) { - weightedMap.add(entry.propAsset.build(argument), entry.weight); + Prop columnProp = entry.propAsset.build(argument); + Vector3i readSize = columnProp.getReadBounds_voxelGrid().getSize(); + Vector3i writeSize = columnProp.getWriteBounds_voxelGrid().getSize(); + if (readSize.x != 1 || readSize.z != 1) { + LoggerUtil.getLogger().log(Level.WARNING, "Cluster Prop child has a read area larger than a column."); + } else if (writeSize.x == 1 && writeSize.z == 1) { + weightedMap.add(entry.propAsset.build(argument), entry.weight); + } else { + LoggerUtil.getLogger().log(Level.WARNING, "Cluster Prop child has a write area larger than a column."); + } } Pattern pattern = this.patternAsset == null ? Pattern.yesPattern() : this.patternAsset.build(PatternAsset.argumentFrom(argument)); @@ -106,9 +115,6 @@ public class ClusterPropAsset extends PropAsset { private double weight = 1.0; private PropAsset propAsset; - public WeightedPropAsset() { - } - public String getId() { return this.id; } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/ColumnPropAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/ColumnPropAsset.java index 1a00018..d703423 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/ColumnPropAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/ColumnPropAsset.java @@ -45,9 +45,6 @@ public class ColumnPropAsset extends PropAsset { private DirectionalityAsset directionalityAsset = new StaticDirectionalityAsset(); private ScannerAsset scannerAsset = new OriginScannerAsset(); - public ColumnPropAsset() { - } - @Nonnull @Override public Prop build(@Nonnull PropAsset.Argument argument) { @@ -104,9 +101,6 @@ public class ColumnPropAsset extends PropAsset { private int y = 1; private MaterialAsset materialAsset = new MaterialAsset("Empty", "Empty"); - public ColumnBlock() { - } - public String getId() { return this.id; } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/DensityPropAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/DensityPropAsset.java index ecbd19e..411849b 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/DensityPropAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/DensityPropAsset.java @@ -48,9 +48,6 @@ public class DensityPropAsset extends PropAsset { private MaterialProviderAsset materialProviderAsset = new ConstantMaterialProviderAsset(); private DensityAsset densityAsset = new ConstantDensityAsset(); - public DensityPropAsset() { - } - @Nonnull @Override public Prop build(@Nonnull PropAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/ImportedPropAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/ImportedPropAsset.java index 7920cec..09936da 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/ImportedPropAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/ImportedPropAsset.java @@ -14,9 +14,6 @@ public class ImportedPropAsset extends PropAsset { .build(); private String name = ""; - public ImportedPropAsset() { - } - @Override public Prop build(@Nonnull PropAsset.Argument argument) { if (super.skip()) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/NoPropAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/NoPropAsset.java index bca6987..cc2e411 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/NoPropAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/NoPropAsset.java @@ -10,18 +10,16 @@ import com.hypixel.hytale.builtin.hytalegenerator.threadindexer.WorkerIndexer; import com.hypixel.hytale.codec.builder.BuilderCodec; import com.hypixel.hytale.math.vector.Vector3i; import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class NoPropAsset extends PropAsset { public static final BuilderCodec CODEC = BuilderCodec.builder(NoPropAsset.class, NoPropAsset::new, PropAsset.ABSTRACT_CODEC).build(); - public NoPropAsset() { - } - @Nonnull @Override public Prop build(@Nonnull PropAsset.Argument argument) { return new Prop() { - final Bounds3i writeBounds_voxelGrid = new Bounds3i(); + final Bounds3i emptyBounds_voxelGrid = new Bounds3i(); @Override public ScanResult scan(@Nonnull Vector3i position, @Nonnull VoxelSpace materialSpace, @Nonnull WorkerIndexer.Id id) { @@ -37,10 +35,16 @@ public class NoPropAsset extends PropAsset { return ContextDependency.EMPTY; } + @NonNullDecl + @Override + public Bounds3i getReadBounds_voxelGrid() { + return this.emptyBounds_voxelGrid; + } + @Nonnull @Override - public Bounds3i getWriteBounds() { - return this.writeBounds_voxelGrid; + public Bounds3i getWriteBounds_voxelGrid() { + return this.emptyBounds_voxelGrid; } }; } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/OffsetPropAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/OffsetPropAsset.java new file mode 100644 index 0000000..bf4e43d --- /dev/null +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/OffsetPropAsset.java @@ -0,0 +1,30 @@ +package com.hypixel.hytale.builtin.hytalegenerator.assets.props; + +import com.hypixel.hytale.builtin.hytalegenerator.props.OffsetProp; +import com.hypixel.hytale.builtin.hytalegenerator.props.Prop; +import com.hypixel.hytale.codec.KeyedCodec; +import com.hypixel.hytale.codec.builder.BuilderCodec; +import com.hypixel.hytale.math.vector.Vector3i; +import javax.annotation.Nonnull; + +public class OffsetPropAsset extends PropAsset { + public static final BuilderCodec CODEC = BuilderCodec.builder(OffsetPropAsset.class, OffsetPropAsset::new, PropAsset.ABSTRACT_CODEC) + .append(new KeyedCodec<>("Offset", Vector3i.CODEC, true), (asset, value) -> asset.offset_voxelGrid = value, asset -> asset.offset_voxelGrid) + .add() + .append(new KeyedCodec<>("Prop", PropAsset.CODEC, true), (asset, value) -> asset.propAsset = value, asset -> asset.propAsset) + .add() + .build(); + private Vector3i offset_voxelGrid = new Vector3i(); + private PropAsset propAsset = new NoPropAsset(); + + @Nonnull + @Override + public Prop build(@Nonnull PropAsset.Argument argument) { + return (Prop)(super.skip() ? Prop.noProp() : new OffsetProp(this.offset_voxelGrid, this.propAsset.build(argument))); + } + + @Override + public void cleanUp() { + this.propAsset.cleanUp(); + } +} diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/PondFillerPropAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/PondFillerPropAsset.java index 7b04cc3..ba707d7 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/PondFillerPropAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/PondFillerPropAsset.java @@ -47,9 +47,6 @@ public class PondFillerPropAsset extends PropAsset { private PatternAsset patternAsset = new ConstantPatternAsset(); private ScannerAsset scannerAsset = new OriginScannerAsset(); - public PondFillerPropAsset() { - } - @Nonnull @Override public Prop build(@Nonnull PropAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/QueuePropAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/QueuePropAsset.java index 0f6b1f0..b98001b 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/QueuePropAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/QueuePropAsset.java @@ -17,9 +17,6 @@ public class QueuePropAsset extends PropAsset { .build(); private PropAsset[] propAssets = new PropAsset[0]; - public QueuePropAsset() { - } - @Nonnull @Override public Prop build(@Nonnull PropAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/UnionPropAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/UnionPropAsset.java index 9eed7eb..0331d6a 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/UnionPropAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/UnionPropAsset.java @@ -17,9 +17,6 @@ public class UnionPropAsset extends PropAsset { .build(); private PropAsset[] propAssets = new PropAsset[0]; - public UnionPropAsset() { - } - @Nonnull @Override public Prop build(@Nonnull PropAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/WeightedPropAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/WeightedPropAsset.java new file mode 100644 index 0000000..069aa95 --- /dev/null +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/WeightedPropAsset.java @@ -0,0 +1,87 @@ +package com.hypixel.hytale.builtin.hytalegenerator.assets.props; + +import com.hypixel.hytale.assetstore.AssetExtraInfo; +import com.hypixel.hytale.assetstore.codec.AssetBuilderCodec; +import com.hypixel.hytale.assetstore.map.DefaultAssetMap; +import com.hypixel.hytale.assetstore.map.JsonAssetWithMap; +import com.hypixel.hytale.builtin.hytalegenerator.assets.Cleanable; +import com.hypixel.hytale.builtin.hytalegenerator.datastructures.WeightedMap; +import com.hypixel.hytale.builtin.hytalegenerator.props.Prop; +import com.hypixel.hytale.builtin.hytalegenerator.props.WeightedProp; +import com.hypixel.hytale.codec.Codec; +import com.hypixel.hytale.codec.KeyedCodec; +import com.hypixel.hytale.codec.builder.BuilderCodec; +import com.hypixel.hytale.codec.codecs.array.ArrayCodec; +import com.hypixel.hytale.codec.validation.Validators; +import javax.annotation.Nonnull; + +public class WeightedPropAsset extends PropAsset { + public static final BuilderCodec CODEC = BuilderCodec.builder(WeightedPropAsset.class, WeightedPropAsset::new, PropAsset.ABSTRACT_CODEC) + .append( + new KeyedCodec<>("Entries", new ArrayCodec<>(WeightedPropAsset.EntryAsset.CODEC, WeightedPropAsset.EntryAsset[]::new), true), + (asset, value) -> asset.entryAssets = value, + asset -> asset.entryAssets + ) + .add() + .append(new KeyedCodec<>("Seed", Codec.STRING, true), (asset, value) -> asset.seed = value, asset -> asset.seed) + .add() + .build(); + private WeightedPropAsset.EntryAsset[] entryAssets = new WeightedPropAsset.EntryAsset[0]; + private String seed = ""; + + @Nonnull + @Override + public Prop build(@Nonnull PropAsset.Argument argument) { + if (!super.skip() && this.entryAssets.length != 0) { + WeightedMap weightedProps = new WeightedMap<>(this.entryAssets.length); + PropAsset.Argument childArgument = new PropAsset.Argument(argument); + childArgument.parentSeed = argument.parentSeed.child(this.seed); + + for (WeightedPropAsset.EntryAsset entryAsset : this.entryAssets) { + weightedProps.add(entryAsset.propAsset.build(childArgument), entryAsset.weight); + } + + return new WeightedProp(weightedProps, childArgument.parentSeed.createSupplier().get()); + } else { + return Prop.noProp(); + } + } + + @Override + public void cleanUp() { + for (WeightedPropAsset.EntryAsset asset : this.entryAssets) { + asset.cleanUp(); + } + } + + public static class EntryAsset implements Cleanable, JsonAssetWithMap> { + public static final AssetBuilderCodec CODEC = AssetBuilderCodec.builder( + WeightedPropAsset.EntryAsset.class, + WeightedPropAsset.EntryAsset::new, + Codec.STRING, + (asset, id) -> asset.id = id, + config -> config.id, + (config, data) -> config.data = data, + config -> config.data + ) + .append(new KeyedCodec<>("Weight", Codec.DOUBLE, true), (asset, value) -> asset.weight = value, asset -> asset.weight) + .addValidator(Validators.greaterThan(0.0)) + .add() + .append(new KeyedCodec<>("Prop", PropAsset.CODEC, true), (asset, value) -> asset.propAsset = value, asset -> asset.propAsset) + .add() + .build(); + private String id; + private AssetExtraInfo.Data data; + private double weight = 1.0; + private PropAsset propAsset = new NoPropAsset(); + + public String getId() { + return this.id; + } + + @Override + public void cleanUp() { + this.propAsset.cleanUp(); + } + } +} diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/prefabprop/PrefabLoader.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/prefabprop/PrefabLoader.java index c1d6e30..8746996 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/prefabprop/PrefabLoader.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/prefabprop/PrefabLoader.java @@ -14,9 +14,6 @@ import javax.annotation.Nullable; import org.bson.BsonDocument; public class PrefabLoader { - public PrefabLoader() { - } - @Nonnull public static void loadAllPrefabBuffersUnder(@Nonnull Path dirPath, List pathPrefabs) { if (!Files.isDirectory(dirPath)) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/prefabprop/PrefabPropAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/prefabprop/PrefabPropAsset.java index 2c9004c..e5f382a 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/prefabprop/PrefabPropAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/prefabprop/PrefabPropAsset.java @@ -79,9 +79,6 @@ public class PrefabPropAsset extends PropAsset { private PatternAsset moldingPatternAsset = new ConstantPatternAsset(); private boolean moldChildren = false; - public PrefabPropAsset() { - } - @Override public void cleanUp() { this.directionalityAsset.cleanUp(); @@ -202,9 +199,6 @@ public class PrefabPropAsset extends PropAsset { private double weight = 1.0; private String path; - public WeightedPathAsset() { - } - public String getId() { return this.id; } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/prefabprop/directionality/ImportedDirectionalityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/prefabprop/directionality/ImportedDirectionalityAsset.java index 54c77ac..307657e 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/prefabprop/directionality/ImportedDirectionalityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/prefabprop/directionality/ImportedDirectionalityAsset.java @@ -16,9 +16,6 @@ public class ImportedDirectionalityAsset extends DirectionalityAsset { .build(); private String name = ""; - public ImportedDirectionalityAsset() { - } - @Override public Directionality build(@Nonnull DirectionalityAsset.Argument argument) { if (this.name != null && !this.name.isEmpty()) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/prefabprop/directionality/PatternDirectionalityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/prefabprop/directionality/PatternDirectionalityAsset.java index 6303b05..66e7a48 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/prefabprop/directionality/PatternDirectionalityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/prefabprop/directionality/PatternDirectionalityAsset.java @@ -35,9 +35,6 @@ public class PatternDirectionalityAsset extends DirectionalityAsset { private PatternAsset eastPatternAsset = new ConstantPatternAsset(); private PatternAsset westPatternAsset = new ConstantPatternAsset(); - public PatternDirectionalityAsset() { - } - @Nonnull @Override public Directionality build(@Nonnull DirectionalityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/prefabprop/directionality/RandomDirectionalityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/prefabprop/directionality/RandomDirectionalityAsset.java index 1c5518a..82d6b84 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/prefabprop/directionality/RandomDirectionalityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/prefabprop/directionality/RandomDirectionalityAsset.java @@ -21,9 +21,6 @@ public class RandomDirectionalityAsset extends DirectionalityAsset { private String seed = "A"; private PatternAsset patternAsset = new ConstantPatternAsset(); - public RandomDirectionalityAsset() { - } - @Nonnull @Override public Directionality build(@Nonnull DirectionalityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/prefabprop/directionality/StaticDirectionalityAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/prefabprop/directionality/StaticDirectionalityAsset.java index 09dc183..146d6ca 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/prefabprop/directionality/StaticDirectionalityAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/props/prefabprop/directionality/StaticDirectionalityAsset.java @@ -28,9 +28,6 @@ public class StaticDirectionalityAsset extends DirectionalityAsset { private int rotation = 0; private PatternAsset patternAsset = new ConstantPatternAsset(); - public StaticDirectionalityAsset() { - } - @Nonnull @Override public Directionality build(@Nonnull DirectionalityAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/scanners/AreaScannerAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/scanners/AreaScannerAsset.java index 07efe80..cef7796 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/scanners/AreaScannerAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/scanners/AreaScannerAsset.java @@ -26,9 +26,6 @@ public class AreaScannerAsset extends ScannerAsset { private int scanRange = 0; private ScannerAsset childScannerAsset = new OriginScannerAsset(); - public AreaScannerAsset() { - } - @Nonnull @Override public Scanner build(@Nonnull ScannerAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/scanners/ColumnLinearScannerAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/scanners/ColumnLinearScannerAsset.java index 8da2497..5670796 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/scanners/ColumnLinearScannerAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/scanners/ColumnLinearScannerAsset.java @@ -36,9 +36,6 @@ public class ColumnLinearScannerAsset extends ScannerAsset { private boolean isRelativeToPosition = false; private String baseHeight = ""; - public ColumnLinearScannerAsset() { - } - @Nonnull @Override public Scanner build(@Nonnull ScannerAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/scanners/ColumnRandomScannerAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/scanners/ColumnRandomScannerAsset.java index 6fea444..247f2ae 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/scanners/ColumnRandomScannerAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/scanners/ColumnRandomScannerAsset.java @@ -42,9 +42,6 @@ public class ColumnRandomScannerAsset extends ScannerAsset { private boolean isRelativeToPosition = false; private String baseHeight = ""; - public ColumnRandomScannerAsset() { - } - @Nonnull @Override public Scanner build(@Nonnull ScannerAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/scanners/ImportedScannerAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/scanners/ImportedScannerAsset.java index 09ef135..8555e53 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/scanners/ImportedScannerAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/scanners/ImportedScannerAsset.java @@ -16,9 +16,6 @@ public class ImportedScannerAsset extends ScannerAsset { .build(); private String name = ""; - public ImportedScannerAsset() { - } - @Override public Scanner build(@Nonnull ScannerAsset.Argument argument) { if (super.skip()) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/scanners/OriginScannerAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/scanners/OriginScannerAsset.java index 3acad31..40b77bb 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/scanners/OriginScannerAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/scanners/OriginScannerAsset.java @@ -11,9 +11,6 @@ public class OriginScannerAsset extends ScannerAsset { ) .build(); - public OriginScannerAsset() { - } - @Nonnull @Override public Scanner build(@Nonnull ScannerAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/terrains/DensityTerrainAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/terrains/DensityTerrainAsset.java index dbcfdcf..92f30ac 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/terrains/DensityTerrainAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/terrains/DensityTerrainAsset.java @@ -20,9 +20,6 @@ public class DensityTerrainAsset extends TerrainAsset { @Nonnull private DensityAsset densityAsset = new ConstantDensityAsset(); - public DensityTerrainAsset() { - } - @Nonnull @Override public Density buildDensity(@Nonnull SeedBox parentSeed, @Nonnull ReferenceBundle referenceBundle, @Nonnull WorkerIndexer workerIndexer) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/tintproviders/ConstantTintProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/tintproviders/ConstantTintProviderAsset.java index 210c314..74e846b 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/tintproviders/ConstantTintProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/tintproviders/ConstantTintProviderAsset.java @@ -19,9 +19,6 @@ public class ConstantTintProviderAsset extends TintProviderAsset { .build(); private Color color = DEFAULT_COLOR; - public ConstantTintProviderAsset() { - } - @Nonnull @Override public TintProvider build(@Nonnull TintProviderAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/tintproviders/DensityDelimitedTintProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/tintproviders/DensityDelimitedTintProviderAsset.java index 5a45ef2..5c60f5d 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/tintproviders/DensityDelimitedTintProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/tintproviders/DensityDelimitedTintProviderAsset.java @@ -39,9 +39,6 @@ public class DensityDelimitedTintProviderAsset extends TintProviderAsset { private DensityDelimitedTintProviderAsset.DelimiterAsset[] delimiterAssets = new DensityDelimitedTintProviderAsset.DelimiterAsset[0]; private DensityAsset densityAsset = DensityAsset.getFallbackAsset(); - public DensityDelimitedTintProviderAsset() { - } - @Nonnull @Override public TintProvider build(@Nonnull TintProviderAsset.Argument argument) { @@ -79,9 +76,6 @@ public class DensityDelimitedTintProviderAsset extends TintProviderAsset { private RangeDoubleAsset rangeAsset = new RangeDoubleAsset(); private TintProviderAsset tintProviderAsset = TintProviderAsset.getFallbackAsset(); - public DelimiterAsset() { - } - @Nonnull public DelimiterDouble build(@Nonnull TintProviderAsset.Argument argument) { RangeDouble range = this.rangeAsset.build(); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/vectorproviders/DensityGradientVectorProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/vectorproviders/DensityGradientVectorProviderAsset.java index eb3ef77..4b5fd65 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/vectorproviders/DensityGradientVectorProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/vectorproviders/DensityGradientVectorProviderAsset.java @@ -27,9 +27,6 @@ public class DensityGradientVectorProviderAsset extends VectorProviderAsset { private DensityAsset densityAsset = new ConstantDensityAsset(); private double sampleDistance = 1.0; - public DensityGradientVectorProviderAsset() { - } - @Override public VectorProvider build(@Nonnull VectorProviderAsset.Argument argument) { if (this.isSkipped()) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/vectorproviders/ExportedVectorProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/vectorproviders/ExportedVectorProviderAsset.java index cb8ce69..0c9386e 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/vectorproviders/ExportedVectorProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/vectorproviders/ExportedVectorProviderAsset.java @@ -25,9 +25,6 @@ public class ExportedVectorProviderAsset extends VectorProviderAsset { private boolean singleInstance = false; private VectorProviderAsset vectorProviderAsset = new ConstantVectorProviderAsset(); - public ExportedVectorProviderAsset() { - } - @Override public VectorProvider build(@Nonnull VectorProviderAsset.Argument argument) { if (this.isSkipped()) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/vectorproviders/ImportedVectorProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/vectorproviders/ImportedVectorProviderAsset.java index 6e8caf1..8aec94f 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/vectorproviders/ImportedVectorProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/vectorproviders/ImportedVectorProviderAsset.java @@ -18,9 +18,6 @@ public class ImportedVectorProviderAsset extends VectorProviderAsset { .build(); private String importedNodeName = ""; - public ImportedVectorProviderAsset() { - } - @Override public VectorProvider build(@Nonnull VectorProviderAsset.Argument argument) { if (this.isSkipped()) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/vectorproviders/VectorProviderAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/vectorproviders/VectorProviderAsset.java index c2b9704..8e27604 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/vectorproviders/VectorProviderAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/vectorproviders/VectorProviderAsset.java @@ -105,8 +105,5 @@ public abstract class VectorProviderAsset implements Cleanable, JsonAssetWithMap public boolean singleInstance; public VectorProviderAsset asset; public VectorProvider builtInstance; - - public Exported() { - } } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/worldstructures/basic/BasicWorldStructureAsset.java b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/worldstructures/basic/BasicWorldStructureAsset.java index fd11c15..ac51f3b 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/assets/worldstructures/basic/BasicWorldStructureAsset.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/assets/worldstructures/basic/BasicWorldStructureAsset.java @@ -67,9 +67,6 @@ public class BasicWorldStructureAsset extends WorldStructureAsset { private String defaultBiomeId = ""; private ContentFieldAsset[] contentFieldAssets = new ContentFieldAsset[0]; - public BasicWorldStructureAsset() { - } - @Nullable @Override public BiomeMap buildBiomeMap(@Nonnull WorldStructureAsset.Argument argument) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/biomemap/BiomeMap.java b/src/com/hypixel/hytale/builtin/hytalegenerator/biomemap/BiomeMap.java index 60ed5c4..da393b9 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/biomemap/BiomeMap.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/biomemap/BiomeMap.java @@ -4,6 +4,4 @@ import com.hypixel.hytale.builtin.hytalegenerator.biome.BiomeType; import com.hypixel.hytale.builtin.hytalegenerator.framework.interfaces.functions.BiCarta; public abstract class BiomeMap extends BiCarta { - public BiomeMap() { - } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/bounds/SpaceSize.java b/src/com/hypixel/hytale/builtin/hytalegenerator/bounds/SpaceSize.java index cb3e1d5..407504f 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/bounds/SpaceSize.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/bounds/SpaceSize.java @@ -57,6 +57,11 @@ public class SpaceSize { return Vector3i.max(absMin, absMax); } + @Nonnull + public Bounds3i toBounds3i() { + return new Bounds3i(this.minInclusive, this.maxExclusive); + } + @Nonnull public SpaceSize clone() { return new SpaceSize(this.minInclusive, this.maxExclusive); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/chunkgenerator/ChunkRequest.java b/src/com/hypixel/hytale/builtin/hytalegenerator/chunkgenerator/ChunkRequest.java index 5dc6050..6eacfd6 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/chunkgenerator/ChunkRequest.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/chunkgenerator/ChunkRequest.java @@ -1,6 +1,5 @@ package com.hypixel.hytale.builtin.hytalegenerator.chunkgenerator; -import com.hypixel.hytale.math.vector.Transform; import java.util.Objects; import java.util.function.LongPredicate; import javax.annotation.Nonnull; @@ -13,13 +12,10 @@ public record ChunkRequest(@Nonnull ChunkRequest.GeneratorProfile generatorProfi public static final class GeneratorProfile { @Nonnull private final String worldStructureName; - @Nonnull - private final Transform spawnPosition; private int seed; - public GeneratorProfile(@Nonnull String worldStructureName, @Nonnull Transform spawnPosition, int seed) { + public GeneratorProfile(@Nonnull String worldStructureName, int seed) { this.worldStructureName = worldStructureName; - this.spawnPosition = spawnPosition; this.seed = seed; } @@ -28,11 +24,6 @@ public record ChunkRequest(@Nonnull ChunkRequest.GeneratorProfile generatorProfi return this.worldStructureName; } - @Nonnull - public Transform spawnPosition() { - return this.spawnPosition; - } - public int seed() { return this.seed; } @@ -47,9 +38,7 @@ public record ChunkRequest(@Nonnull ChunkRequest.GeneratorProfile generatorProfi return true; } else if (obj != null && obj.getClass() == this.getClass()) { ChunkRequest.GeneratorProfile that = (ChunkRequest.GeneratorProfile)obj; - return Objects.equals(this.worldStructureName, that.worldStructureName) - && Objects.equals(this.spawnPosition, that.spawnPosition) - && this.seed == that.seed; + return Objects.equals(this.worldStructureName, that.worldStructureName) && this.seed == that.seed; } else { return false; } @@ -57,12 +46,12 @@ public record ChunkRequest(@Nonnull ChunkRequest.GeneratorProfile generatorProfi @Override public int hashCode() { - return Objects.hash(this.worldStructureName, this.spawnPosition, this.seed); + return Objects.hash(this.worldStructureName, this.seed); } @Override public String toString() { - return "GeneratorProfile[worldStructureName=" + this.worldStructureName + ", spawnPosition=" + this.spawnPosition + ", seed=" + this.seed + "]"; + return "GeneratorProfile[worldStructureName=" + this.worldStructureName + ", seed=" + this.seed + "]"; } } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/chunkgenerator/FallbackGenerator.java b/src/com/hypixel/hytale/builtin/hytalegenerator/chunkgenerator/FallbackGenerator.java index 7c81d67..b57132f 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/chunkgenerator/FallbackGenerator.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/chunkgenerator/FallbackGenerator.java @@ -9,9 +9,6 @@ import javax.annotation.Nonnull; public class FallbackGenerator implements ChunkGenerator { public static final FallbackGenerator INSTANCE = new FallbackGenerator(); - public FallbackGenerator() { - } - @Override public GeneratedChunk generate(@Nonnull ChunkRequest.Arguments arguments) { return new GeneratedChunk( diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/conveyor/stagedconveyor/ContextDependency.java b/src/com/hypixel/hytale/builtin/hytalegenerator/conveyor/stagedconveyor/ContextDependency.java index 8c2d583..4127ba7 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/conveyor/stagedconveyor/ContextDependency.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/conveyor/stagedconveyor/ContextDependency.java @@ -29,7 +29,12 @@ public class ContextDependency { } @Nonnull - public Bounds3i getTotalPropBounds_voxelGrid() { + public Bounds3i getReadBounds_voxelGrid() { + return new Bounds3i(this.getReadRange().clone().scale(-1), this.getReadRange().clone().add(Vector3i.ALL_ONES)); + } + + @Nonnull + public Bounds3i getWriteBounds_voxelGrid() { Vector3i readMin_voxelGrid = this.getReadRange().scale(-1); Vector3i readMax_voxelGrid = this.getReadRange().add(Vector3i.ALL_ONES); Vector3i writeMin_voxelGrid = this.getWriteRange().scale(-1); @@ -164,6 +169,19 @@ public class ContextDependency { return new ContextDependency(read, write); } + @Nonnull + public static ContextDependency from(@Nonnull Bounds3i readBounds, @Nonnull Bounds3i writeBounds) { + return new ContextDependency(rangeFromBounds(readBounds), rangeFromBounds(writeBounds)); + } + + private static Vector3i rangeFromBounds(@Nonnull Bounds3i readBounds) { + Vector3i readRange = new Vector3i(); + readRange.x = Math.max(Math.abs(readBounds.min.x), Math.abs(readBounds.max.x - 1)); + readRange.y = Math.max(Math.abs(readBounds.min.y), Math.abs(readBounds.max.y - 1)); + readRange.z = Math.max(Math.abs(readBounds.min.z), Math.abs(readBounds.max.z - 1)); + return readRange; + } + @Nonnull public ContextDependency clone() { return new ContextDependency(this.readRange, this.writeRange); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/datastructures/CollectionFactory.java b/src/com/hypixel/hytale/builtin/hytalegenerator/datastructures/CollectionFactory.java index f03c173..939874a 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/datastructures/CollectionFactory.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/datastructures/CollectionFactory.java @@ -5,9 +5,6 @@ import java.util.Set; import javax.annotation.Nonnull; public class CollectionFactory { - public CollectionFactory() { - } - @Nonnull public static Set hashSetOf(@Nonnull T... elements) { Set set = new HashSet<>(elements.length); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/datastructures/bicoordinatecache/HashedBiCoordinateCache.java b/src/com/hypixel/hytale/builtin/hytalegenerator/datastructures/bicoordinatecache/HashedBiCoordinateCache.java index 277b1a0..c1c9199 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/datastructures/bicoordinatecache/HashedBiCoordinateCache.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/datastructures/bicoordinatecache/HashedBiCoordinateCache.java @@ -7,9 +7,6 @@ public class HashedBiCoordinateCache implements BiCoordinateCache { @Nonnull private final ConcurrentHashMap values = new ConcurrentHashMap<>(); - public HashedBiCoordinateCache() { - } - public static long hash(int x, int z) { long hash = x; hash <<= 32; diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/datastructures/compression/Compressor.java b/src/com/hypixel/hytale/builtin/hytalegenerator/datastructures/compression/Compressor.java index 9e2e808..751eb03 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/datastructures/compression/Compressor.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/datastructures/compression/Compressor.java @@ -5,9 +5,6 @@ import javax.annotation.Nonnull; public class Compressor { private final int MIN_RUN = 7; - public Compressor() { - } - @Nonnull public Compressor.CompressedArray compressOnReference(@Nonnull T[] in) { int currentRun = 0; diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/datastructures/voxelspace/VoxelSpaceUtil.java b/src/com/hypixel/hytale/builtin/hytalegenerator/datastructures/voxelspace/VoxelSpaceUtil.java index 957d0af..86779fc 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/datastructures/voxelspace/VoxelSpaceUtil.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/datastructures/voxelspace/VoxelSpaceUtil.java @@ -8,9 +8,6 @@ import java.util.concurrent.ExecutionException; import javax.annotation.Nonnull; public class VoxelSpaceUtil { - public VoxelSpaceUtil() { - } - public static void parallelCopy(@Nonnull VoxelSpace source, @Nonnull VoxelSpace destination, int concurrency) { if (concurrency < 1) { throw new IllegalArgumentException("negative concurrency"); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/density/Density.java b/src/com/hypixel/hytale/builtin/hytalegenerator/density/Density.java index c0cb76d..f66cab3 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/density/Density.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/density/Density.java @@ -17,9 +17,6 @@ public abstract class Density { public static final double DEFAULT_VALUE = Double.MAX_VALUE; public static final double DEFAULT_DENSITY = 0.0; - public Density() { - } - public abstract double process(@Nonnull Density.Context var1); public void setInputs(Density[] inputs) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/CacheDensity.java b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/CacheDensity.java index a77bc2d..47a2e05 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/CacheDensity.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/CacheDensity.java @@ -43,8 +43,5 @@ public class CacheDensity extends Density { private static class Cache { Vector3d position; double value; - - private Cache() { - } } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/CellWallDistanceDensity.java b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/CellWallDistanceDensity.java index 380a083..b2ad883 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/CellWallDistanceDensity.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/CellWallDistanceDensity.java @@ -4,9 +4,6 @@ import com.hypixel.hytale.builtin.hytalegenerator.density.Density; import javax.annotation.Nonnull; public class CellWallDistanceDensity extends Density { - public CellWallDistanceDensity() { - } - @Override public double process(@Nonnull Density.Context context) { return context.distanceFromCellWall; diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/DistanceToBiomeEdgeDensity.java b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/DistanceToBiomeEdgeDensity.java index 20a6198..c0b1518 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/DistanceToBiomeEdgeDensity.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/DistanceToBiomeEdgeDensity.java @@ -4,9 +4,6 @@ import com.hypixel.hytale.builtin.hytalegenerator.density.Density; import javax.annotation.Nonnull; public class DistanceToBiomeEdgeDensity extends Density { - public DistanceToBiomeEdgeDensity() { - } - @Override public double process(@Nonnull Density.Context context) { return context.distanceToBiomeEdge; diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/MultiMixDensity.java b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/MultiMixDensity.java index d089303..82b9b06 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/MultiMixDensity.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/MultiMixDensity.java @@ -125,9 +125,6 @@ public class MultiMixDensity extends Density { public static class GaugeSegmentComparator implements BiFunction { public static final MultiMixDensity.Segment.GaugeSegmentComparator INSTANCE = new MultiMixDensity.Segment.GaugeSegmentComparator(); - public GaugeSegmentComparator() { - } - @Nonnull public Integer apply(Double gauge, @Nonnull MultiMixDensity.Segment segment) { if (gauge < segment.key0.value) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/PositionsHorizontalPinchDensity.java b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/PositionsHorizontalPinchDensity.java index 1c8dedb..f8386f3 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/PositionsHorizontalPinchDensity.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/PositionsHorizontalPinchDensity.java @@ -152,8 +152,5 @@ public class PositionsHorizontalPinchDensity extends Density { double z; Vector3d warpVector; boolean hasValue; - - private Cache() { - } } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/RotatorDensity.java b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/RotatorDensity.java index cb10805..01aaba5 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/RotatorDensity.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/RotatorDensity.java @@ -77,8 +77,5 @@ public class RotatorDensity extends Density { NONE, Y_AXIS, INVERTED_Y_AXIS; - - private SpecialCase() { - } } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/TerrainDensity.java b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/TerrainDensity.java index 1fc4013..3c24de6 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/TerrainDensity.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/TerrainDensity.java @@ -4,9 +4,6 @@ import com.hypixel.hytale.builtin.hytalegenerator.density.Density; import javax.annotation.Nonnull; public class TerrainDensity extends Density { - public TerrainDensity() { - } - @Override public double process(@Nonnull Density.Context context) { return context.terrainDensityProvider == null ? 0.0 : context.terrainDensityProvider.get(context.position.toVector3i(), context.workerId); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/XValueDensity.java b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/XValueDensity.java index 27621d7..0cc3e6e 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/XValueDensity.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/XValueDensity.java @@ -4,9 +4,6 @@ import com.hypixel.hytale.builtin.hytalegenerator.density.Density; import javax.annotation.Nonnull; public class XValueDensity extends Density { - public XValueDensity() { - } - @Override public double process(@Nonnull Density.Context context) { return context.position.x; diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/YValueDensity.java b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/YValueDensity.java index 5c5f01a..57babe5 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/YValueDensity.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/YValueDensity.java @@ -4,9 +4,6 @@ import com.hypixel.hytale.builtin.hytalegenerator.density.Density; import javax.annotation.Nonnull; public class YValueDensity extends Density { - public YValueDensity() { - } - @Override public double process(@Nonnull Density.Context context) { return context.position.y; diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/ZValueDensity.java b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/ZValueDensity.java index 924d465..40dedf1 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/ZValueDensity.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/ZValueDensity.java @@ -4,9 +4,6 @@ import com.hypixel.hytale.builtin.hytalegenerator.density.Density; import javax.annotation.Nonnull; public class ZValueDensity extends Density { - public ZValueDensity() { - } - @Override public double process(@Nonnull Density.Context context) { return context.position.z; diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/distancefunctions/DistanceFunction.java b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/distancefunctions/DistanceFunction.java index 1b01d2c..328497c 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/distancefunctions/DistanceFunction.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/distancefunctions/DistanceFunction.java @@ -4,8 +4,5 @@ import com.hypixel.hytale.math.vector.Vector3d; import javax.annotation.Nonnull; public abstract class DistanceFunction { - public DistanceFunction() { - } - public abstract double getDistance(@Nonnull Vector3d var1); } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/distancefunctions/EuclideanDistanceFunction.java b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/distancefunctions/EuclideanDistanceFunction.java index 559edf3..5700831 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/distancefunctions/EuclideanDistanceFunction.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/distancefunctions/EuclideanDistanceFunction.java @@ -4,9 +4,6 @@ import com.hypixel.hytale.math.vector.Vector3d; import javax.annotation.Nonnull; public class EuclideanDistanceFunction extends DistanceFunction { - public EuclideanDistanceFunction() { - } - @Override public double getDistance(@Nonnull Vector3d point) { return point.x * point.x + point.y * point.y + point.z * point.z; diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/distancefunctions/ManhattanDistanceFunction.java b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/distancefunctions/ManhattanDistanceFunction.java index 1c6b6ed..cb2a407 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/distancefunctions/ManhattanDistanceFunction.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/distancefunctions/ManhattanDistanceFunction.java @@ -4,9 +4,6 @@ import com.hypixel.hytale.math.vector.Vector3d; import javax.annotation.Nonnull; public class ManhattanDistanceFunction extends DistanceFunction { - public ManhattanDistanceFunction() { - } - @Override public double getDistance(@Nonnull Vector3d point) { return Math.abs(point.x) + Math.abs(point.y) + Math.abs(point.z); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/DensityReturnType.java b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/DensityReturnType.java index d8983a6..bdbb82f 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/DensityReturnType.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/DensityReturnType.java @@ -122,9 +122,6 @@ public class DensityReturnType extends ReturnType { } private static class Vector3dComparator implements Comparator { - private Vector3dComparator() { - } - public int compare(@Nonnull Vector3d o1, @Nonnull Vector3d o2) { if (o1.y < o2.y || o1.x < o2.x || o1.z < o2.z) { return -1; diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/Distance2AddReturnType.java b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/Distance2AddReturnType.java index 887ed35..fa588dc 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/Distance2AddReturnType.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/Distance2AddReturnType.java @@ -6,9 +6,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class Distance2AddReturnType extends ReturnType { - public Distance2AddReturnType() { - } - @Override public double get( double distance0, diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/Distance2DivReturnType.java b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/Distance2DivReturnType.java index 8011180..8303c0d 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/Distance2DivReturnType.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/Distance2DivReturnType.java @@ -6,9 +6,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class Distance2DivReturnType extends ReturnType { - public Distance2DivReturnType() { - } - @Override public double get( double distance0, diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/Distance2MulReturnType.java b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/Distance2MulReturnType.java index 0c73e12..e88b257 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/Distance2MulReturnType.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/Distance2MulReturnType.java @@ -6,9 +6,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class Distance2MulReturnType extends ReturnType { - public Distance2MulReturnType() { - } - @Override public double get( double distance0, diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/Distance2ReturnType.java b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/Distance2ReturnType.java index f46bea5..6d17e8c 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/Distance2ReturnType.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/Distance2ReturnType.java @@ -6,9 +6,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class Distance2ReturnType extends ReturnType { - public Distance2ReturnType() { - } - @Override public double get( double distance0, diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/Distance2SubReturnType.java b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/Distance2SubReturnType.java index d48e327..fb8eea1 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/Distance2SubReturnType.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/Distance2SubReturnType.java @@ -6,9 +6,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class Distance2SubReturnType extends ReturnType { - public Distance2SubReturnType() { - } - @Override public double get( double distance0, diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/DistanceReturnType.java b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/DistanceReturnType.java index 8219979..ea862f3 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/DistanceReturnType.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/DistanceReturnType.java @@ -6,9 +6,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class DistanceReturnType extends ReturnType { - public DistanceReturnType() { - } - @Override public double get( double distance0, diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/ReturnType.java b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/ReturnType.java index 384875e..90b02ed 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/ReturnType.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/density/nodes/positions/returntypes/ReturnType.java @@ -8,9 +8,6 @@ import javax.annotation.Nullable; public abstract class ReturnType { protected double maxDistance = Double.MAX_VALUE; - public ReturnType() { - } - public abstract double get( double var1, double var3, @Nonnull Vector3d var5, @Nullable Vector3d var6, @Nullable Vector3d var7, @Nullable Density.Context var8 ); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/environmentproviders/EnvironmentProvider.java b/src/com/hypixel/hytale/builtin/hytalegenerator/environmentproviders/EnvironmentProvider.java index 90484e3..f901e0e 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/environmentproviders/EnvironmentProvider.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/environmentproviders/EnvironmentProvider.java @@ -5,9 +5,6 @@ import com.hypixel.hytale.math.vector.Vector3i; import javax.annotation.Nonnull; public abstract class EnvironmentProvider { - public EnvironmentProvider() { - } - public abstract int getValue(@Nonnull EnvironmentProvider.Context var1); @Nonnull diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/fields/FastNoiseLite.java b/src/com/hypixel/hytale/builtin/hytalegenerator/fields/FastNoiseLite.java index 7fb414d..1ab442e 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/fields/FastNoiseLite.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/fields/FastNoiseLite.java @@ -3815,9 +3815,6 @@ public class FastNoiseLite { EuclideanSq, Manhattan, Hybrid; - - private CellularDistanceFunction() { - } } public static enum CellularReturnType { @@ -3830,18 +3827,12 @@ public class FastNoiseLite { Distance2Div; public static final Codec CODEC = new EnumCodec<>(FastNoiseLite.CellularReturnType.class); - - private CellularReturnType() { - } } public static enum DomainWarpType { OpenSimplex2, OpenSimplex2Reduced, BasicGrid; - - private DomainWarpType() { - } } public static enum FractalType { @@ -3851,9 +3842,6 @@ public class FastNoiseLite { PingPong, DomainWarpProgressive, DomainWarpIndependent; - - private FractalType() { - } } public static enum NoiseType { @@ -3863,18 +3851,12 @@ public class FastNoiseLite { Perlin, ValueCubic, Value; - - private NoiseType() { - } } public static enum RotationType3D { None, ImproveXYPlanes, ImproveXZPlanes; - - private RotationType3D() { - } } private static enum TransformType3D { @@ -3882,9 +3864,6 @@ public class FastNoiseLite { ImproveXYPlanes, ImproveXZPlanes, DefaultOpenSimplex2; - - private TransformType3D() { - } } public static class Vector2 { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/fields/noise/NoiseField.java b/src/com/hypixel/hytale/builtin/hytalegenerator/fields/noise/NoiseField.java index b5dd575..127fc2e 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/fields/noise/NoiseField.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/fields/noise/NoiseField.java @@ -8,9 +8,6 @@ public abstract class NoiseField { protected double scaleZ = 1.0; protected double scaleW = 1.0; - public NoiseField() { - } - public abstract double valueAt(double var1, double var3, double var5, double var7); public abstract double valueAt(double var1, double var3, double var5); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/fields/noise/Simplex.java b/src/com/hypixel/hytale/builtin/hytalegenerator/fields/noise/Simplex.java index abb91b1..31fb6af 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/fields/noise/Simplex.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/fields/noise/Simplex.java @@ -318,9 +318,6 @@ class Simplex { private static final short[] perm = new short[512]; private static final short[] permMod12 = new short[512]; - Simplex() { - } - private static int fastfloor(double x) { int xi = (int)x; return x < xi ? xi - 1 : xi; diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/fields/points/PointField.java b/src/com/hypixel/hytale/builtin/hytalegenerator/fields/points/PointField.java index bf320b7..22b4fd0 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/fields/points/PointField.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/fields/points/PointField.java @@ -14,9 +14,6 @@ public abstract class PointField implements PointProvider { protected double scaleZ = 1.0; protected double scaleW = 1.0; - public PointField() { - } - @Nonnull @Override public List points3i(@Nonnull Vector3i min, @Nonnull Vector3i max) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/cartas/ImageCarta.java b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/cartas/ImageCarta.java index 07d6479..5ba4c61 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/cartas/ImageCarta.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/cartas/ImageCarta.java @@ -92,9 +92,6 @@ public class ImageCarta extends TriCarta { private TriDoubleFunction noiseY; private boolean noiseCheck; - public Builder() { - } - @Nonnull public ImageCarta build() { if (this.bufferedImageCheck && this.noiseCheck) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/interfaces/functions/BiCarta.java b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/interfaces/functions/BiCarta.java index 1086d87..d49500d 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/interfaces/functions/BiCarta.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/interfaces/functions/BiCarta.java @@ -5,9 +5,6 @@ import java.util.List; import javax.annotation.Nonnull; public abstract class BiCarta { - public BiCarta() { - } - public abstract R apply(int var1, int var2, @Nonnull WorkerIndexer.Id var3); public abstract List allPossibleValues(); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/interfaces/functions/TriCarta.java b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/interfaces/functions/TriCarta.java index 7581980..8c3709f 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/interfaces/functions/TriCarta.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/interfaces/functions/TriCarta.java @@ -6,9 +6,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public abstract class TriCarta { - public TriCarta() { - } - @Nullable public abstract R apply(int var1, int var2, int var3, @Nonnull WorkerIndexer.Id var4); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/BitConverter.java b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/BitConverter.java index 677f8b9..2437087 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/BitConverter.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/BitConverter.java @@ -3,9 +3,6 @@ package com.hypixel.hytale.builtin.hytalegenerator.framework.math; import javax.annotation.Nonnull; public class BitConverter { - public BitConverter() { - } - public static void main(String[] args) { System.out.println("LONG TEST:"); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/Calculator.java b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/Calculator.java index 3351a68..91008f8 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/Calculator.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/Calculator.java @@ -5,9 +5,6 @@ import java.util.Objects; import javax.annotation.Nonnull; public class Calculator { - public Calculator() { - } - public static int toIntFloored(double d) { d = Math.floor(d); return (int)d; diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/CoPrimeGenerator.java b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/CoPrimeGenerator.java index b3616f6..2fff977 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/CoPrimeGenerator.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/CoPrimeGenerator.java @@ -5,9 +5,6 @@ import java.util.stream.IntStream; import javax.annotation.Nonnull; public class CoPrimeGenerator { - public CoPrimeGenerator() { - } - public static long[] generateCoPrimes(long seed, int bucketSize, int numberOfBuckets, long floor) { if (bucketSize >= 1 && numberOfBuckets >= 1) { Random rand = new Random(seed); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/Combiner.java b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/Combiner.java index 02797f0..d8bf34d 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/Combiner.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/Combiner.java @@ -23,9 +23,6 @@ public class Combiner { public static enum IntersectionPolicy { MAX_POLICY, MIN_POLICY; - - private IntersectionPolicy() { - } } public class Layer { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/Interpolation.java b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/Interpolation.java index 1321a41..8cc1bbe 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/Interpolation.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/Interpolation.java @@ -1,9 +1,6 @@ package com.hypixel.hytale.builtin.hytalegenerator.framework.math; public class Interpolation { - public Interpolation() { - } - public static double linear(double valueA, double valueB, double weight) { if (!(weight < 0.0) && !(weight > 1.0)) { return valueA * (1.0 - weight) + valueB * weight; diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/MultipliedIteration.java b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/MultipliedIteration.java index 91c56f1..5444780 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/MultipliedIteration.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/MultipliedIteration.java @@ -1,9 +1,6 @@ package com.hypixel.hytale.builtin.hytalegenerator.framework.math; public class MultipliedIteration { - public MultipliedIteration() { - } - public static double calculateMultiplier(double startValue, double endValue, int numberOfIterations, double precision) { if (startValue < endValue) { throw new IllegalArgumentException("start smaller than end"); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/NodeFunction.java b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/NodeFunction.java index e1532fd..cb2e6e0 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/NodeFunction.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/NodeFunction.java @@ -15,9 +15,6 @@ public class NodeFunction implements Function, Double2DoubleFunc @Nonnull private final List ranges = new ArrayList<>(2); - public NodeFunction() { - } - public Double apply(@Nonnull Double input) { return this.get(input); } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/Normalizer.java b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/Normalizer.java index 0e9a466..78d64d1 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/Normalizer.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/Normalizer.java @@ -1,9 +1,6 @@ package com.hypixel.hytale.builtin.hytalegenerator.framework.math; public class Normalizer { - public Normalizer() { - } - public static double normalizeNoise(double input) { return normalize(-1.0, 1.0, 0.0, 1.0, input); } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/Probability.java b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/Probability.java index 18fab11..0bab9cd 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/Probability.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/Probability.java @@ -3,9 +3,6 @@ package com.hypixel.hytale.builtin.hytalegenerator.framework.math; import java.util.Random; public class Probability { - public Probability() { - } - public static boolean of(double chance, long seed) { Random rand = new Random(seed); return rand.nextDouble() < chance; diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/Splitter.java b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/Splitter.java index 05d7f07..ac5a4e9 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/Splitter.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/framework/math/Splitter.java @@ -3,9 +3,6 @@ package com.hypixel.hytale.builtin.hytalegenerator.framework.math; import javax.annotation.Nonnull; public class Splitter { - public Splitter() { - } - @Nonnull public static Splitter.Range[] split(@Nonnull Splitter.Range range, int pieces) { if (pieces < 0) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/iterators/IntIterators.java b/src/com/hypixel/hytale/builtin/hytalegenerator/iterators/IntIterators.java index 7c6b372..478769b 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/iterators/IntIterators.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/iterators/IntIterators.java @@ -4,9 +4,6 @@ import it.unimi.dsi.fastutil.ints.IntIterator; import javax.annotation.Nonnull; public class IntIterators { - public IntIterators() { - } - @Nonnull public static IntIterator range(int start, int end) { return (IntIterator)(start <= end ? new ForwardIntIterator(start, end) : new BackwardIntIterator(end, start)); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/material/Material.java b/src/com/hypixel/hytale/builtin/hytalegenerator/material/Material.java index 57bda72..7e99f13 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/material/Material.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/material/Material.java @@ -69,8 +69,5 @@ public final class Material { private class Hash { int value = 0; boolean isCalculated = false; - - private Hash() { - } } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/material/MaterialCache.java b/src/com/hypixel/hytale/builtin/hytalegenerator/material/MaterialCache.java index a7b291c..7373d9c 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/material/MaterialCache.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/material/MaterialCache.java @@ -32,9 +32,6 @@ public class MaterialCache { public final FluidMaterial EMPTY_FLUID = this.getFluidMaterial(Fluid.EMPTY.getId()); public final Material EMPTY = this.getMaterial(this.EMPTY_AIR, this.EMPTY_FLUID); - public MaterialCache() { - } - @Nonnull public Material getMaterial(@Nonnull SolidMaterial solidMaterial, @Nonnull FluidMaterial fluidMaterial) { int hash = Material.hashCode(solidMaterial, fluidMaterial); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/materialproviders/MaterialProvider.java b/src/com/hypixel/hytale/builtin/hytalegenerator/materialproviders/MaterialProvider.java index bb63402..f1b0fe8 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/materialproviders/MaterialProvider.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/materialproviders/MaterialProvider.java @@ -7,9 +7,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public abstract class MaterialProvider { - public MaterialProvider() { - } - @Nullable public abstract V getVoxelTypeAt(@Nonnull MaterialProvider.Context var1); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/materialproviders/spaceanddepth/SpaceAndDepthMaterialProvider.java b/src/com/hypixel/hytale/builtin/hytalegenerator/materialproviders/spaceanddepth/SpaceAndDepthMaterialProvider.java index 4c66a24..b88e267 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/materialproviders/spaceanddepth/SpaceAndDepthMaterialProvider.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/materialproviders/spaceanddepth/SpaceAndDepthMaterialProvider.java @@ -92,9 +92,6 @@ public class SpaceAndDepthMaterialProvider extends MaterialProvider { } public abstract static class Layer { - public Layer() { - } - public abstract int getThicknessAt(int var1, int var2, int var3, int var4, int var5, int var6, int var7, double var8); @Nullable @@ -108,8 +105,5 @@ public class SpaceAndDepthMaterialProvider extends MaterialProvider { public static final Codec CODEC = new EnumCodec<>( SpaceAndDepthMaterialProvider.LayerContextType.class, EnumCodec.EnumStyle.LEGACY ); - - private LayerContextType() { - } } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/materialproviders/spaceanddepth/conditions/ConditionParameter.java b/src/com/hypixel/hytale/builtin/hytalegenerator/materialproviders/spaceanddepth/conditions/ConditionParameter.java index 198c129..e9e1ab9 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/materialproviders/spaceanddepth/conditions/ConditionParameter.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/materialproviders/spaceanddepth/conditions/ConditionParameter.java @@ -8,7 +8,4 @@ public enum ConditionParameter { SPACE_BELOW_CEILING; public static final Codec CODEC = new EnumCodec<>(ConditionParameter.class, EnumCodec.EnumStyle.LEGACY); - - private ConditionParameter() { - } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/GridUtils.java b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/GridUtils.java index c15ce2c..32b673a 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/GridUtils.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/GridUtils.java @@ -11,9 +11,6 @@ import javax.annotation.Nonnull; public class GridUtils { public static final int BUFFER_COUNT_IN_CHUNK_Y = 320 / NVoxelBuffer.SIZE.y; - public GridUtils() { - } - public static void toBufferGrid_fromVoxelGridOverlap(@Nonnull Bounds3i bounds_voxelGrid) { assert bounds_voxelGrid.isCorrect(); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/NStagedChunkGenerator.java b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/NStagedChunkGenerator.java index aaeda7d..8b67750 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/NStagedChunkGenerator.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/NStagedChunkGenerator.java @@ -571,9 +571,6 @@ public class NStagedChunkGenerator implements ChunkGenerator { private double targetViewDistance; private double targetPlayerCount; - public Builder() { - } - @Nonnull public NStagedChunkGenerator build() { assert this.concurrentExecutor != null; diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/NBufferBundle.java b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/NBufferBundle.java index ffc469c..57282ad 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/NBufferBundle.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/NBufferBundle.java @@ -19,9 +19,6 @@ import javax.annotation.Nonnull; public class NBufferBundle implements MemInstrument { private final Map grids = new HashMap<>(); - public NBufferBundle() { - } - @Nonnull public NBufferBundle.Grid createGrid(@Nonnull NBufferType bufferType, int capacity) { assert capacity >= 0; @@ -366,9 +363,6 @@ public class NBufferBundle implements MemInstrument { public static class MemoryReport { public final List gridEntries = new ArrayList<>(); - public MemoryReport() { - } - @Nonnull @Override public String toString() { @@ -414,9 +408,6 @@ public class NBufferBundle implements MemInstrument { public final int INITIAL_STAGE_INDEX = -1; public int stageIndex = -1; - public Tracker() { - } - @Nonnull @Override public MemInstrument.Report getMemoryUsage() { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/buffers/NBuffer.java b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/buffers/NBuffer.java index f0c8290..0a45ffc 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/buffers/NBuffer.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/buffers/NBuffer.java @@ -3,6 +3,4 @@ package com.hypixel.hytale.builtin.hytalegenerator.newsystem.bufferbundle.buffer import com.hypixel.hytale.builtin.hytalegenerator.newsystem.performanceinstruments.MemInstrument; public abstract class NBuffer implements MemInstrument { - public NBuffer() { - } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/buffers/NCountedPixelBuffer.java b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/buffers/NCountedPixelBuffer.java index 87c1df9..d383caf 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/buffers/NCountedPixelBuffer.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/buffers/NCountedPixelBuffer.java @@ -133,9 +133,6 @@ public class NCountedPixelBuffer extends NPixelBuffer { * NCountedPixelBuffer.SIZE_VOXEL_GRID.z]); private final List allBiomes = new ArrayList<>(1); - public CountedArrayContents() { - } - public void copyFrom(@Nonnull NCountedPixelBuffer.CountedArrayContents countedArrayContents) { ArrayUtil.copy(countedArrayContents.array, this.array); this.allBiomes.clear(); @@ -156,8 +153,5 @@ public class NCountedPixelBuffer extends NPixelBuffer { EMPTY, SINGLE_VALUE, ARRAY; - - private State() { - } } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/buffers/NEntityBuffer.java b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/buffers/NEntityBuffer.java index f94dfe8..e682dc1 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/buffers/NEntityBuffer.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/buffers/NEntityBuffer.java @@ -11,9 +11,6 @@ public class NEntityBuffer extends NBuffer { private List entities = null; private boolean isReference = false; - public NEntityBuffer() { - } - public void forEach(@Nonnull Consumer consumer) { if (this.entities != null) { for (EntityPlacementData entity : this.entities) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/buffers/NPixelBuffer.java b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/buffers/NPixelBuffer.java index 50eb535..fe3b4fe 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/buffers/NPixelBuffer.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/buffers/NPixelBuffer.java @@ -8,9 +8,6 @@ public abstract class NPixelBuffer extends NBuffer { public static final int BUFFER_SIZE_BITS = 3; public static final Vector3i SIZE = new Vector3i(8, 1, 8); - public NPixelBuffer() { - } - @Nullable public abstract T getPixelContent(@Nonnull Vector3i var1); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/buffers/NSimplePixelBuffer.java b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/buffers/NSimplePixelBuffer.java index afdbd5f..320ef12 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/buffers/NSimplePixelBuffer.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/buffers/NSimplePixelBuffer.java @@ -114,9 +114,6 @@ public class NSimplePixelBuffer extends NPixelBuffer { public static class ArrayContents implements MemInstrument { private final T[] array = (T[])(new Object[NPixelBuffer.SIZE.x * NPixelBuffer.SIZE.y * NPixelBuffer.SIZE.z]); - public ArrayContents() { - } - @Nonnull @Override public MemInstrument.Report getMemoryUsage() { @@ -129,8 +126,5 @@ public class NSimplePixelBuffer extends NPixelBuffer { EMPTY, SINGLE_VALUE, ARRAY; - - private State() { - } } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/buffers/NVoxelBuffer.java b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/buffers/NVoxelBuffer.java index 5134cc5..52333d3 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/buffers/NVoxelBuffer.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/bufferbundle/buffers/NVoxelBuffer.java @@ -137,9 +137,6 @@ public class NVoxelBuffer extends NBuffer { public static class ArrayContents implements MemInstrument { private final T[] array = (T[])(new Object[NVoxelBuffer.SIZE.x * NVoxelBuffer.SIZE.y * NVoxelBuffer.SIZE.z]); - public ArrayContents() { - } - @Nonnull @Override public MemInstrument.Report getMemoryUsage() { @@ -153,8 +150,5 @@ public class NVoxelBuffer extends NBuffer { SINGLE_VALUE, ARRAY, REFERENCE; - - private State() { - } } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/performanceinstruments/TimeInstrument.java b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/performanceinstruments/TimeInstrument.java index 34f461b..d41eaaa 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/performanceinstruments/TimeInstrument.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/performanceinstruments/TimeInstrument.java @@ -142,9 +142,6 @@ public class TimeInstrument { NOT_STARTED, STARTED, COMPLETED; - - private State() { - } } } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/stages/NBiomeDistanceStage.java b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/stages/NBiomeDistanceStage.java index bf206f8..a2c2da9 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/stages/NBiomeDistanceStage.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/stages/NBiomeDistanceStage.java @@ -263,8 +263,5 @@ public class NBiomeDistanceStage implements NStage { public static class BiomeDistanceEntry { public BiomeType biomeType; public double distance_voxelGrid; - - public BiomeDistanceEntry() { - } } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/stages/NPropStage.java b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/stages/NPropStage.java index 6dd1c23..683f495 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/stages/NPropStage.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/stages/NPropStage.java @@ -170,7 +170,7 @@ public class NPropStage implements NStage { position2d_voxelGrid.setY(0); double distanceToBiomeEdge = biomeDistanceSpace.getContent(position2d_voxelGrid).distanceToClosestOtherBiome(biomeAtPosition); Prop prop = propField.getPropDistribution().propAt(position, context.workerId, distanceToBiomeEdge); - Bounds3i propWriteBounds = prop.getWriteBounds().clone(); + Bounds3i propWriteBounds = prop.getWriteBounds_voxelGrid().clone(); propWriteBounds.offset(positionInt_voxelGrid); if (propWriteBounds.intersects(localOutputBounds_voxelGrid)) { ScanResult scanResult = prop.scan(positionInt_voxelGrid, materialInputSpace, context.workerId); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/stages/NTerrainStage.java b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/stages/NTerrainStage.java index f1f7235..79ddff7 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/stages/NTerrainStage.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/newsystem/stages/NTerrainStage.java @@ -320,9 +320,6 @@ public class NTerrainStage implements NStage { static class Entry { BiomeType biomeType; float weight; - - Entry() { - } } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/patterns/FieldFunctionPattern.java b/src/com/hypixel/hytale/builtin/hytalegenerator/patterns/FieldFunctionPattern.java index 254d745..52af77e 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/patterns/FieldFunctionPattern.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/patterns/FieldFunctionPattern.java @@ -51,9 +51,6 @@ public class FieldFunctionPattern extends Pattern { double min; double max; - private Delimiter() { - } - boolean isInside(double v) { return v >= this.min && v < this.max; } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/patterns/Pattern.java b/src/com/hypixel/hytale/builtin/hytalegenerator/patterns/Pattern.java index 18623a8..0fd7bf9 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/patterns/Pattern.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/patterns/Pattern.java @@ -8,9 +8,6 @@ import com.hypixel.hytale.math.vector.Vector3i; import javax.annotation.Nonnull; public abstract class Pattern { - public Pattern() { - } - public abstract boolean matches(@Nonnull Pattern.Context var1); public abstract SpaceSize readSpace(); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/patterns/SurfacePattern.java b/src/com/hypixel/hytale/builtin/hytalegenerator/patterns/SurfacePattern.java index 687c7f5..4037cc6 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/patterns/SurfacePattern.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/patterns/SurfacePattern.java @@ -165,8 +165,5 @@ public class SurfacePattern extends Pattern { @Nonnull public static Codec CODEC = new EnumCodec<>(SurfacePattern.Facing.class, EnumCodec.EnumStyle.LEGACY); - - private Facing() { - } } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/patterns/WallPattern.java b/src/com/hypixel/hytale/builtin/hytalegenerator/patterns/WallPattern.java index 0e4f7a3..cc6a092 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/patterns/WallPattern.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/patterns/WallPattern.java @@ -90,8 +90,5 @@ public class WallPattern extends Pattern { W; public static final Codec CODEC = new EnumCodec<>(WallPattern.WallDirection.class, EnumCodec.EnumStyle.LEGACY); - - private WallDirection() { - } } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/plugin/Handle.java b/src/com/hypixel/hytale/builtin/hytalegenerator/plugin/Handle.java index fb78e64..ef7ea73 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/plugin/Handle.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/plugin/Handle.java @@ -37,7 +37,7 @@ public class Handle implements IWorldGen { @Override public Transform[] getSpawnPoints(int seed) { - return new Transform[]{this.profile.spawnPosition().clone()}; + return new Transform[]{new Transform(0.0, 140.0, 0.0)}; } @Nonnull diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/plugin/HandleProvider.java b/src/com/hypixel/hytale/builtin/hytalegenerator/plugin/HandleProvider.java index 4171a1c..9983db0 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/plugin/HandleProvider.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/plugin/HandleProvider.java @@ -1,7 +1,6 @@ package com.hypixel.hytale.builtin.hytalegenerator.plugin; import com.hypixel.hytale.builtin.hytalegenerator.chunkgenerator.ChunkRequest; -import com.hypixel.hytale.math.vector.Transform; import com.hypixel.hytale.server.core.universe.world.worldgen.IWorldGen; import com.hypixel.hytale.server.core.universe.world.worldgen.WorldGenLoadException; import com.hypixel.hytale.server.core.universe.world.worldgen.provider.IWorldGenProvider; @@ -11,13 +10,10 @@ import javax.annotation.Nullable; public class HandleProvider implements IWorldGenProvider { public static final String ID = "HytaleGenerator"; public static final String DEFAULT_WORLD_STRUCTURE_NAME = "Default"; - public static final Transform DEFAULT_PLAYER_SPAWN = new Transform(0.0, 140.0, 0.0); @Nonnull private final HytaleGenerator plugin; @Nonnull private String worldStructureName = "Default"; - @Nonnull - private Transform playerSpawn = DEFAULT_PLAYER_SPAWN; public HandleProvider(@Nonnull HytaleGenerator plugin) { this.plugin = plugin; @@ -27,26 +23,13 @@ public class HandleProvider implements IWorldGenProvider { this.worldStructureName = worldStructureName; } - public void setPlayerSpawn(@Nullable Transform worldSpawn) { - if (worldSpawn == null) { - this.playerSpawn = DEFAULT_PLAYER_SPAWN; - } else { - this.playerSpawn = worldSpawn.clone(); - } - } - @Nonnull public String getWorldStructureName() { return this.worldStructureName; } - @Nonnull - public Transform getPlayerSpawn() { - return this.playerSpawn; - } - @Override public IWorldGen getGenerator() throws WorldGenLoadException { - return new Handle(this.plugin, new ChunkRequest.GeneratorProfile(this.worldStructureName, this.playerSpawn.clone(), 0)); + return new Handle(this.plugin, new ChunkRequest.GeneratorProfile(this.worldStructureName, 0)); } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/plugin/HytaleGenerator.java b/src/com/hypixel/hytale/builtin/hytalegenerator/plugin/HytaleGenerator.java index 74fdc1c..1ac19e0 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/plugin/HytaleGenerator.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/plugin/HytaleGenerator.java @@ -32,9 +32,9 @@ import com.hypixel.hytale.builtin.hytalegenerator.threadindexer.WorkerIndexer; import com.hypixel.hytale.codec.Codec; import com.hypixel.hytale.codec.KeyedCodec; import com.hypixel.hytale.codec.builder.BuilderCodec; -import com.hypixel.hytale.math.vector.Transform; import com.hypixel.hytale.server.core.plugin.JavaPlugin; import com.hypixel.hytale.server.core.plugin.JavaPluginInit; +import com.hypixel.hytale.server.core.universe.world.events.RemoveWorldEvent; import com.hypixel.hytale.server.core.universe.world.worldgen.GeneratedChunk; import com.hypixel.hytale.server.core.universe.world.worldgen.provider.IWorldGenProvider; import java.util.ArrayList; @@ -106,11 +106,14 @@ public class HytaleGenerator extends JavaPlugin { .append(new KeyedCodec<>("WorldStructure", Codec.STRING), HandleProvider::setWorldStructureName, HandleProvider::getWorldStructureName) .documentation("The world structure to be used for this world.") .add() - .append(new KeyedCodec<>("PlayerSpawn", Transform.CODEC), HandleProvider::setPlayerSpawn, HandleProvider::getPlayerSpawn) - .add() .build(); IWorldGenProvider.CODEC.register("HytaleGenerator", HandleProvider.class, generatorProvider); this.getCommandRegistry().registerCommand(new ViewportCommand(this.assetManager)); + this.getEventRegistry().registerGlobal(RemoveWorldEvent.class, event -> { + if (event.getWorld().getChunkStore().getGenerator() instanceof Handle handle) { + this.generators.remove(handle.getProfile()); + } + }); } @Nonnull diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/positionproviders/FieldFunctionPositionProvider.java b/src/com/hypixel/hytale/builtin/hytalegenerator/positionproviders/FieldFunctionPositionProvider.java index cd097df..59851db 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/positionproviders/FieldFunctionPositionProvider.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/positionproviders/FieldFunctionPositionProvider.java @@ -49,9 +49,6 @@ public class FieldFunctionPositionProvider extends PositionProvider { double min; double max; - private Delimiter() { - } - boolean isInside(double v) { return v >= this.min && v < this.max; } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/positionproviders/PositionProvider.java b/src/com/hypixel/hytale/builtin/hytalegenerator/positionproviders/PositionProvider.java index bb86338..dc859ab 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/positionproviders/PositionProvider.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/positionproviders/PositionProvider.java @@ -7,9 +7,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public abstract class PositionProvider { - public PositionProvider() { - } - public abstract void positionsIn(@Nonnull PositionProvider.Context var1); @Nonnull diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/positionproviders/VerticalEliminatorPositionProvider.java b/src/com/hypixel/hytale/builtin/hytalegenerator/positionproviders/SimpleHorizontalPositionProvider.java similarity index 59% rename from src/com/hypixel/hytale/builtin/hytalegenerator/positionproviders/VerticalEliminatorPositionProvider.java rename to src/com/hypixel/hytale/builtin/hytalegenerator/positionproviders/SimpleHorizontalPositionProvider.java index c203c9e..306f11a 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/positionproviders/VerticalEliminatorPositionProvider.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/positionproviders/SimpleHorizontalPositionProvider.java @@ -1,16 +1,15 @@ package com.hypixel.hytale.builtin.hytalegenerator.positionproviders; +import com.hypixel.hytale.builtin.hytalegenerator.delimiters.RangeDouble; import javax.annotation.Nonnull; -public class VerticalEliminatorPositionProvider extends PositionProvider { - private final int maxY; - private final int minY; +public class SimpleHorizontalPositionProvider extends PositionProvider { + private final RangeDouble rangeY; @Nonnull private final PositionProvider positionProvider; - public VerticalEliminatorPositionProvider(int minY, int maxY, @Nonnull PositionProvider positionProvider) { - this.minY = minY; - this.maxY = maxY; + public SimpleHorizontalPositionProvider(@Nonnull RangeDouble rangeY, @Nonnull PositionProvider positionProvider) { + this.rangeY = rangeY; this.positionProvider = positionProvider; } @@ -18,7 +17,7 @@ public class VerticalEliminatorPositionProvider extends PositionProvider { public void positionsIn(@Nonnull PositionProvider.Context context) { PositionProvider.Context childContext = new PositionProvider.Context(context); childContext.consumer = positions -> { - if (!(positions.y < this.minY) && !(positions.y >= this.maxY)) { + if (this.rangeY.contains(positions.y)) { context.consumer.accept(positions); } }; diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/propdistributions/Assignments.java b/src/com/hypixel/hytale/builtin/hytalegenerator/propdistributions/Assignments.java index 11af0ac..96050fc 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/propdistributions/Assignments.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/propdistributions/Assignments.java @@ -8,9 +8,6 @@ import java.util.List; import javax.annotation.Nonnull; public abstract class Assignments { - public Assignments() { - } - public abstract Prop propAt(@Nonnull Vector3d var1, @Nonnull WorkerIndexer.Id var2, double var3); public abstract int getRuntime(); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/props/BoxProp.java b/src/com/hypixel/hytale/builtin/hytalegenerator/props/BoxProp.java index 1d905f7..997c84b 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/props/BoxProp.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/props/BoxProp.java @@ -13,6 +13,7 @@ import com.hypixel.hytale.builtin.hytalegenerator.threadindexer.WorkerIndexer; import com.hypixel.hytale.math.vector.Vector3i; import java.util.List; import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class BoxProp extends Prop { private final Vector3i range; @@ -20,6 +21,7 @@ public class BoxProp extends Prop { private final Scanner scanner; private final Pattern pattern; private final ContextDependency contextDependency; + private final Bounds3i readBounds_voxelGrid; private final Bounds3i writeBounds_voxelGrid; private final Bounds3i boxBounds_voxelGrid; @@ -36,7 +38,8 @@ public class BoxProp extends Prop { Vector3i writeRange = writeSpace.getRange(); Vector3i readRange = scanner.readSpaceWith(pattern).getRange(); this.contextDependency = new ContextDependency(readRange, writeRange); - this.writeBounds_voxelGrid = this.contextDependency.getTotalPropBounds_voxelGrid(); + this.readBounds_voxelGrid = this.contextDependency.getReadBounds_voxelGrid(); + this.writeBounds_voxelGrid = this.contextDependency.getWriteBounds_voxelGrid(); this.boxBounds_voxelGrid = GridUtils.createBounds_fromVector_originVoxelInclusive(range); } } @@ -82,9 +85,15 @@ public class BoxProp extends Prop { return this.contextDependency.clone(); } + @NonNullDecl + @Override + public Bounds3i getReadBounds_voxelGrid() { + return this.readBounds_voxelGrid; + } + @Nonnull @Override - public Bounds3i getWriteBounds() { + public Bounds3i getWriteBounds_voxelGrid() { return this.writeBounds_voxelGrid; } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/props/ClusterProp.java b/src/com/hypixel/hytale/builtin/hytalegenerator/props/ClusterProp.java index 7ce52ee..72715fd 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/props/ClusterProp.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/props/ClusterProp.java @@ -17,6 +17,7 @@ import com.hypixel.hytale.math.vector.Vector3i; import it.unimi.dsi.fastutil.doubles.Double2DoubleFunction; import java.util.List; import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class ClusterProp extends Prop { private final Double2DoubleFunction weightCurve; @@ -26,6 +27,7 @@ public class ClusterProp extends Prop { private final ContextDependency contextDependency; private final Pattern pattern; private final Scanner scanner; + private final Bounds3i readBounds_voxelGrid; private final Bounds3i writeBounds_voxelGrid; public ClusterProp( @@ -54,9 +56,10 @@ public class ClusterProp extends Prop { } }); Vector3i readRange = scanner.readSpaceWith(pattern).getRange(); + this.readBounds_voxelGrid = scanner.readSpaceWith(pattern).toBounds3i(); Vector3i writeRange = new Vector3i(range + readRange.x, 0, range + readRange.z); this.contextDependency = new ContextDependency(readRange, writeRange); - this.writeBounds_voxelGrid = this.contextDependency.getTotalPropBounds_voxelGrid(); + this.writeBounds_voxelGrid = this.contextDependency.getWriteBounds_voxelGrid(); } } @@ -108,9 +111,15 @@ public class ClusterProp extends Prop { return this.contextDependency.clone(); } + @NonNullDecl + @Override + public Bounds3i getReadBounds_voxelGrid() { + return this.readBounds_voxelGrid; + } + @Nonnull @Override - public Bounds3i getWriteBounds() { + public Bounds3i getWriteBounds_voxelGrid() { return this.writeBounds_voxelGrid; } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/props/ColumnProp.java b/src/com/hypixel/hytale/builtin/hytalegenerator/props/ColumnProp.java index 0ddb254..6742264 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/props/ColumnProp.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/props/ColumnProp.java @@ -19,6 +19,7 @@ import com.hypixel.hytale.server.core.prefab.PrefabRotation; import java.util.ArrayList; import java.util.List; import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class ColumnProp extends Prop { private final int[] yPositions; @@ -30,6 +31,9 @@ public class ColumnProp extends Prop { private final Scanner scanner; private final ContextDependency contextDependency; private final Directionality directionality; + @Nonnull + private final Bounds3i readBounds_voxelGrid; + @Nonnull private final Bounds3i writeBounds_voxelGrid; public ColumnProp( @@ -65,7 +69,8 @@ public class ColumnProp extends Prop { Vector3i writeRange = writeSpace.getRange(); Vector3i readRange = directionality.getReadRangeWith(scanner); this.contextDependency = new ContextDependency(readRange, writeRange); - this.writeBounds_voxelGrid = this.contextDependency.getTotalPropBounds_voxelGrid(); + this.readBounds_voxelGrid = this.contextDependency.getReadBounds_voxelGrid(); + this.writeBounds_voxelGrid = this.contextDependency.getWriteBounds_voxelGrid(); } } @@ -126,9 +131,15 @@ public class ColumnProp extends Prop { return this.contextDependency.clone(); } + @NonNullDecl + @Override + public Bounds3i getReadBounds_voxelGrid() { + return this.readBounds_voxelGrid; + } + @Nonnull @Override - public Bounds3i getWriteBounds() { + public Bounds3i getWriteBounds_voxelGrid() { return this.writeBounds_voxelGrid; } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/props/DensityProp.java b/src/com/hypixel/hytale/builtin/hytalegenerator/props/DensityProp.java index 6730c9e..fee9609 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/props/DensityProp.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/props/DensityProp.java @@ -15,6 +15,7 @@ import com.hypixel.hytale.builtin.hytalegenerator.threadindexer.WorkerIndexer; import com.hypixel.hytale.math.vector.Vector3i; import java.util.List; import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class DensityProp extends Prop { private final Vector3i range; @@ -25,6 +26,7 @@ public class DensityProp extends Prop { private final ContextDependency contextDependency; private final BlockMask placementMask; private final Material defaultMaterial; + private final Bounds3i readBounds_voxelGrid; private final Bounds3i writeBounds_voxelGrid; public DensityProp( @@ -48,7 +50,8 @@ public class DensityProp extends Prop { Vector3i writeRange = writeSpace.getRange(); Vector3i readRange = scanner.readSpaceWith(pattern).getRange(); this.contextDependency = new ContextDependency(readRange, writeRange); - this.writeBounds_voxelGrid = this.contextDependency.getTotalPropBounds_voxelGrid(); + this.readBounds_voxelGrid = this.contextDependency.getReadBounds_voxelGrid(); + this.writeBounds_voxelGrid = this.contextDependency.getWriteBounds_voxelGrid(); } public PositionListScanResult scan(@Nonnull Vector3i position, @Nonnull VoxelSpace materialSpace, @Nonnull WorkerIndexer.Id id) { @@ -188,9 +191,15 @@ public class DensityProp extends Prop { return this.contextDependency.clone(); } + @NonNullDecl + @Override + public Bounds3i getReadBounds_voxelGrid() { + return this.readBounds_voxelGrid; + } + @Nonnull @Override - public Bounds3i getWriteBounds() { + public Bounds3i getWriteBounds_voxelGrid() { return this.writeBounds_voxelGrid; } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/props/OffsetProp.java b/src/com/hypixel/hytale/builtin/hytalegenerator/props/OffsetProp.java new file mode 100644 index 0000000..ef87ac2 --- /dev/null +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/props/OffsetProp.java @@ -0,0 +1,54 @@ +package com.hypixel.hytale.builtin.hytalegenerator.props; + +import com.hypixel.hytale.builtin.hytalegenerator.bounds.Bounds3i; +import com.hypixel.hytale.builtin.hytalegenerator.conveyor.stagedconveyor.ContextDependency; +import com.hypixel.hytale.builtin.hytalegenerator.datastructures.voxelspace.VoxelSpace; +import com.hypixel.hytale.builtin.hytalegenerator.material.Material; +import com.hypixel.hytale.builtin.hytalegenerator.threadindexer.WorkerIndexer; +import com.hypixel.hytale.math.vector.Vector3i; +import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.compatqual.NonNullDecl; + +public class OffsetProp extends Prop { + private final Vector3i offset_voxelGrid; + private final Prop childProp; + private final Bounds3i readBounds_voxelGrid; + private final Bounds3i writeBounds_voxelGrid; + private final ContextDependency contextDependency; + + public OffsetProp(@Nonnull Vector3i offset_voxelGrid, @Nonnull Prop childProp) { + this.offset_voxelGrid = offset_voxelGrid.clone(); + this.childProp = childProp; + this.readBounds_voxelGrid = childProp.getReadBounds_voxelGrid().clone().offset(offset_voxelGrid); + this.writeBounds_voxelGrid = childProp.getWriteBounds_voxelGrid().clone().offset(offset_voxelGrid); + this.contextDependency = ContextDependency.from(this.readBounds_voxelGrid, this.writeBounds_voxelGrid); + } + + @Override + public ScanResult scan(@NonNullDecl Vector3i position_voxelGrid, @NonNullDecl VoxelSpace materialSpace, @NonNullDecl WorkerIndexer.Id id) { + Vector3i childPosition_voxelGrid = position_voxelGrid.clone().add(this.offset_voxelGrid); + return this.childProp.scan(childPosition_voxelGrid, materialSpace, id); + } + + @Override + public void place(@NonNullDecl Prop.Context context) { + this.childProp.place(context); + } + + @Override + public ContextDependency getContextDependency() { + return this.contextDependency; + } + + @NonNullDecl + @Override + public Bounds3i getReadBounds_voxelGrid() { + return this.readBounds_voxelGrid; + } + + @NonNullDecl + @Override + public Bounds3i getWriteBounds_voxelGrid() { + return this.writeBounds_voxelGrid; + } +} diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/props/Prop.java b/src/com/hypixel/hytale/builtin/hytalegenerator/props/Prop.java index 26cd215..769f848 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/props/Prop.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/props/Prop.java @@ -8,11 +8,9 @@ import com.hypixel.hytale.builtin.hytalegenerator.newsystem.views.EntityContaine import com.hypixel.hytale.builtin.hytalegenerator.threadindexer.WorkerIndexer; import com.hypixel.hytale.math.vector.Vector3i; import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public abstract class Prop { - public Prop() { - } - public abstract ScanResult scan(@Nonnull Vector3i var1, @Nonnull VoxelSpace var2, @Nonnull WorkerIndexer.Id var3); public abstract void place(@Nonnull Prop.Context var1); @@ -20,7 +18,10 @@ public abstract class Prop { public abstract ContextDependency getContextDependency(); @Nonnull - public abstract Bounds3i getWriteBounds(); + public abstract Bounds3i getReadBounds_voxelGrid(); + + @Nonnull + public abstract Bounds3i getWriteBounds_voxelGrid(); @Nonnull public static Prop noProp() { @@ -31,7 +32,7 @@ public abstract class Prop { } }; final ContextDependency contextDependency = new ContextDependency(new Vector3i(), new Vector3i()); - final Bounds3i writeBounds_voxelGrid = new Bounds3i(); + final Bounds3i zeroBounds_voxelGrid = new Bounds3i(); return new Prop() { @Nonnull @Override @@ -49,10 +50,16 @@ public abstract class Prop { return contextDependency; } + @NonNullDecl + @Override + public Bounds3i getReadBounds_voxelGrid() { + return zeroBounds_voxelGrid; + } + @Nonnull @Override - public Bounds3i getWriteBounds() { - return writeBounds_voxelGrid; + public Bounds3i getWriteBounds_voxelGrid() { + return zeroBounds_voxelGrid; } }; } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/props/QueueProp.java b/src/com/hypixel/hytale/builtin/hytalegenerator/props/QueueProp.java index df1c05f..9277ec4 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/props/QueueProp.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/props/QueueProp.java @@ -9,6 +9,7 @@ import com.hypixel.hytale.math.vector.Vector3i; import java.util.ArrayList; import java.util.List; import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class QueueProp extends Prop { @Nonnull @@ -16,20 +17,25 @@ public class QueueProp extends Prop { @Nonnull private final ContextDependency contextDependency; @Nonnull + private final Bounds3i readBounds_voxelGrid; + @Nonnull private final Bounds3i writeBounds_voxelGrid; public QueueProp(@Nonnull List propsQueue) { this.props = new ArrayList<>(propsQueue); + this.readBounds_voxelGrid = new Bounds3i(); + this.writeBounds_voxelGrid = new Bounds3i(); Vector3i writeRange = new Vector3i(); Vector3i readRange = new Vector3i(); for (Prop prop : propsQueue) { writeRange = Vector3i.max(writeRange, prop.getContextDependency().getWriteRange()); readRange = Vector3i.max(readRange, prop.getContextDependency().getReadRange()); + this.readBounds_voxelGrid.encompass(prop.getReadBounds_voxelGrid()); + this.writeBounds_voxelGrid.encompass(prop.getWriteBounds_voxelGrid()); } this.contextDependency = new ContextDependency(readRange, writeRange); - this.writeBounds_voxelGrid = this.contextDependency.getTotalPropBounds_voxelGrid(); } @Nonnull @@ -63,9 +69,15 @@ public class QueueProp extends Prop { return this.contextDependency.clone(); } + @NonNullDecl + @Override + public Bounds3i getReadBounds_voxelGrid() { + return this.readBounds_voxelGrid; + } + @Nonnull @Override - public Bounds3i getWriteBounds() { + public Bounds3i getWriteBounds_voxelGrid() { return this.writeBounds_voxelGrid; } @@ -73,9 +85,6 @@ public class QueueProp extends Prop { ScanResult propScanResult; Prop prop; - private QueueScanResult() { - } - @Nonnull public static QueueProp.QueueScanResult cast(ScanResult scanResult) { if (!(scanResult instanceof QueueProp.QueueScanResult)) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/props/UnionProp.java b/src/com/hypixel/hytale/builtin/hytalegenerator/props/UnionProp.java index 4e4aef0..75228be 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/props/UnionProp.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/props/UnionProp.java @@ -9,6 +9,7 @@ import com.hypixel.hytale.math.vector.Vector3i; import java.util.ArrayList; import java.util.List; import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class UnionProp extends Prop { @Nonnull @@ -16,20 +17,25 @@ public class UnionProp extends Prop { @Nonnull private final ContextDependency contextDependency; @Nonnull + private final Bounds3i readBounds_voxelGrid; + @Nonnull private final Bounds3i writeBounds_voxelGrid; public UnionProp(@Nonnull List propChain) { this.props = new ArrayList<>(propChain); + this.readBounds_voxelGrid = new Bounds3i(); + this.writeBounds_voxelGrid = new Bounds3i(); Vector3i writeRange = new Vector3i(); Vector3i readRange = new Vector3i(); for (Prop prop : propChain) { writeRange = Vector3i.max(writeRange, prop.getContextDependency().getWriteRange()); readRange = Vector3i.max(readRange, prop.getContextDependency().getReadRange()); + this.readBounds_voxelGrid.encompass(prop.getReadBounds_voxelGrid()); + this.writeBounds_voxelGrid.encompass(prop.getWriteBounds_voxelGrid()); } this.contextDependency = new ContextDependency(readRange, writeRange); - this.writeBounds_voxelGrid = this.contextDependency.getTotalPropBounds_voxelGrid(); } @Nonnull @@ -63,18 +69,21 @@ public class UnionProp extends Prop { return this.contextDependency.clone(); } + @NonNullDecl + @Override + public Bounds3i getReadBounds_voxelGrid() { + return this.readBounds_voxelGrid; + } + @Nonnull @Override - public Bounds3i getWriteBounds() { + public Bounds3i getWriteBounds_voxelGrid() { return this.writeBounds_voxelGrid; } private static class ChainedScanResult implements ScanResult { List scanResults; - private ChainedScanResult() { - } - @Nonnull public static UnionProp.ChainedScanResult cast(ScanResult scanResult) { if (!(scanResult instanceof UnionProp.ChainedScanResult)) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/props/WeightedProp.java b/src/com/hypixel/hytale/builtin/hytalegenerator/props/WeightedProp.java new file mode 100644 index 0000000..68c4b5a --- /dev/null +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/props/WeightedProp.java @@ -0,0 +1,107 @@ +package com.hypixel.hytale.builtin.hytalegenerator.props; + +import com.hypixel.hytale.builtin.hytalegenerator.bounds.Bounds3i; +import com.hypixel.hytale.builtin.hytalegenerator.conveyor.stagedconveyor.ContextDependency; +import com.hypixel.hytale.builtin.hytalegenerator.datastructures.WeightedMap; +import com.hypixel.hytale.builtin.hytalegenerator.datastructures.voxelspace.VoxelSpace; +import com.hypixel.hytale.builtin.hytalegenerator.framework.math.SeedGenerator; +import com.hypixel.hytale.builtin.hytalegenerator.material.Material; +import com.hypixel.hytale.builtin.hytalegenerator.threadindexer.WorkerIndexer; +import com.hypixel.hytale.math.vector.Vector3i; +import java.util.Random; +import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.compatqual.NonNullDecl; + +public class WeightedProp extends Prop { + @Nonnull + private final WeightedMap props; + @Nonnull + private final ContextDependency contextDependency; + @Nonnull + private final Bounds3i readBounds_voxelGrid; + @Nonnull + private final Bounds3i writeBounds_voxelGrid; + @Nonnull + private final SeedGenerator seedGenerator; + + public WeightedProp(@Nonnull WeightedMap props, int seed) { + this.props = new WeightedMap<>(props); + this.readBounds_voxelGrid = new Bounds3i(); + this.writeBounds_voxelGrid = new Bounds3i(); + this.seedGenerator = new SeedGenerator(seed); + Vector3i writeRange = new Vector3i(); + Vector3i readRange = new Vector3i(); + + for (Prop prop : this.props.allElements()) { + writeRange = Vector3i.max(writeRange, prop.getContextDependency().getWriteRange()); + readRange = Vector3i.max(readRange, prop.getContextDependency().getReadRange()); + this.readBounds_voxelGrid.encompass(prop.getReadBounds_voxelGrid()); + this.writeBounds_voxelGrid.encompass(prop.getWriteBounds_voxelGrid()); + } + + this.contextDependency = new ContextDependency(readRange, writeRange); + } + + @Nonnull + @Override + public ScanResult scan(@Nonnull Vector3i position, @Nonnull VoxelSpace materialSpace, @Nonnull WorkerIndexer.Id id) { + if (this.props.size() == 0) { + return new WeightedProp.PickedScanResult(); + } else { + Random rand = new Random(this.seedGenerator.seedAt((long)position.x, (long)position.y, (long)position.z)); + Prop pickedProp = this.props.pick(rand); + ScanResult scanResult = pickedProp.scan(position, materialSpace, id); + WeightedProp.PickedScanResult pickedScanResult = new WeightedProp.PickedScanResult(); + pickedScanResult.prop = pickedProp; + pickedScanResult.scanResult = scanResult; + return pickedScanResult; + } + } + + @Override + public void place(@Nonnull Prop.Context context) { + if (!context.scanResult.isNegative()) { + WeightedProp.PickedScanResult pickedScanResult = WeightedProp.PickedScanResult.cast(context.scanResult); + Prop.Context childContext = new Prop.Context(context); + childContext.scanResult = pickedScanResult.scanResult; + pickedScanResult.prop.place(childContext); + } + } + + @Nonnull + @Override + public ContextDependency getContextDependency() { + return this.contextDependency.clone(); + } + + @NonNullDecl + @Override + public Bounds3i getReadBounds_voxelGrid() { + return this.readBounds_voxelGrid; + } + + @Nonnull + @Override + public Bounds3i getWriteBounds_voxelGrid() { + return this.writeBounds_voxelGrid; + } + + private static class PickedScanResult implements ScanResult { + ScanResult scanResult; + Prop prop; + + @Nonnull + public static WeightedProp.PickedScanResult cast(ScanResult scanResult) { + if (!(scanResult instanceof WeightedProp.PickedScanResult)) { + throw new IllegalArgumentException("The provided ScanResult isn't compatible with this prop."); + } else { + return (WeightedProp.PickedScanResult)scanResult; + } + } + + @Override + public boolean isNegative() { + return this.scanResult == null || this.scanResult.isNegative(); + } + } +} diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/props/directionality/Directionality.java b/src/com/hypixel/hytale/builtin/hytalegenerator/props/directionality/Directionality.java index 26b4c6f..94e1603 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/props/directionality/Directionality.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/props/directionality/Directionality.java @@ -10,9 +10,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public abstract class Directionality { - public Directionality() { - } - @Nullable public abstract PrefabRotation getRotationAt(@Nonnull Pattern.Context var1); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/props/directionality/OrthogonalDirection.java b/src/com/hypixel/hytale/builtin/hytalegenerator/props/directionality/OrthogonalDirection.java index 35ffe86..d4632f0 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/props/directionality/OrthogonalDirection.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/props/directionality/OrthogonalDirection.java @@ -12,7 +12,4 @@ public enum OrthogonalDirection { D; public static final Codec CODEC = new EnumCodec<>(OrthogonalDirection.class, EnumCodec.EnumStyle.LEGACY); - - private OrthogonalDirection() { - } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/props/filler/PondFillerProp.java b/src/com/hypixel/hytale/builtin/hytalegenerator/props/filler/PondFillerProp.java index 148d3c8..a3521b6 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/props/filler/PondFillerProp.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/props/filler/PondFillerProp.java @@ -17,6 +17,7 @@ import java.util.ArrayDeque; import java.util.ArrayList; import java.util.List; import javax.annotation.Nonnull; +import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class PondFillerProp extends Prop { private static final int TRAVERSED = 1; @@ -30,6 +31,7 @@ public class PondFillerProp extends Prop { private final Scanner scanner; private final Pattern pattern; private final ContextDependency contextDependency; + private final Bounds3i readBounds_voxelGrid; private final Bounds3i writeBounds_voxelGrid; public PondFillerProp( @@ -51,7 +53,8 @@ public class PondFillerProp extends Prop { SpaceSize.stack(scanner.readSpaceWith(pattern), boundingSpace); Vector3i range = boundingSpace.getRange(); this.contextDependency = new ContextDependency(range, range); - this.writeBounds_voxelGrid = this.contextDependency.getTotalPropBounds_voxelGrid(); + this.readBounds_voxelGrid = this.contextDependency.getReadBounds_voxelGrid(); + this.writeBounds_voxelGrid = this.contextDependency.getWriteBounds_voxelGrid(); } public FillerPropScanResult scan(@Nonnull Vector3i position, @Nonnull VoxelSpace materialSpace, @Nonnull WorkerIndexer.Id id) { @@ -221,9 +224,15 @@ public class PondFillerProp extends Prop { return this.contextDependency.clone(); } + @NonNullDecl + @Override + public Bounds3i getReadBounds_voxelGrid() { + return this.readBounds_voxelGrid; + } + @Nonnull @Override - public Bounds3i getWriteBounds() { + public Bounds3i getWriteBounds_voxelGrid() { return this.writeBounds_voxelGrid; } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/props/prefab/MoldingDirection.java b/src/com/hypixel/hytale/builtin/hytalegenerator/props/prefab/MoldingDirection.java index 9359db7..d197d46 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/props/prefab/MoldingDirection.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/props/prefab/MoldingDirection.java @@ -13,7 +13,4 @@ public enum MoldingDirection { WEST; public static final Codec CODEC = new EnumCodec<>(MoldingDirection.class, EnumCodec.EnumStyle.LEGACY); - - private MoldingDirection() { - } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/props/prefab/PrefabProp.java b/src/com/hypixel/hytale/builtin/hytalegenerator/props/prefab/PrefabProp.java index a1c1d9f..6b25e48 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/props/prefab/PrefabProp.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/props/prefab/PrefabProp.java @@ -43,6 +43,7 @@ import java.util.Random; import java.util.function.Function; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class PrefabProp extends Prop { private final WeightedMap> prefabPool; @@ -52,6 +53,7 @@ public class PrefabProp extends Prop { private final SeedGenerator seedGenerator; private final BlockMask materialMask; private final Directionality directionality; + private final Bounds3i readBounds_voxelGrid; private final Bounds3i writeBounds_voxelGrid; private final Bounds3i prefabBounds_voxelGrid; private final List childProps; @@ -148,7 +150,8 @@ public class PrefabProp extends Prop { } } - this.writeBounds_voxelGrid = this.contextDependency.getTotalPropBounds_voxelGrid(); + this.readBounds_voxelGrid = this.contextDependency.getReadBounds_voxelGrid(); + this.writeBounds_voxelGrid = this.contextDependency.getWriteBounds_voxelGrid(); this.prefabBounds_voxelGrid = new Bounds3i(); this.prefabBounds_voxelGrid.min.assign(this.contextDependency.getWriteRange()).scale(-1); this.prefabBounds_voxelGrid.max.assign(this.contextDependency.getWriteRange()).add(Vector3i.ALL_ONES); @@ -348,12 +351,18 @@ public class PrefabProp extends Prop { @Override public ContextDependency getContextDependency() { - return this.contextDependency.clone(); + return this.contextDependency; + } + + @NonNullDecl + @Override + public Bounds3i getReadBounds_voxelGrid() { + return this.readBounds_voxelGrid; } @Nonnull @Override - public Bounds3i getWriteBounds() { + public Bounds3i getWriteBounds_voxelGrid() { return this.writeBounds_voxelGrid; } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/props/prefab/PropPrefabUtil.java b/src/com/hypixel/hytale/builtin/hytalegenerator/props/prefab/PropPrefabUtil.java index 83872ec..1725fa9 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/props/prefab/PropPrefabUtil.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/props/prefab/PropPrefabUtil.java @@ -6,9 +6,6 @@ import com.hypixel.hytale.server.core.prefab.selection.buffer.impl.PrefabBuffer; import javax.annotation.Nonnull; public class PropPrefabUtil { - public PropPrefabUtil() { - } - @Nonnull public static Vector3i getMin(@Nonnull PrefabBuffer.PrefabBufferAccessor prefab) { int minX = prefab.getMinX(PrefabRotation.ROTATION_0); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/rangemaps/DoubleRangeMap.java b/src/com/hypixel/hytale/builtin/hytalegenerator/rangemaps/DoubleRangeMap.java index 855808f..f8d7750 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/rangemaps/DoubleRangeMap.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/rangemaps/DoubleRangeMap.java @@ -9,9 +9,6 @@ public class DoubleRangeMap { private ArrayList ranges = new ArrayList<>(1); private ArrayList values = new ArrayList<>(1); - public DoubleRangeMap() { - } - @Nullable public T get(double k) { for (int i = 0; i < this.ranges.size(); i++) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/referencebundle/Reference.java b/src/com/hypixel/hytale/builtin/hytalegenerator/referencebundle/Reference.java index 809ac32..f3c6ba4 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/referencebundle/Reference.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/referencebundle/Reference.java @@ -1,6 +1,4 @@ package com.hypixel.hytale.builtin.hytalegenerator.referencebundle; public class Reference { - public Reference() { - } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/referencebundle/ReferenceBundle.java b/src/com/hypixel/hytale/builtin/hytalegenerator/referencebundle/ReferenceBundle.java index 57e1652..22a8cc8 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/referencebundle/ReferenceBundle.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/referencebundle/ReferenceBundle.java @@ -11,9 +11,6 @@ public class ReferenceBundle { @Nonnull private final Map layerTypeMap = new HashMap<>(); - public ReferenceBundle() { - } - public void put(@Nonnull String name, @Nonnull Reference reference, @Nonnull Class type) { this.dataLayerMap.put(name, reference); this.layerTypeMap.put(name, type.getName()); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/scanners/AreaScanner.java b/src/com/hypixel/hytale/builtin/hytalegenerator/scanners/AreaScanner.java index 38527c0..5aef4a1 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/scanners/AreaScanner.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/scanners/AreaScanner.java @@ -82,16 +82,10 @@ public class AreaScanner extends Scanner { SQUARE; public static final Codec CODEC = new EnumCodec<>(AreaScanner.ScanShape.class, EnumCodec.EnumStyle.LEGACY); - - private ScanShape() { - } } public static enum Verticality { GLOBAL, LOCAL; - - private Verticality() { - } } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/scanners/ColumnRandomScanner.java b/src/com/hypixel/hytale/builtin/hytalegenerator/scanners/ColumnRandomScanner.java index 702c095..2ac092d 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/scanners/ColumnRandomScanner.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/scanners/ColumnRandomScanner.java @@ -162,8 +162,5 @@ public class ColumnRandomScanner extends Scanner { public static enum Strategy { DART_THROW, PICK_VALID; - - private Strategy() { - } } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/scanners/Scanner.java b/src/com/hypixel/hytale/builtin/hytalegenerator/scanners/Scanner.java index 846d970..04bf160 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/scanners/Scanner.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/scanners/Scanner.java @@ -11,9 +11,6 @@ import java.util.List; import javax.annotation.Nonnull; public abstract class Scanner { - public Scanner() { - } - public abstract List scan(@Nonnull Scanner.Context var1); public abstract SpaceSize scanSpace(); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/threadindexer/WorkerIndexer.java b/src/com/hypixel/hytale/builtin/hytalegenerator/threadindexer/WorkerIndexer.java index 6e6a5d2..e817fb2 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/threadindexer/WorkerIndexer.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/threadindexer/WorkerIndexer.java @@ -88,9 +88,6 @@ public class WorkerIndexer { public class Session { private int index = 0; - public Session() { - } - public WorkerIndexer.Id next() { if (this.index >= WorkerIndexer.this.workerCount) { throw new IllegalStateException("worker count exceeded"); diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/tintproviders/NoTintProvider.java b/src/com/hypixel/hytale/builtin/hytalegenerator/tintproviders/NoTintProvider.java index 0e22e4c..ae67736 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/tintproviders/NoTintProvider.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/tintproviders/NoTintProvider.java @@ -3,9 +3,6 @@ package com.hypixel.hytale.builtin.hytalegenerator.tintproviders; import javax.annotation.Nonnull; public class NoTintProvider extends TintProvider { - public NoTintProvider() { - } - @Nonnull @Override public TintProvider.Result getValue(@Nonnull TintProvider.Context context) { diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/tintproviders/TintProvider.java b/src/com/hypixel/hytale/builtin/hytalegenerator/tintproviders/TintProvider.java index e3269d6..cb97604 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/tintproviders/TintProvider.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/tintproviders/TintProvider.java @@ -9,9 +9,6 @@ import javax.annotation.Nonnull; public abstract class TintProvider { public static final int DEFAULT_TINT = ColorParseUtil.colorToARGBInt(new Color((byte)91, (byte)-98, (byte)40)); - public TintProvider() { - } - public abstract TintProvider.Result getValue(@Nonnull TintProvider.Context var1); @Nonnull diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/vectorproviders/CacheVectorProvider.java b/src/com/hypixel/hytale/builtin/hytalegenerator/vectorproviders/CacheVectorProvider.java index bd6053b..2cfd870 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/vectorproviders/CacheVectorProvider.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/vectorproviders/CacheVectorProvider.java @@ -39,8 +39,5 @@ public class CacheVectorProvider extends VectorProvider { public static class Cache { Vector3d position; Vector3d value; - - public Cache() { - } } } diff --git a/src/com/hypixel/hytale/builtin/hytalegenerator/vectorproviders/VectorProvider.java b/src/com/hypixel/hytale/builtin/hytalegenerator/vectorproviders/VectorProvider.java index 9d93c5d..0b6c6c3 100644 --- a/src/com/hypixel/hytale/builtin/hytalegenerator/vectorproviders/VectorProvider.java +++ b/src/com/hypixel/hytale/builtin/hytalegenerator/vectorproviders/VectorProvider.java @@ -8,9 +8,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public abstract class VectorProvider { - public VectorProvider() { - } - @Nonnull public abstract Vector3d process(@Nonnull VectorProvider.Context var1); diff --git a/src/com/hypixel/hytale/builtin/instances/InstanceValidator.java b/src/com/hypixel/hytale/builtin/instances/InstanceValidator.java index 52017d5..bb81cf6 100644 --- a/src/com/hypixel/hytale/builtin/instances/InstanceValidator.java +++ b/src/com/hypixel/hytale/builtin/instances/InstanceValidator.java @@ -9,9 +9,6 @@ import javax.annotation.Nonnull; public class InstanceValidator implements Validator { public static final InstanceValidator INSTANCE = new InstanceValidator(); - public InstanceValidator() { - } - public void accept(@Nonnull String s, @Nonnull ValidationResults results) { if (!InstancesPlugin.doesInstanceAssetExist(s)) { results.fail("Instance asset with name '" + s + "' does not exist"); diff --git a/src/com/hypixel/hytale/builtin/instances/InstancesPlugin.java b/src/com/hypixel/hytale/builtin/instances/InstancesPlugin.java index a8ce0b7..64a5eab 100644 --- a/src/com/hypixel/hytale/builtin/instances/InstancesPlugin.java +++ b/src/com/hypixel/hytale/builtin/instances/InstancesPlugin.java @@ -296,15 +296,9 @@ public class InstancesPlugin extends JavaPlugin { if (spawnProvider == null) { throw new IllegalStateException("Spawn provider cannot be null when teleporting player to instance!"); } else { - HeadRotation headRotationComponent = componentAccessor.getComponent(playerRef, HeadRotation.getComponentType()); - - assert headRotationComponent != null; - - Vector3f headRotation = headRotationComponent.getRotation(); - Transform spawnPoint = spawnProvider.getSpawnPoint(targetWorld, playerUUID); - Vector3f spawnHeadRotation = headRotation.clone(); - spawnHeadRotation.setYaw(spawnPoint.getRotation().getYaw()); - componentAccessor.addComponent(playerRef, Teleport.getComponentType(), new Teleport(targetWorld, spawnPoint).withHeadRotation(spawnHeadRotation)); + Transform spawnTransform = spawnProvider.getSpawnPoint(targetWorld, playerUUID); + Teleport teleportComponent = Teleport.createForPlayer(targetWorld, spawnTransform); + componentAccessor.addComponent(playerRef, Teleport.getComponentType(), teleportComponent); } } @@ -326,7 +320,7 @@ public class InstancesPlugin extends JavaPlugin { if (targetWorld == null) { throw new IllegalArgumentException("Missing return world"); } else { - Teleport teleportComponent = new Teleport(targetWorld, returnPoint.getReturnPoint()); + Teleport teleportComponent = Teleport.createForPlayer(targetWorld, returnPoint.getReturnPoint()); componentAccessor.addComponent(targetRef, Teleport.getComponentType(), teleportComponent); } } diff --git a/src/com/hypixel/hytale/builtin/instances/blocks/ConfigurableInstanceBlock.java b/src/com/hypixel/hytale/builtin/instances/blocks/ConfigurableInstanceBlock.java index 11d42d5..b9cf14b 100644 --- a/src/com/hypixel/hytale/builtin/instances/blocks/ConfigurableInstanceBlock.java +++ b/src/com/hypixel/hytale/builtin/instances/blocks/ConfigurableInstanceBlock.java @@ -193,9 +193,6 @@ public class ConfigurableInstanceBlock implements Component { } public static class OnRemove extends RefSystem { - public OnRemove() { - } - @Override public void onEntityAdded( @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer diff --git a/src/com/hypixel/hytale/builtin/instances/blocks/InstanceBlock.java b/src/com/hypixel/hytale/builtin/instances/blocks/InstanceBlock.java index 9e68507..546b556 100644 --- a/src/com/hypixel/hytale/builtin/instances/blocks/InstanceBlock.java +++ b/src/com/hypixel/hytale/builtin/instances/blocks/InstanceBlock.java @@ -79,9 +79,6 @@ public class InstanceBlock implements Component { } public static class OnRemove extends RefSystem { - public OnRemove() { - } - @Override public void onEntityAdded( @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer diff --git a/src/com/hypixel/hytale/builtin/instances/command/InstanceEditLoadCommand.java b/src/com/hypixel/hytale/builtin/instances/command/InstanceEditLoadCommand.java index 9502f7f..16d28ff 100644 --- a/src/com/hypixel/hytale/builtin/instances/command/InstanceEditLoadCommand.java +++ b/src/com/hypixel/hytale/builtin/instances/command/InstanceEditLoadCommand.java @@ -46,8 +46,9 @@ public class InstanceEditLoadCommand extends AbstractAsyncCommand { Store playerStore = ref.getStore(); World playerWorld = playerStore.getExternalData().getWorld(); playerWorld.execute(() -> { - Transform spawn = world.getWorldConfig().getSpawnProvider().getSpawnPoint(ref, playerStore); - playerStore.addComponent(ref, Teleport.getComponentType(), new Teleport(world, spawn)); + Transform spawnTransform = world.getWorldConfig().getSpawnProvider().getSpawnPoint(ref, playerStore); + Teleport teleportComponent = Teleport.createForPlayer(world, spawnTransform); + playerStore.addComponent(ref, Teleport.getComponentType(), teleportComponent); }); } }); diff --git a/src/com/hypixel/hytale/builtin/instances/config/ExitInstance.java b/src/com/hypixel/hytale/builtin/instances/config/ExitInstance.java index f4a9f83..b9e46d3 100644 --- a/src/com/hypixel/hytale/builtin/instances/config/ExitInstance.java +++ b/src/com/hypixel/hytale/builtin/instances/config/ExitInstance.java @@ -4,13 +4,14 @@ import com.hypixel.hytale.builtin.instances.InstancesPlugin; import com.hypixel.hytale.codec.KeyedCodec; import com.hypixel.hytale.codec.builder.BuilderCodec; import com.hypixel.hytale.codec.validation.Validators; -import com.hypixel.hytale.component.CommandBuffer; +import com.hypixel.hytale.component.ComponentAccessor; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.server.core.asset.type.gameplay.respawn.HomeOrSpawnPoint; import com.hypixel.hytale.server.core.asset.type.gameplay.respawn.RespawnController; import com.hypixel.hytale.server.core.universe.PlayerRef; import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; +import java.util.concurrent.CompletableFuture; import java.util.logging.Level; import javax.annotation.Nonnull; @@ -24,20 +25,20 @@ public class ExitInstance implements RespawnController { @Nonnull private RespawnController fallback = HomeOrSpawnPoint.INSTANCE; - public ExitInstance() { - } - @Override - public void respawnPlayer(@Nonnull World world, @Nonnull Ref playerReference, @Nonnull CommandBuffer commandBuffer) { + public CompletableFuture respawnPlayer( + @Nonnull World world, @Nonnull Ref playerReference, @Nonnull ComponentAccessor commandBuffer + ) { try { InstancesPlugin.exitInstance(playerReference, commandBuffer); + return CompletableFuture.completedFuture(null); } catch (Exception var6) { PlayerRef playerRefComponent = commandBuffer.getComponent(playerReference, PlayerRef.getComponentType()); assert playerRefComponent != null; InstancesPlugin.get().getLogger().at(Level.WARNING).withCause(var6).log(playerRefComponent.getUsername() + " failed to leave an instance"); - this.fallback.respawnPlayer(world, playerReference, commandBuffer); + return this.fallback.respawnPlayer(world, playerReference, commandBuffer); } } } diff --git a/src/com/hypixel/hytale/builtin/instances/config/InstanceDiscoveryConfig.java b/src/com/hypixel/hytale/builtin/instances/config/InstanceDiscoveryConfig.java index d5db053..602d53f 100644 --- a/src/com/hypixel/hytale/builtin/instances/config/InstanceDiscoveryConfig.java +++ b/src/com/hypixel/hytale/builtin/instances/config/InstanceDiscoveryConfig.java @@ -58,9 +58,6 @@ public class InstanceDiscoveryConfig { private float fadeInDuration = 1.5F; private float fadeOutDuration = 1.5F; - public InstanceDiscoveryConfig() { - } - @Nullable public String getTitleKey() { return this.titleKey; diff --git a/src/com/hypixel/hytale/builtin/instances/config/InstanceEntityConfig.java b/src/com/hypixel/hytale/builtin/instances/config/InstanceEntityConfig.java index 41211d0..b17e38c 100644 --- a/src/com/hypixel/hytale/builtin/instances/config/InstanceEntityConfig.java +++ b/src/com/hypixel/hytale/builtin/instances/config/InstanceEntityConfig.java @@ -21,9 +21,6 @@ public class InstanceEntityConfig implements Component { private WorldReturnPoint returnPoint; private transient WorldReturnPoint returnPointOverride; - public InstanceEntityConfig() { - } - @Nonnull public static ComponentType getComponentType() { return InstancesPlugin.get().getInstanceEntityConfigComponentType(); diff --git a/src/com/hypixel/hytale/builtin/instances/config/InstanceWorldConfig.java b/src/com/hypixel/hytale/builtin/instances/config/InstanceWorldConfig.java index 9cebcf1..f6a26c1 100644 --- a/src/com/hypixel/hytale/builtin/instances/config/InstanceWorldConfig.java +++ b/src/com/hypixel/hytale/builtin/instances/config/InstanceWorldConfig.java @@ -44,9 +44,6 @@ public class InstanceWorldConfig { @Nullable private InstanceDiscoveryConfig discovery; - public InstanceWorldConfig() { - } - @Nullable public static InstanceWorldConfig get(@Nonnull WorldConfig config) { return config.getPluginConfig().get(InstanceWorldConfig.class); diff --git a/src/com/hypixel/hytale/builtin/instances/interactions/ExitInstanceInteraction.java b/src/com/hypixel/hytale/builtin/instances/interactions/ExitInstanceInteraction.java index b789646..022e4a9 100644 --- a/src/com/hypixel/hytale/builtin/instances/interactions/ExitInstanceInteraction.java +++ b/src/com/hypixel/hytale/builtin/instances/interactions/ExitInstanceInteraction.java @@ -23,9 +23,6 @@ public class ExitInstanceInteraction extends SimpleInstantInteraction { .documentation("Teleports the **Entity** out of the current **Instance** and places them at their set return point.") .build(); - public ExitInstanceInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { diff --git a/src/com/hypixel/hytale/builtin/instances/interactions/TeleportConfigInstanceInteraction.java b/src/com/hypixel/hytale/builtin/instances/interactions/TeleportConfigInstanceInteraction.java index e0712ee..7831124 100644 --- a/src/com/hypixel/hytale/builtin/instances/interactions/TeleportConfigInstanceInteraction.java +++ b/src/com/hypixel/hytale/builtin/instances/interactions/TeleportConfigInstanceInteraction.java @@ -59,9 +59,6 @@ public class TeleportConfigInstanceInteraction extends SimpleBlockInteraction { .build(); private static final int SET_BLOCK_SETTINGS = 256; - public TeleportConfigInstanceInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { diff --git a/src/com/hypixel/hytale/builtin/instances/interactions/TeleportInstanceInteraction.java b/src/com/hypixel/hytale/builtin/instances/interactions/TeleportInstanceInteraction.java index 42752c8..a16b750 100644 --- a/src/com/hypixel/hytale/builtin/instances/interactions/TeleportInstanceInteraction.java +++ b/src/com/hypixel/hytale/builtin/instances/interactions/TeleportInstanceInteraction.java @@ -129,9 +129,6 @@ public class TeleportInstanceInteraction extends SimpleInstantInteraction { private boolean closeOnBlockRemove = true; private double removeBlockAfter = -1.0; - public TeleportInstanceInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { @@ -320,8 +317,5 @@ public class TeleportInstanceInteraction extends SimpleInstantInteraction { public static EnumCodec CODEC = new EnumCodec<>(TeleportInstanceInteraction.OriginSource.class) .documentKey(PLAYER, "The origin of operations will be based on the player's current position.") .documentKey(BLOCK, "The origin of operations will be based on the middle of the block's hitbox."); - - private OriginSource() { - } } } diff --git a/src/com/hypixel/hytale/builtin/instances/page/ConfigureInstanceBlockPage.java b/src/com/hypixel/hytale/builtin/instances/page/ConfigureInstanceBlockPage.java index d2fd1aa..b7fe427 100644 --- a/src/com/hypixel/hytale/builtin/instances/page/ConfigureInstanceBlockPage.java +++ b/src/com/hypixel/hytale/builtin/instances/page/ConfigureInstanceBlockPage.java @@ -201,9 +201,6 @@ public class ConfigureInstanceBlockPage extends InteractiveCustomUIPage BUTTON_LABEL_STYLE = Value.ref("Pages/BasicTextButton.ui", "LabelStyle"); private static final Value BUTTON_LABEL_STYLE_SELECTED = Value.ref("Pages/BasicTextButton.ui", "SelectedLabelStyle"); + private static final String ASSET_PACK_SUB_PATH = "Server/Instances"; @Nullable private String selectedInstance; - private List instances = new ObjectArrayList<>(); + @Nonnull + private final ServerFileBrowser browser; public InstanceListPage(@Nonnull PlayerRef playerRef) { super(playerRef, CustomPageLifetime.CanDismiss, InstanceListPage.PageData.CODEC); + FileBrowserConfig config = FileBrowserConfig.builder() + .listElementId("#List") + .searchInputId("#SearchInput") + .currentPathId("#CurrentPath") + .enableRootSelector(false) + .enableSearch(true) + .enableDirectoryNav(true) + .maxResults(50) + .assetPackMode(true, "Server/Instances") + .terminalDirectoryPredicate(path -> Files.exists(path.resolve("instance.bson"))) + .build(); + this.browser = new ServerFileBrowser(config); } @Override @@ -50,89 +66,141 @@ public class InstanceListPage extends InteractiveCustomUIPage ref, @Nonnull Store store, @Nonnull InstanceListPage.PageData data) { - if (data.getInstance() != null) { - this.updateSelection(data.getInstance()); - } - - if (data.getAction() != null) { - switch (data.getAction()) { - case Load: - if (this.selectedInstance != null) { - this.load(ref, store); - this.close(); - } - break; - case Spawn: - if (this.selectedInstance != null) { - this.spawn(ref, store); - this.close(); + if (data.searchQuery != null) { + this.browser.setSearchQuery(data.searchQuery.trim().toLowerCase()); + UICommandBuilder commandBuilder = new UICommandBuilder(); + UIEventBuilder eventBuilder = new UIEventBuilder(); + this.browser.buildCurrentPath(commandBuilder); + this.browser.buildFileList(commandBuilder, eventBuilder); + this.sendUpdate(commandBuilder, eventBuilder, false); + } else if (data.searchResult != null) { + Path resolvedPath = this.browser.resolveAssetPackPath(data.searchResult); + if (resolvedPath != null && this.isInstance(resolvedPath)) { + this.updateSelection(data.searchResult); + } + } else if (data.file != null) { + String fileName = data.file; + if ("..".equals(fileName)) { + this.browser.navigateUp(); + this.selectedInstance = null; + UICommandBuilder commandBuilder = new UICommandBuilder(); + UIEventBuilder eventBuilder = new UIEventBuilder(); + this.browser.buildCurrentPath(commandBuilder); + this.browser.buildFileList(commandBuilder, eventBuilder); + commandBuilder.set("#Name.Text", ""); + commandBuilder.set("#Name.Visible", false); + commandBuilder.set("#Spawn.Disabled", true); + commandBuilder.set("#Load.Disabled", true); + this.sendUpdate(commandBuilder, eventBuilder, false); + } else { + if (this.browser.handleEvent(FileBrowserEventData.file(fileName))) { + this.selectedInstance = null; + UICommandBuilder commandBuilder = new UICommandBuilder(); + UIEventBuilder eventBuilder = new UIEventBuilder(); + this.browser.buildCurrentPath(commandBuilder); + this.browser.buildFileList(commandBuilder, eventBuilder); + commandBuilder.set("#Name.Text", ""); + commandBuilder.set("#Name.Visible", false); + commandBuilder.set("#Spawn.Disabled", true); + commandBuilder.set("#Load.Disabled", true); + this.sendUpdate(commandBuilder, eventBuilder, false); + } else { + String virtualPath = this.browser.getAssetPackCurrentPath().isEmpty() ? fileName : this.browser.getAssetPackCurrentPath() + "/" + fileName; + Path resolvedPath = this.browser.resolveAssetPackPath(virtualPath); + if (resolvedPath != null && this.isInstance(resolvedPath)) { + this.updateSelection(virtualPath); } + } + } + } else { + if (data.getAction() != null) { + switch (data.getAction()) { + case Load: + if (this.selectedInstance != null) { + this.load(ref, store); + this.close(); + } + break; + case Spawn: + if (this.selectedInstance != null) { + this.spawn(ref, store); + this.close(); + } + } } } } + private boolean isInstance(@Nonnull Path path) { + return Files.isDirectory(path) && Files.exists(path.resolve("instance.bson")); + } + private void load(@Nonnull Ref ref, @Nonnull Store store) { - Player player = store.getComponent(ref, Player.getComponentType()); - InstancesPlugin.get(); - InstancesPlugin.loadInstanceAssetForEdit(this.selectedInstance).thenAccept(world -> { - Store playerStore = ref.getStore(); - World playerWorld = playerStore.getExternalData().getWorld(); - playerWorld.execute(() -> { - Transform spawn = world.getWorldConfig().getSpawnProvider().getSpawnPoint(ref, playerStore); - playerStore.addComponent(ref, Teleport.getComponentType(), new Teleport(world, spawn)); + String instanceName = this.getInstanceNameFromVirtualPath(this.selectedInstance); + if (instanceName != null) { + InstancesPlugin.get(); + InstancesPlugin.loadInstanceAssetForEdit(instanceName).thenAccept(world -> { + Store playerStore = ref.getStore(); + World playerWorld = playerStore.getExternalData().getWorld(); + playerWorld.execute(() -> { + Transform spawnTransform = world.getWorldConfig().getSpawnProvider().getSpawnPoint(ref, playerStore); + Teleport teleportComponent = Teleport.createForPlayer(world, spawnTransform); + playerStore.addComponent(ref, Teleport.getComponentType(), teleportComponent); + }); + }).exceptionally(ex -> { + ex.printStackTrace(); + return null; }); - }).exceptionally(ex -> { - ex.printStackTrace(); - return null; - }); + } } private void spawn(@Nonnull Ref ref, @Nonnull Store store) { - World world = store.getExternalData().getWorld(); - world.execute(() -> { - TransformComponent transformComponent = store.getComponent(ref, TransformComponent.getComponentType()); - HeadRotation headRotationComponent = store.getComponent(ref, HeadRotation.getComponentType()); + String instanceName = this.getInstanceNameFromVirtualPath(this.selectedInstance); + if (instanceName != null) { + World world = store.getExternalData().getWorld(); + world.execute(() -> { + TransformComponent transformComponent = store.getComponent(ref, TransformComponent.getComponentType()); + HeadRotation headRotationComponent = store.getComponent(ref, HeadRotation.getComponentType()); - assert transformComponent != null; + assert transformComponent != null; - Vector3d position = transformComponent.getPosition(); - Transform returnLocation = new Transform(position.clone(), headRotationComponent.getRotation().clone()); - CompletableFuture instanceWorld = InstancesPlugin.get().spawnInstance(this.selectedInstance, world, returnLocation); - InstancesPlugin.teleportPlayerToLoadingInstance(ref, store, instanceWorld, null); - }); + Vector3d position = transformComponent.getPosition(); + Transform returnLocation = new Transform(position.clone(), headRotationComponent.getRotation().clone()); + CompletableFuture instanceWorld = InstancesPlugin.get().spawnInstance(instanceName, world, returnLocation); + InstancesPlugin.teleportPlayerToLoadingInstance(ref, store, instanceWorld, null); + }); + } } - private void updateSelection(String instance) { - UICommandBuilder commandBuilder = new UICommandBuilder(); - if (this.selectedInstance != null) { - commandBuilder.set("#List[" + this.instances.indexOf(this.selectedInstance) + "].Style", BUTTON_LABEL_STYLE); - } - - if (Objects.equals(instance, this.selectedInstance)) { - this.selectedInstance = null; + @Nullable + private String getInstanceNameFromVirtualPath(@Nullable String virtualPath) { + if (virtualPath != null && !virtualPath.isEmpty()) { + String normalizedPath = virtualPath.replace('\\', '/'); + String[] parts = normalizedPath.split("/", 2); + return parts.length > 1 ? parts[1] : normalizedPath; } else { - this.selectedInstance = instance; + return null; } + } - if (this.selectedInstance != null) { - commandBuilder.set("#List[" + this.instances.indexOf(this.selectedInstance) + "].Style", BUTTON_LABEL_STYLE_SELECTED); - } - - commandBuilder.set("#Name.Text", this.selectedInstance != null ? this.selectedInstance : ""); - commandBuilder.set("#Spawn.Disabled", this.selectedInstance == null); - commandBuilder.set("#Load.Disabled", this.selectedInstance == null); + private void updateSelection(@Nonnull String virtualPath) { + this.selectedInstance = virtualPath; + UICommandBuilder commandBuilder = new UICommandBuilder(); + String displayName = virtualPath.contains("/") ? virtualPath.substring(virtualPath.lastIndexOf(47) + 1) : virtualPath; + commandBuilder.set("#Name.Text", displayName); + commandBuilder.set("#Name.Visible", true); + commandBuilder.set("#Spawn.Disabled", false); + commandBuilder.set("#Load.Disabled", false); this.sendUpdate(commandBuilder, false); } @@ -140,9 +208,6 @@ public class InstanceListPage extends InteractiveCustomUIPage CODEC = BuilderCodec.builder(InstanceListPage.PageData.class, InstanceListPage.PageData::new) .addField(new KeyedCodec<>("Instance", BuilderCodec.STRING), (o, i) -> o.instance = i, o -> o.instance) .addField(new KeyedCodec<>("Action", new EnumCodec<>(InstanceListPage.Action.class)), (o, i) -> o.action = i, o -> o.action) + .addField(new KeyedCodec<>("File", Codec.STRING), (o, s) -> o.file = s, o -> o.file) + .addField(new KeyedCodec<>("@SearchQuery", Codec.STRING), (o, s) -> o.searchQuery = s, o -> o.searchQuery) + .addField(new KeyedCodec<>("SearchResult", Codec.STRING), (o, s) -> o.searchResult = s, o -> o.searchResult) .build(); private String instance; private InstanceListPage.Action action; - - public PageData() { - } + @Nullable + private String file; + @Nullable + private String searchQuery; + @Nullable + private String searchResult; public String getInstance() { return this.instance; diff --git a/src/com/hypixel/hytale/builtin/instances/removal/IdleTimeoutCondition.java b/src/com/hypixel/hytale/builtin/instances/removal/IdleTimeoutCondition.java index 030d1a8..2983cd3 100644 --- a/src/com/hypixel/hytale/builtin/instances/removal/IdleTimeoutCondition.java +++ b/src/com/hypixel/hytale/builtin/instances/removal/IdleTimeoutCondition.java @@ -20,9 +20,6 @@ public class IdleTimeoutCondition implements RemovalCondition { .build(); private double timeoutSeconds = TimeUnit.MINUTES.toSeconds(5L); - public IdleTimeoutCondition() { - } - @Override public boolean shouldRemoveWorld(@Nonnull Store store) { InstanceDataResource instanceDataResource = store.getResource(InstanceDataResource.getResourceType()); diff --git a/src/com/hypixel/hytale/builtin/instances/removal/InstanceDataResource.java b/src/com/hypixel/hytale/builtin/instances/removal/InstanceDataResource.java index 2f07494..50890ce 100644 --- a/src/com/hypixel/hytale/builtin/instances/removal/InstanceDataResource.java +++ b/src/com/hypixel/hytale/builtin/instances/removal/InstanceDataResource.java @@ -27,9 +27,6 @@ public class InstanceDataResource implements Resource { private boolean hadPlayer; private Instant worldTimeoutTimer; - public InstanceDataResource() { - } - @Nonnull public static ResourceType getResourceType() { return InstancesPlugin.get().getInstanceDataResourceType(); diff --git a/src/com/hypixel/hytale/builtin/instances/removal/RemovalSystem.java b/src/com/hypixel/hytale/builtin/instances/removal/RemovalSystem.java index 74dd77c..366a4f5 100644 --- a/src/com/hypixel/hytale/builtin/instances/removal/RemovalSystem.java +++ b/src/com/hypixel/hytale/builtin/instances/removal/RemovalSystem.java @@ -11,9 +11,6 @@ import java.util.concurrent.CompletableFuture; import javax.annotation.Nonnull; public class RemovalSystem extends TickingSystem implements RunWhenPausedSystem { - public RemovalSystem() { - } - @Override public void tick(float dt, int systemIndex, @Nonnull Store store) { InstanceDataResource data = store.getResource(InstanceDataResource.getResourceType()); diff --git a/src/com/hypixel/hytale/builtin/model/pages/ChangeModelPage.java b/src/com/hypixel/hytale/builtin/model/pages/ChangeModelPage.java index 829e649..e46684a 100644 --- a/src/com/hypixel/hytale/builtin/model/pages/ChangeModelPage.java +++ b/src/com/hypixel/hytale/builtin/model/pages/ChangeModelPage.java @@ -247,8 +247,5 @@ public class ChangeModelPage extends InteractiveCustomUIPage ref, @Nonnull CommandBuffer commandBuffer, @Nonnull MountedComponent component) { Ref mountedToEntity = component.getMountedToEntity(); if (mountedToEntity != null && mountedToEntity.isValid()) { @@ -91,9 +88,6 @@ public class MountSystems { } public static class EnsureMinecartComponents extends HolderSystem { - public EnsureMinecartComponents() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { holder.ensureComponent(Interactable.getComponentType()); @@ -121,9 +115,6 @@ public class MountSystems { private final Query query = Query.and(MountedComponent.getComponentType(), PlayerInput.getComponentType()); private final Set> deps = Set.of(new SystemDependency<>(Order.BEFORE, PlayerSystems.ProcessPlayerInput.class)); - public HandleMountInput() { - } - @Override public void tick( float dt, @@ -203,9 +194,6 @@ public class MountSystems { } public static class MountedEntityDeath extends RefChangeSystem { - public MountedEntityDeath() { - } - @Override public Query getQuery() { return MountedComponent.getComponentType(); @@ -250,9 +238,6 @@ public class MountSystems { new SystemGroupDependency<>(Order.BEFORE, DamageModule.get().getInspectDamageGroup()) ); - public OnMinecartHit() { - } - @Override public Query getQuery() { return QUERY; @@ -314,9 +299,6 @@ public class MountSystems { public static class PlayerMount extends RefChangeSystem { private final Query query = PlayerInput.getComponentType(); - public PlayerMount() { - } - @Override public Query getQuery() { return this.query; @@ -374,9 +356,6 @@ public class MountSystems { } public static class RemoveBlockSeat extends RefSystem { - public RemoveBlockSeat() { - } - @Override public void onEntityAdded( @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer @@ -411,9 +390,6 @@ public class MountSystems { } public static class RemoveMounted extends RefSystem { - public RemoveMounted() { - } - @Override public void onEntityAdded( @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer @@ -436,9 +412,6 @@ public class MountSystems { } public static class RemoveMountedBy extends RefSystem { - public RemoveMountedBy() { - } - @Override public void onEntityAdded( @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer @@ -476,9 +449,6 @@ public class MountSystems { new SystemDependency<>(Order.BEFORE, TeleportSystems.PlayerMoveSystem.class, OrderPriority.CLOSEST) ); - public TeleportMountedEntity() { - } - @Override public Query getQuery() { return MountedComponent.getComponentType(); @@ -518,9 +488,6 @@ public class MountSystems { } public static class TrackedMounted extends RefChangeSystem { - public TrackedMounted() { - } - @Override public Query getQuery() { return MountedComponent.getComponentType(); @@ -565,9 +532,6 @@ public class MountSystems { } public static class TrackerRemove extends RefChangeSystem { - public TrackerRemove() { - } - @Override public Query getQuery() { return EntityTrackerSystems.Visible.getComponentType(); @@ -621,9 +585,6 @@ public class MountSystems { @Nonnull private final Query query = Query.and(this.componentType, MountedComponent.getComponentType()); - public TrackerUpdate() { - } - @Nullable @Override public SystemGroup getGroup() { diff --git a/src/com/hypixel/hytale/builtin/mounts/MountedByComponent.java b/src/com/hypixel/hytale/builtin/mounts/MountedByComponent.java index ad8a951..0f5c6f1 100644 --- a/src/com/hypixel/hytale/builtin/mounts/MountedByComponent.java +++ b/src/com/hypixel/hytale/builtin/mounts/MountedByComponent.java @@ -12,9 +12,6 @@ public class MountedByComponent implements Component { @Nonnull private final List> passengers = new ObjectArrayList<>(); - public MountedByComponent() { - } - public static ComponentType getComponentType() { return MountPlugin.getInstance().getMountedByComponentType(); } diff --git a/src/com/hypixel/hytale/builtin/mounts/NPCMountComponent.java b/src/com/hypixel/hytale/builtin/mounts/NPCMountComponent.java index 64c6441..eace2ed 100644 --- a/src/com/hypixel/hytale/builtin/mounts/NPCMountComponent.java +++ b/src/com/hypixel/hytale/builtin/mounts/NPCMountComponent.java @@ -26,9 +26,6 @@ public class NPCMountComponent implements Component { private float anchorY; private float anchorZ; - public NPCMountComponent() { - } - public static ComponentType getComponentType() { return MountPlugin.getInstance().getMountComponentType(); } diff --git a/src/com/hypixel/hytale/builtin/mounts/NPCMountSystems.java b/src/com/hypixel/hytale/builtin/mounts/NPCMountSystems.java index 3e849ea..3d8ff16 100644 --- a/src/com/hypixel/hytale/builtin/mounts/NPCMountSystems.java +++ b/src/com/hypixel/hytale/builtin/mounts/NPCMountSystems.java @@ -20,13 +20,7 @@ import com.hypixel.hytale.server.npc.systems.RoleChangeSystem; import javax.annotation.Nonnull; public class NPCMountSystems { - public NPCMountSystems() { - } - public static class DismountOnMountDeath extends DeathSystems.OnDeathSystem { - public DismountOnMountDeath() { - } - @Override public Query getQuery() { return NPCMountComponent.getComponentType(); @@ -47,9 +41,6 @@ public class NPCMountSystems { } public static class DismountOnPlayerDeath extends DeathSystems.OnDeathSystem { - public DismountOnPlayerDeath() { - } - @Nonnull @Override public Query getQuery() { diff --git a/src/com/hypixel/hytale/builtin/mounts/interactions/MountInteraction.java b/src/com/hypixel/hytale/builtin/mounts/interactions/MountInteraction.java index 96e3b95..922bfe8 100644 --- a/src/com/hypixel/hytale/builtin/mounts/interactions/MountInteraction.java +++ b/src/com/hypixel/hytale/builtin/mounts/interactions/MountInteraction.java @@ -42,9 +42,6 @@ public class MountInteraction extends SimpleInstantInteraction { private com.hypixel.hytale.math.vector.Vector3f attachmentOffset = new com.hypixel.hytale.math.vector.Vector3f(0.0F, 0.0F, 0.0F); private MountController controller; - public MountInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { Ref target = context.getTargetEntity(); diff --git a/src/com/hypixel/hytale/builtin/mounts/interactions/SeatingInteraction.java b/src/com/hypixel/hytale/builtin/mounts/interactions/SeatingInteraction.java index 1e926c9..8e13fd7 100644 --- a/src/com/hypixel/hytale/builtin/mounts/interactions/SeatingInteraction.java +++ b/src/com/hypixel/hytale/builtin/mounts/interactions/SeatingInteraction.java @@ -32,9 +32,6 @@ public class SeatingInteraction extends SimpleBlockInteraction { .documentation("Arranges perfect seating accommodations") .build(); - public SeatingInteraction() { - } - @Override protected void interactWithBlock( @Nonnull World world, @@ -52,7 +49,7 @@ public class SeatingInteraction extends SimpleBlockInteraction { Vector3f whereWasHit = new Vector3f(rawTarget.x + 0.5F, rawTarget.y + 0.5F, rawTarget.z + 0.5F); BlockMountAPI.BlockMountResult result = BlockMountAPI.mountOnBlock(ref, commandBuffer, targetBlock, whereWasHit); if (result == BlockMountAPI.DidNotMount.ALREADY_MOUNTED) { - int soundEventIndex = SoundEvent.getAssetMap().getIndex("Creative_Play_Add_Mask"); + int soundEventIndex = SoundEvent.getAssetMap().getIndex("SFX_Creative_Play_Add_Mask"); SoundUtil.playSoundEvent2d(ref, soundEventIndex, SoundCategory.SFX, commandBuffer); } else if (result instanceof BlockMountAPI.Mounted mounted) { BlockSoundSet soundSet = BlockSoundSet.getAssetMap().getAsset(mounted.blockType().getBlockSoundSetIndex()); diff --git a/src/com/hypixel/hytale/builtin/mounts/interactions/SpawnMinecartInteraction.java b/src/com/hypixel/hytale/builtin/mounts/interactions/SpawnMinecartInteraction.java index 2ead381..ac80335 100644 --- a/src/com/hypixel/hytale/builtin/mounts/interactions/SpawnMinecartInteraction.java +++ b/src/com/hypixel/hytale/builtin/mounts/interactions/SpawnMinecartInteraction.java @@ -61,9 +61,6 @@ public class SpawnMinecartInteraction extends SimpleBlockInteraction { private String modelId; private Map cartInteractions = Collections.emptyMap(); - public SpawnMinecartInteraction() { - } - @Override protected void interactWithBlock( @Nonnull World world, diff --git a/src/com/hypixel/hytale/builtin/mounts/npc/builders/BuilderActionMount.java b/src/com/hypixel/hytale/builtin/mounts/npc/builders/BuilderActionMount.java index dac1592..c97320c 100644 --- a/src/com/hypixel/hytale/builtin/mounts/npc/builders/BuilderActionMount.java +++ b/src/com/hypixel/hytale/builtin/mounts/npc/builders/BuilderActionMount.java @@ -17,9 +17,6 @@ public class BuilderActionMount extends BuilderActionBase { protected final FloatHolder anchorZ = new FloatHolder(); protected final StringHolder movementConfig = new StringHolder(); - public BuilderActionMount() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/CombatActionEvaluatorSystems.java b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/CombatActionEvaluatorSystems.java index fd02036..65d03b6 100644 --- a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/CombatActionEvaluatorSystems.java +++ b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/CombatActionEvaluatorSystems.java @@ -52,9 +52,6 @@ import javax.annotation.Nullable; public class CombatActionEvaluatorSystems { private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); - public CombatActionEvaluatorSystems() { - } - public static class CombatConstructionData implements Component { protected String combatState; protected int markedTargetSlot; @@ -62,9 +59,6 @@ public class CombatActionEvaluatorSystems { protected int maxRangeSlot; protected int positioningAngleSlot; - public CombatConstructionData() { - } - public static ComponentType getComponentType() { return NPCCombatActionEvaluatorPlugin.get().getCombatConstructionDataComponentType(); } diff --git a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/Positioning.java b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/Positioning.java index 6270aec..59d5700 100644 --- a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/Positioning.java +++ b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/Positioning.java @@ -5,7 +5,4 @@ public enum Positioning { Front, Behind, Flank; - - private Positioning() { - } } diff --git a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/conditions/RecentSustainedDamageCondition.java b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/conditions/RecentSustainedDamageCondition.java index 54af585..01155ea 100644 --- a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/conditions/RecentSustainedDamageCondition.java +++ b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/conditions/RecentSustainedDamageCondition.java @@ -20,9 +20,6 @@ public class RecentSustainedDamageCondition extends ScaledCurveCondition { .build(); protected static final ComponentType DAMAGE_MEMORY_COMPONENT_TYPE = DamageMemory.getComponentType(); - public RecentSustainedDamageCondition() { - } - @Override protected double getInput( int selfIndex, diff --git a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/conditions/TargetMemoryCountCondition.java b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/conditions/TargetMemoryCountCondition.java index 4dfc1da..11a244f 100644 --- a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/conditions/TargetMemoryCountCondition.java +++ b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/conditions/TargetMemoryCountCondition.java @@ -34,9 +34,6 @@ public class TargetMemoryCountCondition extends ScaledCurveCondition { protected static final ComponentType TARGET_MEMORY_COMPONENT_TYPE = TargetMemory.getComponentType(); protected TargetMemoryCountCondition.TargetType targetType = TargetMemoryCountCondition.TargetType.Hostile; - public TargetMemoryCountCondition() { - } - @Override protected double getInput( int selfIndex, @@ -58,8 +55,5 @@ public class TargetMemoryCountCondition extends ScaledCurveCondition { Hostile, Friendly, All; - - private TargetType() { - } } } diff --git a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/conditions/TotalSustainedDamageCondition.java b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/conditions/TotalSustainedDamageCondition.java index a970dab..4155b44 100644 --- a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/conditions/TotalSustainedDamageCondition.java +++ b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/conditions/TotalSustainedDamageCondition.java @@ -20,9 +20,6 @@ public class TotalSustainedDamageCondition extends ScaledCurveCondition { .build(); protected static final ComponentType DAMAGE_MEMORY_COMPONENT_TYPE = DamageMemory.getComponentType(); - public TotalSustainedDamageCondition() { - } - @Override protected double getInput( int selfIndex, diff --git a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/config/CombatBalanceAsset.java b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/config/CombatBalanceAsset.java index d96696b..4bd5e75 100644 --- a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/config/CombatBalanceAsset.java +++ b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/config/CombatBalanceAsset.java @@ -9,7 +9,7 @@ import com.hypixel.hytale.server.npc.config.balancing.BalanceAsset; import javax.annotation.Nonnull; public class CombatBalanceAsset extends BalanceAsset { - public static final BuilderCodec CODEC = BuilderCodec.builder(CombatBalanceAsset.class, CombatBalanceAsset::new, ABSTRACT_CODEC) + public static final BuilderCodec CODEC = BuilderCodec.builder(CombatBalanceAsset.class, CombatBalanceAsset::new, BASE_CODEC) .documentation("A balance asset which also configures a combat action evaluator.") .appendInherited( new KeyedCodec<>("TargetMemoryDuration", Codec.FLOAT), @@ -33,9 +33,6 @@ public class CombatBalanceAsset extends BalanceAsset { protected float targetMemoryDuration = 15.0F; protected CombatActionEvaluatorConfig evaluatorConfig; - public CombatBalanceAsset() { - } - public float getTargetMemoryDuration() { return this.targetMemoryDuration; } diff --git a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/CombatTargetCollector.java b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/CombatTargetCollector.java index e323408..1d9f047 100644 --- a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/CombatTargetCollector.java +++ b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/CombatTargetCollector.java @@ -25,9 +25,6 @@ public class CombatTargetCollector implements ISensorEntityCollector { private TargetMemory targetMemory; private double closestHostileDistanceSquared = Double.MAX_VALUE; - public CombatTargetCollector() { - } - @Override public void registerWithSupport(@Nonnull Role role) { role.getWorldSupport().requireAttitudeCache(); diff --git a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/builders/BuilderActionAddToTargetMemory.java b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/builders/BuilderActionAddToTargetMemory.java index ca1ba0b..c4f6d37 100644 --- a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/builders/BuilderActionAddToTargetMemory.java +++ b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/builders/BuilderActionAddToTargetMemory.java @@ -11,9 +11,6 @@ import com.hypixel.hytale.server.npc.instructions.Action; import javax.annotation.Nonnull; public class BuilderActionAddToTargetMemory extends BuilderActionBase { - public BuilderActionAddToTargetMemory() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/builders/BuilderActionCombatAbility.java b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/builders/BuilderActionCombatAbility.java index 477d679..3357236 100644 --- a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/builders/BuilderActionCombatAbility.java +++ b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/builders/BuilderActionCombatAbility.java @@ -7,9 +7,6 @@ import com.hypixel.hytale.server.npc.corecomponents.builders.BuilderActionBase; import javax.annotation.Nonnull; public class BuilderActionCombatAbility extends BuilderActionBase { - public BuilderActionCombatAbility() { - } - @Nonnull public ActionCombatAbility build(@Nonnull BuilderSupport builderSupport) { return new ActionCombatAbility(this, builderSupport); diff --git a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/builders/BuilderCombatTargetCollector.java b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/builders/BuilderCombatTargetCollector.java index a7e072f..ba25bc6 100644 --- a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/builders/BuilderCombatTargetCollector.java +++ b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/builders/BuilderCombatTargetCollector.java @@ -9,9 +9,6 @@ import com.hypixel.hytale.server.npc.util.expression.ExecutionContext; import javax.annotation.Nonnull; public class BuilderCombatTargetCollector extends BuilderBase { - public BuilderCombatTargetCollector() { - } - @Nonnull public ISensorEntityCollector build(BuilderSupport builderSupport) { return new CombatTargetCollector(); diff --git a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/builders/BuilderSensorCombatActionEvaluator.java b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/builders/BuilderSensorCombatActionEvaluator.java index 84e12a4..534331b 100644 --- a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/builders/BuilderSensorCombatActionEvaluator.java +++ b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/builders/BuilderSensorCombatActionEvaluator.java @@ -25,9 +25,6 @@ public class BuilderSensorCombatActionEvaluator extends BuilderSensorBase { protected ToIntFunction maxRangeStoreSlot; protected ToIntFunction positioningAngleStoreSlot; - public BuilderSensorCombatActionEvaluator() { - } - @Nonnull public Sensor build(@Nonnull BuilderSupport builderSupport) { return new SensorCombatActionEvaluator(this, builderSupport); diff --git a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/builders/BuilderSensorHasHostileTargetMemory.java b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/builders/BuilderSensorHasHostileTargetMemory.java index 4d8bcac..680c855 100644 --- a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/builders/BuilderSensorHasHostileTargetMemory.java +++ b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/builders/BuilderSensorHasHostileTargetMemory.java @@ -8,9 +8,6 @@ import com.hypixel.hytale.server.npc.instructions.Sensor; import javax.annotation.Nonnull; public class BuilderSensorHasHostileTargetMemory extends BuilderSensorBase { - public BuilderSensorHasHostileTargetMemory() { - } - @Nonnull public Sensor build(BuilderSupport builderSupport) { return new SensorHasHostileTargetMemory(this); diff --git a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/evaluator/CombatActionEvaluatorConfig.java b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/evaluator/CombatActionEvaluatorConfig.java index 291dc68..ab699d6 100644 --- a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/evaluator/CombatActionEvaluatorConfig.java +++ b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/evaluator/CombatActionEvaluatorConfig.java @@ -87,9 +87,6 @@ public class CombatActionEvaluatorConfig { protected double minActionUtility = 0.1; protected double[] predictabilityRange = DEFAULT_PREDICTABILITY_RANGE; - public CombatActionEvaluatorConfig() { - } - public Map getAvailableActions() { return this.availableActions; } diff --git a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/evaluator/combatactions/AbilityCombatAction.java b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/evaluator/combatactions/AbilityCombatAction.java index 782dcf0..1148a94 100644 --- a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/evaluator/combatactions/AbilityCombatAction.java +++ b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/evaluator/combatactions/AbilityCombatAction.java @@ -187,9 +187,6 @@ public class AbilityCombatAction extends CombatActionOption { protected boolean positionFirst; protected double chargeDistance; - public AbilityCombatAction() { - } - public String getAbility() { return this.ability; } diff --git a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/evaluator/combatactions/BasicAttackTargetCombatAction.java b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/evaluator/combatactions/BasicAttackTargetCombatAction.java index a600f68..958545f 100644 --- a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/evaluator/combatactions/BasicAttackTargetCombatAction.java +++ b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/evaluator/combatactions/BasicAttackTargetCombatAction.java @@ -44,9 +44,6 @@ public class BasicAttackTargetCombatAction extends CombatActionOption { protected int weaponSlot; protected int offhandSlot; - public BasicAttackTargetCombatAction() { - } - @Override public void execute( int index, diff --git a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/evaluator/combatactions/CombatActionOption.java b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/evaluator/combatactions/CombatActionOption.java index 8c9b8ed..5dfa792 100644 --- a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/evaluator/combatactions/CombatActionOption.java +++ b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/evaluator/combatactions/CombatActionOption.java @@ -165,8 +165,5 @@ public abstract class CombatActionOption extends Option implements JsonAssetWith .documentKey(Self, "Action targets self.") .documentKey(Hostile, "Action targets any hostile target.") .documentKey(Friendly, "Action targets any friendly target."); - - private Target() { - } } } diff --git a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/evaluator/combatactions/StateCombatAction.java b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/evaluator/combatactions/StateCombatAction.java index 6d0a291..c78bb16 100644 --- a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/evaluator/combatactions/StateCombatAction.java +++ b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/evaluator/combatactions/StateCombatAction.java @@ -34,9 +34,6 @@ public class StateCombatAction extends CombatActionOption { protected String state; protected String subState; - public StateCombatAction() { - } - public String getState() { return this.state; } diff --git a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/memory/DamageMemory.java b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/memory/DamageMemory.java index 5567272..c71bc7e 100644 --- a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/memory/DamageMemory.java +++ b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/memory/DamageMemory.java @@ -10,9 +10,6 @@ public class DamageMemory implements Component { private float recentDamage; private float totalCombatDamage; - public DamageMemory() { - } - public static ComponentType getComponentType() { return NPCCombatActionEvaluatorPlugin.get().getDamageMemoryComponentType(); } diff --git a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/memory/DamageMemorySystems.java b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/memory/DamageMemorySystems.java index 3e85431..a377504 100644 --- a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/memory/DamageMemorySystems.java +++ b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/memory/DamageMemorySystems.java @@ -14,9 +14,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class DamageMemorySystems { - public DamageMemorySystems() { - } - public static class CollectDamage extends DamageEventSystem { private final ComponentType damageMemoryComponentType; @Nonnull diff --git a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/memory/TargetMemorySystems.java b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/memory/TargetMemorySystems.java index 6dc0fc1..fecb2aa 100644 --- a/src/com/hypixel/hytale/builtin/npccombatactionevaluator/memory/TargetMemorySystems.java +++ b/src/com/hypixel/hytale/builtin/npccombatactionevaluator/memory/TargetMemorySystems.java @@ -26,9 +26,6 @@ public class TargetMemorySystems { @Nonnull public static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); - public TargetMemorySystems() { - } - public static class Ticking extends EntityTickingSystem { @Nonnull private static final String HOSTILE = "hostile"; diff --git a/src/com/hypixel/hytale/builtin/parkour/ParkourCheckpointSystems.java b/src/com/hypixel/hytale/builtin/parkour/ParkourCheckpointSystems.java index ea59efe..7e37f77 100644 --- a/src/com/hypixel/hytale/builtin/parkour/ParkourCheckpointSystems.java +++ b/src/com/hypixel/hytale/builtin/parkour/ParkourCheckpointSystems.java @@ -35,15 +35,9 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Nonnull; public class ParkourCheckpointSystems { - public ParkourCheckpointSystems() { - } - public static class EnsureNetworkSendable extends HolderSystem { private final Query query = Query.and(ParkourCheckpoint.getComponentType(), Query.not(NetworkId.getComponentType())); - public EnsureNetworkSendable() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { holder.addComponent(NetworkId.getComponentType(), new NetworkId(store.getExternalData().takeNextNetworkId())); diff --git a/src/com/hypixel/hytale/builtin/path/PrefabPathCollection.java b/src/com/hypixel/hytale/builtin/path/PrefabPathCollection.java index ebc3987..35730c9 100644 --- a/src/com/hypixel/hytale/builtin/path/PrefabPathCollection.java +++ b/src/com/hypixel/hytale/builtin/path/PrefabPathCollection.java @@ -118,9 +118,6 @@ public class PrefabPathCollection { private static class PathSet { private final List paths = new ObjectArrayList<>(); - private PathSet() { - } - public void add(IPrefabPath path) { this.paths.add(path); } diff --git a/src/com/hypixel/hytale/builtin/path/PrefabPathSystems.java b/src/com/hypixel/hytale/builtin/path/PrefabPathSystems.java index 8176da8..143961d 100644 --- a/src/com/hypixel/hytale/builtin/path/PrefabPathSystems.java +++ b/src/com/hypixel/hytale/builtin/path/PrefabPathSystems.java @@ -40,13 +40,8 @@ import java.util.UUID; import java.util.logging.Level; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; public class PrefabPathSystems { - public PrefabPathSystems() { - } - public static class AddOrRemove extends HolderSystem { public static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); @Nullable @@ -56,9 +51,6 @@ public class PrefabPathSystems { private static final ComponentType WORLD_GEN_ID_COMPONENT_TYPE = WorldGenId.getComponentType(); private static final Set> DEPENDENCIES = Set.of(new SystemDependency<>(Order.BEFORE, ModelSystems.ModelSpawned.class)); - public AddOrRemove() { - } - @Nullable @Override public Query getQuery() { @@ -126,9 +118,6 @@ public class PrefabPathSystems { private static final Query QUERY = Query.and(PATH_MARKER_ENTITY_COMPONENT_TYPE, FROM_WORLD_GEN_COMPONENT_TYPE); private static final Set> DEPENDENCIES = Set.of(new SystemDependency<>(Order.BEFORE, PrefabPathSystems.AddOrRemove.class)); - public AddedFromWorldGen() { - } - @Nonnull @Override public Query getQuery() { @@ -158,9 +147,6 @@ public class PrefabPathSystems { } public static class NameplateHolderSystem extends HolderSystem { - public NameplateHolderSystem() { - } - @Nonnull @Override public Query getQuery() { @@ -168,7 +154,7 @@ public class PrefabPathSystems { } @Override - public void onEntityAdd(@NonNullDecl Holder holder, @NonNullDecl AddReason reason, @NonNullDecl Store store) { + public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { PatrolPathMarkerEntity patrolPathMarkerComponent = holder.getComponent(PatrolPathMarkerEntity.getComponentType()); assert patrolPathMarkerComponent != null; @@ -190,14 +176,11 @@ public class PrefabPathSystems { } @Override - public void onEntityRemoved(@NonNullDecl Holder holder, @NonNullDecl RemoveReason reason, @NonNullDecl Store store) { + public void onEntityRemoved(@Nonnull Holder holder, @Nonnull RemoveReason reason, @Nonnull Store store) { } } public static class NameplateRefChangeSystem extends RefChangeSystem { - public NameplateRefChangeSystem() { - } - @Nonnull @Override public Query getQuery() { @@ -268,9 +251,6 @@ public class PrefabPathSystems { @Nonnull private static final Message MESSAGE_PREFABS_UNKNOWN = Message.translation("server.prefabs.unknown"); - public WorldGenChangeSystem() { - } - @Nonnull @Override public Query getQuery() { @@ -284,10 +264,7 @@ public class PrefabPathSystems { } public void onComponentAdded( - @NonNullDecl Ref ref, - @NonNullDecl WorldGenId component, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, @Nonnull WorldGenId component, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { PatrolPathMarkerEntity patrolPathMarkerComponent = commandBuffer.getComponent(ref, PatrolPathMarkerEntity.getComponentType()); @@ -299,11 +276,11 @@ public class PrefabPathSystems { } public void onComponentSet( - @NonNullDecl Ref ref, - @NullableDecl WorldGenId oldComponent, - @NonNullDecl WorldGenId newComponent, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, + @Nullable WorldGenId oldComponent, + @Nonnull WorldGenId newComponent, + @Nonnull Store store, + @Nonnull CommandBuffer commandBuffer ) { PatrolPathMarkerEntity patrolPathMarkerComponent = commandBuffer.getComponent(ref, PatrolPathMarkerEntity.getComponentType()); @@ -315,10 +292,7 @@ public class PrefabPathSystems { } public void onComponentRemoved( - @NonNullDecl Ref ref, - @NonNullDecl WorldGenId component, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, @Nonnull WorldGenId component, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { commandBuffer.putComponent(ref, DisplayNameComponent.getComponentType(), new DisplayNameComponent(MESSAGE_PREFABS_UNKNOWN)); } diff --git a/src/com/hypixel/hytale/builtin/path/WorldPathBuilder.java b/src/com/hypixel/hytale/builtin/path/WorldPathBuilder.java index a1554e3..8a8a464 100644 --- a/src/com/hypixel/hytale/builtin/path/WorldPathBuilder.java +++ b/src/com/hypixel/hytale/builtin/path/WorldPathBuilder.java @@ -10,9 +10,6 @@ import javax.annotation.Nonnull; public class WorldPathBuilder implements Component { private WorldPath path; - public WorldPathBuilder() { - } - public static ComponentType getComponentType() { return PathPlugin.get().getWorldPathBuilderComponentType(); } diff --git a/src/com/hypixel/hytale/builtin/path/WorldPathData.java b/src/com/hypixel/hytale/builtin/path/WorldPathData.java index 753f55b..3a9d96c 100644 --- a/src/com/hypixel/hytale/builtin/path/WorldPathData.java +++ b/src/com/hypixel/hytale/builtin/path/WorldPathData.java @@ -20,9 +20,6 @@ import javax.annotation.Nullable; public class WorldPathData implements Resource { private final Int2ObjectMap prefabPaths = new Int2ObjectOpenHashMap<>(); - public WorldPathData() { - } - public static ResourceType getResourceType() { return PathPlugin.get().getWorldPathDataResourceType(); } diff --git a/src/com/hypixel/hytale/builtin/path/commands/WorldPathBuilderCommand.java b/src/com/hypixel/hytale/builtin/path/commands/WorldPathBuilderCommand.java index a1374a2..a7d60b4 100644 --- a/src/com/hypixel/hytale/builtin/path/commands/WorldPathBuilderCommand.java +++ b/src/com/hypixel/hytale/builtin/path/commands/WorldPathBuilderCommand.java @@ -144,7 +144,9 @@ public class WorldPathBuilderCommand extends AbstractCommandCollection { if (builder != null) { Integer index = this.indexArg.get(context); WorldPath worldPath = builder.getPath(); - store.addComponent(ref, Teleport.getComponentType(), new Teleport(null, worldPath.getWaypoints().get(index))); + Transform waypointTransform = worldPath.getWaypoints().get(index); + Teleport teleportComponent = Teleport.createForPlayer(null, waypointTransform); + store.addComponent(ref, Teleport.getComponentType(), teleportComponent); context.sendMessage(Message.translation("server.universe.worldpath.teleportedToPoint").param("index", index)); } } @@ -271,7 +273,10 @@ public class WorldPathBuilderCommand extends AbstractCommandCollection { future.complete(null); scheduledFuture[0].cancel(false); } else { - world.execute(() -> store.addComponent(ref, Teleport.getComponentType(), new Teleport(null, transform))); + world.execute(() -> { + Teleport teleportComponent = Teleport.createForPlayer(transform); + store.addComponent(ref, Teleport.getComponentType(), teleportComponent); + }); } }, 1L, 1L, TimeUnit.SECONDS); } diff --git a/src/com/hypixel/hytale/builtin/path/path/TransientPath.java b/src/com/hypixel/hytale/builtin/path/path/TransientPath.java index 3e73ee4..eb6c6ee 100644 --- a/src/com/hypixel/hytale/builtin/path/path/TransientPath.java +++ b/src/com/hypixel/hytale/builtin/path/path/TransientPath.java @@ -18,9 +18,6 @@ import javax.annotation.Nullable; public class TransientPath implements IPath { protected final List waypoints = new ObjectArrayList<>(); - public TransientPath() { - } - public void addWaypoint(@Nonnull Vector3d position, @Nonnull Vector3f rotation) { this.waypoints .add( diff --git a/src/com/hypixel/hytale/builtin/portals/components/PortalDeviceConfig.java b/src/com/hypixel/hytale/builtin/portals/components/PortalDeviceConfig.java index 404ddb7..bcb8758 100644 --- a/src/com/hypixel/hytale/builtin/portals/components/PortalDeviceConfig.java +++ b/src/com/hypixel/hytale/builtin/portals/components/PortalDeviceConfig.java @@ -47,9 +47,6 @@ public class PortalDeviceConfig { private String offState = "default"; private String returnBlock; - public PortalDeviceConfig() { - } - public String getOnState() { return this.onState; } diff --git a/src/com/hypixel/hytale/builtin/portals/components/voidevent/VoidEvent.java b/src/com/hypixel/hytale/builtin/portals/components/voidevent/VoidEvent.java index ec5b26f..e077e15 100644 --- a/src/com/hypixel/hytale/builtin/portals/components/voidevent/VoidEvent.java +++ b/src/com/hypixel/hytale/builtin/portals/components/voidevent/VoidEvent.java @@ -17,9 +17,6 @@ public class VoidEvent implements Component { private SpatialHashGrid> voidSpawners = new SpatialHashGrid<>(62.0); private VoidEventStage activeStage; - public VoidEvent() { - } - public static ComponentType getComponentType() { return PortalsPlugin.getInstance().getVoidEventComponentType(); } diff --git a/src/com/hypixel/hytale/builtin/portals/components/voidevent/VoidSpawner.java b/src/com/hypixel/hytale/builtin/portals/components/voidevent/VoidSpawner.java index 26fcbaa..0c88fd5 100644 --- a/src/com/hypixel/hytale/builtin/portals/components/voidevent/VoidSpawner.java +++ b/src/com/hypixel/hytale/builtin/portals/components/voidevent/VoidSpawner.java @@ -12,9 +12,6 @@ import javax.annotation.Nullable; public class VoidSpawner implements Component { private List spawnBeaconUuids = new ObjectArrayList<>(); - public VoidSpawner() { - } - public static ComponentType getComponentType() { return PortalsPlugin.getInstance().getVoidPortalComponentType(); } diff --git a/src/com/hypixel/hytale/builtin/portals/components/voidevent/config/InvasionPortalConfig.java b/src/com/hypixel/hytale/builtin/portals/components/voidevent/config/InvasionPortalConfig.java index da6b887..711591d 100644 --- a/src/com/hypixel/hytale/builtin/portals/components/voidevent/config/InvasionPortalConfig.java +++ b/src/com/hypixel/hytale/builtin/portals/components/voidevent/config/InvasionPortalConfig.java @@ -25,9 +25,6 @@ public class InvasionPortalConfig { private String[] spawnBeacons; private String onSpawnParticles; - public InvasionPortalConfig() { - } - public String getBlockKey() { return this.blockKey; } diff --git a/src/com/hypixel/hytale/builtin/portals/components/voidevent/config/VoidEventConfig.java b/src/com/hypixel/hytale/builtin/portals/components/voidevent/config/VoidEventConfig.java index a9683f6..bc0344e 100644 --- a/src/com/hypixel/hytale/builtin/portals/components/voidevent/config/VoidEventConfig.java +++ b/src/com/hypixel/hytale/builtin/portals/components/voidevent/config/VoidEventConfig.java @@ -42,9 +42,6 @@ public class VoidEventConfig { private List stagesSortedByStartTime; private String musicAmbienceFX; - public VoidEventConfig() { - } - public int getDurationSeconds() { return this.durationSeconds; } diff --git a/src/com/hypixel/hytale/builtin/portals/components/voidevent/config/VoidEventStage.java b/src/com/hypixel/hytale/builtin/portals/components/voidevent/config/VoidEventStage.java index 0991bf5..5449248 100644 --- a/src/com/hypixel/hytale/builtin/portals/components/voidevent/config/VoidEventStage.java +++ b/src/com/hypixel/hytale/builtin/portals/components/voidevent/config/VoidEventStage.java @@ -19,9 +19,6 @@ public class VoidEventStage { private int secondsInto; private String forcedWeatherId; - public VoidEventStage() { - } - public int getSecondsInto() { return this.secondsInto; } diff --git a/src/com/hypixel/hytale/builtin/portals/integrations/PortalGameplayConfig.java b/src/com/hypixel/hytale/builtin/portals/integrations/PortalGameplayConfig.java index 53b46bc..e982340 100644 --- a/src/com/hypixel/hytale/builtin/portals/integrations/PortalGameplayConfig.java +++ b/src/com/hypixel/hytale/builtin/portals/integrations/PortalGameplayConfig.java @@ -12,9 +12,6 @@ public class PortalGameplayConfig { .build(); private VoidEventConfig voidEvent; - public PortalGameplayConfig() { - } - @Nullable public VoidEventConfig getVoidEvent() { return this.voidEvent; diff --git a/src/com/hypixel/hytale/builtin/portals/integrations/PortalMarkerProvider.java b/src/com/hypixel/hytale/builtin/portals/integrations/PortalMarkerProvider.java index 5d80385..076ad03 100644 --- a/src/com/hypixel/hytale/builtin/portals/integrations/PortalMarkerProvider.java +++ b/src/com/hypixel/hytale/builtin/portals/integrations/PortalMarkerProvider.java @@ -2,25 +2,17 @@ package com.hypixel.hytale.builtin.portals.integrations; import com.hypixel.hytale.math.vector.Transform; import com.hypixel.hytale.protocol.packets.worldmap.MapMarker; -import com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig; import com.hypixel.hytale.server.core.universe.world.World; -import com.hypixel.hytale.server.core.universe.world.WorldMapTracker; import com.hypixel.hytale.server.core.universe.world.spawn.IndividualSpawnProvider; import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager; +import com.hypixel.hytale.server.core.universe.world.worldmap.markers.MapMarkerTracker; import com.hypixel.hytale.server.core.util.PositionUtil; public class PortalMarkerProvider implements WorldMapManager.MarkerProvider { public static final PortalMarkerProvider INSTANCE = new PortalMarkerProvider(); - public PortalMarkerProvider() { - } - @Override - public void update(World world, GameplayConfig gameplayConfig, WorldMapTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ) { - addSpawn(world, tracker, chunkViewRadius, playerChunkX, playerChunkZ); - } - - private static void addSpawn(World world, WorldMapTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ) { + public void update(World world, MapMarkerTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ) { if (world.getWorldConfig().getSpawnProvider() instanceof IndividualSpawnProvider individualSpawnProvider) { Transform spawnPoint = individualSpawnProvider.getFirstSpawnPoint(); if (spawnPoint != null) { diff --git a/src/com/hypixel/hytale/builtin/portals/interactions/EnterPortalInteraction.java b/src/com/hypixel/hytale/builtin/portals/interactions/EnterPortalInteraction.java index 5d4b60e..170c24f 100644 --- a/src/com/hypixel/hytale/builtin/portals/interactions/EnterPortalInteraction.java +++ b/src/com/hypixel/hytale/builtin/portals/interactions/EnterPortalInteraction.java @@ -47,9 +47,6 @@ public class EnterPortalInteraction extends SimpleBlockInteraction { private static final Message MESSAGE_PORTALS_DEVICE_NO_SPAWN = Message.translation("server.portals.device.worldNoSpawn"); private static final Message MESSAGE_PORTALS_DEVICE_BLOCK_ENTITY_REF_INVALID = Message.translation("server.portals.device.blockEntityRefInvalid"); - public EnterPortalInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { @@ -169,8 +166,5 @@ public class EnterPortalInteraction extends SimpleBlockInteraction { WORLD_DEAD, DIED_IN_WORLD, NO_SPAWN_AVAILABLE; - - private TargetWorldState() { - } } } diff --git a/src/com/hypixel/hytale/builtin/portals/interactions/ReturnPortalInteraction.java b/src/com/hypixel/hytale/builtin/portals/interactions/ReturnPortalInteraction.java index 31e5096..de1858a 100644 --- a/src/com/hypixel/hytale/builtin/portals/interactions/ReturnPortalInteraction.java +++ b/src/com/hypixel/hytale/builtin/portals/interactions/ReturnPortalInteraction.java @@ -35,9 +35,6 @@ public class ReturnPortalInteraction extends SimpleBlockInteraction { private static final Message MESSAGE_PORTALS_ATTUNING_TO_WORLD = Message.translation("server.portals.attuningToWorld"); private static final Message MESSAGE_PORTALS_DEVICE_NOT_IN_PORTAL_WORLD = Message.translation("server.portals.device.notInPortalWorld"); - public ReturnPortalInteraction() { - } - @Override protected void interactWithBlock( @Nonnull World world, diff --git a/src/com/hypixel/hytale/builtin/portals/resources/PortalWorld.java b/src/com/hypixel/hytale/builtin/portals/resources/PortalWorld.java index 8a8dc76..724a649 100644 --- a/src/com/hypixel/hytale/builtin/portals/resources/PortalWorld.java +++ b/src/com/hypixel/hytale/builtin/portals/resources/PortalWorld.java @@ -31,9 +31,6 @@ public class PortalWorld implements Resource { private Transform spawnPoint; private Ref voidEventRef; - public PortalWorld() { - } - public static ResourceType getResourceType() { return PortalsPlugin.getInstance().getPortalResourceType(); } diff --git a/src/com/hypixel/hytale/builtin/portals/systems/CloseWorldWhenBreakingDeviceSystems.java b/src/com/hypixel/hytale/builtin/portals/systems/CloseWorldWhenBreakingDeviceSystems.java index 977cf71..74ba573 100644 --- a/src/com/hypixel/hytale/builtin/portals/systems/CloseWorldWhenBreakingDeviceSystems.java +++ b/src/com/hypixel/hytale/builtin/portals/systems/CloseWorldWhenBreakingDeviceSystems.java @@ -13,9 +13,8 @@ import com.hypixel.hytale.component.system.RefSystem; import com.hypixel.hytale.server.core.universe.Universe; import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore; +import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; public final class CloseWorldWhenBreakingDeviceSystems { private CloseWorldWhenBreakingDeviceSystems() { @@ -24,45 +23,34 @@ public final class CloseWorldWhenBreakingDeviceSystems { private static void maybeCloseFragmentWorld(@Nullable PortalDevice device) { if (device != null) { World world = device.getDestinationWorld(); - if (world != null) { - if (world.getPlayerCount() <= 0) { - Universe.get().removeWorld(world.getName()); - } + if (world != null && world.getPlayerCount() <= 0) { + Universe.get().removeWorld(world.getName()); } } } public static class ComponentRemoved extends RefChangeSystem { - public ComponentRemoved() { - } - @Override public ComponentType componentType() { return PortalDevice.getComponentType(); } public void onComponentAdded( - @NonNullDecl Ref ref, - @NonNullDecl PortalDevice component, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, @Nonnull PortalDevice component, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { } public void onComponentSet( - @NonNullDecl Ref ref, - @NullableDecl PortalDevice oldComponent, - @NonNullDecl PortalDevice newComponent, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, + @Nullable PortalDevice oldComponent, + @Nonnull PortalDevice newComponent, + @Nonnull Store store, + @Nonnull CommandBuffer commandBuffer ) { } public void onComponentRemoved( - @NonNullDecl Ref ref, - @NonNullDecl PortalDevice component, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, @Nonnull PortalDevice component, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { CloseWorldWhenBreakingDeviceSystems.maybeCloseFragmentWorld(component); } @@ -74,24 +62,15 @@ public final class CloseWorldWhenBreakingDeviceSystems { } public static class EntityRemoved extends RefSystem { - public EntityRemoved() { - } - @Override public void onEntityAdded( - @NonNullDecl Ref ref, - @NonNullDecl AddReason reason, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { } @Override public void onEntityRemove( - @NonNullDecl Ref ref, - @NonNullDecl RemoveReason reason, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, @Nonnull RemoveReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { PortalDevice device = store.getComponent(ref, PortalDevice.getComponentType()); CloseWorldWhenBreakingDeviceSystems.maybeCloseFragmentWorld(device); diff --git a/src/com/hypixel/hytale/builtin/portals/systems/PortalInvalidDestinationSystem.java b/src/com/hypixel/hytale/builtin/portals/systems/PortalInvalidDestinationSystem.java index 2722661..4b9be22 100644 --- a/src/com/hypixel/hytale/builtin/portals/systems/PortalInvalidDestinationSystem.java +++ b/src/com/hypixel/hytale/builtin/portals/systems/PortalInvalidDestinationSystem.java @@ -23,9 +23,6 @@ import java.util.logging.Level; import javax.annotation.Nonnull; public class PortalInvalidDestinationSystem extends RefSystem { - public PortalInvalidDestinationSystem() { - } - @Override public void onEntityAdded( @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer diff --git a/src/com/hypixel/hytale/builtin/portals/systems/PortalTrackerSystems.java b/src/com/hypixel/hytale/builtin/portals/systems/PortalTrackerSystems.java index 6eb78ef..8e5a8b3 100644 --- a/src/com/hypixel/hytale/builtin/portals/systems/PortalTrackerSystems.java +++ b/src/com/hypixel/hytale/builtin/portals/systems/PortalTrackerSystems.java @@ -26,9 +26,6 @@ public final class PortalTrackerSystems { } public static class TrackerSystem extends RefSystem { - public TrackerSystem() { - } - @Override public void onEntityAdded( @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer diff --git a/src/com/hypixel/hytale/builtin/portals/systems/curse/CurseItemDropsSystem.java b/src/com/hypixel/hytale/builtin/portals/systems/curse/CurseItemDropsSystem.java index a0f4866..1f536c1 100644 --- a/src/com/hypixel/hytale/builtin/portals/systems/curse/CurseItemDropsSystem.java +++ b/src/com/hypixel/hytale/builtin/portals/systems/curse/CurseItemDropsSystem.java @@ -17,9 +17,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class CurseItemDropsSystem extends RefSystem { - public CurseItemDropsSystem() { - } - @Override public void onEntityAdded( @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer diff --git a/src/com/hypixel/hytale/builtin/portals/systems/curse/DeleteCursedItemsOnSpawnSystem.java b/src/com/hypixel/hytale/builtin/portals/systems/curse/DeleteCursedItemsOnSpawnSystem.java index bf7b113..87e46d7 100644 --- a/src/com/hypixel/hytale/builtin/portals/systems/curse/DeleteCursedItemsOnSpawnSystem.java +++ b/src/com/hypixel/hytale/builtin/portals/systems/curse/DeleteCursedItemsOnSpawnSystem.java @@ -15,9 +15,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class DeleteCursedItemsOnSpawnSystem extends RefSystem { - public DeleteCursedItemsOnSpawnSystem() { - } - @Override public void onEntityAdded( @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer diff --git a/src/com/hypixel/hytale/builtin/portals/systems/curse/DiedInPortalSystem.java b/src/com/hypixel/hytale/builtin/portals/systems/curse/DiedInPortalSystem.java index 010c20e..3c9a61b 100644 --- a/src/com/hypixel/hytale/builtin/portals/systems/curse/DiedInPortalSystem.java +++ b/src/com/hypixel/hytale/builtin/portals/systems/curse/DiedInPortalSystem.java @@ -16,9 +16,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class DiedInPortalSystem extends DeathSystems.OnDeathSystem { - public DiedInPortalSystem() { - } - public void onComponentAdded( @Nonnull Ref ref, @Nonnull DeathComponent component, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { diff --git a/src/com/hypixel/hytale/builtin/portals/systems/voidevent/VoidEventRefSystem.java b/src/com/hypixel/hytale/builtin/portals/systems/voidevent/VoidEventRefSystem.java index 0822397..691fca6 100644 --- a/src/com/hypixel/hytale/builtin/portals/systems/voidevent/VoidEventRefSystem.java +++ b/src/com/hypixel/hytale/builtin/portals/systems/voidevent/VoidEventRefSystem.java @@ -18,9 +18,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public final class VoidEventRefSystem extends RefSystem { - public VoidEventRefSystem() { - } - @Override public void onEntityAdded( @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer diff --git a/src/com/hypixel/hytale/builtin/portals/systems/voidevent/VoidSpawnerSystems.java b/src/com/hypixel/hytale/builtin/portals/systems/voidevent/VoidSpawnerSystems.java index e76ffaf..f06d10f 100644 --- a/src/com/hypixel/hytale/builtin/portals/systems/voidevent/VoidSpawnerSystems.java +++ b/src/com/hypixel/hytale/builtin/portals/systems/voidevent/VoidSpawnerSystems.java @@ -32,13 +32,7 @@ import javax.annotation.Nullable; public final class VoidSpawnerSystems { private static final Query QUERY = Query.and(VoidSpawner.getComponentType(), TransformComponent.getComponentType()); - public VoidSpawnerSystems() { - } - public static class Instantiate extends RefSystem { - public Instantiate() { - } - @Override public void onEntityAdded( @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer diff --git a/src/com/hypixel/hytale/builtin/portals/ui/PortalDeviceActivePage.java b/src/com/hypixel/hytale/builtin/portals/ui/PortalDeviceActivePage.java index 1d20bda..933c305 100644 --- a/src/com/hypixel/hytale/builtin/portals/ui/PortalDeviceActivePage.java +++ b/src/com/hypixel/hytale/builtin/portals/ui/PortalDeviceActivePage.java @@ -134,9 +134,6 @@ public class PortalDeviceActivePage extends InteractiveCustomUIPage ref, ComponentAccessor store, PlayerRef playerRef, InteractionContext context) { BlockPosition targetBlock = context.getTargetBlock(); diff --git a/src/com/hypixel/hytale/builtin/portals/ui/PortalDeviceSummonPage.java b/src/com/hypixel/hytale/builtin/portals/ui/PortalDeviceSummonPage.java index f3f9bfa..cf06ab4 100644 --- a/src/com/hypixel/hytale/builtin/portals/ui/PortalDeviceSummonPage.java +++ b/src/com/hypixel/hytale/builtin/portals/ui/PortalDeviceSummonPage.java @@ -312,10 +312,16 @@ public class PortalDeviceSummonPage extends InteractiveCustomUIPage { - Transform computedSpawn = PortalSpawnFinder.computeSpawnTransform(world, portalSpawn); - return computedSpawn == null ? worldSpawnPoint : computedSpawn; - }, world) : CompletableFuture.completedFuture(worldSpawnPoint); + if (DEFAULT_WORLDGEN_SPAWN.equals(worldSpawnPoint) && portalSpawn != null) { + return CompletableFuture.supplyAsync(() -> { + Transform computedSpawn = PortalSpawnFinder.computeSpawnTransform(world, portalSpawn); + return computedSpawn == null ? worldSpawnPoint : computedSpawn; + }, world); + } else { + Transform uppedSpawnPoint = worldSpawnPoint.clone(); + uppedSpawnPoint.getPosition().add(0.0, 0.5, 0.0); + return CompletableFuture.completedFuture(uppedSpawnPoint); + } } } @@ -426,9 +432,6 @@ public class PortalDeviceSummonPage extends InteractiveCustomUIPage flattenedSets = Int2ObjectMaps.unmodifiable(new Int2ObjectOpenHashMap<>()); - public TagSetLookup() { - } - public void putAssetSets( @Nonnull Map tagSetAssets, @Nonnull Object2IntMap tagSetIndexMap, @Nonnull Object2IntMap tagIndexMap ) { diff --git a/src/com/hypixel/hytale/builtin/teleport/TeleportPlugin.java b/src/com/hypixel/hytale/builtin/teleport/TeleportPlugin.java index 674f2f3..4af949a 100644 --- a/src/com/hypixel/hytale/builtin/teleport/TeleportPlugin.java +++ b/src/com/hypixel/hytale/builtin/teleport/TeleportPlugin.java @@ -32,7 +32,6 @@ import com.hypixel.hytale.server.core.plugin.JavaPlugin; import com.hypixel.hytale.server.core.plugin.JavaPluginInit; import com.hypixel.hytale.server.core.universe.Universe; import com.hypixel.hytale.server.core.universe.world.World; -import com.hypixel.hytale.server.core.universe.world.WorldMapTracker; import com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk; import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk; import com.hypixel.hytale.server.core.universe.world.events.AddWorldEvent; @@ -40,6 +39,7 @@ import com.hypixel.hytale.server.core.universe.world.events.AllWorldsLoadedEvent import com.hypixel.hytale.server.core.universe.world.events.ChunkPreLoadProcessEvent; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager; +import com.hypixel.hytale.server.core.universe.world.worldmap.markers.MapMarkerTracker; import com.hypixel.hytale.server.core.util.BsonUtil; import com.hypixel.hytale.server.core.util.PositionUtil; import java.io.IOException; @@ -248,20 +248,11 @@ public class TeleportPlugin extends JavaPlugin { public static class WarpMarkerProvider implements WorldMapManager.MarkerProvider { public static final TeleportPlugin.WarpMarkerProvider INSTANCE = new TeleportPlugin.WarpMarkerProvider(); - public WarpMarkerProvider() { - } - @Override - public void update( - @Nonnull World world, - @Nonnull GameplayConfig gameplayConfig, - @Nonnull WorldMapTracker tracker, - int chunkViewRadius, - int playerChunkX, - int playerChunkZ - ) { + public void update(@Nonnull World world, @Nonnull MapMarkerTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ) { Map warps = TeleportPlugin.get().getWarps(); if (!warps.isEmpty()) { + GameplayConfig gameplayConfig = world.getGameplayConfig(); if (gameplayConfig.getWorldMapConfig().isDisplayWarps()) { for (Warp warp : warps.values()) { if (warp.getWorld().equals(world.getName())) { diff --git a/src/com/hypixel/hytale/builtin/teleport/Warp.java b/src/com/hypixel/hytale/builtin/teleport/Warp.java index bbfb05e..5fe5325 100644 --- a/src/com/hypixel/hytale/builtin/teleport/Warp.java +++ b/src/com/hypixel/hytale/builtin/teleport/Warp.java @@ -48,10 +48,10 @@ public class Warp { public Warp() { } - public Warp(double locX, double locY, double locZ, float yaw, float pitch, float roll, String id, @Nonnull World world, String creator, Instant creationDate) { + public Warp(@Nonnull Transform transform, @Nonnull String id, @Nonnull World world, @Nonnull String creator, @Nonnull Instant creationDate) { this.id = id; this.world = world.getName(); - this.transform = new Transform(locX, locY, locZ, pitch, yaw, roll); + this.transform = transform; this.creator = creator; this.creationDate = creationDate; } @@ -115,6 +115,6 @@ public class Warp { @Nullable public Teleport toTeleport() { World worldInstance = Universe.get().getWorld(this.world); - return worldInstance == null ? null : new Teleport(worldInstance, this.transform); + return worldInstance == null ? null : Teleport.createForPlayer(worldInstance, this.transform); } } diff --git a/src/com/hypixel/hytale/builtin/teleport/WarpListPage.java b/src/com/hypixel/hytale/builtin/teleport/WarpListPage.java index bec61a7..b1e091f 100644 --- a/src/com/hypixel/hytale/builtin/teleport/WarpListPage.java +++ b/src/com/hypixel/hytale/builtin/teleport/WarpListPage.java @@ -100,9 +100,6 @@ public class WarpListPage extends InteractiveCustomUIPage store, @Nonnull Ref ref, @Nonnull PlayerRef playerRef, @Nonnull World world ) { - Transform spawn = resolveSpawn(context, world, playerRef, this.spawnIndexArg); + Transform spawnTransform = resolveSpawn(context, world, playerRef, this.spawnIndexArg); TransformComponent transformComponent = store.getComponent(ref, TransformComponent.getComponentType()); assert transformComponent != null; @@ -50,16 +50,13 @@ public class SpawnCommand extends AbstractPlayerCommand { assert headRotationComponent != null; - Vector3f previousBodyRotation = transformComponent.getRotation().clone(); Vector3d previousPos = transformComponent.getPosition().clone(); Vector3f previousRotation = headRotationComponent.getRotation().clone(); TeleportHistory teleportHistoryComponent = store.ensureAndGetComponent(ref, TeleportHistory.getComponentType()); teleportHistoryComponent.append(world, previousPos, previousRotation, "World " + world.getName() + "'s spawn"); - Vector3f spawnRotation = spawn.getRotation().clone(); - spawn.setRotation(new Vector3f(previousBodyRotation.getPitch(), spawnRotation.getYaw(), previousBodyRotation.getRoll())); - Teleport teleport = new Teleport(world, spawn).withHeadRotation(spawnRotation); - store.addComponent(ref, Teleport.getComponentType(), teleport); - Vector3d position = spawn.getPosition(); + Teleport teleportComponent = Teleport.createForPlayer(world, spawnTransform); + store.addComponent(ref, Teleport.getComponentType(), teleportComponent); + Vector3d position = spawnTransform.getPosition(); context.sendMessage( Message.translation("server.commands.spawn.teleported").param("x", position.getX()).param("y", position.getY()).param("z", position.getZ()) ); @@ -124,15 +121,12 @@ public class SpawnCommand extends AbstractPlayerCommand { assert headRotationComponent != null; - Vector3f previousBodyRotation = transformComponent.getRotation().clone(); Vector3d previousPos = transformComponent.getPosition().clone(); Vector3f previousRotation = headRotationComponent.getRotation().clone(); TeleportHistory teleportHistoryComponent = store.ensureAndGetComponent(ref, TeleportHistory.getComponentType()); teleportHistoryComponent.append(world, previousPos, previousRotation, "World " + world.getName() + "'s spawn"); - Vector3f spawnRotation = spawn.getRotation().clone(); - spawn.setRotation(new Vector3f(previousBodyRotation.getPitch(), spawnRotation.getYaw(), previousBodyRotation.getRoll())); - Teleport teleport = new Teleport(world, spawn).withHeadRotation(spawnRotation); - store.addComponent(ref, Teleport.getComponentType(), teleport); + Teleport teleportComponent = Teleport.createForPlayer(world, spawn); + store.addComponent(ref, Teleport.getComponentType(), teleportComponent); Vector3d position = spawn.getPosition(); context.sendMessage( Message.translation("server.commands.spawn.teleportedOther") diff --git a/src/com/hypixel/hytale/builtin/teleport/commands/teleport/SpawnSetCommand.java b/src/com/hypixel/hytale/builtin/teleport/commands/teleport/SpawnSetCommand.java index 32f8857..4b275b9 100644 --- a/src/com/hypixel/hytale/builtin/teleport/commands/teleport/SpawnSetCommand.java +++ b/src/com/hypixel/hytale/builtin/teleport/commands/teleport/SpawnSetCommand.java @@ -82,9 +82,9 @@ public class SpawnSetCommand extends AbstractWorldCommand { rotation = this.rotationArg.get(context); } - Transform transform = new Transform(position, rotation); + Transform spawnTransform = new Transform(position.clone(), rotation.clone()); WorldConfig worldConfig = world.getWorldConfig(); - worldConfig.setSpawnProvider(new GlobalSpawnProvider(transform)); + worldConfig.setSpawnProvider(new GlobalSpawnProvider(spawnTransform)); worldConfig.markChanged(); world.getLogger().at(Level.INFO).log("Set spawn provider to: %s", worldConfig.getSpawnProvider()); context.sendMessage( diff --git a/src/com/hypixel/hytale/builtin/teleport/commands/teleport/TeleportAllCommand.java b/src/com/hypixel/hytale/builtin/teleport/commands/teleport/TeleportAllCommand.java index 471733e..7d3703c 100644 --- a/src/com/hypixel/hytale/builtin/teleport/commands/teleport/TeleportAllCommand.java +++ b/src/com/hypixel/hytale/builtin/teleport/commands/teleport/TeleportAllCommand.java @@ -28,20 +28,6 @@ public class TeleportAllCommand extends CommandBase { @Nonnull private static final Message MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD = Message.translation("server.commands.errors.playerNotInWorld"); @Nonnull - private static final Message MESSAGE_COMMANDS_ERRORS_PLAYER_OR_ARG = Message.translation("server.commands.errors.playerOrArg"); - @Nonnull - private static final Message MESSAGE_COMMANDS_TELEPORT_TELEPORTED_WITH_LOOK_NOTIFICATION = Message.translation( - "server.commands.teleport.teleportedWithLookNotification" - ); - @Nonnull - private static final Message MESSAGE_COMMANDS_TELEPORT_TELEPORTED_TO_COORDINATES_NOTIFICATION = Message.translation( - "server.commands.teleport.teleportedToCoordinatesNotification" - ); - @Nonnull - private static final Message MESSAGE_COMMANDS_TELEPORT_TELEPORT_EVERYONE_WITH_LOOK = Message.translation("server.commands.teleport.teleportEveryoneWithLook"); - @Nonnull - private static final Message MESSAGE_COMMANDS_TELEPORT_TELEPORT_EVERYONE = Message.translation("server.commands.teleport.teleportEveryone"); - @Nonnull private final RequiredArg xArg = this.withRequiredArg("x", "server.commands.teleport.x.desc", ArgTypes.RELATIVE_DOUBLE_COORD); @Nonnull private final RequiredArg yArg = this.withRequiredArg("y", "server.commands.teleport.y.desc", ArgTypes.RELATIVE_DOUBLE_COORD); @@ -72,7 +58,7 @@ public class TeleportAllCommand extends CommandBase { targetWorld = this.worldArg.get(context); } else { if (!context.isPlayer()) { - context.sendMessage(MESSAGE_COMMANDS_ERRORS_PLAYER_OR_ARG.param("option", "world")); + context.sendMessage(Message.translation("server.commands.errors.playerOrArg").param("option", "world")); return; } @@ -131,8 +117,11 @@ public class TeleportAllCommand extends CommandBase { float roll = this.rollArg.provided(context) ? this.rollArg.get(context).resolve(previousHeadRotation.getRoll() * (180.0F / (float)Math.PI)) * (float) (Math.PI / 180.0) : Float.NaN; - Teleport teleport = new Teleport(new Vector3d(x, y, z), new Vector3f(previousBodyRotation.getPitch(), yaw, previousBodyRotation.getRoll())) - .withHeadRotation(new Vector3f(pitch, yaw, roll)); + Teleport teleport = Teleport.createExact( + new Vector3d(x, y, z), + new Vector3f(previousBodyRotation.getPitch(), yaw, previousBodyRotation.getRoll()), + new Vector3f(pitch, yaw, roll) + ); store.addComponent(ref, Teleport.getComponentType(), teleport); Player playerComponent = store.getComponent(ref, Player.getComponentType()); if (playerComponent != null) { @@ -157,7 +146,8 @@ public class TeleportAllCommand extends CommandBase { : roll * (180.0F / (float)Math.PI); NotificationUtil.sendNotification( playerRefComponent.getPacketHandler(), - MESSAGE_COMMANDS_TELEPORT_TELEPORTED_WITH_LOOK_NOTIFICATION.param("x", x) + Message.translation("server.commands.teleport.teleportedWithLookNotification") + .param("x", x) .param("y", y) .param("z", z) .param("yaw", displayYaw) @@ -170,7 +160,8 @@ public class TeleportAllCommand extends CommandBase { } else { NotificationUtil.sendNotification( playerRefComponent.getPacketHandler(), - MESSAGE_COMMANDS_TELEPORT_TELEPORTED_TO_COORDINATES_NOTIFICATION.param("x", x) + Message.translation("server.commands.teleport.teleportedToCoordinatesNotification") + .param("x", x) .param("y", y) .param("z", z) .param("sender", context.sender().getDisplayName()), @@ -188,7 +179,8 @@ public class TeleportAllCommand extends CommandBase { float displayPitch = this.pitchArg.provided(context) ? this.pitchArg.get(context).getRawValue() : 0.0F; float displayRoll = this.rollArg.provided(context) ? this.rollArg.get(context).getRawValue() : 0.0F; context.sendMessage( - MESSAGE_COMMANDS_TELEPORT_TELEPORT_EVERYONE_WITH_LOOK.param("world", targetWorld.getName()) + Message.translation("server.commands.teleport.teleportEveryoneWithLook") + .param("world", targetWorld.getName()) .param("x", x) .param("y", y) .param("z", z) @@ -197,7 +189,13 @@ public class TeleportAllCommand extends CommandBase { .param("roll", displayRoll) ); } else { - context.sendMessage(MESSAGE_COMMANDS_TELEPORT_TELEPORT_EVERYONE.param("world", targetWorld.getName()).param("x", x).param("y", y).param("z", z)); + context.sendMessage( + Message.translation("server.commands.teleport.teleportEveryone") + .param("world", targetWorld.getName()) + .param("x", x) + .param("y", y) + .param("z", z) + ); } } ); diff --git a/src/com/hypixel/hytale/builtin/teleport/commands/teleport/TeleportHistoryCommand.java b/src/com/hypixel/hytale/builtin/teleport/commands/teleport/TeleportHistoryCommand.java index d918423..4a8d08a 100644 --- a/src/com/hypixel/hytale/builtin/teleport/commands/teleport/TeleportHistoryCommand.java +++ b/src/com/hypixel/hytale/builtin/teleport/commands/teleport/TeleportHistoryCommand.java @@ -17,8 +17,6 @@ import javax.annotation.Nonnull; public class TeleportHistoryCommand extends AbstractPlayerCommand { @Nonnull private static final Message MESSAGE_COMMANDS_TELEPORT_HISTORY_EMPTY = Message.translation("server.commands.teleport.history.empty"); - @Nonnull - private static final Message MESSAGE_COMMANDS_TELEPORT_HISTORY_INFO = Message.translation("server.commands.teleport.history.info"); public TeleportHistoryCommand() { super("history", "server.commands.teleport.dump.desc"); @@ -40,7 +38,7 @@ public class TeleportHistoryCommand extends AbstractPlayerCommand { if (backSize == 0 && forwardSize == 0) { context.sendMessage(MESSAGE_COMMANDS_TELEPORT_HISTORY_EMPTY); } else { - context.sendMessage(MESSAGE_COMMANDS_TELEPORT_HISTORY_INFO.param("backCount", backSize).param("forwardCount", forwardSize)); + context.sendMessage(Message.translation("server.commands.teleport.history.info").param("backCount", backSize).param("forwardCount", forwardSize)); } } } diff --git a/src/com/hypixel/hytale/builtin/teleport/commands/teleport/TeleportHomeCommand.java b/src/com/hypixel/hytale/builtin/teleport/commands/teleport/TeleportHomeCommand.java index 02d5224..a2c5774 100644 --- a/src/com/hypixel/hytale/builtin/teleport/commands/teleport/TeleportHomeCommand.java +++ b/src/com/hypixel/hytale/builtin/teleport/commands/teleport/TeleportHomeCommand.java @@ -3,7 +3,6 @@ package com.hypixel.hytale.builtin.teleport.commands.teleport; import com.hypixel.hytale.builtin.teleport.components.TeleportHistory; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.Store; -import com.hypixel.hytale.math.vector.Transform; import com.hypixel.hytale.math.vector.Vector3d; import com.hypixel.hytale.math.vector.Vector3f; import com.hypixel.hytale.server.core.Message; @@ -40,12 +39,14 @@ public class TeleportHomeCommand extends AbstractPlayerCommand { assert headRotationComponent != null; - Vector3d position = transformComponent.getPosition().clone(); - Vector3f headRotation = headRotationComponent.getRotation().clone(); + Vector3d previousPos = transformComponent.getPosition().clone(); + Vector3f previousHeadRotation = headRotationComponent.getRotation().clone(); TeleportHistory teleportHistoryComponent = store.ensureAndGetComponent(ref, TeleportHistory.getComponentType()); - teleportHistoryComponent.append(world, position, headRotation, "Home"); - Transform homeTransform = Player.getRespawnPosition(ref, world.getName(), store); - store.addComponent(ref, Teleport.getComponentType(), new Teleport(null, homeTransform)); - context.sendMessage(MESSAGE_COMMANDS_TELEPORT_TELEPORTED_SELF_HOME); + teleportHistoryComponent.append(world, previousPos, previousHeadRotation, "Home"); + Player.getRespawnPosition(ref, world.getName(), store).thenAcceptAsync(homeTransform -> { + Teleport teleportComponent = Teleport.createForPlayer(null, homeTransform); + store.addComponent(ref, Teleport.getComponentType(), teleportComponent); + context.sendMessage(MESSAGE_COMMANDS_TELEPORT_TELEPORTED_SELF_HOME); + }, world); } } diff --git a/src/com/hypixel/hytale/builtin/teleport/commands/teleport/TeleportTopCommand.java b/src/com/hypixel/hytale/builtin/teleport/commands/teleport/TeleportTopCommand.java index e5801cc..832bfb3 100644 --- a/src/com/hypixel/hytale/builtin/teleport/commands/teleport/TeleportTopCommand.java +++ b/src/com/hypixel/hytale/builtin/teleport/commands/teleport/TeleportTopCommand.java @@ -52,7 +52,9 @@ public class TeleportTopCommand extends AbstractPlayerCommand { Vector3f headRotation = headRotationComponent.getRotation().clone(); int height = worldChunk.getHeight(MathUtil.floor(position.getX()), MathUtil.floor(position.getZ())); store.ensureAndGetComponent(ref, TeleportHistory.getComponentType()).append(world, position.clone(), headRotation.clone(), "Underground"); - store.addComponent(ref, Teleport.getComponentType(), new Teleport(new Vector3d(position.getX(), height + 2, position.getZ()), Vector3f.NaN)); + store.addComponent( + ref, Teleport.getComponentType(), Teleport.createForPlayer(new Vector3d(position.getX(), height + 2, position.getZ()), Vector3f.NaN) + ); context.sendMessage(MESSAGE_COMMANDS_TELEPORT_TELEPORTED_TO_TOP); } } diff --git a/src/com/hypixel/hytale/builtin/teleport/commands/teleport/TeleportWorldCommand.java b/src/com/hypixel/hytale/builtin/teleport/commands/teleport/TeleportWorldCommand.java index a7e5b39..2db6df8 100644 --- a/src/com/hypixel/hytale/builtin/teleport/commands/teleport/TeleportWorldCommand.java +++ b/src/com/hypixel/hytale/builtin/teleport/commands/teleport/TeleportWorldCommand.java @@ -22,10 +22,6 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class TeleportWorldCommand extends AbstractPlayerCommand { - private static final Message MESSAGE_WORLD_NOT_FOUND = Message.translation("server.world.notFound"); - private static final Message MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD = Message.translation("server.commands.errors.playerNotInWorld"); - private static final Message MESSAGE_WORLD_SPAWN_NOT_SET = Message.translation("server.world.spawn.notSet"); - private static final Message MESSAGE_COMMANDS_TELEPORT_TELEPORTED_TO_WORLD = Message.translation("server.commands.teleport.teleportedToWorld"); @Nonnull private final RequiredArg worldNameArg = this.withRequiredArg("worldName", "server.commands.worldport.worldName.desc", ArgTypes.STRING); @@ -42,11 +38,11 @@ public class TeleportWorldCommand extends AbstractPlayerCommand { String worldName = this.worldNameArg.get(context); World targetWorld = Universe.get().getWorld(worldName); if (targetWorld == null) { - context.sendMessage(MESSAGE_WORLD_NOT_FOUND.param("worldName", worldName)); + context.sendMessage(Message.translation("server.world.notFound").param("worldName", worldName)); } else { Transform spawnPoint = targetWorld.getWorldConfig().getSpawnProvider().getSpawnPoint(ref, store); if (spawnPoint == null) { - context.sendMessage(MESSAGE_WORLD_SPAWN_NOT_SET.param("worldName", worldName)); + context.sendMessage(Message.translation("server.world.spawn.notSet").param("worldName", worldName)); } else { TransformComponent transformComponent = store.getComponent(ref, TransformComponent.getComponentType()); HeadRotation headRotationComponent = store.getComponent(ref, HeadRotation.getComponentType()); @@ -57,10 +53,12 @@ public class TeleportWorldCommand extends AbstractPlayerCommand { teleportHistoryComponent.append(world, previousPos, previousRotation, "World " + targetWorld.getName()); } - store.addComponent(ref, Teleport.getComponentType(), new Teleport(targetWorld, spawnPoint)); + Teleport teleportComponent = Teleport.createForPlayer(targetWorld, spawnPoint); + store.addComponent(ref, Teleport.getComponentType(), teleportComponent); Vector3d spawnPos = spawnPoint.getPosition(); context.sendMessage( - MESSAGE_COMMANDS_TELEPORT_TELEPORTED_TO_WORLD.param("worldName", worldName) + Message.translation("server.commands.teleport.teleportedToWorld") + .param("worldName", worldName) .param("x", spawnPos.getX()) .param("y", spawnPos.getY()) .param("z", spawnPos.getZ()) diff --git a/src/com/hypixel/hytale/builtin/teleport/commands/teleport/variant/TeleportOtherToPlayerCommand.java b/src/com/hypixel/hytale/builtin/teleport/commands/teleport/variant/TeleportOtherToPlayerCommand.java index fc8d1cf..608a13f 100644 --- a/src/com/hypixel/hytale/builtin/teleport/commands/teleport/variant/TeleportOtherToPlayerCommand.java +++ b/src/com/hypixel/hytale/builtin/teleport/commands/teleport/variant/TeleportOtherToPlayerCommand.java @@ -3,6 +3,7 @@ package com.hypixel.hytale.builtin.teleport.commands.teleport.variant; import com.hypixel.hytale.builtin.teleport.components.TeleportHistory; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.Store; +import com.hypixel.hytale.math.vector.Transform; import com.hypixel.hytale.math.vector.Vector3d; import com.hypixel.hytale.math.vector.Vector3f; import com.hypixel.hytale.server.core.Message; @@ -20,15 +21,16 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class TeleportOtherToPlayerCommand extends CommandBase { + @Nonnull private static final Message MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD = Message.translation("server.commands.errors.playerNotInWorld"); + @Nonnull private static final Message MESSAGE_COMMANDS_ERRORS_TARGET_NOT_IN_WORLD = Message.translation("server.commands.errors.targetNotInWorld"); - private static final Message MESSAGE_COMMANDS_TELEPORT_TELEPORTED_OTHER_TO_PLAYER = Message.translation("server.commands.teleport.teleportedOtherToPlayer"); + @Nonnull + private final RequiredArg playerArg = this.withRequiredArg("player", "server.commands.argtype.player.desc", ArgTypes.PLAYER_REF); @Nonnull private final RequiredArg targetPlayerArg = this.withRequiredArg( "targetPlayer", "server.commands.teleport.targetPlayer.desc", ArgTypes.PLAYER_REF ); - @Nonnull - private final RequiredArg playerArg = this.withRequiredArg("player", "server.commands.argtype.player.desc", ArgTypes.PLAYER_REF); public TeleportOtherToPlayerCommand() { super("server.commands.teleport.otherToPlayer.desc"); @@ -70,14 +72,12 @@ public class TeleportOtherToPlayerCommand extends CommandBase { assert targetHeadRotationComponent != null; Vector3d targetPosition = targetTransformComponent.getPosition().clone(); - Vector3f targetRotation = targetTransformComponent.getRotation().clone(); Vector3f targetHeadRotation = targetHeadRotationComponent.getRotation().clone(); + Transform targetTransform = new Transform(targetPosition, targetHeadRotation); sourceWorld.execute( () -> { - Teleport teleport = new Teleport(targetWorld, targetPosition, targetRotation) - .withHeadRotation(targetHeadRotation) - .withResetRoll(); - sourceStore.addComponent(sourceRef, Teleport.getComponentType(), teleport); + Teleport teleportComponent = Teleport.createForPlayer(targetWorld, targetTransform); + sourceStore.addComponent(sourceRef, Teleport.getComponentType(), teleportComponent); PlayerRef sourcePlayerRefComponent = sourceStore.getComponent(sourceRef, PlayerRef.getComponentType()); assert sourcePlayerRefComponent != null; @@ -87,7 +87,8 @@ public class TeleportOtherToPlayerCommand extends CommandBase { assert targetPlayerRefComponent != null; context.sendMessage( - MESSAGE_COMMANDS_TELEPORT_TELEPORTED_OTHER_TO_PLAYER.param("targetName", sourcePlayerRefComponent.getUsername()) + Message.translation("server.commands.teleport.teleportedOtherToPlayer") + .param("targetName", sourcePlayerRefComponent.getUsername()) .param("toName", targetPlayerRefComponent.getUsername()) ); sourceStore.ensureAndGetComponent(sourceRef, TeleportHistory.getComponentType()) diff --git a/src/com/hypixel/hytale/builtin/teleport/commands/teleport/variant/TeleportPlayerToCoordinatesCommand.java b/src/com/hypixel/hytale/builtin/teleport/commands/teleport/variant/TeleportPlayerToCoordinatesCommand.java index fc39c22..9543ce8 100644 --- a/src/com/hypixel/hytale/builtin/teleport/commands/teleport/variant/TeleportPlayerToCoordinatesCommand.java +++ b/src/com/hypixel/hytale/builtin/teleport/commands/teleport/variant/TeleportPlayerToCoordinatesCommand.java @@ -27,12 +27,6 @@ public class TeleportPlayerToCoordinatesCommand extends CommandBase { @Nonnull private static final Message MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD = Message.translation("server.commands.errors.playerNotInWorld"); @Nonnull - private static final Message MESSAGE_COMMANDS_TELEPORT_TELEPORTED_TO_COORDINATES_WITH_LOOK = Message.translation( - "server.commands.teleport.teleportedToCoordinatesWithLook" - ); - @Nonnull - private static final Message MESSAGE_COMMANDS_TELEPORT_TELEPORTED_TO_COORDINATES = Message.translation("server.commands.teleport.teleportedToCoordinates"); - @Nonnull private final RequiredArg playerArg = this.withRequiredArg("player", "server.commands.teleport.targetPlayer.desc", ArgTypes.PLAYER_REF); @Nonnull private final RequiredArg xArg = this.withRequiredArg("x", "server.commands.teleport.x.desc", ArgTypes.RELATIVE_DOUBLE_COORD); @@ -87,8 +81,9 @@ public class TeleportPlayerToCoordinatesCommand extends CommandBase { float roll = this.rollArg.provided(context) ? this.rollArg.get(context).resolve(previousHeadRotation.getRoll() * (180.0F / (float)Math.PI)) * (float) (Math.PI / 180.0) : Float.NaN; - Teleport teleport = new Teleport(new Vector3d(x, y, z), new Vector3f(previousBodyRotation.getPitch(), yaw, previousBodyRotation.getRoll())) - .withHeadRotation(new Vector3f(pitch, yaw, roll)); + Teleport teleport = Teleport.createExact( + new Vector3d(x, y, z), new Vector3f(previousBodyRotation.getPitch(), yaw, previousBodyRotation.getRoll()), new Vector3f(pitch, yaw, roll) + ); store.addComponent(ref, Teleport.getComponentType(), teleport); Player player = store.getComponent(ref, Player.getComponentType()); if (player != null) { @@ -102,7 +97,8 @@ public class TeleportPlayerToCoordinatesCommand extends CommandBase { float displayPitch = Float.isNaN(pitch) ? previousHeadRotation.getPitch() * (180.0F / (float)Math.PI) : pitch * (180.0F / (float)Math.PI); float displayRoll = Float.isNaN(roll) ? previousHeadRotation.getRoll() * (180.0F / (float)Math.PI) : roll * (180.0F / (float)Math.PI); context.sendMessage( - MESSAGE_COMMANDS_TELEPORT_TELEPORTED_TO_COORDINATES_WITH_LOOK.param("x", x) + Message.translation("server.commands.teleport.teleportedToCoordinatesWithLook") + .param("x", x) .param("y", y) .param("z", z) .param("yaw", displayYaw) @@ -110,7 +106,7 @@ public class TeleportPlayerToCoordinatesCommand extends CommandBase { .param("roll", displayRoll) ); } else { - context.sendMessage(MESSAGE_COMMANDS_TELEPORT_TELEPORTED_TO_COORDINATES.param("x", x).param("y", y).param("z", z)); + context.sendMessage(Message.translation("server.commands.teleport.teleportedToCoordinates").param("x", x).param("y", y).param("z", z)); } } ); diff --git a/src/com/hypixel/hytale/builtin/teleport/commands/teleport/variant/TeleportToCoordinatesCommand.java b/src/com/hypixel/hytale/builtin/teleport/commands/teleport/variant/TeleportToCoordinatesCommand.java index 34153e7..6cef2e5 100644 --- a/src/com/hypixel/hytale/builtin/teleport/commands/teleport/variant/TeleportToCoordinatesCommand.java +++ b/src/com/hypixel/hytale/builtin/teleport/commands/teleport/variant/TeleportToCoordinatesCommand.java @@ -23,12 +23,6 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class TeleportToCoordinatesCommand extends AbstractPlayerCommand { - @Nonnull - private static final Message MESSAGE_COMMANDS_TELEPORT_TELEPORTED_TO_COORDINATES_WITH_LOOK = Message.translation( - "server.commands.teleport.teleportedToCoordinatesWithLook" - ); - @Nonnull - private static final Message MESSAGE_COMMANDS_TELEPORT_TELEPORTED_TO_COORDINATES = Message.translation("server.commands.teleport.teleportedToCoordinates"); @Nonnull private final RequiredArg xArg = this.withRequiredArg("x", "server.commands.teleport.x.desc", ArgTypes.RELATIVE_DOUBLE_COORD); @Nonnull @@ -77,8 +71,8 @@ public class TeleportToCoordinatesCommand extends AbstractPlayerCommand { float roll = this.rollArg.provided(context) ? this.rollArg.get(context).resolve(previousHeadRotation.getRoll() * (180.0F / (float)Math.PI)) * (float) (Math.PI / 180.0) : Float.NaN; - Teleport teleport = new Teleport(new Vector3d(x, y, z), new Vector3f(previousBodyRotation.getPitch(), yaw, previousBodyRotation.getRoll())) - .withHeadRotation(new Vector3f(pitch, yaw, roll)); + Teleport teleport = Teleport.createForPlayer(new Vector3d(x, y, z), new Vector3f(previousBodyRotation.getPitch(), yaw, previousBodyRotation.getRoll())) + .setHeadRotation(new Vector3f(pitch, yaw, roll)); store.addComponent(ref, Teleport.getComponentType(), teleport); boolean hasRotation = this.yawArg.provided(context) || this.pitchArg.provided(context) || this.rollArg.provided(context); if (hasRotation) { @@ -86,7 +80,8 @@ public class TeleportToCoordinatesCommand extends AbstractPlayerCommand { float displayPitch = Float.isNaN(pitch) ? previousHeadRotation.getPitch() * (180.0F / (float)Math.PI) : pitch * (180.0F / (float)Math.PI); float displayRoll = Float.isNaN(roll) ? previousHeadRotation.getRoll() * (180.0F / (float)Math.PI) : roll * (180.0F / (float)Math.PI); context.sendMessage( - MESSAGE_COMMANDS_TELEPORT_TELEPORTED_TO_COORDINATES_WITH_LOOK.param("x", x) + Message.translation("server.commands.teleport.teleportedToCoordinatesWithLook") + .param("x", x) .param("y", y) .param("z", z) .param("yaw", displayYaw) @@ -94,7 +89,7 @@ public class TeleportToCoordinatesCommand extends AbstractPlayerCommand { .param("roll", displayRoll) ); } else { - context.sendMessage(MESSAGE_COMMANDS_TELEPORT_TELEPORTED_TO_COORDINATES.param("x", x).param("y", y).param("z", z)); + context.sendMessage(Message.translation("server.commands.teleport.teleportedToCoordinates").param("x", x).param("y", y).param("z", z)); } store.ensureAndGetComponent(ref, TeleportHistory.getComponentType()) diff --git a/src/com/hypixel/hytale/builtin/teleport/commands/teleport/variant/TeleportToPlayerCommand.java b/src/com/hypixel/hytale/builtin/teleport/commands/teleport/variant/TeleportToPlayerCommand.java index 6194a23..a988e5b 100644 --- a/src/com/hypixel/hytale/builtin/teleport/commands/teleport/variant/TeleportToPlayerCommand.java +++ b/src/com/hypixel/hytale/builtin/teleport/commands/teleport/variant/TeleportToPlayerCommand.java @@ -3,6 +3,7 @@ package com.hypixel.hytale.builtin.teleport.commands.teleport.variant; import com.hypixel.hytale.builtin.teleport.components.TeleportHistory; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.Store; +import com.hypixel.hytale.math.vector.Transform; import com.hypixel.hytale.math.vector.Vector3d; import com.hypixel.hytale.math.vector.Vector3f; import com.hypixel.hytale.server.core.Message; @@ -20,8 +21,8 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class TeleportToPlayerCommand extends AbstractPlayerCommand { + @Nonnull private static final Message MESSAGE_COMMANDS_ERRORS_TARGET_NOT_IN_WORLD = Message.translation("server.commands.errors.targetNotInWorld"); - private static final Message MESSAGE_COMMANDS_TELEPORT_TELEPORTED_TO_PLAYER = Message.translation("server.commands.teleport.teleportedToPlayer"); @Nonnull private final RequiredArg targetPlayerArg = this.withRequiredArg( "targetPlayer", "server.commands.teleport.targetPlayer.desc", ArgTypes.PLAYER_REF @@ -62,17 +63,19 @@ public class TeleportToPlayerCommand extends AbstractPlayerCommand { assert targetHeadRotationComponent != null; Vector3d targetPosition = targetTransformComponent.getPosition().clone(); - Vector3f targetRotation = targetTransformComponent.getRotation().clone(); Vector3f targetHeadRotation = targetHeadRotationComponent.getRotation().clone(); + Transform targetTransform = new Transform(targetPosition, targetHeadRotation); world.execute( () -> { - Teleport teleport = new Teleport(targetWorld, targetPosition, targetRotation).withHeadRotation(targetHeadRotation).withResetRoll(); - store.addComponent(ref, Teleport.getComponentType(), teleport); + Teleport teleportComponent = Teleport.createForPlayer(targetWorld, targetTransform); + store.addComponent(ref, Teleport.getComponentType(), teleportComponent); PlayerRef targetPlayerRefComponent = targetStore.getComponent(targetRef, PlayerRef.getComponentType()); assert targetPlayerRefComponent != null; - context.sendMessage(MESSAGE_COMMANDS_TELEPORT_TELEPORTED_TO_PLAYER.param("toName", targetPlayerRefComponent.getUsername())); + context.sendMessage( + Message.translation("server.commands.teleport.teleportedToPlayer").param("toName", targetPlayerRefComponent.getUsername()) + ); store.ensureAndGetComponent(ref, TeleportHistory.getComponentType()) .append(world, pos, rotation, "Teleport to " + targetPlayerRefComponent.getUsername()); } diff --git a/src/com/hypixel/hytale/builtin/teleport/commands/warp/WarpCommand.java b/src/com/hypixel/hytale/builtin/teleport/commands/warp/WarpCommand.java index 31a3ff2..631dc17 100644 --- a/src/com/hypixel/hytale/builtin/teleport/commands/warp/WarpCommand.java +++ b/src/com/hypixel/hytale/builtin/teleport/commands/warp/WarpCommand.java @@ -19,13 +19,8 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class WarpCommand extends AbstractCommandCollection { + @Nonnull private static final Message MESSAGE_COMMANDS_TELEPORT_WARP_NOT_LOADED = Message.translation("server.commands.teleport.warp.notLoaded"); - private static final Message MESSAGE_COMMANDS_TELEPORT_WARP_UNKNOWN_WARP = Message.translation("server.commands.teleport.warp.unknownWarp"); - private static final Message MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD = Message.translation("server.commands.errors.playerNotInWorld"); - private static final Message MESSAGE_COMMANDS_TELEPORT_WARP_WORLD_NAME_FOR_WARP_NOT_FOUND = Message.translation( - "server.commands.teleport.warp.worldNameForWarpNotFound" - ); - private static final Message MESSAGE_COMMANDS_TELEPORT_WARP_WARPED_TO = Message.translation("server.commands.teleport.warp.warpedTo"); public WarpCommand() { super("warp", "server.commands.warp.desc"); @@ -43,12 +38,12 @@ public class WarpCommand extends AbstractCommandCollection { } else { Warp targetWarp = TeleportPlugin.get().getWarps().get(warp.toLowerCase()); if (targetWarp == null) { - context.sendMessage(MESSAGE_COMMANDS_TELEPORT_WARP_UNKNOWN_WARP.param("name", warp)); + context.sendMessage(Message.translation("server.commands.teleport.warp.unknownWarp").param("name", warp)); } else { String worldName = targetWarp.getWorld(); World world = Universe.get().getWorld(worldName); - Teleport teleport = targetWarp.toTeleport(); - if (world != null && teleport != null) { + Teleport teleportComponent = targetWarp.toTeleport(); + if (world != null && teleportComponent != null) { TransformComponent transformComponent = store.getComponent(ref, TransformComponent.getComponentType()); assert transformComponent != null; @@ -61,10 +56,12 @@ public class WarpCommand extends AbstractCommandCollection { Vector3f playerHeadRotation = headRotationComponent.getRotation(); store.ensureAndGetComponent(ref, TeleportHistory.getComponentType()) .append(world, playerPosition.clone(), playerHeadRotation.clone(), "Warp '" + warp + "'"); - store.addComponent(ref, Teleport.getComponentType(), teleport); - context.sendMessage(MESSAGE_COMMANDS_TELEPORT_WARP_WARPED_TO.param("name", warp)); + store.addComponent(ref, Teleport.getComponentType(), teleportComponent); + context.sendMessage(Message.translation("server.commands.teleport.warp.warpedTo").param("name", warp)); } else { - context.sendMessage(MESSAGE_COMMANDS_TELEPORT_WARP_WORLD_NAME_FOR_WARP_NOT_FOUND.param("worldName", worldName).param("warp", warp)); + context.sendMessage( + Message.translation("server.commands.teleport.warp.worldNameForWarpNotFound").param("worldName", worldName).param("warp", warp) + ); } } } diff --git a/src/com/hypixel/hytale/builtin/teleport/commands/warp/WarpListCommand.java b/src/com/hypixel/hytale/builtin/teleport/commands/warp/WarpListCommand.java index e2db919..ca2f68f 100644 --- a/src/com/hypixel/hytale/builtin/teleport/commands/warp/WarpListCommand.java +++ b/src/com/hypixel/hytale/builtin/teleport/commands/warp/WarpListCommand.java @@ -27,10 +27,7 @@ public class WarpListCommand extends CommandBase { private static final Message MESSAGE_COMMANDS_TELEPORT_WARP_NOT_LOADED = Message.translation("server.commands.teleport.warp.notLoaded"); private static final Message MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD = Message.translation("server.commands.errors.playerNotInWorld"); private static final Message MESSAGE_COMMANDS_TELEPORT_WARP_NO_WARPS = Message.translation("server.commands.teleport.warp.noWarps"); - private static final Message MESSAGE_COMMANDS_TELEPORT_WARP_PAGE_NUM_TOO_LOW = Message.translation("server.commands.teleport.warp.pageNumTooLow"); private static final Message MESSAGE_COMMANDS_TELEPORT_WARP_PAGE_NUM_TOO_HIGH = Message.translation("server.commands.teleport.warp.pageNumTooHigh"); - private static final Message MESSAGE_COMMANDS_TELEPORT_WARP_LIST_HEADER = Message.translation("server.commands.teleport.warp.listHeader"); - private static final Message MESSAGE_COMMANDS_TELEPORT_WARP_LIST_ENTRY = Message.translation("server.commands.teleport.warp.listEntry"); @Nonnull private final OptionalArg pageArg = this.withOptionalArg("page", "server.commands.warp.list.page.desc", ArgTypes.INTEGER); @@ -75,7 +72,7 @@ public class WarpListCommand extends CommandBase { } else { int pageNumber = this.pageArg.provided(context) ? this.pageArg.get(context) : 1; if (pageNumber < 1) { - context.sendMessage(MESSAGE_COMMANDS_TELEPORT_WARP_PAGE_NUM_TOO_LOW.param("page", pageNumber)); + context.sendMessage(Message.translation("server.commands.teleport.warp.pageNumTooLow").param("page", pageNumber)); } else { List innerWarps = new ObjectArrayList<>(warps.values()); innerWarps.sort((o1, o2) -> o2.getCreationDate().compareTo(o1.getCreationDate())); @@ -83,14 +80,19 @@ public class WarpListCommand extends CommandBase { if (paginated.size() < pageNumber) { context.sendMessage(MESSAGE_COMMANDS_TELEPORT_WARP_PAGE_NUM_TOO_HIGH); } else { - context.sendMessage(MESSAGE_COMMANDS_TELEPORT_WARP_LIST_HEADER.param("page", pageNumber).param("pages", paginated.size())); + context.sendMessage( + Message.translation("server.commands.teleport.warp.listHeader").param("page", pageNumber).param("pages", paginated.size()) + ); int startIndex = (pageNumber - 1) * 8; List page = paginated.get(pageNumber - 1); int i = 1; for (Warp w : page) { context.sendMessage( - MESSAGE_COMMANDS_TELEPORT_WARP_LIST_ENTRY.param("index", startIndex + i).param("name", w.getId()).param("creator", w.getCreator()) + Message.translation("server.commands.teleport.warp.listEntry") + .param("index", startIndex + i) + .param("name", w.getId()) + .param("creator", w.getCreator()) ); i++; } diff --git a/src/com/hypixel/hytale/builtin/teleport/commands/warp/WarpReloadCommand.java b/src/com/hypixel/hytale/builtin/teleport/commands/warp/WarpReloadCommand.java index f791175..1d4b3e8 100644 --- a/src/com/hypixel/hytale/builtin/teleport/commands/warp/WarpReloadCommand.java +++ b/src/com/hypixel/hytale/builtin/teleport/commands/warp/WarpReloadCommand.java @@ -14,7 +14,6 @@ import javax.annotation.Nonnull; public class WarpReloadCommand extends CommandBase { private static final HytaleLogger logger = HytaleLogger.forEnclosingClass(); private static final Message MESSAGE_COMMANDS_TELEPORT_WARP_NOT_LOADED = Message.translation("server.commands.teleport.warp.notLoaded"); - private static final Message MESSAGE_COMMANDS_TELEPORT_WARP_RELOADED = Message.translation("server.commands.teleport.warp.reloaded"); private static final Message MESSAGE_COMMANDS_TELEPORT_WARP_FAILED_TO_RELOAD = Message.translation("server.commands.teleport.warp.failedToReload"); public WarpReloadCommand() { @@ -31,7 +30,7 @@ public class WarpReloadCommand extends CommandBase { try { TeleportPlugin.get().loadWarps(); - context.sendMessage(MESSAGE_COMMANDS_TELEPORT_WARP_RELOADED.param("count", warps.size())); + context.sendMessage(Message.translation("server.commands.teleport.warp.reloaded").param("count", warps.size())); } catch (Throwable var4) { context.sendMessage(MESSAGE_COMMANDS_TELEPORT_WARP_FAILED_TO_RELOAD); logger.at(Level.SEVERE).withCause(var4).log("Failed to reload warps:"); diff --git a/src/com/hypixel/hytale/builtin/teleport/commands/warp/WarpRemoveCommand.java b/src/com/hypixel/hytale/builtin/teleport/commands/warp/WarpRemoveCommand.java index 10d02ae..73bf9c5 100644 --- a/src/com/hypixel/hytale/builtin/teleport/commands/warp/WarpRemoveCommand.java +++ b/src/com/hypixel/hytale/builtin/teleport/commands/warp/WarpRemoveCommand.java @@ -19,8 +19,6 @@ import javax.annotation.Nonnull; public class WarpRemoveCommand extends CommandBase { private static final Message MESSAGE_COMMANDS_TELEPORT_WARP_NOT_LOADED = Message.translation("server.commands.teleport.warp.notLoaded"); - private static final Message MESSAGE_COMMANDS_TELEPORT_WARP_UNKNOWN_WARP = Message.translation("server.commands.teleport.warp.unknownWarp"); - private static final Message MESSAGE_COMMANDS_TELEPORT_WARP_REMOVED_WARP = Message.translation("server.commands.teleport.warp.removedWarp"); @Nonnull private final RequiredArg nameArg = this.withRequiredArg("name", "server.commands.warp.remove.name.desc", ArgTypes.STRING); @@ -38,10 +36,10 @@ public class WarpRemoveCommand extends CommandBase { String warpName = this.nameArg.get(context).toLowerCase(); Warp old = warps.remove(warpName); if (old == null) { - context.sendMessage(MESSAGE_COMMANDS_TELEPORT_WARP_UNKNOWN_WARP.param("name", warpName)); + context.sendMessage(Message.translation("server.commands.teleport.warp.unknownWarp").param("name", warpName)); } else { TeleportPlugin.get().saveWarps(); - context.sendMessage(MESSAGE_COMMANDS_TELEPORT_WARP_REMOVED_WARP.param("name", warpName)); + context.sendMessage(Message.translation("server.commands.teleport.warp.removedWarp").param("name", warpName)); World targetWorld = Universe.get().getWorld(old.getWorld()); if (targetWorld != null) { ComponentType warpComponentType = TeleportPlugin.WarpComponent.getComponentType(); diff --git a/src/com/hypixel/hytale/builtin/teleport/commands/warp/WarpSetCommand.java b/src/com/hypixel/hytale/builtin/teleport/commands/warp/WarpSetCommand.java index 57dad8e..e8be71d 100644 --- a/src/com/hypixel/hytale/builtin/teleport/commands/warp/WarpSetCommand.java +++ b/src/com/hypixel/hytale/builtin/teleport/commands/warp/WarpSetCommand.java @@ -5,6 +5,7 @@ import com.hypixel.hytale.builtin.teleport.Warp; import com.hypixel.hytale.component.AddReason; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.Store; +import com.hypixel.hytale.math.vector.Transform; import com.hypixel.hytale.math.vector.Vector3d; import com.hypixel.hytale.math.vector.Vector3f; import com.hypixel.hytale.server.core.Message; @@ -54,20 +55,9 @@ public class WarpSetCommand extends AbstractPlayerCommand { assert headRotationComponent != null; Vector3d position = transformComponent.getPosition(); - Vector3f rotation = transformComponent.getRotation(); Vector3f headRotation = headRotationComponent.getRotation(); - Warp newWarp = new Warp( - position.getX(), - position.getY(), - position.getZ(), - headRotation.getYaw(), - rotation.getPitch(), - rotation.getRoll(), - newId, - world, - playerRef.getUsername(), - Instant.now() - ); + Transform transform = new Transform(position.clone(), headRotation.clone()); + Warp newWarp = new Warp(transform, newId, world, playerRef.getUsername(), Instant.now()); warps.put(newWarp.getId().toLowerCase(), newWarp); TeleportPlugin plugin = TeleportPlugin.get(); plugin.saveWarps(); diff --git a/src/com/hypixel/hytale/builtin/teleport/components/TeleportHistory.java b/src/com/hypixel/hytale/builtin/teleport/components/TeleportHistory.java index 9b5fb60..6f3b92f 100644 --- a/src/com/hypixel/hytale/builtin/teleport/components/TeleportHistory.java +++ b/src/com/hypixel/hytale/builtin/teleport/components/TeleportHistory.java @@ -21,16 +21,6 @@ public class TeleportHistory implements Component { private static final int MAX_TELEPORT_HISTORY = 100; private static final Message MESSAGE_COMMANDS_TELEPORT_NOT_FURTHER = Message.translation("server.commands.teleport.notFurther"); private static final Message MESSAGE_COMMANDS_TELEPORT_WORLD_NOT_LOADED = Message.translation("server.commands.teleport.worldNotLoaded"); - private static final Message MESSAGE_COMMANDS_TELEPORT_TELEPORTED_FORWARD_TO_WAYPOINT = Message.translation( - "server.commands.teleport.teleportedForwardToWaypoint" - ); - private static final Message MESSAGE_COMMANDS_TELEPORT_TELEPORTED_BACK_TO_WAYPOINT = Message.translation("server.commands.teleport.teleportedBackToWaypoint"); - private static final Message MESSAGE_COMMANDS_TELEPORT_TELEPORTED_FORWARD_TO_COORDINATES = Message.translation( - "server.commands.teleport.teleportedForwardToCoordinates" - ); - private static final Message MESSAGE_COMMANDS_TELEPORT_TELEPORTED_BACK_TO_COORDINATES = Message.translation( - "server.commands.teleport.teleportedBackToCoordinates" - ); @Nonnull private final Deque back = new ArrayDeque<>(); @Nonnull @@ -41,9 +31,6 @@ public class TeleportHistory implements Component { return TeleportPlugin.get().getTeleportHistoryComponentType(); } - public TeleportHistory() { - } - public void forward(@Nonnull Ref ref, int count) { Store store = ref.getStore(); go(store, ref, this.forward, this.back, count, true); @@ -100,30 +87,33 @@ public class TeleportHistory implements Component { playerRef.sendMessage(MESSAGE_COMMANDS_TELEPORT_WORLD_NOT_LOADED); } else { to.push(point); - store.addComponent(ref, Teleport.getComponentType(), new Teleport(targetWorld, point.position, point.rotation)); + Teleport teleportComponent = Teleport.createForPlayer(targetWorld, point.position, point.rotation); + store.addComponent(ref, Teleport.getComponentType(), teleportComponent); Vector3d pos = point.position; int remainingInDirection = from.size(); int totalInOtherDirection = to.size() - 1; if (point.message != null && !point.message.isEmpty()) { playerRef.sendMessage( - isForward - ? MESSAGE_COMMANDS_TELEPORT_TELEPORTED_FORWARD_TO_WAYPOINT - : MESSAGE_COMMANDS_TELEPORT_TELEPORTED_BACK_TO_WAYPOINT.param("name", point.message) - .param("x", pos.getX()) - .param("y", pos.getY()) - .param("z", pos.getZ()) - .param("remaining", remainingInDirection) - .param("otherDirection", totalInOtherDirection) + (isForward + ? Message.translation("server.commands.teleport.teleportedForwardToWaypoint") + : Message.translation("server.commands.teleport.teleportedBackToWaypoint")) + .param("name", point.message) + .param("x", pos.getX()) + .param("y", pos.getY()) + .param("z", pos.getZ()) + .param("remaining", remainingInDirection) + .param("otherDirection", totalInOtherDirection) ); } else { playerRef.sendMessage( - isForward - ? MESSAGE_COMMANDS_TELEPORT_TELEPORTED_FORWARD_TO_COORDINATES - : MESSAGE_COMMANDS_TELEPORT_TELEPORTED_BACK_TO_COORDINATES.param("x", pos.getX()) - .param("y", pos.getY()) - .param("z", pos.getZ()) - .param("remaining", remainingInDirection) - .param("otherDirection", totalInOtherDirection) + (isForward + ? Message.translation("server.commands.teleport.teleportedForwardToCoordinates") + : Message.translation("server.commands.teleport.teleportedBackToCoordinates")) + .param("x", pos.getX()) + .param("y", pos.getY()) + .param("z", pos.getZ()) + .param("remaining", remainingInDirection) + .param("otherDirection", totalInOtherDirection) ); } } diff --git a/src/com/hypixel/hytale/builtin/weather/commands/WeatherGetCommand.java b/src/com/hypixel/hytale/builtin/weather/commands/WeatherGetCommand.java index 7e6dc2b..a3efba6 100644 --- a/src/com/hypixel/hytale/builtin/weather/commands/WeatherGetCommand.java +++ b/src/com/hypixel/hytale/builtin/weather/commands/WeatherGetCommand.java @@ -11,9 +11,6 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class WeatherGetCommand extends AbstractWorldCommand { - @Nonnull - private static final Message MESSAGE_COMMANDS_WEATHER_GET_FORCED_WEATHER = Message.translation("server.commands.weather.get.getForcedWeather"); - public WeatherGetCommand() { super("get", "server.commands.weather.get.desc"); } @@ -30,6 +27,6 @@ public class WeatherGetCommand extends AbstractWorldCommand { weatherId = "not locked"; } - context.sendMessage(MESSAGE_COMMANDS_WEATHER_GET_FORCED_WEATHER.param("worldName", world.getName()).param("weather", weatherId)); + context.sendMessage(Message.translation("server.commands.weather.get.getForcedWeather").param("worldName", world.getName()).param("weather", weatherId)); } } diff --git a/src/com/hypixel/hytale/builtin/weather/commands/WeatherResetCommand.java b/src/com/hypixel/hytale/builtin/weather/commands/WeatherResetCommand.java index 66a096d..c838283 100644 --- a/src/com/hypixel/hytale/builtin/weather/commands/WeatherResetCommand.java +++ b/src/com/hypixel/hytale/builtin/weather/commands/WeatherResetCommand.java @@ -9,9 +9,6 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class WeatherResetCommand extends AbstractWorldCommand { - @Nonnull - private static final Message MESSAGE_COMMANDS_WEATHER_RESET_FORCED_WEATHER_RESET = Message.translation("server.commands.weather.reset.forcedWeatherReset"); - public WeatherResetCommand() { super("reset", "server.commands.weather.reset.desc"); this.addAliases("clear"); @@ -20,6 +17,6 @@ public class WeatherResetCommand extends AbstractWorldCommand { @Override protected void execute(@Nonnull CommandContext context, @Nonnull World world, @Nonnull Store store) { WeatherSetCommand.setForcedWeather(world, null, store); - context.sendMessage(MESSAGE_COMMANDS_WEATHER_RESET_FORCED_WEATHER_RESET.param("worldName", world.getName())); + context.sendMessage(Message.translation("server.commands.weather.reset.forcedWeatherReset").param("worldName", world.getName())); } } diff --git a/src/com/hypixel/hytale/builtin/weather/commands/WeatherSetCommand.java b/src/com/hypixel/hytale/builtin/weather/commands/WeatherSetCommand.java index 34bcbe1..0caf2e3 100644 --- a/src/com/hypixel/hytale/builtin/weather/commands/WeatherSetCommand.java +++ b/src/com/hypixel/hytale/builtin/weather/commands/WeatherSetCommand.java @@ -16,8 +16,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class WeatherSetCommand extends AbstractWorldCommand { - @Nonnull - private static final Message MESSAGE_COMMANDS_WEATHER_SET_FORCED_WEATHER_SET = Message.translation("server.commands.weather.set.forcedWeatherSet"); @Nonnull private final RequiredArg weatherArg = this.withRequiredArg("weather", "server.commands.weather.set.weather.desc", ArgTypes.WEATHER_ASSET); @@ -30,7 +28,7 @@ public class WeatherSetCommand extends AbstractWorldCommand { Weather weather = this.weatherArg.get(context); String weatherName = weather.getId(); setForcedWeather(world, weatherName, store); - context.sendMessage(MESSAGE_COMMANDS_WEATHER_SET_FORCED_WEATHER_SET.param("worldName", world.getName()).param("weather", weatherName)); + context.sendMessage(Message.translation("server.commands.weather.set.forcedWeatherSet").param("worldName", world.getName()).param("weather", weatherName)); } protected static void setForcedWeather(@Nonnull World world, @Nullable String forcedWeather, ComponentAccessor componentAccessor) { diff --git a/src/com/hypixel/hytale/builtin/weather/systems/WeatherSystem.java b/src/com/hypixel/hytale/builtin/weather/systems/WeatherSystem.java index 052f30a..4cfef55 100644 --- a/src/com/hypixel/hytale/builtin/weather/systems/WeatherSystem.java +++ b/src/com/hypixel/hytale/builtin/weather/systems/WeatherSystem.java @@ -35,62 +35,55 @@ import java.util.Set; import java.util.Map.Entry; import java.util.concurrent.ThreadLocalRandom; import javax.annotation.Nonnull; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import javax.annotation.Nullable; public class WeatherSystem { private static final float JOIN_TRANSITION_SECONDS = 0.5F; private static final float WEATHERCHANGE_TRANSITION_SECONDS = 10.0F; - public WeatherSystem() { - } - public static class InvalidateWeatherAfterTeleport extends RefChangeSystem { + @Nonnull private static final Query QUERY = WeatherTracker.getComponentType(); + @Nonnull private static final Set> DEPENDENCIES = Set.of(new SystemDependency<>(Order.AFTER, TeleportSystems.PlayerMoveSystem.class)); - public InvalidateWeatherAfterTeleport() { - } - - @NonNullDecl + @Nonnull @Override public ComponentType componentType() { return Teleport.getComponentType(); } public void onComponentAdded( - @NonNullDecl Ref ref, - @NonNullDecl Teleport component, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, @Nonnull Teleport component, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { - commandBuffer.getComponent(ref, WeatherTracker.getComponentType()).clear(); + WeatherTracker weatherTrackerComponent = commandBuffer.getComponent(ref, WeatherTracker.getComponentType()); + + assert weatherTrackerComponent != null; + + weatherTrackerComponent.clear(); } public void onComponentSet( - @NonNullDecl Ref ref, - @NullableDecl Teleport oldComponent, - @NonNullDecl Teleport newComponent, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, + @Nullable Teleport oldComponent, + @Nonnull Teleport newComponent, + @Nonnull Store store, + @Nonnull CommandBuffer commandBuffer ) { } public void onComponentRemoved( - @NonNullDecl Ref ref, - @NonNullDecl Teleport component, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, @Nonnull Teleport component, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { } - @NullableDecl + @Nullable @Override public Query getQuery() { return QUERY; } - @NonNullDecl + @Nonnull @Override public Set> getDependencies() { return DEPENDENCIES; @@ -103,9 +96,6 @@ public class WeatherSystem { private static final ComponentType WEATHER_TRACKER_COMPONENT_TYPE = WeatherTracker.getComponentType(); private static final Query QUERY = Archetype.of(PLAYER_REF_COMPONENT_TYPE, TRANSFORM_COMPONENT_TYPE); - public PlayerAddedSystem() { - } - @Override public Query getQuery() { return QUERY; @@ -130,9 +120,6 @@ public class WeatherSystem { private static final ResourceType WEATHER_RESOURCE_TYPE = WeatherResource.getResourceType(); private static final Query QUERY = Archetype.of(PLAYER_REF_COMPONENT_TYPE, TRANSFORM_COMPONENT_TYPE, WEATHER_TRACKER_COMPONENT_TYPE); - public TickingSystem() { - } - @Override public Query getQuery() { return QUERY; @@ -210,9 +197,6 @@ public class WeatherSystem { @Nonnull private final ResourceType weatherResourceType = WeatherResource.getResourceType(); - public WorldAddedSystem() { - } - @Override public void onSystemAddedToStore(@Nonnull Store store) { String forcedWeather = store.getExternalData().getWorld().getWorldConfig().getForcedWeather(); diff --git a/src/com/hypixel/hytale/codec/builder/BuilderCodec.java b/src/com/hypixel/hytale/codec/builder/BuilderCodec.java index c8e7c30..66f75ea 100644 --- a/src/com/hypixel/hytale/codec/builder/BuilderCodec.java +++ b/src/com/hypixel/hytale/codec/builder/BuilderCodec.java @@ -1037,9 +1037,6 @@ public class BuilderCodec implements Codec, DirectDecodeCodec, RawJsonC FIELD, IGNORE, IGNORE_IN_BASE_OBJECT; - - private EntryType() { - } } protected static class KeyEntry { diff --git a/src/com/hypixel/hytale/codec/codecs/BsonDocumentCodec.java b/src/com/hypixel/hytale/codec/codecs/BsonDocumentCodec.java index e3ca431..fc0d27b 100644 --- a/src/com/hypixel/hytale/codec/codecs/BsonDocumentCodec.java +++ b/src/com/hypixel/hytale/codec/codecs/BsonDocumentCodec.java @@ -13,9 +13,6 @@ import org.bson.BsonValue; @Deprecated public class BsonDocumentCodec implements Codec { - public BsonDocumentCodec() { - } - public BsonDocument decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { return bsonValue.asDocument(); } diff --git a/src/com/hypixel/hytale/codec/codecs/EnumCodec.java b/src/com/hypixel/hytale/codec/codecs/EnumCodec.java index a61f820..56630b4 100644 --- a/src/com/hypixel/hytale/codec/codecs/EnumCodec.java +++ b/src/com/hypixel/hytale/codec/codecs/EnumCodec.java @@ -116,9 +116,6 @@ public class EnumCodec> implements Codec { LEGACY, CAMEL_CASE; - private EnumStyle() { - } - @Nullable public > T match(@Nonnull T[] enumConstants, @Nonnull String[] enumKeys, String value) { return this.match(enumConstants, enumKeys, value, false); diff --git a/src/com/hypixel/hytale/codec/codecs/StringIntegerCodec.java b/src/com/hypixel/hytale/codec/codecs/StringIntegerCodec.java index 6c9480b..569db60 100644 --- a/src/com/hypixel/hytale/codec/codecs/StringIntegerCodec.java +++ b/src/com/hypixel/hytale/codec/codecs/StringIntegerCodec.java @@ -16,9 +16,6 @@ public class StringIntegerCodec implements Codec { public static final StringIntegerCodec INSTANCE = new StringIntegerCodec(); private static final Pattern INTEGER_PATTERN = Pattern.compile("^[0-9]+$"); - public StringIntegerCodec() { - } - @Nonnull public Integer decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { return bsonValue.isString() ? Integer.parseInt(bsonValue.asString().getValue()) : bsonValue.asNumber().intValue(); diff --git a/src/com/hypixel/hytale/codec/codecs/UUIDBinaryCodec.java b/src/com/hypixel/hytale/codec/codecs/UUIDBinaryCodec.java index 1c1600f..4f7d537 100644 --- a/src/com/hypixel/hytale/codec/codecs/UUIDBinaryCodec.java +++ b/src/com/hypixel/hytale/codec/codecs/UUIDBinaryCodec.java @@ -16,9 +16,6 @@ import org.bson.BsonBinarySubType; import org.bson.BsonValue; public class UUIDBinaryCodec implements Codec { - public UUIDBinaryCodec() { - } - @Nonnull public UUID decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { BsonBinary bsonBinary = bsonValue.asBinary(); diff --git a/src/com/hypixel/hytale/codec/codecs/array/DoubleArrayCodec.java b/src/com/hypixel/hytale/codec/codecs/array/DoubleArrayCodec.java index c856e87..d558ef4 100644 --- a/src/com/hypixel/hytale/codec/codecs/array/DoubleArrayCodec.java +++ b/src/com/hypixel/hytale/codec/codecs/array/DoubleArrayCodec.java @@ -18,9 +18,6 @@ import org.bson.BsonValue; public class DoubleArrayCodec implements Codec, RawJsonCodec { public static final double[] EMPTY_DOUBLE_ARRAY = new double[0]; - public DoubleArrayCodec() { - } - public double[] decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { BsonArray array = bsonValue.asArray(); double[] doubles = new double[array.size()]; diff --git a/src/com/hypixel/hytale/codec/codecs/array/FloatArrayCodec.java b/src/com/hypixel/hytale/codec/codecs/array/FloatArrayCodec.java index 8cb3d5c..78384f7 100644 --- a/src/com/hypixel/hytale/codec/codecs/array/FloatArrayCodec.java +++ b/src/com/hypixel/hytale/codec/codecs/array/FloatArrayCodec.java @@ -18,9 +18,6 @@ import org.bson.BsonValue; public class FloatArrayCodec implements Codec, RawJsonCodec { public static final float[] EMPTY_FLOAT_ARRAY = new float[0]; - public FloatArrayCodec() { - } - public float[] decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { BsonArray array = bsonValue.asArray(); float[] floats = new float[array.size()]; diff --git a/src/com/hypixel/hytale/codec/codecs/array/IntArrayCodec.java b/src/com/hypixel/hytale/codec/codecs/array/IntArrayCodec.java index a981021..4eeede8 100644 --- a/src/com/hypixel/hytale/codec/codecs/array/IntArrayCodec.java +++ b/src/com/hypixel/hytale/codec/codecs/array/IntArrayCodec.java @@ -18,9 +18,6 @@ import org.bson.BsonValue; public class IntArrayCodec implements Codec, RawJsonCodec { public static final int[] EMPTY_INT_ARRAY = new int[0]; - public IntArrayCodec() { - } - public int[] decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { BsonArray array = bsonValue.asArray(); int[] ints = new int[array.size()]; diff --git a/src/com/hypixel/hytale/codec/codecs/array/LongArrayCodec.java b/src/com/hypixel/hytale/codec/codecs/array/LongArrayCodec.java index 827e112..c213018 100644 --- a/src/com/hypixel/hytale/codec/codecs/array/LongArrayCodec.java +++ b/src/com/hypixel/hytale/codec/codecs/array/LongArrayCodec.java @@ -18,9 +18,6 @@ import org.bson.BsonValue; public class LongArrayCodec implements Codec, RawJsonCodec { public static final long[] EMPTY_LONG_ARRAY = new long[0]; - public LongArrayCodec() { - } - public long[] decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { BsonArray array = bsonValue.asArray(); long[] longs = new long[array.size()]; diff --git a/src/com/hypixel/hytale/codec/codecs/simple/BooleanCodec.java b/src/com/hypixel/hytale/codec/codecs/simple/BooleanCodec.java index 1ad4fec..8ed549c 100644 --- a/src/com/hypixel/hytale/codec/codecs/simple/BooleanCodec.java +++ b/src/com/hypixel/hytale/codec/codecs/simple/BooleanCodec.java @@ -15,9 +15,6 @@ import org.bson.BsonBoolean; import org.bson.BsonValue; public class BooleanCodec implements Codec, RawJsonCodec, PrimitiveCodec { - public BooleanCodec() { - } - @Nonnull public Boolean decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { return bsonValue.asBoolean().getValue(); diff --git a/src/com/hypixel/hytale/codec/codecs/simple/ByteCodec.java b/src/com/hypixel/hytale/codec/codecs/simple/ByteCodec.java index 1b929f5..56367f8 100644 --- a/src/com/hypixel/hytale/codec/codecs/simple/ByteCodec.java +++ b/src/com/hypixel/hytale/codec/codecs/simple/ByteCodec.java @@ -15,9 +15,6 @@ import org.bson.BsonInt32; import org.bson.BsonValue; public class ByteCodec implements Codec, RawJsonCodec, PrimitiveCodec { - public ByteCodec() { - } - @Nonnull public Byte decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { int intValue = bsonValue.asNumber().intValue(); diff --git a/src/com/hypixel/hytale/codec/codecs/simple/DoubleCodec.java b/src/com/hypixel/hytale/codec/codecs/simple/DoubleCodec.java index 12e7ebd..ce31f6f 100644 --- a/src/com/hypixel/hytale/codec/codecs/simple/DoubleCodec.java +++ b/src/com/hypixel/hytale/codec/codecs/simple/DoubleCodec.java @@ -15,9 +15,6 @@ import org.bson.BsonDouble; import org.bson.BsonValue; public class DoubleCodec implements Codec, RawJsonCodec, PrimitiveCodec { - public DoubleCodec() { - } - @Nonnull public Double decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { if (bsonValue.isString()) { diff --git a/src/com/hypixel/hytale/codec/codecs/simple/FloatCodec.java b/src/com/hypixel/hytale/codec/codecs/simple/FloatCodec.java index fcfb728..00ddb9c 100644 --- a/src/com/hypixel/hytale/codec/codecs/simple/FloatCodec.java +++ b/src/com/hypixel/hytale/codec/codecs/simple/FloatCodec.java @@ -18,9 +18,6 @@ import org.bson.BsonValue; public class FloatCodec implements Codec, RawJsonCodec, PrimitiveCodec { public static final String STRING_SCHEMA_PATTERN = "^(-?Infinity|NaN)$"; - public FloatCodec() { - } - @Nonnull public Float decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { return decodeFloat(bsonValue); diff --git a/src/com/hypixel/hytale/codec/codecs/simple/IntegerCodec.java b/src/com/hypixel/hytale/codec/codecs/simple/IntegerCodec.java index 6aa1219..6baeeb5 100644 --- a/src/com/hypixel/hytale/codec/codecs/simple/IntegerCodec.java +++ b/src/com/hypixel/hytale/codec/codecs/simple/IntegerCodec.java @@ -15,9 +15,6 @@ import org.bson.BsonInt32; import org.bson.BsonValue; public class IntegerCodec implements Codec, RawJsonCodec, PrimitiveCodec { - public IntegerCodec() { - } - @Nonnull public Integer decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { int intValue = bsonValue.asNumber().intValue(); diff --git a/src/com/hypixel/hytale/codec/codecs/simple/LongCodec.java b/src/com/hypixel/hytale/codec/codecs/simple/LongCodec.java index 3662a06..d4d140e 100644 --- a/src/com/hypixel/hytale/codec/codecs/simple/LongCodec.java +++ b/src/com/hypixel/hytale/codec/codecs/simple/LongCodec.java @@ -15,9 +15,6 @@ import org.bson.BsonInt64; import org.bson.BsonValue; public class LongCodec implements Codec, RawJsonCodec, PrimitiveCodec { - public LongCodec() { - } - @Nonnull public Long decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { long longValue = bsonValue.asNumber().longValue(); diff --git a/src/com/hypixel/hytale/codec/codecs/simple/ShortCodec.java b/src/com/hypixel/hytale/codec/codecs/simple/ShortCodec.java index a957042..65aea12 100644 --- a/src/com/hypixel/hytale/codec/codecs/simple/ShortCodec.java +++ b/src/com/hypixel/hytale/codec/codecs/simple/ShortCodec.java @@ -14,9 +14,6 @@ import org.bson.BsonInt32; import org.bson.BsonValue; public class ShortCodec implements Codec, RawJsonCodec, PrimitiveCodec { - public ShortCodec() { - } - @Nonnull public Short decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { int intValue = bsonValue.asNumber().intValue(); diff --git a/src/com/hypixel/hytale/codec/codecs/simple/StringCodec.java b/src/com/hypixel/hytale/codec/codecs/simple/StringCodec.java index 72e9b9e..04c5870 100644 --- a/src/com/hypixel/hytale/codec/codecs/simple/StringCodec.java +++ b/src/com/hypixel/hytale/codec/codecs/simple/StringCodec.java @@ -14,9 +14,6 @@ import org.bson.BsonString; import org.bson.BsonValue; public class StringCodec implements Codec, RawJsonCodec { - public StringCodec() { - } - public String decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { return bsonValue.asString().getValue(); } diff --git a/src/com/hypixel/hytale/codec/schema/SchemaContext.java b/src/com/hypixel/hytale/codec/schema/SchemaContext.java index 5132e25..784413a 100644 --- a/src/com/hypixel/hytale/codec/schema/SchemaContext.java +++ b/src/com/hypixel/hytale/codec/schema/SchemaContext.java @@ -24,9 +24,6 @@ public class SchemaContext { @Nonnull private final Map, String> fileReferences = new Object2ObjectOpenHashMap<>(); - public SchemaContext() { - } - public void addFileReference(@Nonnull String fileName, @Nonnull SchemaConvertable codec) { this.fileReferences.put(codec, fileName + "#"); } diff --git a/src/com/hypixel/hytale/codec/schema/config/ArraySchema.java b/src/com/hypixel/hytale/codec/schema/config/ArraySchema.java index 9dd5c32..373c8da 100644 --- a/src/com/hypixel/hytale/codec/schema/config/ArraySchema.java +++ b/src/com/hypixel/hytale/codec/schema/config/ArraySchema.java @@ -108,9 +108,6 @@ public class ArraySchema extends Schema { @Nonnull private ArrayCodec array = new ArrayCodec<>(Schema.CODEC, Schema[]::new); - private ItemOrItems() { - } - @Override public Object decode(@Nonnull BsonValue bsonValue, @Nonnull ExtraInfo extraInfo) { return bsonValue.isArray() ? this.array.decode(bsonValue, extraInfo) : Schema.CODEC.decode(bsonValue, extraInfo); diff --git a/src/com/hypixel/hytale/codec/schema/config/BooleanSchema.java b/src/com/hypixel/hytale/codec/schema/config/BooleanSchema.java index 1fc7a98..a317276 100644 --- a/src/com/hypixel/hytale/codec/schema/config/BooleanSchema.java +++ b/src/com/hypixel/hytale/codec/schema/config/BooleanSchema.java @@ -11,9 +11,6 @@ public class BooleanSchema extends Schema { .build(); private Boolean default_; - public BooleanSchema() { - } - public Boolean getDefault() { return this.default_; } diff --git a/src/com/hypixel/hytale/codec/schema/config/IntegerSchema.java b/src/com/hypixel/hytale/codec/schema/config/IntegerSchema.java index f5acced..2601919 100644 --- a/src/com/hypixel/hytale/codec/schema/config/IntegerSchema.java +++ b/src/com/hypixel/hytale/codec/schema/config/IntegerSchema.java @@ -32,9 +32,6 @@ public class IntegerSchema extends Schema { private Integer const_; private Integer default_; - public IntegerSchema() { - } - @Nullable public Object getMinimum() { return this.minimum; @@ -171,9 +168,6 @@ public class IntegerSchema extends Schema { private static class IntegerOrSchema implements Codec { private static final IntegerSchema.IntegerOrSchema INSTANCE = new IntegerSchema.IntegerOrSchema(); - private IntegerOrSchema() { - } - @Override public Object decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { return bsonValue.isNumber() ? Codec.INTEGER.decode(bsonValue, extraInfo) : Schema.CODEC.decode(bsonValue, extraInfo); diff --git a/src/com/hypixel/hytale/codec/schema/config/NullSchema.java b/src/com/hypixel/hytale/codec/schema/config/NullSchema.java index da35525..84c1224 100644 --- a/src/com/hypixel/hytale/codec/schema/config/NullSchema.java +++ b/src/com/hypixel/hytale/codec/schema/config/NullSchema.java @@ -5,7 +5,4 @@ import com.hypixel.hytale.codec.builder.BuilderCodec; public class NullSchema extends Schema { public static final BuilderCodec CODEC = BuilderCodec.builder(NullSchema.class, NullSchema::new, Schema.BASE_CODEC).build(); public static final NullSchema INSTANCE = new NullSchema(); - - public NullSchema() { - } } diff --git a/src/com/hypixel/hytale/codec/schema/config/NumberSchema.java b/src/com/hypixel/hytale/codec/schema/config/NumberSchema.java index c65cc73..cd80a8c 100644 --- a/src/com/hypixel/hytale/codec/schema/config/NumberSchema.java +++ b/src/com/hypixel/hytale/codec/schema/config/NumberSchema.java @@ -32,9 +32,6 @@ public class NumberSchema extends Schema { private Double const_; private Double default_; - public NumberSchema() { - } - @Nullable public Object getMinimum() { return this.minimum; @@ -171,9 +168,6 @@ public class NumberSchema extends Schema { private static class DoubleOrSchema implements Codec { private static final NumberSchema.DoubleOrSchema INSTANCE = new NumberSchema.DoubleOrSchema(); - private DoubleOrSchema() { - } - @Override public Object decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { return bsonValue.isNumber() ? Codec.DOUBLE.decode(bsonValue, extraInfo) : Schema.CODEC.decode(bsonValue, extraInfo); diff --git a/src/com/hypixel/hytale/codec/schema/config/ObjectSchema.java b/src/com/hypixel/hytale/codec/schema/config/ObjectSchema.java index 111f661..35af5fd 100644 --- a/src/com/hypixel/hytale/codec/schema/config/ObjectSchema.java +++ b/src/com/hypixel/hytale/codec/schema/config/ObjectSchema.java @@ -22,9 +22,6 @@ public class ObjectSchema extends Schema { private StringSchema propertyNames; private Schema unevaluatedProperties; - public ObjectSchema() { - } - public Map getProperties() { return this.properties; } diff --git a/src/com/hypixel/hytale/codec/schema/config/Schema.java b/src/com/hypixel/hytale/codec/schema/config/Schema.java index b480533..393aaf8 100644 --- a/src/com/hypixel/hytale/codec/schema/config/Schema.java +++ b/src/com/hypixel/hytale/codec/schema/config/Schema.java @@ -35,7 +35,11 @@ public class Schema { .addField(new KeyedCodec<>("$id", Codec.STRING, false, true), (o, i) -> o.id = i, o -> o.id) .addField(new KeyedCodec<>("type", new Schema.ArrayOrNull(), false, true), (o, i) -> o.types = i, o -> o.types) .addField(new KeyedCodec<>("title", Codec.STRING, false, true), (o, i) -> o.title = i, o -> o.title) - .addField(new KeyedCodec<>("description", Codec.STRING, false, true), (o, i) -> o.description = i, o -> o.description) + .addField( + new KeyedCodec<>("description", Codec.STRING, false, true), + (o, i) -> o.description = i, + o -> o.description == null && o.markdownDescription != null ? Documentation.stripMarkdown(o.markdownDescription) : o.description + ) .addField(new KeyedCodec<>("markdownDescription", Codec.STRING, false, true), (o, i) -> o.markdownDescription = i, o -> o.markdownDescription) .addField(new KeyedCodec<>("enumDescriptions", Codec.STRING_ARRAY, false, true), (o, i) -> o.enumDescriptions = i, o -> { if (o.enumDescriptions == null && o.markdownEnumDescriptions != null) { @@ -471,9 +475,6 @@ public class Schema { @Deprecated private static class ArrayOrNull implements Codec { - private ArrayOrNull() { - } - @Nullable public String[] decode(@Nonnull BsonValue bsonValue, @Nonnull ExtraInfo extraInfo) { return bsonValue.isArray() ? Codec.STRING_ARRAY.decode(bsonValue, extraInfo) : null; @@ -493,9 +494,6 @@ public class Schema { @Deprecated protected static class BooleanOrSchema implements Codec { - protected BooleanOrSchema() { - } - @Override public Object decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { return bsonValue.isBoolean() ? Codec.BOOLEAN.decode(bsonValue, extraInfo) : Schema.CODEC.decode(bsonValue, extraInfo); @@ -1033,9 +1031,6 @@ public class Schema { @Deprecated private static class StringOrBlank implements Codec { - private StringOrBlank() { - } - public String decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { if (bsonValue.isString()) { return Codec.STRING.decode(bsonValue, extraInfo); diff --git a/src/com/hypixel/hytale/codec/schema/config/StringSchema.java b/src/com/hypixel/hytale/codec/schema/config/StringSchema.java index 79aca10..2ff0a61 100644 --- a/src/com/hypixel/hytale/codec/schema/config/StringSchema.java +++ b/src/com/hypixel/hytale/codec/schema/config/StringSchema.java @@ -28,9 +28,6 @@ public class StringSchema extends Schema { private StringSchema.CommonAsset hytaleCommonAsset; private String hytaleCosmeticAsset; - public StringSchema() { - } - public String getPattern() { return this.pattern; } diff --git a/src/com/hypixel/hytale/codec/schema/metadata/ui/UIDisplayMode.java b/src/com/hypixel/hytale/codec/schema/metadata/ui/UIDisplayMode.java index c5cae22..fdd752c 100644 --- a/src/com/hypixel/hytale/codec/schema/metadata/ui/UIDisplayMode.java +++ b/src/com/hypixel/hytale/codec/schema/metadata/ui/UIDisplayMode.java @@ -23,8 +23,5 @@ public class UIDisplayMode implements Metadata { NORMAL, COMPACT, HIDDEN; - - private DisplayMode() { - } } } diff --git a/src/com/hypixel/hytale/codec/schema/metadata/ui/UIEditor.java b/src/com/hypixel/hytale/codec/schema/metadata/ui/UIEditor.java index 76e118e..3111021 100644 --- a/src/com/hypixel/hytale/codec/schema/metadata/ui/UIEditor.java +++ b/src/com/hypixel/hytale/codec/schema/metadata/ui/UIEditor.java @@ -137,9 +137,6 @@ public class UIEditor implements Metadata { UIEditor.MultilineTextField.class, UIEditor.MultilineTextField::new ) .build(); - - public MultilineTextField() { - } } public static class TextField implements UIEditor.EditorComponent { @@ -158,16 +155,10 @@ public class UIEditor implements Metadata { public static class Timeline implements UIEditor.EditorComponent { public static final BuilderCodec CODEC = BuilderCodec.builder(UIEditor.Timeline.class, UIEditor.Timeline::new).build(); - - public Timeline() { - } } public static class WeightedTimeline implements UIEditor.EditorComponent { public static final BuilderCodec CODEC = BuilderCodec.builder(UIEditor.WeightedTimeline.class, UIEditor.WeightedTimeline::new) .build(); - - public WeightedTimeline() { - } } } diff --git a/src/com/hypixel/hytale/codec/schema/metadata/ui/UIEditorFeatures.java b/src/com/hypixel/hytale/codec/schema/metadata/ui/UIEditorFeatures.java index 66ac236..fae6223 100644 --- a/src/com/hypixel/hytale/codec/schema/metadata/ui/UIEditorFeatures.java +++ b/src/com/hypixel/hytale/codec/schema/metadata/ui/UIEditorFeatures.java @@ -19,8 +19,5 @@ public class UIEditorFeatures implements Metadata { public static enum EditorFeature { WEATHER_DAYTIME_BAR, WEATHER_PREVIEW_LOCAL; - - private EditorFeature() { - } } } diff --git a/src/com/hypixel/hytale/codec/schema/metadata/ui/UIEditorPreview.java b/src/com/hypixel/hytale/codec/schema/metadata/ui/UIEditorPreview.java index b32c26e..e1c9b57 100644 --- a/src/com/hypixel/hytale/codec/schema/metadata/ui/UIEditorPreview.java +++ b/src/com/hypixel/hytale/codec/schema/metadata/ui/UIEditorPreview.java @@ -21,8 +21,5 @@ public class UIEditorPreview implements Metadata { MODEL, REVERB_EFFECT, EQUALIZER_EFFECT; - - private PreviewType() { - } } } diff --git a/src/com/hypixel/hytale/codec/schema/metadata/ui/UIRebuildCaches.java b/src/com/hypixel/hytale/codec/schema/metadata/ui/UIRebuildCaches.java index b1d71a7..5fa1023 100644 --- a/src/com/hypixel/hytale/codec/schema/metadata/ui/UIRebuildCaches.java +++ b/src/com/hypixel/hytale/codec/schema/metadata/ui/UIRebuildCaches.java @@ -29,8 +29,5 @@ public class UIRebuildCaches implements Metadata { MODEL_TEXTURES, MAP_GEOMETRY, ITEM_ICONS; - - private ClientCache() { - } } } diff --git a/src/com/hypixel/hytale/codec/util/Documentation.java b/src/com/hypixel/hytale/codec/util/Documentation.java index ad4f703..aff44b6 100644 --- a/src/com/hypixel/hytale/codec/util/Documentation.java +++ b/src/com/hypixel/hytale/codec/util/Documentation.java @@ -1,18 +1,17 @@ package com.hypixel.hytale.codec.util; +import it.unimi.dsi.fastutil.chars.CharArrayList; import it.unimi.dsi.fastutil.ints.IntArrayList; import javax.annotation.Nullable; public class Documentation { - public Documentation() { - } - public static String stripMarkdown(@Nullable String markdown) { if (markdown == null) { return null; } else { StringBuilder output = new StringBuilder(); IntArrayList counts = new IntArrayList(); + CharArrayList expectedChars = new CharArrayList(); for (int i = 0; i < markdown.length(); i++) { char c = markdown.charAt(i); @@ -21,31 +20,37 @@ public class Documentation { case '_': int start = i; boolean isEnding = i >= 1 && !Character.isWhitespace(markdown.charAt(i - 1)); - int targetCount = !counts.isEmpty() && isEnding ? counts.getInt(counts.size() - 1) : -1; + if (!isEnding || !expectedChars.isEmpty() && expectedChars.getChar(expectedChars.size() - 1) == c) { + int targetCount = !counts.isEmpty() && isEnding ? counts.getInt(counts.size() - 1) : -1; - while (i < markdown.length() && markdown.charAt(i) == c && i - start != targetCount) { - i++; - } - - int matchingCount = i - start; - if (!counts.isEmpty() && counts.getInt(counts.size() - 1) == matchingCount) { - if (!isEnding) { - output.append(String.valueOf(c).repeat(matchingCount)); - break; + while (i < markdown.length() && markdown.charAt(i) == c && i - start != targetCount) { + i++; } - counts.removeInt(counts.size() - 1); + int matchingCount = i - start; + if (!counts.isEmpty() && counts.getInt(counts.size() - 1) == matchingCount) { + if (!isEnding) { + output.append(String.valueOf(c).repeat(matchingCount)); + continue; + } + + counts.removeInt(counts.size() - 1); + expectedChars.removeChar(expectedChars.size() - 1); + } else { + if (i < markdown.length() && Character.isWhitespace(markdown.charAt(i))) { + output.append(String.valueOf(c).repeat(matchingCount)); + output.append(markdown.charAt(i)); + continue; + } + + counts.add(matchingCount); + expectedChars.add(c); + } + + i--; } else { - if (i < markdown.length() && Character.isWhitespace(markdown.charAt(i))) { - output.append(String.valueOf(c).repeat(matchingCount)); - output.append(markdown.charAt(i)); - break; - } - - counts.add(matchingCount); + output.append(markdown.charAt(i)); } - - i--; break; default: output.append(c); diff --git a/src/com/hypixel/hytale/codec/validation/ValidationResults.java b/src/com/hypixel/hytale/codec/validation/ValidationResults.java index 6f74bf2..34c65e2 100644 --- a/src/com/hypixel/hytale/codec/validation/ValidationResults.java +++ b/src/com/hypixel/hytale/codec/validation/ValidationResults.java @@ -127,9 +127,6 @@ public class ValidationResults { SUCCESS, WARNING, FAIL; - - private Result() { - } } public record ValidationResult(ValidationResults.Result result, String reason) { diff --git a/src/com/hypixel/hytale/codec/validation/Validators.java b/src/com/hypixel/hytale/codec/validation/Validators.java index d7101a9..ee43808 100644 --- a/src/com/hypixel/hytale/codec/validation/Validators.java +++ b/src/com/hypixel/hytale/codec/validation/Validators.java @@ -25,9 +25,6 @@ import java.util.Map; import javax.annotation.Nonnull; public class Validators { - public Validators() { - } - @Nonnull public static DeprecatedValidator deprecated() { return (DeprecatedValidator)DeprecatedValidator.INSTANCE; diff --git a/src/com/hypixel/hytale/common/benchmark/ContinuousValueRecorder.java b/src/com/hypixel/hytale/common/benchmark/ContinuousValueRecorder.java index 8b728c3..4f6ddea 100644 --- a/src/com/hypixel/hytale/common/benchmark/ContinuousValueRecorder.java +++ b/src/com/hypixel/hytale/common/benchmark/ContinuousValueRecorder.java @@ -6,9 +6,6 @@ public class ContinuousValueRecorder { protected double sumValues = 0.0; protected long count = 0L; - public ContinuousValueRecorder() { - } - public void reset() { this.minValue = Double.MAX_VALUE; this.maxValue = -Double.MAX_VALUE; diff --git a/src/com/hypixel/hytale/common/benchmark/TimeRecorder.java b/src/com/hypixel/hytale/common/benchmark/TimeRecorder.java index ae3ba0f..4157521 100644 --- a/src/com/hypixel/hytale/common/benchmark/TimeRecorder.java +++ b/src/com/hypixel/hytale/common/benchmark/TimeRecorder.java @@ -11,9 +11,6 @@ public class TimeRecorder extends ContinuousValueRecorder { public static final String[] DEFAULT_COLUMNS = DiscreteValueRecorder.DEFAULT_COLUMNS; public static final double NANOS_TO_SECONDS = 1.0E-9; - public TimeRecorder() { - } - public long start() { return System.nanoTime(); } diff --git a/src/com/hypixel/hytale/common/collection/BucketItem.java b/src/com/hypixel/hytale/common/collection/BucketItem.java index 0e9355c..9ecb8d6 100644 --- a/src/com/hypixel/hytale/common/collection/BucketItem.java +++ b/src/com/hypixel/hytale/common/collection/BucketItem.java @@ -6,9 +6,6 @@ public class BucketItem { public E item; public double squaredDistance; - public BucketItem() { - } - @Nonnull public BucketItem set(E reference, double squaredDistance) { this.item = reference; diff --git a/src/com/hypixel/hytale/common/collection/BucketItemPool.java b/src/com/hypixel/hytale/common/collection/BucketItemPool.java index e8dc48f..3ee0a1d 100644 --- a/src/com/hypixel/hytale/common/collection/BucketItemPool.java +++ b/src/com/hypixel/hytale/common/collection/BucketItemPool.java @@ -9,9 +9,6 @@ public class BucketItemPool { @Nonnull protected final List> pool = new ObjectArrayList<>(); - public BucketItemPool() { - } - public void deallocate(BucketItem[] entityHolders, int count) { this.pool.addAll(Arrays.asList(entityHolders).subList(0, count)); } diff --git a/src/com/hypixel/hytale/common/collection/BucketList.java b/src/com/hypixel/hytale/common/collection/BucketList.java index b3ed0b0..19c6e71 100644 --- a/src/com/hypixel/hytale/common/collection/BucketList.java +++ b/src/com/hypixel/hytale/common/collection/BucketList.java @@ -285,9 +285,6 @@ public class BucketList { public static class SortBufferProvider implements IntFunction { protected BucketItem[] buffer = new BucketItem[4]; - public SortBufferProvider() { - } - public BucketItem[] apply(int size) { if (size <= this.buffer.length) { return this.buffer; diff --git a/src/com/hypixel/hytale/common/fastutil/HLongOpenHashSet.java b/src/com/hypixel/hytale/common/fastutil/HLongOpenHashSet.java index 0dc8cd2..7a130e2 100644 --- a/src/com/hypixel/hytale/common/fastutil/HLongOpenHashSet.java +++ b/src/com/hypixel/hytale/common/fastutil/HLongOpenHashSet.java @@ -7,9 +7,6 @@ import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import javax.annotation.Nonnull; public class HLongOpenHashSet extends LongOpenHashSet implements HLongSet { - public HLongOpenHashSet() { - } - @Override public void removeIf(@Nonnull LongTriIntBiObjPredicate predicate, int ia, int ib, int ic, T obj1, V obj2) { int pos = super.n; diff --git a/src/com/hypixel/hytale/common/fastutil/HObjectOpenHashSet.java b/src/com/hypixel/hytale/common/fastutil/HObjectOpenHashSet.java index 8a5e932..97624a4 100644 --- a/src/com/hypixel/hytale/common/fastutil/HObjectOpenHashSet.java +++ b/src/com/hypixel/hytale/common/fastutil/HObjectOpenHashSet.java @@ -6,9 +6,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class HObjectOpenHashSet extends ObjectOpenHashSet { - public HObjectOpenHashSet() { - } - @Nullable public K first() { if (this.containsNull) { diff --git a/src/com/hypixel/hytale/common/plugin/AuthorInfo.java b/src/com/hypixel/hytale/common/plugin/AuthorInfo.java index ff109b6..d9f5064 100644 --- a/src/com/hypixel/hytale/common/plugin/AuthorInfo.java +++ b/src/com/hypixel/hytale/common/plugin/AuthorInfo.java @@ -23,9 +23,6 @@ public class AuthorInfo { @Nullable private String url; - public AuthorInfo() { - } - @Nullable public String getName() { return this.name; diff --git a/src/com/hypixel/hytale/common/thread/HytaleForkJoinThreadFactory.java b/src/com/hypixel/hytale/common/thread/HytaleForkJoinThreadFactory.java index c899867..51c2416 100644 --- a/src/com/hypixel/hytale/common/thread/HytaleForkJoinThreadFactory.java +++ b/src/com/hypixel/hytale/common/thread/HytaleForkJoinThreadFactory.java @@ -7,9 +7,6 @@ import java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory; import javax.annotation.Nonnull; public class HytaleForkJoinThreadFactory implements ForkJoinWorkerThreadFactory { - public HytaleForkJoinThreadFactory() { - } - @Nonnull @Override public ForkJoinWorkerThread newThread(@Nonnull ForkJoinPool pool) { diff --git a/src/com/hypixel/hytale/common/util/ArrayUtil.java b/src/com/hypixel/hytale/common/util/ArrayUtil.java index 29ef6f9..da5acb6 100644 --- a/src/com/hypixel/hytale/common/util/ArrayUtil.java +++ b/src/com/hypixel/hytale/common/util/ArrayUtil.java @@ -28,9 +28,6 @@ public class ArrayUtil { private static final Supplier[] EMPTY_SUPPLIER_ARRAY = new Supplier[0]; private static final Entry[] EMPTY_ENTRY_ARRAY = new Entry[0]; - public ArrayUtil() { - } - @Nonnull public static T[] emptyArray() { return (T[])EMPTY_OBJECT_ARRAY; diff --git a/src/com/hypixel/hytale/common/util/AudioUtil.java b/src/com/hypixel/hytale/common/util/AudioUtil.java index 9dff136..55c9ccb 100644 --- a/src/com/hypixel/hytale/common/util/AudioUtil.java +++ b/src/com/hypixel/hytale/common/util/AudioUtil.java @@ -6,9 +6,6 @@ public class AudioUtil { public static final float MIN_SEMITONE_PITCH = -12.0F; public static final float MAX_SEMITONE_PITCH = 12.0F; - public AudioUtil() { - } - public static float decibelsToLinearGain(float decibels) { return decibels <= -100.0F ? 0.0F : (float)Math.pow(10.0, decibels / 20.0F); } diff --git a/src/com/hypixel/hytale/common/util/BitSetUtil.java b/src/com/hypixel/hytale/common/util/BitSetUtil.java index 81db201..4b3c687 100644 --- a/src/com/hypixel/hytale/common/util/BitSetUtil.java +++ b/src/com/hypixel/hytale/common/util/BitSetUtil.java @@ -9,9 +9,6 @@ public class BitSetUtil { public static final long WORDS_OFFSET; public static final long WORDS_IN_USE_OFFSET; - public BitSetUtil() { - } - public static void copyValues(@Nonnull BitSet from, @Nonnull BitSet to) { if (UnsafeUtil.UNSAFE == null) { copyValuesSlow(from, to); diff --git a/src/com/hypixel/hytale/common/util/BitUtil.java b/src/com/hypixel/hytale/common/util/BitUtil.java index 1341c15..ecffef2 100644 --- a/src/com/hypixel/hytale/common/util/BitUtil.java +++ b/src/com/hypixel/hytale/common/util/BitUtil.java @@ -3,9 +3,6 @@ package com.hypixel.hytale.common.util; import javax.annotation.Nonnull; public class BitUtil { - public BitUtil() { - } - public static void setNibble(@Nonnull byte[] data, int idx, byte b) { int fieldIdx = idx >> 1; byte val = data[fieldIdx]; diff --git a/src/com/hypixel/hytale/common/util/CompletableFutureUtil.java b/src/com/hypixel/hytale/common/util/CompletableFutureUtil.java index 150c22b..f478972 100644 --- a/src/com/hypixel/hytale/common/util/CompletableFutureUtil.java +++ b/src/com/hypixel/hytale/common/util/CompletableFutureUtil.java @@ -19,9 +19,6 @@ public class CompletableFutureUtil { throw new CompletableFutureUtil.TailedRuntimeException(throwable); }; - public CompletableFutureUtil() { - } - @Nonnull public static CompletableFuture whenComplete(@Nonnull CompletableFuture future, @Nonnull CompletableFuture callee) { return future.whenComplete((result, throwable) -> { diff --git a/src/com/hypixel/hytale/common/util/ExceptionUtil.java b/src/com/hypixel/hytale/common/util/ExceptionUtil.java index 2d6f381..bba0a7d 100644 --- a/src/com/hypixel/hytale/common/util/ExceptionUtil.java +++ b/src/com/hypixel/hytale/common/util/ExceptionUtil.java @@ -6,9 +6,6 @@ import java.io.StringWriter; import javax.annotation.Nonnull; public class ExceptionUtil { - public ExceptionUtil() { - } - @Nonnull public static String combineMessages(Throwable thrown, @Nonnull String joiner) { StringBuilder sb = new StringBuilder(); diff --git a/src/com/hypixel/hytale/common/util/FormatUtil.java b/src/com/hypixel/hytale/common/util/FormatUtil.java index 0f8ff94..70d289e 100644 --- a/src/com/hypixel/hytale/common/util/FormatUtil.java +++ b/src/com/hypixel/hytale/common/util/FormatUtil.java @@ -28,9 +28,6 @@ public class FormatUtil { public static final long MILLISECOND_AS_NANOS = TimeUnit.MILLISECONDS.toNanos(1L); public static final long MICOSECOND_AS_NANOS = TimeUnit.MICROSECONDS.toNanos(1L); - public FormatUtil() { - } - @Nonnull public static TimeUnit largestUnit(long value, @Nonnull TimeUnit unit) { long nanos = unit.toNanos(value); diff --git a/src/com/hypixel/hytale/common/util/GCUtil.java b/src/com/hypixel/hytale/common/util/GCUtil.java index 368c80d..9c4841c 100644 --- a/src/com/hypixel/hytale/common/util/GCUtil.java +++ b/src/com/hypixel/hytale/common/util/GCUtil.java @@ -9,9 +9,6 @@ import javax.management.NotificationEmitter; import javax.management.openmbean.CompositeData; public class GCUtil { - public GCUtil() { - } - public static void register(@Nonnull Consumer consumer) { for (GarbageCollectorMXBean gcBean : ManagementFactory.getGarbageCollectorMXBeans()) { NotificationEmitter emitter = (NotificationEmitter)gcBean; diff --git a/src/com/hypixel/hytale/common/util/HardwareUtil.java b/src/com/hypixel/hytale/common/util/HardwareUtil.java index 97a8b03..c092c45 100644 --- a/src/com/hypixel/hytale/common/util/HardwareUtil.java +++ b/src/com/hypixel/hytale/common/util/HardwareUtil.java @@ -108,9 +108,6 @@ public class HardwareUtil { } }); - public HardwareUtil() { - } - @Nullable private static String runCommand(String... command) { try { diff --git a/src/com/hypixel/hytale/common/util/ListUtil.java b/src/com/hypixel/hytale/common/util/ListUtil.java index 44771f3..2b8719c 100644 --- a/src/com/hypixel/hytale/common/util/ListUtil.java +++ b/src/com/hypixel/hytale/common/util/ListUtil.java @@ -9,9 +9,6 @@ import java.util.function.Predicate; import javax.annotation.Nonnull; public class ListUtil { - public ListUtil() { - } - @Nonnull public static List> partition(@Nonnull List list, int sectionSize) { List> sections = new ObjectArrayList<>(); diff --git a/src/com/hypixel/hytale/common/util/MapUtil.java b/src/com/hypixel/hytale/common/util/MapUtil.java index 5d34217..a04a1f8 100644 --- a/src/com/hypixel/hytale/common/util/MapUtil.java +++ b/src/com/hypixel/hytale/common/util/MapUtil.java @@ -7,9 +7,6 @@ import java.util.function.Supplier; import javax.annotation.Nonnull; public class MapUtil { - public MapUtil() { - } - @Nonnull public static Map combineUnmodifiable(@Nonnull Map one, @Nonnull Map two) { Map map = new Object2ObjectOpenHashMap<>(); diff --git a/src/com/hypixel/hytale/common/util/NetworkUtil.java b/src/com/hypixel/hytale/common/util/NetworkUtil.java index 1f966cc..f1b206a 100644 --- a/src/com/hypixel/hytale/common/util/NetworkUtil.java +++ b/src/com/hypixel/hytale/common/util/NetworkUtil.java @@ -24,9 +24,6 @@ public class NetworkUtil { public static Inet6Address LOOPBACK_IPV6_ADDRESS; public static Inet4Address LOOPBACK_IPV4_ADDRESS; - public NetworkUtil() { - } - @Nullable public static InetAddress getFirstNonLoopbackAddress() throws SocketException { InetAddress firstInet6Address = null; diff --git a/src/com/hypixel/hytale/common/util/PathUtil.java b/src/com/hypixel/hytale/common/util/PathUtil.java index 6e8a1e3..8f5da5f 100644 --- a/src/com/hypixel/hytale/common/util/PathUtil.java +++ b/src/com/hypixel/hytale/common/util/PathUtil.java @@ -13,9 +13,6 @@ import javax.annotation.Nullable; public class PathUtil { private static final Pattern PATH_PATTERN = Pattern.compile("[\\\\/]"); - public PathUtil() { - } - @Nonnull public static Path getParent(@Nonnull Path path) { if (path.isAbsolute()) { diff --git a/src/com/hypixel/hytale/common/util/PatternUtil.java b/src/com/hypixel/hytale/common/util/PatternUtil.java index 78b445f..b5fa7d1 100644 --- a/src/com/hypixel/hytale/common/util/PatternUtil.java +++ b/src/com/hypixel/hytale/common/util/PatternUtil.java @@ -3,9 +3,6 @@ package com.hypixel.hytale.common.util; import javax.annotation.Nonnull; public class PatternUtil { - public PatternUtil() { - } - @Nonnull public static String replaceBackslashWithForwardSlash(@Nonnull String name) { return name.replace("\\", "/"); diff --git a/src/com/hypixel/hytale/common/util/RandomUtil.java b/src/com/hypixel/hytale/common/util/RandomUtil.java index d1a6097..0221d19 100644 --- a/src/com/hypixel/hytale/common/util/RandomUtil.java +++ b/src/com/hypixel/hytale/common/util/RandomUtil.java @@ -11,9 +11,6 @@ import javax.annotation.Nullable; public class RandomUtil { public static final ThreadLocal SECURE_RANDOM = ThreadLocal.withInitial(SecureRandom::new); - public RandomUtil() { - } - public static T roll(int roll, T[] data, @Nonnull int[] chances) { roll++; int lower = 0; diff --git a/src/com/hypixel/hytale/common/util/StringCompareUtil.java b/src/com/hypixel/hytale/common/util/StringCompareUtil.java index fc5e596..58f5362 100644 --- a/src/com/hypixel/hytale/common/util/StringCompareUtil.java +++ b/src/com/hypixel/hytale/common/util/StringCompareUtil.java @@ -5,9 +5,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class StringCompareUtil { - public StringCompareUtil() { - } - public static int indexOfDifference(@Nullable CharSequence cs1, @Nullable CharSequence cs2) { if (cs1 == cs2) { return -1; diff --git a/src/com/hypixel/hytale/common/util/StringUtil.java b/src/com/hypixel/hytale/common/util/StringUtil.java index ca1b2bd..2264031 100644 --- a/src/com/hypixel/hytale/common/util/StringUtil.java +++ b/src/com/hypixel/hytale/common/util/StringUtil.java @@ -20,10 +20,7 @@ import javax.annotation.Nullable; public class StringUtil { public static final Pattern RAW_ARGS_PATTERN = Pattern.compile(" -- "); @Nonnull - private static final char[] GRAPH_CHARS = new char[]{'_', '\u2584', '\u2500', '\u2580', '\u00af'}; - - public StringUtil() { - } + private static final char[] GRAPH_CHARS = new char[]{'_', '▄', '─', '▀', '¯'}; public static boolean isNumericString(@Nonnull String str) { for (int i = 0; i < str.length(); i++) { @@ -537,8 +534,5 @@ public class StringUtil { INDEX_DIFFERENCE, EQUALS, CASE_INSENSITIVE; - - private MatchType() { - } } } diff --git a/src/com/hypixel/hytale/common/util/SystemUtil.java b/src/com/hypixel/hytale/common/util/SystemUtil.java index 73d8cf6..ce6fe9d 100644 --- a/src/com/hypixel/hytale/common/util/SystemUtil.java +++ b/src/com/hypixel/hytale/common/util/SystemUtil.java @@ -5,9 +5,6 @@ import javax.annotation.Nonnull; public class SystemUtil { public static final SystemUtil.SystemType TYPE = getSystemType(); - public SystemUtil() { - } - @Nonnull private static SystemUtil.SystemType getSystemType() { String osName = System.getProperty("os.name"); @@ -22,13 +19,15 @@ public class SystemUtil { } } + public static boolean getEnvBoolean(@Nonnull String name) { + String value = System.getenv(name); + return value == null ? false : !"false".equalsIgnoreCase(value) && !"0".equals(value) && !"no".equalsIgnoreCase(value); + } + public static enum SystemType { WINDOWS, MACOS, LINUX, OTHER; - - private SystemType() { - } } } diff --git a/src/com/hypixel/hytale/common/util/TimeUtil.java b/src/com/hypixel/hytale/common/util/TimeUtil.java index ebdba76..985f51f 100644 --- a/src/com/hypixel/hytale/common/util/TimeUtil.java +++ b/src/com/hypixel/hytale/common/util/TimeUtil.java @@ -8,9 +8,6 @@ import java.time.temporal.ChronoUnit; import javax.annotation.Nonnull; public class TimeUtil { - public TimeUtil() { - } - public static int compareDifference(@Nonnull Instant from, @Nonnull Instant to, @Nonnull Duration duration) { if (from.equals(Instant.MIN) && !to.equals(Instant.MIN) && !duration.isZero()) { return 1; diff --git a/src/com/hypixel/hytale/common/util/java/ManifestUtil.java b/src/com/hypixel/hytale/common/util/java/ManifestUtil.java index f8989b0..52e5da9 100644 --- a/src/com/hypixel/hytale/common/util/java/ManifestUtil.java +++ b/src/com/hypixel/hytale/common/util/java/ManifestUtil.java @@ -91,9 +91,6 @@ public class ManifestUtil { return "NoJar".equals(version) ? null : Semver.fromString(version); }); - public ManifestUtil() { - } - public static boolean isJar() { return MANIFEST.get() != null; } diff --git a/src/com/hypixel/hytale/component/AddReason.java b/src/com/hypixel/hytale/component/AddReason.java index fac7bb7..0e26346 100644 --- a/src/com/hypixel/hytale/component/AddReason.java +++ b/src/com/hypixel/hytale/component/AddReason.java @@ -3,7 +3,4 @@ package com.hypixel.hytale.component; public enum AddReason { SPAWN, LOAD; - - private AddReason() { - } } diff --git a/src/com/hypixel/hytale/component/Archetype.java b/src/com/hypixel/hytale/component/Archetype.java index 1bd5d13..dde85ac 100644 --- a/src/com/hypixel/hytale/component/Archetype.java +++ b/src/com/hypixel/hytale/component/Archetype.java @@ -115,6 +115,7 @@ public class Archetype implements Query { } } + @Nonnull public Archetype getSerializableArchetype(@Nonnull ComponentRegistry.Data data) { if (this.isEmpty()) { return EMPTY; @@ -273,7 +274,7 @@ public class Archetype implements Query { } @Override - public void validateRegistry(ComponentRegistry registry) { + public void validateRegistry(@Nonnull ComponentRegistry registry) { if (!this.isEmpty()) { this.componentTypes[this.minIndex].validateRegistry(registry); } diff --git a/src/com/hypixel/hytale/component/ComponentRegistry.java b/src/com/hypixel/hytale/component/ComponentRegistry.java index 2e8e7a4..84e3f0a 100644 --- a/src/com/hypixel/hytale/component/ComponentRegistry.java +++ b/src/com/hypixel/hytale/component/ComponentRegistry.java @@ -1461,11 +1461,12 @@ public class ComponentRegistry implements IComponentRegistry ? componentCodec : TempUnknownComponent.COMPONENT_CODEC; return BuilderCodec.builder(Holder.class, this.registry::newHolder) - .addField( + .append( new KeyedCodec<>("Components", new MapProvidedMapCodec<>(this.codecMap, function, LinkedHashMap::new, false)), (holder, map) -> holder.loadComponentsMap(this, map), holder -> holder.createComponentsMap(this) ) + .add() .build(); } diff --git a/src/com/hypixel/hytale/component/ComponentType.java b/src/com/hypixel/hytale/component/ComponentType.java index 46a8584..96ef25e 100644 --- a/src/com/hypixel/hytale/component/ComponentType.java +++ b/src/com/hypixel/hytale/component/ComponentType.java @@ -12,9 +12,6 @@ public class ComponentType> implements C private int index; private boolean invalid = true; - public ComponentType() { - } - void init(@Nonnull ComponentRegistry registry, @Nonnull Class tClass, int index) { this.registry = registry; this.tClass = tClass; @@ -55,7 +52,7 @@ public class ComponentType> implements C } @Override - public void validateRegistry(ComponentRegistry registry) { + public void validateRegistry(@Nonnull ComponentRegistry registry) { if (!this.registry.equals(registry)) { throw new IllegalArgumentException("ComponentType is for a different registry! " + this); } diff --git a/src/com/hypixel/hytale/component/EmptyResourceStorage.java b/src/com/hypixel/hytale/component/EmptyResourceStorage.java index 143cc8f..57001fd 100644 --- a/src/com/hypixel/hytale/component/EmptyResourceStorage.java +++ b/src/com/hypixel/hytale/component/EmptyResourceStorage.java @@ -6,9 +6,6 @@ import javax.annotation.Nonnull; public class EmptyResourceStorage implements IResourceStorage { private static final EmptyResourceStorage INSTANCE = new EmptyResourceStorage(); - public EmptyResourceStorage() { - } - public static EmptyResourceStorage get() { return INSTANCE; } diff --git a/src/com/hypixel/hytale/component/Holder.java b/src/com/hypixel/hytale/component/Holder.java index 47b7009..68f1f7c 100644 --- a/src/com/hypixel/hytale/component/Holder.java +++ b/src/com/hypixel/hytale/component/Holder.java @@ -354,6 +354,37 @@ public class Holder { return var9; } + public Holder cloneSerializable(@Nonnull ComponentRegistry.Data data) { + assert this.archetype != null; + + assert this.components != null; + + assert this.registry != null; + + long stamp = this.lock.readLock(); + + Holder var11; + try { + Archetype serializableArchetype = this.archetype.getSerializableArchetype(data); + Component[] componentsClone = new Component[serializableArchetype.length()]; + + for (int i = serializableArchetype.getMinIndex(); i < serializableArchetype.length(); i++) { + ComponentType> componentType = (ComponentType>)serializableArchetype.get( + i + ); + if (componentType != null) { + componentsClone[i] = this.components[i].cloneSerializable(); + } + } + + var11 = this.registry.newHolder(serializableArchetype, componentsClone); + } finally { + this.lock.unlockRead(stamp); + } + + return var11; + } + void loadComponentsMap(@Nonnull ComponentRegistry.Data data, @Nonnull Map> map) { assert this.components != null; diff --git a/src/com/hypixel/hytale/component/NonSerialized.java b/src/com/hypixel/hytale/component/NonSerialized.java index cfd086e..4fb6c80 100644 --- a/src/com/hypixel/hytale/component/NonSerialized.java +++ b/src/com/hypixel/hytale/component/NonSerialized.java @@ -1,10 +1,10 @@ package com.hypixel.hytale.component; -public class NonSerialized implements Component { - private static final NonSerialized INSTANCE = new NonSerialized(); +import javax.annotation.Nonnull; - public NonSerialized() { - } +public class NonSerialized implements Component { + @Nonnull + private static final NonSerialized INSTANCE = new NonSerialized(); public static NonSerialized get() { return (NonSerialized)INSTANCE; diff --git a/src/com/hypixel/hytale/component/NonTicking.java b/src/com/hypixel/hytale/component/NonTicking.java index e81be47..265af4c 100644 --- a/src/com/hypixel/hytale/component/NonTicking.java +++ b/src/com/hypixel/hytale/component/NonTicking.java @@ -1,10 +1,10 @@ package com.hypixel.hytale.component; -public class NonTicking implements Component { - private static final NonTicking INSTANCE = new NonTicking(); +import javax.annotation.Nonnull; - public NonTicking() { - } +public class NonTicking implements Component { + @Nonnull + private static final NonTicking INSTANCE = new NonTicking(); public static NonTicking get() { return (NonTicking)INSTANCE; diff --git a/src/com/hypixel/hytale/component/ReadWriteQuery.java b/src/com/hypixel/hytale/component/ReadWriteQuery.java index d4b3ad2..a6d5c01 100644 --- a/src/com/hypixel/hytale/component/ReadWriteQuery.java +++ b/src/com/hypixel/hytale/component/ReadWriteQuery.java @@ -1,14 +1,20 @@ package com.hypixel.hytale.component; import com.hypixel.hytale.component.query.ReadWriteArchetypeQuery; +import java.util.Objects; +import javax.annotation.Nonnull; public class ReadWriteQuery implements ReadWriteArchetypeQuery { + @Nonnull private final Archetype read; + @Nonnull private final Archetype write; - public ReadWriteQuery(Archetype read, Archetype write) { + public ReadWriteQuery(@Nonnull Archetype read, @Nonnull Archetype write) { this.read = read; this.write = write; + Objects.requireNonNull(read, "Read archetype for ReadWriteQuery cannot be null"); + Objects.requireNonNull(write, "Write archetype for ReadWriteQuery cannot be null"); } @Override diff --git a/src/com/hypixel/hytale/component/RemoveReason.java b/src/com/hypixel/hytale/component/RemoveReason.java index f52d244..4991242 100644 --- a/src/com/hypixel/hytale/component/RemoveReason.java +++ b/src/com/hypixel/hytale/component/RemoveReason.java @@ -3,7 +3,4 @@ package com.hypixel.hytale.component; public enum RemoveReason { REMOVE, UNLOAD; - - private RemoveReason() { - } } diff --git a/src/com/hypixel/hytale/component/ResourceType.java b/src/com/hypixel/hytale/component/ResourceType.java index 7a45a28..3a99387 100644 --- a/src/com/hypixel/hytale/component/ResourceType.java +++ b/src/com/hypixel/hytale/component/ResourceType.java @@ -11,9 +11,6 @@ public class ResourceType> implements Com private int index; private boolean invalid = true; - public ResourceType() { - } - void init(@Nonnull ComponentRegistry registry, @Nonnull Class tClass, int index) { this.registry = registry; this.tClass = tClass; diff --git a/src/com/hypixel/hytale/component/Store.java b/src/com/hypixel/hytale/component/Store.java index c76050b..73bc3df 100644 --- a/src/com/hypixel/hytale/component/Store.java +++ b/src/com/hypixel/hytale/component/Store.java @@ -1444,7 +1444,7 @@ public class Store implements ComponentAccessor { } public , Q, R> void fetch( - @Nonnull Collection> refs, @Nonnull SystemType systemType, Q query, @Nonnull List results + @Nonnull Collection> refs, @Nonnull SystemType systemType, @Nonnull Q query, @Nonnull List results ) { if (this.shutdown) { throw new IllegalStateException("Store is shutdown!"); @@ -2118,9 +2118,6 @@ public class Store implements ComponentAccessor { private static class ProcessingCounter implements Lock { private int count = 0; - private ProcessingCounter() { - } - public boolean isHeld() { return this.count > 0; } diff --git a/src/com/hypixel/hytale/component/data/ForEachTaskData.java b/src/com/hypixel/hytale/component/data/ForEachTaskData.java index c00a667..2ab58c0 100644 --- a/src/com/hypixel/hytale/component/data/ForEachTaskData.java +++ b/src/com/hypixel/hytale/component/data/ForEachTaskData.java @@ -17,9 +17,6 @@ public class ForEachTaskData implements IntConsumer { @Nullable private CommandBuffer commandBuffer; - public ForEachTaskData() { - } - public void init( IntBiObjectConsumer, CommandBuffer> consumer, ArchetypeChunk archetypeChunk, diff --git a/src/com/hypixel/hytale/component/data/change/ChangeType.java b/src/com/hypixel/hytale/component/data/change/ChangeType.java index 8d67941..6b931bc 100644 --- a/src/com/hypixel/hytale/component/data/change/ChangeType.java +++ b/src/com/hypixel/hytale/component/data/change/ChangeType.java @@ -3,7 +3,4 @@ package com.hypixel.hytale.component.data.change; public enum ChangeType { REGISTERED, UNREGISTERED; - - private ChangeType() { - } } diff --git a/src/com/hypixel/hytale/component/data/unknown/TempUnknownComponent.java b/src/com/hypixel/hytale/component/data/unknown/TempUnknownComponent.java index 0880dd3..f6a1b75 100644 --- a/src/com/hypixel/hytale/component/data/unknown/TempUnknownComponent.java +++ b/src/com/hypixel/hytale/component/data/unknown/TempUnknownComponent.java @@ -7,15 +7,18 @@ import javax.annotation.Nonnull; import org.bson.BsonDocument; public class TempUnknownComponent implements Component { + @Nonnull public static final Codec COMPONENT_CODEC = new FunctionCodec<>( Codec.BSON_DOCUMENT, TempUnknownComponent::new, component -> ((TempUnknownComponent)component).document ); - private BsonDocument document; + @Nonnull + private final BsonDocument document; - public TempUnknownComponent(BsonDocument document) { + public TempUnknownComponent(@Nonnull BsonDocument document) { this.document = document; } + @Nonnull public BsonDocument getDocument() { return this.document; } diff --git a/src/com/hypixel/hytale/component/data/unknown/UnknownComponents.java b/src/com/hypixel/hytale/component/data/unknown/UnknownComponents.java index e6530e5..ae666fe 100644 --- a/src/com/hypixel/hytale/component/data/unknown/UnknownComponents.java +++ b/src/com/hypixel/hytale/component/data/unknown/UnknownComponents.java @@ -15,8 +15,11 @@ import org.bson.BsonDocument; import org.bson.BsonValue; public class UnknownComponents implements Component { + @Nonnull public static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); + @Nonnull public static final String ID = "Unknown"; + @Nonnull public static final BuilderCodec CODEC = BuilderCodec.builder(UnknownComponents.class, UnknownComponents::new) .addField( new KeyedCodec<>("Components", new MapCodec<>(Codec.BSON_DOCUMENT, Object2ObjectOpenHashMap::new, false)), @@ -24,33 +27,34 @@ public class UnknownComponents implements Component { o -> o.unknownComponents ) .build(); + @Nonnull private Map unknownComponents; public UnknownComponents() { this.unknownComponents = new Object2ObjectOpenHashMap<>(); } - public UnknownComponents(Map unknownComponents) { + public UnknownComponents(@Nonnull Map unknownComponents) { this.unknownComponents = unknownComponents; } - public void addComponent(String componentId, Component component, @Nonnull Codec> codec) { + public void addComponent(@Nonnull String componentId, @Nonnull Component component, @Nonnull Codec> codec) { ExtraInfo extraInfo = ExtraInfo.THREAD_LOCAL.get(); BsonValue bsonValue = codec.encode(component, extraInfo); extraInfo.getValidationResults().logOrThrowValidatorExceptions(LOGGER); this.unknownComponents.put(componentId, bsonValue.asDocument()); } - public void addComponent(String componentId, @Nonnull TempUnknownComponent component) { + public void addComponent(@Nonnull String componentId, @Nonnull TempUnknownComponent component) { this.unknownComponents.put(componentId, component.getDocument()); } - public boolean contains(String componentId) { + public boolean contains(@Nonnull String componentId) { return this.unknownComponents.containsKey(componentId); } @Nullable - public > T removeComponent(String componentId, @Nonnull Codec codec) { + public > T removeComponent(@Nonnull String componentId, @Nonnull Codec codec) { BsonDocument bsonDocument = this.unknownComponents.remove(componentId); if (bsonDocument == null) { return null; @@ -62,6 +66,7 @@ public class UnknownComponents implements Component { } } + @Nonnull public Map getUnknownComponents() { return this.unknownComponents; } diff --git a/src/com/hypixel/hytale/component/dependency/Dependency.java b/src/com/hypixel/hytale/component/dependency/Dependency.java index 465b816..8fcf0fc 100644 --- a/src/com/hypixel/hytale/component/dependency/Dependency.java +++ b/src/com/hypixel/hytale/component/dependency/Dependency.java @@ -35,6 +35,6 @@ public abstract class Dependency { @Nonnull @Override public String toString() { - return "Dependency{order=" + this.order + "}"; + return "Dependency{order=" + this.order + ", priority=" + this.priority + "}"; } } diff --git a/src/com/hypixel/hytale/component/dependency/DependencyGraph.java b/src/com/hypixel/hytale/component/dependency/DependencyGraph.java index 94b7c48..766fe8d 100644 --- a/src/com/hypixel/hytale/component/dependency/DependencyGraph.java +++ b/src/com/hypixel/hytale/component/dependency/DependencyGraph.java @@ -15,8 +15,11 @@ import javax.annotation.Nullable; public class DependencyGraph { @Nonnull private final ISystem[] systems; + @Nonnull private final Map, List>> beforeSystemEdges = new Object2ObjectOpenHashMap<>(); + @Nonnull private final Map, List>> afterSystemEdges = new Object2ObjectOpenHashMap<>(); + @Nonnull private final Map, Set>> afterSystemUnfulfilledEdges = new Object2ObjectOpenHashMap<>(); private DependencyGraph.Edge[] edges = DependencyGraph.Edge.emptyArray(); @@ -102,7 +105,7 @@ public class DependencyGraph { } } - public void sort(ISystem[] sortedSystems) { + public void sort(@Nonnull ISystem[] sortedSystems) { int index = 0; label52: @@ -135,7 +138,7 @@ public class DependencyGraph { } } - private boolean hasEdgeOfLaterPriority(ISystem system, int priority) { + private boolean hasEdgeOfLaterPriority(@Nonnull ISystem system, int priority) { for (DependencyGraph.Edge edge : this.afterSystemEdges.get(system)) { if (!edge.resolved && edge.priority > priority) { return true; @@ -145,13 +148,13 @@ public class DependencyGraph { return false; } - private void resolveEdgesFor(ISystem system) { + private void resolveEdgesFor(@Nonnull ISystem system) { for (DependencyGraph.Edge edge : this.afterSystemEdges.get(system)) { edge.resolved = true; } } - private void fulfillEdgesFor(ISystem system) { + private void fulfillEdgesFor(@Nonnull ISystem system) { for (DependencyGraph.Edge edge : this.beforeSystemEdges.get(system)) { edge.fulfilled = true; this.afterSystemUnfulfilledEdges.get(edge.afterSystem).remove(edge); @@ -165,6 +168,7 @@ public class DependencyGraph { } private static class Edge implements Comparable> { + @Nonnull private static final DependencyGraph.Edge[] EMPTY_ARRAY = new DependencyGraph.Edge[0]; @Nullable private final ISystem beforeSystem; @@ -177,7 +181,7 @@ public class DependencyGraph { return (DependencyGraph.Edge[])EMPTY_ARRAY; } - public Edge(@Nullable ISystem beforeSystem, ISystem afterSystem, int priority) { + public Edge(@Nullable ISystem beforeSystem, @Nonnull ISystem afterSystem, int priority) { this.beforeSystem = beforeSystem; this.afterSystem = afterSystem; this.priority = priority; diff --git a/src/com/hypixel/hytale/component/dependency/Order.java b/src/com/hypixel/hytale/component/dependency/Order.java index bee3fe6..85666d7 100644 --- a/src/com/hypixel/hytale/component/dependency/Order.java +++ b/src/com/hypixel/hytale/component/dependency/Order.java @@ -3,7 +3,4 @@ package com.hypixel.hytale.component.dependency; public enum Order { BEFORE, AFTER; - - private Order() { - } } diff --git a/src/com/hypixel/hytale/component/dependency/OrderPriority.java b/src/com/hypixel/hytale/component/dependency/OrderPriority.java index b1b553b..06f94b2 100644 --- a/src/com/hypixel/hytale/component/dependency/OrderPriority.java +++ b/src/com/hypixel/hytale/component/dependency/OrderPriority.java @@ -9,7 +9,7 @@ public enum OrderPriority { private final int value; - private OrderPriority(int value) { + private OrderPriority(final int value) { this.value = value; } diff --git a/src/com/hypixel/hytale/component/query/AndQuery.java b/src/com/hypixel/hytale/component/query/AndQuery.java index 698befa..9b85ce0 100644 --- a/src/com/hypixel/hytale/component/query/AndQuery.java +++ b/src/com/hypixel/hytale/component/query/AndQuery.java @@ -3,13 +3,22 @@ package com.hypixel.hytale.component.query; import com.hypixel.hytale.component.Archetype; import com.hypixel.hytale.component.ComponentRegistry; import com.hypixel.hytale.component.ComponentType; +import javax.annotation.Nonnull; public class AndQuery implements Query { + @Nonnull private final Query[] queries; @SafeVarargs - public AndQuery(Query... queries) { + public AndQuery(@Nonnull Query... queries) { this.queries = queries; + + for (int i = 0; i < queries.length; i++) { + Query query = queries[i]; + if (query == null) { + throw new IllegalArgumentException("Query in AndQuery cannot be null (Index: " + i + ")"); + } + } } @Override @@ -35,7 +44,7 @@ public class AndQuery implements Query { } @Override - public void validateRegistry(ComponentRegistry registry) { + public void validateRegistry(@Nonnull ComponentRegistry registry) { for (Query query : this.queries) { query.validateRegistry(registry); } diff --git a/src/com/hypixel/hytale/component/query/AnyQuery.java b/src/com/hypixel/hytale/component/query/AnyQuery.java index 55e04a2..92a3803 100644 --- a/src/com/hypixel/hytale/component/query/AnyQuery.java +++ b/src/com/hypixel/hytale/component/query/AnyQuery.java @@ -3,13 +3,12 @@ package com.hypixel.hytale.component.query; import com.hypixel.hytale.component.Archetype; import com.hypixel.hytale.component.ComponentRegistry; import com.hypixel.hytale.component.ComponentType; +import javax.annotation.Nonnull; -class AnyQuery implements Query { +public class AnyQuery implements Query { + @Nonnull static final AnyQuery INSTANCE = new AnyQuery(); - AnyQuery() { - } - @Override public boolean test(Archetype archetype) { return true; @@ -21,7 +20,7 @@ class AnyQuery implements Query { } @Override - public void validateRegistry(ComponentRegistry registry) { + public void validateRegistry(@Nonnull ComponentRegistry registry) { } @Override diff --git a/src/com/hypixel/hytale/component/query/ExactArchetypeQuery.java b/src/com/hypixel/hytale/component/query/ExactArchetypeQuery.java index b5af335..e040445 100644 --- a/src/com/hypixel/hytale/component/query/ExactArchetypeQuery.java +++ b/src/com/hypixel/hytale/component/query/ExactArchetypeQuery.java @@ -3,13 +3,16 @@ package com.hypixel.hytale.component.query; import com.hypixel.hytale.component.Archetype; import com.hypixel.hytale.component.ComponentRegistry; import com.hypixel.hytale.component.ComponentType; +import java.util.Objects; import javax.annotation.Nonnull; public class ExactArchetypeQuery implements Query { + @Nonnull private final Archetype archetype; - public ExactArchetypeQuery(Archetype archetype) { + public ExactArchetypeQuery(@Nonnull Archetype archetype) { this.archetype = archetype; + Objects.requireNonNull(archetype, "Archetype for ExactArchetypeQuery cannot be null"); } public Archetype getArchetype() { @@ -27,7 +30,7 @@ public class ExactArchetypeQuery implements Query { } @Override - public void validateRegistry(ComponentRegistry registry) { + public void validateRegistry(@Nonnull ComponentRegistry registry) { this.archetype.validateRegistry(registry); } diff --git a/src/com/hypixel/hytale/component/query/NotQuery.java b/src/com/hypixel/hytale/component/query/NotQuery.java index f9ed16d..18fb97e 100644 --- a/src/com/hypixel/hytale/component/query/NotQuery.java +++ b/src/com/hypixel/hytale/component/query/NotQuery.java @@ -3,12 +3,16 @@ package com.hypixel.hytale.component.query; import com.hypixel.hytale.component.Archetype; import com.hypixel.hytale.component.ComponentRegistry; import com.hypixel.hytale.component.ComponentType; +import java.util.Objects; +import javax.annotation.Nonnull; public class NotQuery implements Query { + @Nonnull private final Query query; - public NotQuery(Query query) { + public NotQuery(@Nonnull Query query) { this.query = query; + Objects.requireNonNull(query, "Sub-query for NotQuery cannot be null"); } @Override @@ -22,7 +26,7 @@ public class NotQuery implements Query { } @Override - public void validateRegistry(ComponentRegistry registry) { + public void validateRegistry(@Nonnull ComponentRegistry registry) { this.query.validateRegistry(registry); } diff --git a/src/com/hypixel/hytale/component/query/OrQuery.java b/src/com/hypixel/hytale/component/query/OrQuery.java index 8d7946e..fd3eaa8 100644 --- a/src/com/hypixel/hytale/component/query/OrQuery.java +++ b/src/com/hypixel/hytale/component/query/OrQuery.java @@ -3,12 +3,23 @@ package com.hypixel.hytale.component.query; import com.hypixel.hytale.component.Archetype; import com.hypixel.hytale.component.ComponentRegistry; import com.hypixel.hytale.component.ComponentType; +import javax.annotation.Nonnull; public class OrQuery implements Query { + @Nonnull private final Query[] queries; - public OrQuery(Query... queries) { + public OrQuery(@Nonnull Query... queries) { this.queries = queries; + if (queries.length == 0) { + throw new IllegalArgumentException("At least one query must be provided for OrQuery"); + } else { + for (int i = 0; i < queries.length; i++) { + if (queries[i] == null) { + throw new NullPointerException("Query at index " + i + " for OrQuery cannot be null"); + } + } + } } @Override @@ -34,7 +45,7 @@ public class OrQuery implements Query { } @Override - public void validateRegistry(ComponentRegistry registry) { + public void validateRegistry(@Nonnull ComponentRegistry registry) { for (Query query : this.queries) { query.validateRegistry(registry); } diff --git a/src/com/hypixel/hytale/component/query/Query.java b/src/com/hypixel/hytale/component/query/Query.java index bd90a4e..a01d6ab 100644 --- a/src/com/hypixel/hytale/component/query/Query.java +++ b/src/com/hypixel/hytale/component/query/Query.java @@ -12,19 +12,19 @@ public interface Query { } @Nonnull - static NotQuery not(Query query) { + static NotQuery not(@Nonnull Query query) { return new NotQuery<>(query); } @Nonnull @SafeVarargs - static AndQuery and(Query... queries) { + static AndQuery and(@Nonnull Query... queries) { return new AndQuery<>(queries); } @Nonnull @SafeVarargs - static OrQuery or(Query... queries) { + static OrQuery or(@Nonnull Query... queries) { return new OrQuery<>(queries); } @@ -32,7 +32,7 @@ public interface Query { boolean requiresComponentType(ComponentType var1); - void validateRegistry(ComponentRegistry var1); + void validateRegistry(@Nonnull ComponentRegistry var1); void validate(); } diff --git a/src/com/hypixel/hytale/component/query/ReadWriteArchetypeQuery.java b/src/com/hypixel/hytale/component/query/ReadWriteArchetypeQuery.java index f568672..c812d2d 100644 --- a/src/com/hypixel/hytale/component/query/ReadWriteArchetypeQuery.java +++ b/src/com/hypixel/hytale/component/query/ReadWriteArchetypeQuery.java @@ -21,7 +21,7 @@ public interface ReadWriteArchetypeQuery extends Query { } @Override - default void validateRegistry(ComponentRegistry registry) { + default void validateRegistry(@Nonnull ComponentRegistry registry) { this.getReadArchetype().validateRegistry(registry); this.getWriteArchetype().validateRegistry(registry); } diff --git a/src/com/hypixel/hytale/component/spatial/KDTree.java b/src/com/hypixel/hytale/component/spatial/KDTree.java index 006d6cd..85252f0 100644 --- a/src/com/hypixel/hytale/component/spatial/KDTree.java +++ b/src/com/hypixel/hytale/component/spatial/KDTree.java @@ -442,7 +442,7 @@ public class KDTree implements SpatialStructure { this._internal_ordered3DAxis(results, primary, center, xSearchRadius, ySearchRadius, zSearchRadius, newDepth); double plane = get(node.vector, axis); double component = get(center, axis); - double radius = axis == 0 ? xSearchRadius : (axis == 1 ? ySearchRadius : zSearchRadius); + double radius = axis == 0 ? xSearchRadius : (axis == 1 ? zSearchRadius : ySearchRadius); if (Math.abs(component - plane) <= radius) { this._internal_ordered3DAxis(results, secondary, center, xSearchRadius, ySearchRadius, zSearchRadius, newDepth); } diff --git a/src/com/hypixel/hytale/component/spatial/MortonCode.java b/src/com/hypixel/hytale/component/spatial/MortonCode.java index ec3426a..d3b87d5 100644 --- a/src/com/hypixel/hytale/component/spatial/MortonCode.java +++ b/src/com/hypixel/hytale/component/spatial/MortonCode.java @@ -4,9 +4,6 @@ public class MortonCode { private static final int BITS_PER_AXIS = 21; private static final long MAX_COORD = 2097151L; - public MortonCode() { - } - public static long encode(double x, double y, double z, double minX, double minY, double minZ, double maxX, double maxY, double maxZ) { double nx = (x - minX) / (maxX - minX); double ny = (y - minY) / (maxY - minY); diff --git a/src/com/hypixel/hytale/component/spatial/SpatialData.java b/src/com/hypixel/hytale/component/spatial/SpatialData.java index a23678f..17564d7 100644 --- a/src/com/hypixel/hytale/component/spatial/SpatialData.java +++ b/src/com/hypixel/hytale/component/spatial/SpatialData.java @@ -18,9 +18,6 @@ public class SpatialData { private T[] data = (T[])ArrayUtil.emptyArray(); private int size; - public SpatialData() { - } - public int size() { return this.size; } diff --git a/src/com/hypixel/hytale/component/system/ArchetypeChunkSystem.java b/src/com/hypixel/hytale/component/system/ArchetypeChunkSystem.java index 85343b0..1411423 100644 --- a/src/com/hypixel/hytale/component/system/ArchetypeChunkSystem.java +++ b/src/com/hypixel/hytale/component/system/ArchetypeChunkSystem.java @@ -3,9 +3,6 @@ package com.hypixel.hytale.component.system; import com.hypixel.hytale.component.ArchetypeChunk; public abstract class ArchetypeChunkSystem extends System implements QuerySystem { - public ArchetypeChunkSystem() { - } - public abstract void onSystemAddedToArchetypeChunk(ArchetypeChunk var1); public abstract void onSystemRemovedFromArchetypeChunk(ArchetypeChunk var1); diff --git a/src/com/hypixel/hytale/component/system/CancellableEcsEvent.java b/src/com/hypixel/hytale/component/system/CancellableEcsEvent.java index 2119a92..cb6b0b3 100644 --- a/src/com/hypixel/hytale/component/system/CancellableEcsEvent.java +++ b/src/com/hypixel/hytale/component/system/CancellableEcsEvent.java @@ -3,9 +3,6 @@ package com.hypixel.hytale.component.system; public abstract class CancellableEcsEvent extends EcsEvent implements ICancellableEcsEvent { private boolean cancelled = false; - public CancellableEcsEvent() { - } - @Override public final boolean isCancelled() { return this.cancelled; diff --git a/src/com/hypixel/hytale/component/system/DelayedSystem.java b/src/com/hypixel/hytale/component/system/DelayedSystem.java index dcff3d3..2d32d0f 100644 --- a/src/com/hypixel/hytale/component/system/DelayedSystem.java +++ b/src/com/hypixel/hytale/component/system/DelayedSystem.java @@ -40,9 +40,6 @@ public abstract class DelayedSystem extends TickingSystem { private static class Data implements Resource { private float dt; - private Data() { - } - @Nonnull @Override public Resource clone() { diff --git a/src/com/hypixel/hytale/component/system/EcsEvent.java b/src/com/hypixel/hytale/component/system/EcsEvent.java index 4c63683..62088ea 100644 --- a/src/com/hypixel/hytale/component/system/EcsEvent.java +++ b/src/com/hypixel/hytale/component/system/EcsEvent.java @@ -1,6 +1,4 @@ package com.hypixel.hytale.component.system; public abstract class EcsEvent { - public EcsEvent() { - } } diff --git a/src/com/hypixel/hytale/component/system/HolderSystem.java b/src/com/hypixel/hytale/component/system/HolderSystem.java index 20f5f24..0be4568 100644 --- a/src/com/hypixel/hytale/component/system/HolderSystem.java +++ b/src/com/hypixel/hytale/component/system/HolderSystem.java @@ -7,9 +7,6 @@ import com.hypixel.hytale.component.Store; import javax.annotation.Nonnull; public abstract class HolderSystem extends System implements QuerySystem { - public HolderSystem() { - } - public abstract void onEntityAdd(@Nonnull Holder var1, @Nonnull AddReason var2, @Nonnull Store var3); public abstract void onEntityRemoved(@Nonnull Holder var1, @Nonnull RemoveReason var2, @Nonnull Store var3); diff --git a/src/com/hypixel/hytale/component/system/RefChangeSystem.java b/src/com/hypixel/hytale/component/system/RefChangeSystem.java index cd214d3..9a9ae7b 100644 --- a/src/com/hypixel/hytale/component/system/RefChangeSystem.java +++ b/src/com/hypixel/hytale/component/system/RefChangeSystem.java @@ -9,9 +9,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public abstract class RefChangeSystem> extends System implements QuerySystem { - public RefChangeSystem() { - } - @Nonnull public abstract ComponentType componentType(); diff --git a/src/com/hypixel/hytale/component/system/RefSystem.java b/src/com/hypixel/hytale/component/system/RefSystem.java index 58fa34f..3cc4133 100644 --- a/src/com/hypixel/hytale/component/system/RefSystem.java +++ b/src/com/hypixel/hytale/component/system/RefSystem.java @@ -8,9 +8,6 @@ import com.hypixel.hytale.component.Store; import javax.annotation.Nonnull; public abstract class RefSystem extends System implements QuerySystem { - public RefSystem() { - } - public abstract void onEntityAdded( @Nonnull Ref var1, @Nonnull AddReason var2, @Nonnull Store var3, @Nonnull CommandBuffer var4 ); diff --git a/src/com/hypixel/hytale/component/system/StoreSystem.java b/src/com/hypixel/hytale/component/system/StoreSystem.java index 681e96c..090d2a2 100644 --- a/src/com/hypixel/hytale/component/system/StoreSystem.java +++ b/src/com/hypixel/hytale/component/system/StoreSystem.java @@ -4,9 +4,6 @@ import com.hypixel.hytale.component.Store; import javax.annotation.Nonnull; public abstract class StoreSystem extends System { - public StoreSystem() { - } - public abstract void onSystemAddedToStore(@Nonnull Store var1); public abstract void onSystemRemovedFromStore(@Nonnull Store var1); diff --git a/src/com/hypixel/hytale/component/system/System.java b/src/com/hypixel/hytale/component/system/System.java index 1af1842..842b713 100644 --- a/src/com/hypixel/hytale/component/system/System.java +++ b/src/com/hypixel/hytale/component/system/System.java @@ -20,9 +20,6 @@ public abstract class System implements ISystem { @Nonnull private final ObjectList> resourceRegistrations = new ObjectArrayList<>(); - public System() { - } - @Nonnull protected > ComponentType registerComponent(@Nonnull Class tClass, @Nonnull Supplier supplier) { return this.registerComponent(tClass, null, null, supplier); diff --git a/src/com/hypixel/hytale/component/system/data/ArchetypeDataSystem.java b/src/com/hypixel/hytale/component/system/data/ArchetypeDataSystem.java index 526d75e..baaaf0d 100644 --- a/src/com/hypixel/hytale/component/system/data/ArchetypeDataSystem.java +++ b/src/com/hypixel/hytale/component/system/data/ArchetypeDataSystem.java @@ -8,8 +8,5 @@ import com.hypixel.hytale.component.system.System; import java.util.List; public abstract class ArchetypeDataSystem extends System implements QuerySystem { - public ArchetypeDataSystem() { - } - public abstract void fetch(ArchetypeChunk var1, Store var2, CommandBuffer var3, Q var4, List var5); } diff --git a/src/com/hypixel/hytale/component/system/data/EntityDataSystem.java b/src/com/hypixel/hytale/component/system/data/EntityDataSystem.java index a211b49..8ffe0fb 100644 --- a/src/com/hypixel/hytale/component/system/data/EntityDataSystem.java +++ b/src/com/hypixel/hytale/component/system/data/EntityDataSystem.java @@ -12,9 +12,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public abstract class EntityDataSystem extends ArchetypeDataSystem { - public EntityDataSystem() { - } - public boolean isParallel() { return false; } @@ -76,9 +73,6 @@ public abstract class EntityDataSystem extends ArchetypeDataSyst @Nullable private Q query; - public SystemTaskData() { - } - public void init( EntityDataSystem system, ArchetypeChunk archetypeChunk, diff --git a/src/com/hypixel/hytale/component/system/tick/ArchetypeTickingSystem.java b/src/com/hypixel/hytale/component/system/tick/ArchetypeTickingSystem.java index 46a989d..f1b2a47 100644 --- a/src/com/hypixel/hytale/component/system/tick/ArchetypeTickingSystem.java +++ b/src/com/hypixel/hytale/component/system/tick/ArchetypeTickingSystem.java @@ -9,9 +9,6 @@ import com.hypixel.hytale.component.system.QuerySystem; import javax.annotation.Nonnull; public abstract class ArchetypeTickingSystem extends TickingSystem implements QuerySystem { - public ArchetypeTickingSystem() { - } - @Override public boolean test(@Nonnull ComponentRegistry componentRegistry, @Nonnull Archetype archetype) { return !this.isExplicitQuery() && componentRegistry.getNonTickingComponentType().test(archetype) ? false : this.getQuery().test(archetype); diff --git a/src/com/hypixel/hytale/component/system/tick/DelayedEntitySystem.java b/src/com/hypixel/hytale/component/system/tick/DelayedEntitySystem.java index fbd4c61..0b02d9e 100644 --- a/src/com/hypixel/hytale/component/system/tick/DelayedEntitySystem.java +++ b/src/com/hypixel/hytale/component/system/tick/DelayedEntitySystem.java @@ -38,9 +38,6 @@ public abstract class DelayedEntitySystem extends EntityTickingSystem< private static class Data implements Resource { private float dt; - private Data() { - } - @Nonnull @Override public Resource clone() { diff --git a/src/com/hypixel/hytale/component/system/tick/EntityTickingSystem.java b/src/com/hypixel/hytale/component/system/tick/EntityTickingSystem.java index d485637..cc1306f 100644 --- a/src/com/hypixel/hytale/component/system/tick/EntityTickingSystem.java +++ b/src/com/hypixel/hytale/component/system/tick/EntityTickingSystem.java @@ -10,9 +10,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public abstract class EntityTickingSystem extends ArchetypeTickingSystem { - public EntityTickingSystem() { - } - protected static boolean maybeUseParallel(int archetypeChunkSize, int taskCount) { return false; } @@ -69,9 +66,6 @@ public abstract class EntityTickingSystem extends ArchetypeTickingSyst @Nullable private CommandBuffer commandBuffer; - public SystemTaskData() { - } - public void init( EntityTickingSystem system, float dt, ArchetypeChunk archetypeChunk, Store store, CommandBuffer commandBuffer ) { diff --git a/src/com/hypixel/hytale/component/system/tick/TickingSystem.java b/src/com/hypixel/hytale/component/system/tick/TickingSystem.java index 0013b7a..a25253f 100644 --- a/src/com/hypixel/hytale/component/system/tick/TickingSystem.java +++ b/src/com/hypixel/hytale/component/system/tick/TickingSystem.java @@ -5,9 +5,6 @@ import com.hypixel.hytale.component.system.System; import javax.annotation.Nonnull; public abstract class TickingSystem extends System implements TickableSystem { - public TickingSystem() { - } - @Override public abstract void tick(float var1, int var2, @Nonnull Store var3); } diff --git a/src/com/hypixel/hytale/event/EventBusRegistry.java b/src/com/hypixel/hytale/event/EventBusRegistry.java index e3c37bb..73931ad 100644 --- a/src/com/hypixel/hytale/event/EventBusRegistry.java +++ b/src/com/hypixel/hytale/event/EventBusRegistry.java @@ -125,9 +125,6 @@ public abstract class EventBusRegistry> map = new Short2ObjectConcurrentHashMap<>(true, (short)-32768); - public EventConsumerMap() { - } - public boolean isEmpty() { return this.map.isEmpty(); } diff --git a/src/com/hypixel/hytale/function/supplier/SupplierUtil.java b/src/com/hypixel/hytale/function/supplier/SupplierUtil.java index 3ccfed8..9d93c84 100644 --- a/src/com/hypixel/hytale/function/supplier/SupplierUtil.java +++ b/src/com/hypixel/hytale/function/supplier/SupplierUtil.java @@ -4,9 +4,6 @@ import java.util.function.Supplier; import javax.annotation.Nonnull; public class SupplierUtil { - public SupplierUtil() { - } - @Nonnull public static CachedSupplier cache(Supplier delegate) { return new CachedSupplier<>(delegate); diff --git a/src/com/hypixel/hytale/logger/HytaleLogger.java b/src/com/hypixel/hytale/logger/HytaleLogger.java index 1c7f979..d3a1ed2 100644 --- a/src/com/hypixel/hytale/logger/HytaleLogger.java +++ b/src/com/hypixel/hytale/logger/HytaleLogger.java @@ -156,7 +156,5 @@ public class HytaleLogger extends AbstractLogger { } private static final class NoOp extends com.google.common.flogger.LoggingApi.NoOp implements HytaleLogger.Api { - private NoOp() { - } } } diff --git a/src/com/hypixel/hytale/logger/backend/HytaleUncaughtExceptionHandler.java b/src/com/hypixel/hytale/logger/backend/HytaleUncaughtExceptionHandler.java index 21a75c5..3728df7 100644 --- a/src/com/hypixel/hytale/logger/backend/HytaleUncaughtExceptionHandler.java +++ b/src/com/hypixel/hytale/logger/backend/HytaleUncaughtExceptionHandler.java @@ -7,9 +7,6 @@ import java.util.logging.Level; public class HytaleUncaughtExceptionHandler implements UncaughtExceptionHandler { public static final HytaleUncaughtExceptionHandler INSTANCE = new HytaleUncaughtExceptionHandler(); - public HytaleUncaughtExceptionHandler() { - } - public static void setup() { Thread.setDefaultUncaughtExceptionHandler(INSTANCE); System.setProperty("java.util.concurrent.ForkJoinPool.common.exceptionHandler", HytaleUncaughtExceptionHandler.class.getName()); diff --git a/src/com/hypixel/hytale/logger/sentry/HytaleSentryHandler.java b/src/com/hypixel/hytale/logger/sentry/HytaleSentryHandler.java index c5738c4..1da7d94 100644 --- a/src/com/hypixel/hytale/logger/sentry/HytaleSentryHandler.java +++ b/src/com/hypixel/hytale/logger/sentry/HytaleSentryHandler.java @@ -300,9 +300,6 @@ public class HytaleSentryHandler extends Handler { } private static final class DropSentryFilter implements Filter { - private DropSentryFilter() { - } - @Override public boolean isLoggable(@Nonnull LogRecord record) { String loggerName = record.getLoggerName(); diff --git a/src/com/hypixel/hytale/logger/util/GithubMessageUtil.java b/src/com/hypixel/hytale/logger/util/GithubMessageUtil.java index 34d8cbb..2917395 100644 --- a/src/com/hypixel/hytale/logger/util/GithubMessageUtil.java +++ b/src/com/hypixel/hytale/logger/util/GithubMessageUtil.java @@ -5,9 +5,6 @@ import javax.annotation.Nonnull; public class GithubMessageUtil { private static final String CI = System.getenv("CI"); - public GithubMessageUtil() { - } - public static boolean isGithub() { return CI != null; } diff --git a/src/com/hypixel/hytale/math/block/BlockConeUtil.java b/src/com/hypixel/hytale/math/block/BlockConeUtil.java index 55c33e9..7a630e9 100644 --- a/src/com/hypixel/hytale/math/block/BlockConeUtil.java +++ b/src/com/hypixel/hytale/math/block/BlockConeUtil.java @@ -4,9 +4,6 @@ import com.hypixel.hytale.function.predicate.TriIntObjPredicate; import javax.annotation.Nonnull; public class BlockConeUtil { - public BlockConeUtil() { - } - public static void forEachBlock( int originX, int originY, int originZ, int radiusX, int height, int radiusZ, T t, @Nonnull TriIntObjPredicate consumer ) { diff --git a/src/com/hypixel/hytale/math/block/BlockCubeUtil.java b/src/com/hypixel/hytale/math/block/BlockCubeUtil.java index 00847d3..0660294 100644 --- a/src/com/hypixel/hytale/math/block/BlockCubeUtil.java +++ b/src/com/hypixel/hytale/math/block/BlockCubeUtil.java @@ -5,9 +5,6 @@ import com.hypixel.hytale.math.vector.Vector3i; import javax.annotation.Nonnull; public class BlockCubeUtil { - public BlockCubeUtil() { - } - public static boolean forEachBlock( int originX, int originY, int originZ, int radiusX, int height, int radiusZ, T t, @Nonnull TriIntObjPredicate consumer ) { diff --git a/src/com/hypixel/hytale/math/block/BlockCylinderUtil.java b/src/com/hypixel/hytale/math/block/BlockCylinderUtil.java index 746cba0..4e68c46 100644 --- a/src/com/hypixel/hytale/math/block/BlockCylinderUtil.java +++ b/src/com/hypixel/hytale/math/block/BlockCylinderUtil.java @@ -5,9 +5,6 @@ import com.hypixel.hytale.math.util.MathUtil; import javax.annotation.Nonnull; public class BlockCylinderUtil { - public BlockCylinderUtil() { - } - public static boolean forEachBlock( int originX, int originY, int originZ, int radiusX, int height, int radiusZ, T t, @Nonnull TriIntObjPredicate consumer ) { diff --git a/src/com/hypixel/hytale/math/block/BlockDiamondUtil.java b/src/com/hypixel/hytale/math/block/BlockDiamondUtil.java index 9d7fdb0..7286ead 100644 --- a/src/com/hypixel/hytale/math/block/BlockDiamondUtil.java +++ b/src/com/hypixel/hytale/math/block/BlockDiamondUtil.java @@ -5,9 +5,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class BlockDiamondUtil { - public BlockDiamondUtil() { - } - public static boolean forEachBlock( int originX, int originY, int originZ, int radiusX, int radiusY, int radiusZ, @Nullable T t, @Nonnull TriIntObjPredicate consumer ) { diff --git a/src/com/hypixel/hytale/math/block/BlockDomeUtil.java b/src/com/hypixel/hytale/math/block/BlockDomeUtil.java index a1a8293..1a8ee4f 100644 --- a/src/com/hypixel/hytale/math/block/BlockDomeUtil.java +++ b/src/com/hypixel/hytale/math/block/BlockDomeUtil.java @@ -5,9 +5,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class BlockDomeUtil { - public BlockDomeUtil() { - } - public static boolean forEachBlock( int originX, int originY, int originZ, int radiusX, int radiusY, int radiusZ, @Nullable T t, @Nonnull TriIntObjPredicate consumer ) { diff --git a/src/com/hypixel/hytale/math/block/BlockInvertedDomeUtil.java b/src/com/hypixel/hytale/math/block/BlockInvertedDomeUtil.java index 64066f3..3c82121 100644 --- a/src/com/hypixel/hytale/math/block/BlockInvertedDomeUtil.java +++ b/src/com/hypixel/hytale/math/block/BlockInvertedDomeUtil.java @@ -5,9 +5,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class BlockInvertedDomeUtil { - public BlockInvertedDomeUtil() { - } - public static boolean forEachBlock( int originX, int originY, int originZ, int radiusX, int radiusY, int radiusZ, @Nullable T t, @Nonnull TriIntObjPredicate consumer ) { diff --git a/src/com/hypixel/hytale/math/block/BlockPyramidUtil.java b/src/com/hypixel/hytale/math/block/BlockPyramidUtil.java index e827ddb..0e5d4b9 100644 --- a/src/com/hypixel/hytale/math/block/BlockPyramidUtil.java +++ b/src/com/hypixel/hytale/math/block/BlockPyramidUtil.java @@ -4,9 +4,6 @@ import com.hypixel.hytale.function.predicate.TriIntObjPredicate; import javax.annotation.Nonnull; public class BlockPyramidUtil { - public BlockPyramidUtil() { - } - public static void forEachBlock( int originX, int originY, int originZ, int radiusX, int height, int radiusZ, T t, @Nonnull TriIntObjPredicate consumer ) { diff --git a/src/com/hypixel/hytale/math/block/BlockSphereUtil.java b/src/com/hypixel/hytale/math/block/BlockSphereUtil.java index 3440446..1b19cc2 100644 --- a/src/com/hypixel/hytale/math/block/BlockSphereUtil.java +++ b/src/com/hypixel/hytale/math/block/BlockSphereUtil.java @@ -6,9 +6,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class BlockSphereUtil { - public BlockSphereUtil() { - } - public static void forEachBlockExact(int originX, int originY, int originZ, double radius, @Nullable T t, @Nonnull TriIntObjPredicate consumer) { if (radius <= 0.0) { throw new IllegalArgumentException(String.valueOf(radius)); diff --git a/src/com/hypixel/hytale/math/block/BlockTorusUtil.java b/src/com/hypixel/hytale/math/block/BlockTorusUtil.java index e13619e..3fff077 100644 --- a/src/com/hypixel/hytale/math/block/BlockTorusUtil.java +++ b/src/com/hypixel/hytale/math/block/BlockTorusUtil.java @@ -5,9 +5,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class BlockTorusUtil { - public BlockTorusUtil() { - } - public static boolean forEachBlock( int originX, int originY, int originZ, int outerRadius, int minorRadius, @Nullable T t, @Nonnull TriIntObjPredicate consumer ) { diff --git a/src/com/hypixel/hytale/math/block/BlockUtil.java b/src/com/hypixel/hytale/math/block/BlockUtil.java index 5c2f610..02a24a1 100644 --- a/src/com/hypixel/hytale/math/block/BlockUtil.java +++ b/src/com/hypixel/hytale/math/block/BlockUtil.java @@ -16,9 +16,6 @@ public class BlockUtil { public static final long DIRECTION_INVERT = -67108864L; public static final long DIRECTION_MASK = 67108863L; - public BlockUtil() { - } - public static long pack(@Nonnull Vector3i val) { return pack(val.x, val.y, val.z); } @@ -48,6 +45,23 @@ public class BlockUtil { } } + public static long packUnchecked(int x, int y, int z) { + long l = (y & 511L) << 54 | (z & 67108863L) << 27 | x & 67108863L; + if (y < 0) { + l |= Long.MIN_VALUE; + } + + if (z < 0) { + l |= 9007199254740992L; + } + + if (x < 0) { + l |= 67108864L; + } + + return l; + } + public static int unpackX(long packed) { int i = (int)(packed & 67108863L); if ((packed & 67108864L) != 0L) { diff --git a/src/com/hypixel/hytale/math/codec/FloatRangeArrayCodec.java b/src/com/hypixel/hytale/math/codec/FloatRangeArrayCodec.java index c9b336b..2d91e70 100644 --- a/src/com/hypixel/hytale/math/codec/FloatRangeArrayCodec.java +++ b/src/com/hypixel/hytale/math/codec/FloatRangeArrayCodec.java @@ -20,9 +20,6 @@ import org.bson.BsonDouble; import org.bson.BsonValue; public class FloatRangeArrayCodec implements Codec, ValidatableCodec { - public FloatRangeArrayCodec() { - } - @Nonnull public FloatRange decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { BsonArray document = bsonValue.asArray(); diff --git a/src/com/hypixel/hytale/math/codec/IntRangeArrayCodec.java b/src/com/hypixel/hytale/math/codec/IntRangeArrayCodec.java index 114c1ab..e952ec1 100644 --- a/src/com/hypixel/hytale/math/codec/IntRangeArrayCodec.java +++ b/src/com/hypixel/hytale/math/codec/IntRangeArrayCodec.java @@ -18,9 +18,6 @@ import org.bson.BsonDouble; import org.bson.BsonValue; public class IntRangeArrayCodec implements Codec, ValidatableCodec { - public IntRangeArrayCodec() { - } - @Nonnull public IntRange decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { BsonArray document = bsonValue.asArray(); diff --git a/src/com/hypixel/hytale/math/codec/Vector2dArrayCodec.java b/src/com/hypixel/hytale/math/codec/Vector2dArrayCodec.java index c997b4a..cbf6533 100644 --- a/src/com/hypixel/hytale/math/codec/Vector2dArrayCodec.java +++ b/src/com/hypixel/hytale/math/codec/Vector2dArrayCodec.java @@ -16,9 +16,6 @@ import org.bson.BsonValue; @Deprecated public class Vector2dArrayCodec implements Codec { - public Vector2dArrayCodec() { - } - @Nonnull public Vector2d decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { BsonArray document = bsonValue.asArray(); diff --git a/src/com/hypixel/hytale/math/codec/Vector3dArrayCodec.java b/src/com/hypixel/hytale/math/codec/Vector3dArrayCodec.java index d7757e3..f333cd5 100644 --- a/src/com/hypixel/hytale/math/codec/Vector3dArrayCodec.java +++ b/src/com/hypixel/hytale/math/codec/Vector3dArrayCodec.java @@ -16,9 +16,6 @@ import org.bson.BsonValue; @Deprecated public class Vector3dArrayCodec implements Codec { - public Vector3dArrayCodec() { - } - @Nonnull public Vector3d decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { BsonArray document = bsonValue.asArray(); diff --git a/src/com/hypixel/hytale/math/codec/Vector3iArrayCodec.java b/src/com/hypixel/hytale/math/codec/Vector3iArrayCodec.java index 7d9b4f7..8a8434d 100644 --- a/src/com/hypixel/hytale/math/codec/Vector3iArrayCodec.java +++ b/src/com/hypixel/hytale/math/codec/Vector3iArrayCodec.java @@ -16,9 +16,6 @@ import org.bson.BsonValue; @Deprecated public class Vector3iArrayCodec implements Codec { - public Vector3iArrayCodec() { - } - @Nonnull public Vector3i decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { BsonArray document = bsonValue.asArray(); diff --git a/src/com/hypixel/hytale/math/hitdetection/HitDetectionExecutor.java b/src/com/hypixel/hytale/math/hitdetection/HitDetectionExecutor.java index 1c4b340..651aa8d 100644 --- a/src/com/hypixel/hytale/math/hitdetection/HitDetectionExecutor.java +++ b/src/com/hypixel/hytale/math/hitdetection/HitDetectionExecutor.java @@ -42,9 +42,6 @@ public class HitDetectionExecutor { private LineOfSightProvider losProvider = LineOfSightProvider.DEFAULT_TRUE; private int maxRayTests = 10; - public HitDetectionExecutor() { - } - public Vector4d getHitLocation() { return this.buffer.hitPosition; } diff --git a/src/com/hypixel/hytale/math/iterator/BlockIterator.java b/src/com/hypixel/hytale/math/iterator/BlockIterator.java index 7b76fa9..6554dc8 100644 --- a/src/com/hypixel/hytale/math/iterator/BlockIterator.java +++ b/src/com/hypixel/hytale/math/iterator/BlockIterator.java @@ -298,9 +298,6 @@ public final class BlockIterator { static final double TWO_POWER_52 = 4.5035996E15F; static final double ROUNDING_ERROR = 1.0E-15; - FastMath() { - } - static boolean eq(double a, double b) { return abs(a - b) < 1.0E-15; } diff --git a/src/com/hypixel/hytale/math/iterator/BoxBlockIterator.java b/src/com/hypixel/hytale/math/iterator/BoxBlockIterator.java index a82fec1..21ba8c5 100644 --- a/src/com/hypixel/hytale/math/iterator/BoxBlockIterator.java +++ b/src/com/hypixel/hytale/math/iterator/BoxBlockIterator.java @@ -253,9 +253,6 @@ public final class BoxBlockIterator { long posX; long posY; long posZ; - - public BoxIterationBuffer() { - } } public interface BoxIterationConsumer { diff --git a/src/com/hypixel/hytale/math/iterator/CircleSpiralIterator.java b/src/com/hypixel/hytale/math/iterator/CircleSpiralIterator.java index d1f6493..85be388 100644 --- a/src/com/hypixel/hytale/math/iterator/CircleSpiralIterator.java +++ b/src/com/hypixel/hytale/math/iterator/CircleSpiralIterator.java @@ -21,9 +21,6 @@ public class CircleSpiralIterator { private boolean hasNext; private long nextChunk; - public CircleSpiralIterator() { - } - public void init(int chunkX, int chunkZ, int radiusTo) { this.init(chunkX, chunkZ, 0, radiusTo); } diff --git a/src/com/hypixel/hytale/math/raycast/RaycastAABB.java b/src/com/hypixel/hytale/math/raycast/RaycastAABB.java index 047269d..b973066 100644 --- a/src/com/hypixel/hytale/math/raycast/RaycastAABB.java +++ b/src/com/hypixel/hytale/math/raycast/RaycastAABB.java @@ -5,9 +5,6 @@ import javax.annotation.Nonnull; public class RaycastAABB { public static final double EPSILON = -1.0E-8; - public RaycastAABB() { - } - public static double intersect( double minX, double minY, double minZ, double maxX, double maxY, double maxZ, double ox, double oy, double oz, double dx, double dy, double dz ) { diff --git a/src/com/hypixel/hytale/math/util/NumberUtil.java b/src/com/hypixel/hytale/math/util/NumberUtil.java index 32c2d9b..58d3586 100644 --- a/src/com/hypixel/hytale/math/util/NumberUtil.java +++ b/src/com/hypixel/hytale/math/util/NumberUtil.java @@ -1,9 +1,6 @@ package com.hypixel.hytale.math.util; public class NumberUtil { - public NumberUtil() { - } - public static short sum(short a, short b) { return (short)(a + b); } diff --git a/src/com/hypixel/hytale/math/util/TrigMathUtil.java b/src/com/hypixel/hytale/math/util/TrigMathUtil.java index da59f46..cfd0247 100644 --- a/src/com/hypixel/hytale/math/util/TrigMathUtil.java +++ b/src/com/hypixel/hytale/math/util/TrigMathUtil.java @@ -51,9 +51,6 @@ public class TrigMathUtil { private static final int SIZE_AR = 100001; private static final float[] ATAN2 = new float[100001]; - private Icecore() { - } - public static float atan2(float y, float x) { if (y < 0.0F) { if (x < 0.0F) { @@ -94,9 +91,6 @@ public class TrigMathUtil { @Nonnull private static final float[] COS = new float[SIN_COUNT]; - private Riven() { - } - public static float sin(float rad) { return SIN[(int)(rad * radToIndex) & SIN_MASK]; } diff --git a/src/com/hypixel/hytale/math/vector/VectorBoxUtil.java b/src/com/hypixel/hytale/math/vector/VectorBoxUtil.java index d4aa054..6912e04 100644 --- a/src/com/hypixel/hytale/math/vector/VectorBoxUtil.java +++ b/src/com/hypixel/hytale/math/vector/VectorBoxUtil.java @@ -13,9 +13,6 @@ import java.util.function.Function; import javax.annotation.Nonnull; public class VectorBoxUtil { - public VectorBoxUtil() { - } - public static void forEachVector(Iterable vectors, double originX, double originY, double originZ, double apothem, Consumer consumer) { forEachVector(vectors, originX, originY, originZ, apothem, apothem, apothem, consumer); } diff --git a/src/com/hypixel/hytale/math/vector/VectorSphereUtil.java b/src/com/hypixel/hytale/math/vector/VectorSphereUtil.java index e210f20..c171355 100644 --- a/src/com/hypixel/hytale/math/vector/VectorSphereUtil.java +++ b/src/com/hypixel/hytale/math/vector/VectorSphereUtil.java @@ -13,9 +13,6 @@ import java.util.function.Function; import javax.annotation.Nonnull; public class VectorSphereUtil { - public VectorSphereUtil() { - } - public static void forEachVector(Iterable vectors, double originX, double originY, double originZ, double radius, Consumer consumer) { forEachVector(vectors, originX, originY, originZ, radius, radius, radius, consumer); } diff --git a/src/com/hypixel/hytale/metrics/ExecutorMetricsRegistry.java b/src/com/hypixel/hytale/metrics/ExecutorMetricsRegistry.java index 6da7f51..25be242 100644 --- a/src/com/hypixel/hytale/metrics/ExecutorMetricsRegistry.java +++ b/src/com/hypixel/hytale/metrics/ExecutorMetricsRegistry.java @@ -9,9 +9,6 @@ import javax.annotation.Nonnull; import org.bson.BsonValue; public class ExecutorMetricsRegistry extends MetricsRegistry { - public ExecutorMetricsRegistry() { - } - public BsonValue encode(@Nonnull T t, ExtraInfo extraInfo) { return t.isInThread() ? super.encode(t, extraInfo) : CompletableFuture.supplyAsync(() -> super.encode(t, extraInfo), t).join(); } diff --git a/src/com/hypixel/hytale/metrics/JVMMetrics.java b/src/com/hypixel/hytale/metrics/JVMMetrics.java index b886c4f..a16b1ab 100644 --- a/src/com/hypixel/hytale/metrics/JVMMetrics.java +++ b/src/com/hypixel/hytale/metrics/JVMMetrics.java @@ -35,9 +35,6 @@ public class JVMMetrics { @Nonnull public static final MetricsRegistry METRICS_REGISTRY = new MetricsRegistry<>(); - public JVMMetrics() { - } - static { CLASS_LOADER_METRICS_REGISTRY.register("Name", ClassLoader::getName, Codec.STRING); CLASS_LOADER_METRICS_REGISTRY.register("Parent", ClassLoader::getParent, CLASS_LOADER_METRICS_REGISTRY); diff --git a/src/com/hypixel/hytale/metrics/MetricResults.java b/src/com/hypixel/hytale/metrics/MetricResults.java index 67666da..9be5f17 100644 --- a/src/com/hypixel/hytale/metrics/MetricResults.java +++ b/src/com/hypixel/hytale/metrics/MetricResults.java @@ -27,9 +27,6 @@ public class MetricResults { } private static class MetricResultsCodec implements Codec { - private MetricResultsCodec() { - } - @Nullable public MetricResults decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { return Codec.isNullBsonValue(bsonValue) ? null : new MetricResults(bsonValue.asDocument()); diff --git a/src/com/hypixel/hytale/metrics/metric/AverageCollector.java b/src/com/hypixel/hytale/metrics/metric/AverageCollector.java index bb1e3b9..0ec8dc6 100644 --- a/src/com/hypixel/hytale/metrics/metric/AverageCollector.java +++ b/src/com/hypixel/hytale/metrics/metric/AverageCollector.java @@ -4,9 +4,6 @@ public class AverageCollector { private double val = 0.0; private long n = 0L; - public AverageCollector() { - } - public double get() { return this.val; } diff --git a/src/com/hypixel/hytale/metrics/metric/SynchronizedAverageCollector.java b/src/com/hypixel/hytale/metrics/metric/SynchronizedAverageCollector.java index a272b7c..2769197 100644 --- a/src/com/hypixel/hytale/metrics/metric/SynchronizedAverageCollector.java +++ b/src/com/hypixel/hytale/metrics/metric/SynchronizedAverageCollector.java @@ -1,9 +1,6 @@ package com.hypixel.hytale.metrics.metric; public class SynchronizedAverageCollector extends AverageCollector { - public SynchronizedAverageCollector() { - } - @Override public synchronized double get() { return super.get(); diff --git a/src/com/hypixel/hytale/procedurallib/NoiseType.java b/src/com/hypixel/hytale/procedurallib/NoiseType.java index 51ae549..cd32c78 100644 --- a/src/com/hypixel/hytale/procedurallib/NoiseType.java +++ b/src/com/hypixel/hytale/procedurallib/NoiseType.java @@ -12,7 +12,4 @@ public enum NoiseType { MESH, BRANCH, POINT; - - private NoiseType() { - } } diff --git a/src/com/hypixel/hytale/procedurallib/condition/DoubleThreshold.java b/src/com/hypixel/hytale/procedurallib/condition/DoubleThreshold.java index fd298fb..928630c 100644 --- a/src/com/hypixel/hytale/procedurallib/condition/DoubleThreshold.java +++ b/src/com/hypixel/hytale/procedurallib/condition/DoubleThreshold.java @@ -4,9 +4,6 @@ import java.util.Arrays; import javax.annotation.Nonnull; public class DoubleThreshold { - public DoubleThreshold() { - } - public static class Multiple implements IDoubleThreshold { protected final DoubleThreshold.Single[] singles; diff --git a/src/com/hypixel/hytale/procedurallib/json/JsonLoader.java b/src/com/hypixel/hytale/procedurallib/json/JsonLoader.java index a31a581..957a9b4 100644 --- a/src/com/hypixel/hytale/procedurallib/json/JsonLoader.java +++ b/src/com/hypixel/hytale/procedurallib/json/JsonLoader.java @@ -8,6 +8,7 @@ import com.google.gson.stream.JsonReader; import java.io.File; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Objects; import java.util.function.Function; import java.util.function.Predicate; import javax.annotation.Nonnull; @@ -30,15 +31,26 @@ public abstract class JsonLoader extends Loader return this.json != null && this.json.isJsonObject() && this.json.getAsJsonObject().has(name); } + @Nonnull + public JsonElement getOrLoad(@Nonnull JsonElement element) { + if (element.isJsonObject()) { + JsonObject obj = element.getAsJsonObject(); + JsonElement path = obj.get("File"); + if (path != null && path.isJsonPrimitive() && path.getAsJsonPrimitive().isString()) { + JsonElement loaded = this.loadFileElem(path.getAsString()); + element = Objects.requireNonNullElse(loaded, element); + } + } + + return element; + } + @Nullable public JsonElement get(String name) { if (this.json != null && this.json.isJsonObject()) { JsonElement element = this.json.getAsJsonObject().get(name); if (element != null && element.isJsonObject()) { - JsonObject object = element.getAsJsonObject(); - if (object.has("File")) { - element = this.loadFileElem(object.get("File").getAsString()); - } + element = this.getOrLoad(element); } return element; diff --git a/src/com/hypixel/hytale/procedurallib/logic/DoubleArray.java b/src/com/hypixel/hytale/procedurallib/logic/DoubleArray.java index 0fb8eb8..9f16a6e 100644 --- a/src/com/hypixel/hytale/procedurallib/logic/DoubleArray.java +++ b/src/com/hypixel/hytale/procedurallib/logic/DoubleArray.java @@ -3,9 +3,6 @@ package com.hypixel.hytale.procedurallib.logic; import javax.annotation.Nonnull; public class DoubleArray { - public DoubleArray() { - } - public static class Double2 { public final double x; public final double y; diff --git a/src/com/hypixel/hytale/procedurallib/logic/ResultBuffer.java b/src/com/hypixel/hytale/procedurallib/logic/ResultBuffer.java index 9a843d3..e7d0273 100644 --- a/src/com/hypixel/hytale/procedurallib/logic/ResultBuffer.java +++ b/src/com/hypixel/hytale/procedurallib/logic/ResultBuffer.java @@ -5,18 +5,12 @@ public class ResultBuffer { public static final ResultBuffer.ResultBuffer2d buffer2d = new ResultBuffer.ResultBuffer2d(); public static final ResultBuffer.ResultBuffer3d buffer3d = new ResultBuffer.ResultBuffer3d(); - public ResultBuffer() { - } - public static class Bounds2d { public double minX; public double minY; public double maxX; public double maxY; - public Bounds2d() { - } - public void assign(double minX, double minY, double maxX, double maxY) { this.minX = minX; this.minY = minY; @@ -43,9 +37,6 @@ public class ResultBuffer { public double x2; public double y2; - public ResultBuffer2d() { - } - public void register(int hash, int ix, int iy, double distance, double x, double y) { if (distance < this.distance) { this.ix = ix; @@ -100,9 +91,6 @@ public class ResultBuffer { public double y2; public double z2; - public ResultBuffer3d() { - } - public void register(int hash, int ix, int iy, int iz, double distance, double x, double y, double z) { if (distance < this.distance) { this.hash = hash; diff --git a/src/com/hypixel/hytale/procedurallib/logic/cell/CellType.java b/src/com/hypixel/hytale/procedurallib/logic/cell/CellType.java index 0342edb..0e12fbc 100644 --- a/src/com/hypixel/hytale/procedurallib/logic/cell/CellType.java +++ b/src/com/hypixel/hytale/procedurallib/logic/cell/CellType.java @@ -3,7 +3,4 @@ package com.hypixel.hytale.procedurallib.logic.cell; public enum CellType { SQUARE, HEX; - - private CellType() { - } } diff --git a/src/com/hypixel/hytale/procedurallib/logic/cell/GridCellDistanceFunction.java b/src/com/hypixel/hytale/procedurallib/logic/cell/GridCellDistanceFunction.java index 5320757..02f8407 100644 --- a/src/com/hypixel/hytale/procedurallib/logic/cell/GridCellDistanceFunction.java +++ b/src/com/hypixel/hytale/procedurallib/logic/cell/GridCellDistanceFunction.java @@ -33,9 +33,6 @@ public class GridCellDistanceFunction implements CellDistanceFunction { } }; - public GridCellDistanceFunction() { - } - @Override public void nearest2D(int seed, double x, double y, int cellX, int cellY, ResultBuffer.ResultBuffer2d buffer, @Nonnull PointEvaluator pointEvaluator) { for (int cy = cellY - 1; cy <= cellY + 1; cy++) { diff --git a/src/com/hypixel/hytale/procedurallib/logic/cell/HexCellDistanceFunction.java b/src/com/hypixel/hytale/procedurallib/logic/cell/HexCellDistanceFunction.java index 2d52427..c1440f4 100644 --- a/src/com/hypixel/hytale/procedurallib/logic/cell/HexCellDistanceFunction.java +++ b/src/com/hypixel/hytale/procedurallib/logic/cell/HexCellDistanceFunction.java @@ -55,9 +55,6 @@ public class HexCellDistanceFunction implements CellDistanceFunction { .map(d -> new DoubleArray.Double2(d.x - 0.5, d.y - 0.5)) .toArray(DoubleArray.Double2[]::new); - public HexCellDistanceFunction() { - } - @Override public double scale(double value) { return value * SCALE; @@ -256,9 +253,6 @@ public class HexCellDistanceFunction implements CellDistanceFunction { protected static final int BIT_NOISE2 = -1255572915; protected static final int BIT_NOISE3 = -1255572915; - public SquirrelHash() { - } - public static int hash(int seed, int x, int y) { int hash = x + y * 198491317; hash *= -1255572915; diff --git a/src/com/hypixel/hytale/procedurallib/logic/cell/MeasurementMode.java b/src/com/hypixel/hytale/procedurallib/logic/cell/MeasurementMode.java index d69ef4d..d392ae5 100644 --- a/src/com/hypixel/hytale/procedurallib/logic/cell/MeasurementMode.java +++ b/src/com/hypixel/hytale/procedurallib/logic/cell/MeasurementMode.java @@ -3,7 +3,4 @@ package com.hypixel.hytale.procedurallib.logic.cell; public enum MeasurementMode { CENTRE_DISTANCE, BORDER_DISTANCE; - - private MeasurementMode() { - } } diff --git a/src/com/hypixel/hytale/procedurallib/logic/cell/evaluator/BorderPointEvaluator.java b/src/com/hypixel/hytale/procedurallib/logic/cell/evaluator/BorderPointEvaluator.java index 27b2ddd..38ec92f 100644 --- a/src/com/hypixel/hytale/procedurallib/logic/cell/evaluator/BorderPointEvaluator.java +++ b/src/com/hypixel/hytale/procedurallib/logic/cell/evaluator/BorderPointEvaluator.java @@ -7,9 +7,6 @@ import javax.annotation.Nonnull; public class BorderPointEvaluator implements PointEvaluator { public static final BorderPointEvaluator INSTANCE = new BorderPointEvaluator(); - public BorderPointEvaluator() { - } - @Override public void evalPoint( int seed, double x, double y, int cellHash, int cellX, int cellY, double cellPointX, double cellPointY, @Nonnull ResultBuffer.ResultBuffer2d buffer diff --git a/src/com/hypixel/hytale/procedurallib/logic/cell/evaluator/BranchEvaluator.java b/src/com/hypixel/hytale/procedurallib/logic/cell/evaluator/BranchEvaluator.java index dac22eb..29c3f74 100644 --- a/src/com/hypixel/hytale/procedurallib/logic/cell/evaluator/BranchEvaluator.java +++ b/src/com/hypixel/hytale/procedurallib/logic/cell/evaluator/BranchEvaluator.java @@ -135,8 +135,5 @@ public class BranchEvaluator implements PointEvaluator { OUTWARD, INWARD, RANDOM; - - private Direction() { - } } } diff --git a/src/com/hypixel/hytale/procedurallib/logic/cell/evaluator/SkipCellPointEvaluator.java b/src/com/hypixel/hytale/procedurallib/logic/cell/evaluator/SkipCellPointEvaluator.java index b22c79f..e07d5dd 100644 --- a/src/com/hypixel/hytale/procedurallib/logic/cell/evaluator/SkipCellPointEvaluator.java +++ b/src/com/hypixel/hytale/procedurallib/logic/cell/evaluator/SkipCellPointEvaluator.java @@ -5,7 +5,6 @@ import com.hypixel.hytale.procedurallib.logic.cell.jitter.CellJitter; import com.hypixel.hytale.procedurallib.logic.point.PointConsumer; import it.unimi.dsi.fastutil.HashCommon; import javax.annotation.Nonnull; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class SkipCellPointEvaluator implements PointEvaluator { @Nonnull @@ -83,7 +82,7 @@ public class SkipCellPointEvaluator implements PointEvaluator { } @Override - public void collectPoint(int cellHash, int cellX, int cellY, double cellCentreX, double cellCentreY, T ctx, @NonNullDecl PointConsumer consumer) { + public void collectPoint(int cellHash, int cellX, int cellY, double cellCentreX, double cellCentreY, T ctx, @Nonnull PointConsumer consumer) { if (!this.skip(this.mode, cellX, cellY)) { this.pointEvaluator.collectPoint(cellHash, cellX, cellY, cellCentreX, cellCentreY, ctx, consumer); } @@ -99,8 +98,5 @@ public class SkipCellPointEvaluator implements PointEvaluator { public static enum Mode { CHECKERBOARD, GRID; - - private Mode() { - } } } diff --git a/src/com/hypixel/hytale/procedurallib/logic/cell/jitter/DefaultCellJitter.java b/src/com/hypixel/hytale/procedurallib/logic/cell/jitter/DefaultCellJitter.java index 9ce5331..8236f34 100644 --- a/src/com/hypixel/hytale/procedurallib/logic/cell/jitter/DefaultCellJitter.java +++ b/src/com/hypixel/hytale/procedurallib/logic/cell/jitter/DefaultCellJitter.java @@ -6,9 +6,6 @@ import javax.annotation.Nonnull; public class DefaultCellJitter implements CellJitter { public static final CellJitter DEFAULT_ONE = new DefaultCellJitter(); - public DefaultCellJitter() { - } - @Override public double getMaxX() { return 1.0; diff --git a/src/com/hypixel/hytale/procedurallib/property/GradientNoiseProperty.java b/src/com/hypixel/hytale/procedurallib/property/GradientNoiseProperty.java index b90b156..362f053 100644 --- a/src/com/hypixel/hytale/procedurallib/property/GradientNoiseProperty.java +++ b/src/com/hypixel/hytale/procedurallib/property/GradientNoiseProperty.java @@ -61,8 +61,5 @@ public class GradientNoiseProperty implements NoiseProperty { MAGNITUDE, ANGLE, ANGLE_ABS; - - private GradientMode() { - } } } diff --git a/src/com/hypixel/hytale/procedurallib/property/NoisePropertyType.java b/src/com/hypixel/hytale/procedurallib/property/NoisePropertyType.java index 51981fb..4482824 100644 --- a/src/com/hypixel/hytale/procedurallib/property/NoisePropertyType.java +++ b/src/com/hypixel/hytale/procedurallib/property/NoisePropertyType.java @@ -15,7 +15,4 @@ public enum NoisePropertyType { GRADIENT, CURVE, BLEND; - - private NoisePropertyType() { - } } diff --git a/src/com/hypixel/hytale/procedurallib/random/CoordinateRandomizer.java b/src/com/hypixel/hytale/procedurallib/random/CoordinateRandomizer.java index 5dbc73a..83915f1 100644 --- a/src/com/hypixel/hytale/procedurallib/random/CoordinateRandomizer.java +++ b/src/com/hypixel/hytale/procedurallib/random/CoordinateRandomizer.java @@ -132,9 +132,6 @@ public class CoordinateRandomizer implements ICoordinateRandomizer { } private static class EmptyCoordinateRandomizer implements ICoordinateRandomizer { - private EmptyCoordinateRandomizer() { - } - @Override public double randomDoubleX(int seed, double x, double y) { return x; diff --git a/src/com/hypixel/hytale/procedurallib/supplier/DoubleRange.java b/src/com/hypixel/hytale/procedurallib/supplier/DoubleRange.java index ab0c7a1..99c51e5 100644 --- a/src/com/hypixel/hytale/procedurallib/supplier/DoubleRange.java +++ b/src/com/hypixel/hytale/procedurallib/supplier/DoubleRange.java @@ -9,9 +9,6 @@ public class DoubleRange { public static final DoubleRange.Constant ZERO = new DoubleRange.Constant(0.0); public static final DoubleRange.Constant ONE = new DoubleRange.Constant(1.0); - public DoubleRange() { - } - public static class Constant implements IDoubleRange { protected final double result; diff --git a/src/com/hypixel/hytale/procedurallib/supplier/FloatRange.java b/src/com/hypixel/hytale/procedurallib/supplier/FloatRange.java index 1e4dff2..684789d 100644 --- a/src/com/hypixel/hytale/procedurallib/supplier/FloatRange.java +++ b/src/com/hypixel/hytale/procedurallib/supplier/FloatRange.java @@ -7,9 +7,6 @@ public class FloatRange { public static final FloatRange.Constant ZERO = new FloatRange.Constant(0.0F); public static final FloatRange.Constant ONE = new FloatRange.Constant(1.0F); - public FloatRange() { - } - public static class Constant implements IFloatRange { protected final float result; diff --git a/src/com/hypixel/hytale/protocol/AmbienceFX.java b/src/com/hypixel/hytale/protocol/AmbienceFX.java index 3910966..ee27bc6 100644 --- a/src/com/hypixel/hytale/protocol/AmbienceFX.java +++ b/src/com/hypixel/hytale/protocol/AmbienceFX.java @@ -74,13 +74,13 @@ public class AmbienceFX { public static AmbienceFX deserialize(@Nonnull ByteBuf buf, int offset) { AmbienceFX obj = new AmbienceFX(); byte nullBits = buf.getByte(offset); - if ((nullBits & 32) != 0) { + if ((nullBits & 1) != 0) { obj.soundEffect = AmbienceFXSoundEffect.deserialize(buf, offset + 1); } obj.priority = buf.getIntLE(offset + 10); obj.audioCategoryIndex = buf.getIntLE(offset + 14); - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int varPos0 = offset + 42 + buf.getIntLE(offset + 18); int idLen = VarInt.peek(buf, varPos0); if (idLen < 0) { @@ -94,12 +94,12 @@ public class AmbienceFX { obj.id = PacketIO.readVarString(buf, varPos0, PacketIO.UTF8); } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int varPos1 = offset + 42 + buf.getIntLE(offset + 22); obj.conditions = AmbienceFXConditions.deserialize(buf, varPos1); } - if ((nullBits & 4) != 0) { + if ((nullBits & 8) != 0) { int varPos2 = offset + 42 + buf.getIntLE(offset + 26); int soundsCount = VarInt.peek(buf, varPos2); if (soundsCount < 0) { @@ -124,12 +124,12 @@ public class AmbienceFX { } } - if ((nullBits & 8) != 0) { + if ((nullBits & 16) != 0) { int varPos3 = offset + 42 + buf.getIntLE(offset + 30); obj.music = AmbienceFXMusic.deserialize(buf, varPos3); } - if ((nullBits & 16) != 0) { + if ((nullBits & 32) != 0) { int varPos4 = offset + 42 + buf.getIntLE(offset + 34); obj.ambientBed = AmbienceFXAmbientBed.deserialize(buf, varPos4); } @@ -163,7 +163,7 @@ public class AmbienceFX { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 42; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int fieldOffset0 = buf.getIntLE(offset + 18); int pos0 = offset + 42 + fieldOffset0; int sl = VarInt.peek(buf, pos0); @@ -173,7 +173,7 @@ public class AmbienceFX { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int fieldOffset1 = buf.getIntLE(offset + 22); int pos1 = offset + 42 + fieldOffset1; pos1 += AmbienceFXConditions.computeBytesConsumed(buf, pos1); @@ -182,7 +182,7 @@ public class AmbienceFX { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 8) != 0) { int fieldOffset2 = buf.getIntLE(offset + 26); int pos2 = offset + 42 + fieldOffset2; int arrLen = VarInt.peek(buf, pos2); @@ -197,7 +197,7 @@ public class AmbienceFX { } } - if ((nullBits & 8) != 0) { + if ((nullBits & 16) != 0) { int fieldOffset3 = buf.getIntLE(offset + 30); int pos3 = offset + 42 + fieldOffset3; pos3 += AmbienceFXMusic.computeBytesConsumed(buf, pos3); @@ -206,7 +206,7 @@ public class AmbienceFX { } } - if ((nullBits & 16) != 0) { + if ((nullBits & 32) != 0) { int fieldOffset4 = buf.getIntLE(offset + 34); int pos4 = offset + 42 + fieldOffset4; pos4 += AmbienceFXAmbientBed.computeBytesConsumed(buf, pos4); @@ -231,27 +231,27 @@ public class AmbienceFX { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.id != null) { + if (this.soundEffect != null) { nullBits = (byte)(nullBits | 1); } - if (this.conditions != null) { + if (this.id != null) { nullBits = (byte)(nullBits | 2); } - if (this.sounds != null) { + if (this.conditions != null) { nullBits = (byte)(nullBits | 4); } - if (this.music != null) { + if (this.sounds != null) { nullBits = (byte)(nullBits | 8); } - if (this.ambientBed != null) { + if (this.music != null) { nullBits = (byte)(nullBits | 16); } - if (this.soundEffect != null) { + if (this.ambientBed != null) { nullBits = (byte)(nullBits | 32); } @@ -374,7 +374,7 @@ public class AmbienceFX { return ValidationResult.error("Buffer too small: expected at least 42 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int idOffset = buffer.getIntLE(offset + 18); if (idOffset < 0) { return ValidationResult.error("Invalid offset for Id"); @@ -401,7 +401,7 @@ public class AmbienceFX { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int conditionsOffset = buffer.getIntLE(offset + 22); if (conditionsOffset < 0) { return ValidationResult.error("Invalid offset for Conditions"); @@ -420,7 +420,7 @@ public class AmbienceFX { posx += AmbienceFXConditions.computeBytesConsumed(buffer, posx); } - if ((nullBits & 4) != 0) { + if ((nullBits & 8) != 0) { int soundsOffset = buffer.getIntLE(offset + 26); if (soundsOffset < 0) { return ValidationResult.error("Invalid offset for Sounds"); @@ -447,7 +447,7 @@ public class AmbienceFX { } } - if ((nullBits & 8) != 0) { + if ((nullBits & 16) != 0) { int musicOffset = buffer.getIntLE(offset + 30); if (musicOffset < 0) { return ValidationResult.error("Invalid offset for Music"); @@ -466,7 +466,7 @@ public class AmbienceFX { posxxx += AmbienceFXMusic.computeBytesConsumed(buffer, posxxx); } - if ((nullBits & 16) != 0) { + if ((nullBits & 32) != 0) { int ambientBedOffset = buffer.getIntLE(offset + 34); if (ambientBedOffset < 0) { return ValidationResult.error("Invalid offset for AmbientBed"); diff --git a/src/com/hypixel/hytale/protocol/AmbienceFXConditions.java b/src/com/hypixel/hytale/protocol/AmbienceFXConditions.java index e1a8828..00d2c54 100644 --- a/src/com/hypixel/hytale/protocol/AmbienceFXConditions.java +++ b/src/com/hypixel/hytale/protocol/AmbienceFXConditions.java @@ -108,34 +108,34 @@ public class AmbienceFXConditions { obj.never = buf.getByte(offset + 2) != 0; obj.environmentTagPatternIndex = buf.getIntLE(offset + 3); obj.weatherTagPatternIndex = buf.getIntLE(offset + 7); - if ((nullBits[0] & 16) != 0) { + if ((nullBits[0] & 1) != 0) { obj.altitude = Range.deserialize(buf, offset + 11); } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[0] & 2) != 0) { obj.walls = Rangeb.deserialize(buf, offset + 19); } obj.roof = buf.getByte(offset + 21) != 0; obj.roofMaterialTagPatternIndex = buf.getIntLE(offset + 22); obj.floor = buf.getByte(offset + 26) != 0; - if ((nullBits[0] & 64) != 0) { + if ((nullBits[0] & 4) != 0) { obj.sunLightLevel = Rangeb.deserialize(buf, offset + 27); } - if ((nullBits[0] & 128) != 0) { + if ((nullBits[0] & 8) != 0) { obj.torchLightLevel = Rangeb.deserialize(buf, offset + 29); } - if ((nullBits[1] & 1) != 0) { + if ((nullBits[0] & 16) != 0) { obj.globalLightLevel = Rangeb.deserialize(buf, offset + 31); } - if ((nullBits[1] & 2) != 0) { + if ((nullBits[0] & 32) != 0) { obj.dayTime = Rangef.deserialize(buf, offset + 33); } - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 64) != 0) { int varPos0 = offset + 57 + buf.getIntLE(offset + 41); int environmentIndicesCount = VarInt.peek(buf, varPos0); if (environmentIndicesCount < 0) { @@ -158,7 +158,7 @@ public class AmbienceFXConditions { } } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 128) != 0) { int varPos1 = offset + 57 + buf.getIntLE(offset + 45); int weatherIndicesCount = VarInt.peek(buf, varPos1); if (weatherIndicesCount < 0) { @@ -181,7 +181,7 @@ public class AmbienceFXConditions { } } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[1] & 1) != 0) { int varPos2 = offset + 57 + buf.getIntLE(offset + 49); int fluidFXIndicesCount = VarInt.peek(buf, varPos2); if (fluidFXIndicesCount < 0) { @@ -204,7 +204,7 @@ public class AmbienceFXConditions { } } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[1] & 2) != 0) { int varPos3 = offset + 57 + buf.getIntLE(offset + 53); int surroundingBlockSoundSetsCount = VarInt.peek(buf, varPos3); if (surroundingBlockSoundSetsCount < 0) { @@ -235,7 +235,7 @@ public class AmbienceFXConditions { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte[] nullBits = PacketIO.readBytes(buf, offset, 2); int maxEnd = 57; - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 64) != 0) { int fieldOffset0 = buf.getIntLE(offset + 41); int pos0 = offset + 57 + fieldOffset0; int arrLen = VarInt.peek(buf, pos0); @@ -245,7 +245,7 @@ public class AmbienceFXConditions { } } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 128) != 0) { int fieldOffset1 = buf.getIntLE(offset + 45); int pos1 = offset + 57 + fieldOffset1; int arrLen = VarInt.peek(buf, pos1); @@ -255,7 +255,7 @@ public class AmbienceFXConditions { } } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[1] & 1) != 0) { int fieldOffset2 = buf.getIntLE(offset + 49); int pos2 = offset + 57 + fieldOffset2; int arrLen = VarInt.peek(buf, pos2); @@ -265,7 +265,7 @@ public class AmbienceFXConditions { } } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[1] & 2) != 0) { int fieldOffset3 = buf.getIntLE(offset + 53); int pos3 = offset + 57 + fieldOffset3; int arrLen = VarInt.peek(buf, pos3); @@ -286,43 +286,43 @@ public class AmbienceFXConditions { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte[] nullBits = new byte[2]; - if (this.environmentIndices != null) { + if (this.altitude != null) { nullBits[0] = (byte)(nullBits[0] | 1); } - if (this.weatherIndices != null) { + if (this.walls != null) { nullBits[0] = (byte)(nullBits[0] | 2); } - if (this.fluidFXIndices != null) { + if (this.sunLightLevel != null) { nullBits[0] = (byte)(nullBits[0] | 4); } - if (this.surroundingBlockSoundSets != null) { + if (this.torchLightLevel != null) { nullBits[0] = (byte)(nullBits[0] | 8); } - if (this.altitude != null) { + if (this.globalLightLevel != null) { nullBits[0] = (byte)(nullBits[0] | 16); } - if (this.walls != null) { + if (this.dayTime != null) { nullBits[0] = (byte)(nullBits[0] | 32); } - if (this.sunLightLevel != null) { + if (this.environmentIndices != null) { nullBits[0] = (byte)(nullBits[0] | 64); } - if (this.torchLightLevel != null) { + if (this.weatherIndices != null) { nullBits[0] = (byte)(nullBits[0] | 128); } - if (this.globalLightLevel != null) { + if (this.fluidFXIndices != null) { nullBits[1] = (byte)(nullBits[1] | 1); } - if (this.dayTime != null) { + if (this.surroundingBlockSoundSets != null) { nullBits[1] = (byte)(nullBits[1] | 2); } @@ -465,7 +465,7 @@ public class AmbienceFXConditions { return ValidationResult.error("Buffer too small: expected at least 57 bytes"); } else { byte[] nullBits = PacketIO.readBytes(buffer, offset, 2); - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 64) != 0) { int environmentIndicesOffset = buffer.getIntLE(offset + 41); if (environmentIndicesOffset < 0) { return ValidationResult.error("Invalid offset for EnvironmentIndices"); @@ -492,7 +492,7 @@ public class AmbienceFXConditions { } } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 128) != 0) { int weatherIndicesOffset = buffer.getIntLE(offset + 45); if (weatherIndicesOffset < 0) { return ValidationResult.error("Invalid offset for WeatherIndices"); @@ -519,7 +519,7 @@ public class AmbienceFXConditions { } } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[1] & 1) != 0) { int fluidFXIndicesOffset = buffer.getIntLE(offset + 49); if (fluidFXIndicesOffset < 0) { return ValidationResult.error("Invalid offset for FluidFXIndices"); @@ -546,7 +546,7 @@ public class AmbienceFXConditions { } } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[1] & 2) != 0) { int surroundingBlockSoundSetsOffset = buffer.getIntLE(offset + 53); if (surroundingBlockSoundSetsOffset < 0) { return ValidationResult.error("Invalid offset for SurroundingBlockSoundSets"); diff --git a/src/com/hypixel/hytale/protocol/AnimationSet.java b/src/com/hypixel/hytale/protocol/AnimationSet.java index a6c4c2d..86fcef0 100644 --- a/src/com/hypixel/hytale/protocol/AnimationSet.java +++ b/src/com/hypixel/hytale/protocol/AnimationSet.java @@ -42,11 +42,11 @@ public class AnimationSet { public static AnimationSet deserialize(@Nonnull ByteBuf buf, int offset) { AnimationSet obj = new AnimationSet(); byte nullBits = buf.getByte(offset); - if ((nullBits & 4) != 0) { + if ((nullBits & 1) != 0) { obj.nextAnimationDelay = Rangef.deserialize(buf, offset + 1); } - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int varPos0 = offset + 17 + buf.getIntLE(offset + 9); int idLen = VarInt.peek(buf, varPos0); if (idLen < 0) { @@ -60,7 +60,7 @@ public class AnimationSet { obj.id = PacketIO.readVarString(buf, varPos0, PacketIO.UTF8); } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int varPos1 = offset + 17 + buf.getIntLE(offset + 13); int animationsCount = VarInt.peek(buf, varPos1); if (animationsCount < 0) { @@ -91,7 +91,7 @@ public class AnimationSet { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 17; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int fieldOffset0 = buf.getIntLE(offset + 9); int pos0 = offset + 17 + fieldOffset0; int sl = VarInt.peek(buf, pos0); @@ -101,7 +101,7 @@ public class AnimationSet { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int fieldOffset1 = buf.getIntLE(offset + 13); int pos1 = offset + 17 + fieldOffset1; int arrLen = VarInt.peek(buf, pos1); @@ -122,15 +122,15 @@ public class AnimationSet { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.id != null) { + if (this.nextAnimationDelay != null) { nullBits = (byte)(nullBits | 1); } - if (this.animations != null) { + if (this.id != null) { nullBits = (byte)(nullBits | 2); } - if (this.nextAnimationDelay != null) { + if (this.animations != null) { nullBits = (byte)(nullBits | 4); } @@ -193,7 +193,7 @@ public class AnimationSet { return ValidationResult.error("Buffer too small: expected at least 17 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int idOffset = buffer.getIntLE(offset + 9); if (idOffset < 0) { return ValidationResult.error("Invalid offset for Id"); @@ -220,7 +220,7 @@ public class AnimationSet { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int animationsOffset = buffer.getIntLE(offset + 13); if (animationsOffset < 0) { return ValidationResult.error("Invalid offset for Animations"); diff --git a/src/com/hypixel/hytale/protocol/ApplicationEffects.java b/src/com/hypixel/hytale/protocol/ApplicationEffects.java index bb49f58..2f672a8 100644 --- a/src/com/hypixel/hytale/protocol/ApplicationEffects.java +++ b/src/com/hypixel/hytale/protocol/ApplicationEffects.java @@ -107,13 +107,13 @@ public class ApplicationEffects { obj.horizontalSpeedMultiplier = buf.getFloatLE(offset + 8); obj.soundEventIndexLocal = buf.getIntLE(offset + 12); obj.soundEventIndexWorld = buf.getIntLE(offset + 16); - if ((nullBits[0] & 128) != 0) { + if ((nullBits[0] & 4) != 0) { obj.movementEffects = MovementEffects.deserialize(buf, offset + 20); } obj.mouseSensitivityAdjustmentTarget = buf.getFloatLE(offset + 27); obj.mouseSensitivityAdjustmentDuration = buf.getFloatLE(offset + 31); - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 8) != 0) { int varPos0 = offset + 59 + buf.getIntLE(offset + 35); int entityAnimationIdLen = VarInt.peek(buf, varPos0); if (entityAnimationIdLen < 0) { @@ -127,7 +127,7 @@ public class ApplicationEffects { obj.entityAnimationId = PacketIO.readVarString(buf, varPos0, PacketIO.UTF8); } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[0] & 16) != 0) { int varPos1 = offset + 59 + buf.getIntLE(offset + 39); int particlesCount = VarInt.peek(buf, varPos1); if (particlesCount < 0) { @@ -152,7 +152,7 @@ public class ApplicationEffects { } } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[0] & 32) != 0) { int varPos2 = offset + 59 + buf.getIntLE(offset + 43); int firstPersonParticlesCount = VarInt.peek(buf, varPos2); if (firstPersonParticlesCount < 0) { @@ -177,7 +177,7 @@ public class ApplicationEffects { } } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[0] & 64) != 0) { int varPos3 = offset + 59 + buf.getIntLE(offset + 47); int screenEffectLen = VarInt.peek(buf, varPos3); if (screenEffectLen < 0) { @@ -191,7 +191,7 @@ public class ApplicationEffects { obj.screenEffect = PacketIO.readVarString(buf, varPos3, PacketIO.UTF8); } - if ((nullBits[0] & 64) != 0) { + if ((nullBits[0] & 128) != 0) { int varPos4 = offset + 59 + buf.getIntLE(offset + 51); int modelVFXIdLen = VarInt.peek(buf, varPos4); if (modelVFXIdLen < 0) { @@ -216,7 +216,7 @@ public class ApplicationEffects { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte[] nullBits = PacketIO.readBytes(buf, offset, 2); int maxEnd = 59; - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 8) != 0) { int fieldOffset0 = buf.getIntLE(offset + 35); int pos0 = offset + 59 + fieldOffset0; int sl = VarInt.peek(buf, pos0); @@ -226,7 +226,7 @@ public class ApplicationEffects { } } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[0] & 16) != 0) { int fieldOffset1 = buf.getIntLE(offset + 39); int pos1 = offset + 59 + fieldOffset1; int arrLen = VarInt.peek(buf, pos1); @@ -241,7 +241,7 @@ public class ApplicationEffects { } } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[0] & 32) != 0) { int fieldOffset2 = buf.getIntLE(offset + 43); int pos2 = offset + 59 + fieldOffset2; int arrLen = VarInt.peek(buf, pos2); @@ -256,7 +256,7 @@ public class ApplicationEffects { } } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[0] & 64) != 0) { int fieldOffset3 = buf.getIntLE(offset + 47); int pos3 = offset + 59 + fieldOffset3; int sl = VarInt.peek(buf, pos3); @@ -266,7 +266,7 @@ public class ApplicationEffects { } } - if ((nullBits[0] & 64) != 0) { + if ((nullBits[0] & 128) != 0) { int fieldOffset4 = buf.getIntLE(offset + 51); int pos4 = offset + 59 + fieldOffset4; int sl = VarInt.peek(buf, pos4); @@ -299,27 +299,27 @@ public class ApplicationEffects { nullBits[0] = (byte)(nullBits[0] | 2); } - if (this.entityAnimationId != null) { + if (this.movementEffects != null) { nullBits[0] = (byte)(nullBits[0] | 4); } - if (this.particles != null) { + if (this.entityAnimationId != null) { nullBits[0] = (byte)(nullBits[0] | 8); } - if (this.firstPersonParticles != null) { + if (this.particles != null) { nullBits[0] = (byte)(nullBits[0] | 16); } - if (this.screenEffect != null) { + if (this.firstPersonParticles != null) { nullBits[0] = (byte)(nullBits[0] | 32); } - if (this.modelVFXId != null) { + if (this.screenEffect != null) { nullBits[0] = (byte)(nullBits[0] | 64); } - if (this.movementEffects != null) { + if (this.modelVFXId != null) { nullBits[0] = (byte)(nullBits[0] | 128); } @@ -469,7 +469,7 @@ public class ApplicationEffects { return ValidationResult.error("Buffer too small: expected at least 59 bytes"); } else { byte[] nullBits = PacketIO.readBytes(buffer, offset, 2); - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 8) != 0) { int entityAnimationIdOffset = buffer.getIntLE(offset + 35); if (entityAnimationIdOffset < 0) { return ValidationResult.error("Invalid offset for EntityAnimationId"); @@ -496,7 +496,7 @@ public class ApplicationEffects { } } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[0] & 16) != 0) { int particlesOffset = buffer.getIntLE(offset + 39); if (particlesOffset < 0) { return ValidationResult.error("Invalid offset for Particles"); @@ -528,7 +528,7 @@ public class ApplicationEffects { } } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[0] & 32) != 0) { int firstPersonParticlesOffset = buffer.getIntLE(offset + 43); if (firstPersonParticlesOffset < 0) { return ValidationResult.error("Invalid offset for FirstPersonParticles"); @@ -560,7 +560,7 @@ public class ApplicationEffects { } } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[0] & 64) != 0) { int screenEffectOffset = buffer.getIntLE(offset + 47); if (screenEffectOffset < 0) { return ValidationResult.error("Invalid offset for ScreenEffect"); @@ -587,7 +587,7 @@ public class ApplicationEffects { } } - if ((nullBits[0] & 64) != 0) { + if ((nullBits[0] & 128) != 0) { int modelVFXIdOffset = buffer.getIntLE(offset + 51); if (modelVFXIdOffset < 0) { return ValidationResult.error("Invalid offset for ModelVFXId"); diff --git a/src/com/hypixel/hytale/protocol/ApplyForceInteraction.java b/src/com/hypixel/hytale/protocol/ApplyForceInteraction.java index fb7f95d..22041f1 100644 --- a/src/com/hypixel/hytale/protocol/ApplyForceInteraction.java +++ b/src/com/hypixel/hytale/protocol/ApplyForceInteraction.java @@ -133,13 +133,13 @@ public class ApplyForceInteraction extends SimpleInteraction { obj.cancelOnItemChange = buf.getByte(offset + 10) != 0; obj.next = buf.getIntLE(offset + 11); obj.failed = buf.getIntLE(offset + 15); - if ((nullBits & 32) != 0) { + if ((nullBits & 1) != 0) { obj.velocityConfig = VelocityConfig.deserialize(buf, offset + 19); } obj.changeVelocityType = ChangeVelocityType.fromValue(buf.getByte(offset + 40)); obj.duration = buf.getFloatLE(offset + 41); - if ((nullBits & 128) != 0) { + if ((nullBits & 2) != 0) { obj.verticalClamp = FloatRange.deserialize(buf, offset + 45); } @@ -152,12 +152,12 @@ public class ApplyForceInteraction extends SimpleInteraction { obj.raycastDistance = buf.getFloatLE(offset + 71); obj.raycastHeightOffset = buf.getFloatLE(offset + 75); obj.raycastMode = RaycastMode.fromValue(buf.getByte(offset + 79)); - if ((nullBits & 1) != 0) { + if ((nullBits & 4) != 0) { int varPos0 = offset + 104 + buf.getIntLE(offset + 80); obj.effects = InteractionEffects.deserialize(buf, varPos0); } - if ((nullBits & 2) != 0) { + if ((nullBits & 8) != 0) { int varPos1 = offset + 104 + buf.getIntLE(offset + 84); int settingsCount = VarInt.peek(buf, varPos1); if (settingsCount < 0) { @@ -182,12 +182,12 @@ public class ApplyForceInteraction extends SimpleInteraction { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 16) != 0) { int varPos2 = offset + 104 + buf.getIntLE(offset + 88); obj.rules = InteractionRules.deserialize(buf, varPos2); } - if ((nullBits & 8) != 0) { + if ((nullBits & 32) != 0) { int varPos3 = offset + 104 + buf.getIntLE(offset + 92); int tagsCount = VarInt.peek(buf, varPos3); if (tagsCount < 0) { @@ -210,12 +210,12 @@ public class ApplyForceInteraction extends SimpleInteraction { } } - if ((nullBits & 16) != 0) { + if ((nullBits & 64) != 0) { int varPos4 = offset + 104 + buf.getIntLE(offset + 96); obj.camera = InteractionCameraSettings.deserialize(buf, varPos4); } - if ((nullBits & 64) != 0) { + if ((nullBits & 128) != 0) { int varPos5 = offset + 104 + buf.getIntLE(offset + 100); int forcesCount = VarInt.peek(buf, varPos5); if (forcesCount < 0) { @@ -246,7 +246,7 @@ public class ApplyForceInteraction extends SimpleInteraction { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 104; - if ((nullBits & 1) != 0) { + if ((nullBits & 4) != 0) { int fieldOffset0 = buf.getIntLE(offset + 80); int pos0 = offset + 104 + fieldOffset0; pos0 += InteractionEffects.computeBytesConsumed(buf, pos0); @@ -255,7 +255,7 @@ public class ApplyForceInteraction extends SimpleInteraction { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 8) != 0) { int fieldOffset1 = buf.getIntLE(offset + 84); int pos1 = offset + 104 + fieldOffset1; int dictLen = VarInt.peek(buf, pos1); @@ -270,7 +270,7 @@ public class ApplyForceInteraction extends SimpleInteraction { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 16) != 0) { int fieldOffset2 = buf.getIntLE(offset + 88); int pos2 = offset + 104 + fieldOffset2; pos2 += InteractionRules.computeBytesConsumed(buf, pos2); @@ -279,7 +279,7 @@ public class ApplyForceInteraction extends SimpleInteraction { } } - if ((nullBits & 8) != 0) { + if ((nullBits & 32) != 0) { int fieldOffset3 = buf.getIntLE(offset + 92); int pos3 = offset + 104 + fieldOffset3; int arrLen = VarInt.peek(buf, pos3); @@ -289,7 +289,7 @@ public class ApplyForceInteraction extends SimpleInteraction { } } - if ((nullBits & 16) != 0) { + if ((nullBits & 64) != 0) { int fieldOffset4 = buf.getIntLE(offset + 96); int pos4 = offset + 104 + fieldOffset4; pos4 += InteractionCameraSettings.computeBytesConsumed(buf, pos4); @@ -298,7 +298,7 @@ public class ApplyForceInteraction extends SimpleInteraction { } } - if ((nullBits & 64) != 0) { + if ((nullBits & 128) != 0) { int fieldOffset5 = buf.getIntLE(offset + 100); int pos5 = offset + 104 + fieldOffset5; int arrLen = VarInt.peek(buf, pos5); @@ -320,35 +320,35 @@ public class ApplyForceInteraction extends SimpleInteraction { public int serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.effects != null) { + if (this.velocityConfig != null) { nullBits = (byte)(nullBits | 1); } - if (this.settings != null) { + if (this.verticalClamp != null) { nullBits = (byte)(nullBits | 2); } - if (this.rules != null) { + if (this.effects != null) { nullBits = (byte)(nullBits | 4); } - if (this.tags != null) { + if (this.settings != null) { nullBits = (byte)(nullBits | 8); } - if (this.camera != null) { + if (this.rules != null) { nullBits = (byte)(nullBits | 16); } - if (this.velocityConfig != null) { + if (this.tags != null) { nullBits = (byte)(nullBits | 32); } - if (this.forces != null) { + if (this.camera != null) { nullBits = (byte)(nullBits | 64); } - if (this.verticalClamp != null) { + if (this.forces != null) { nullBits = (byte)(nullBits | 128); } @@ -500,7 +500,7 @@ public class ApplyForceInteraction extends SimpleInteraction { return ValidationResult.error("Buffer too small: expected at least 104 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 4) != 0) { int effectsOffset = buffer.getIntLE(offset + 80); if (effectsOffset < 0) { return ValidationResult.error("Invalid offset for Effects"); @@ -519,7 +519,7 @@ public class ApplyForceInteraction extends SimpleInteraction { pos += InteractionEffects.computeBytesConsumed(buffer, pos); } - if ((nullBits & 2) != 0) { + if ((nullBits & 8) != 0) { int settingsOffset = buffer.getIntLE(offset + 84); if (settingsOffset < 0) { return ValidationResult.error("Invalid offset for Settings"); @@ -547,7 +547,7 @@ public class ApplyForceInteraction extends SimpleInteraction { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 16) != 0) { int rulesOffset = buffer.getIntLE(offset + 88); if (rulesOffset < 0) { return ValidationResult.error("Invalid offset for Rules"); @@ -566,7 +566,7 @@ public class ApplyForceInteraction extends SimpleInteraction { posxx += InteractionRules.computeBytesConsumed(buffer, posxx); } - if ((nullBits & 8) != 0) { + if ((nullBits & 32) != 0) { int tagsOffset = buffer.getIntLE(offset + 92); if (tagsOffset < 0) { return ValidationResult.error("Invalid offset for Tags"); @@ -593,7 +593,7 @@ public class ApplyForceInteraction extends SimpleInteraction { } } - if ((nullBits & 16) != 0) { + if ((nullBits & 64) != 0) { int cameraOffset = buffer.getIntLE(offset + 96); if (cameraOffset < 0) { return ValidationResult.error("Invalid offset for Camera"); @@ -612,7 +612,7 @@ public class ApplyForceInteraction extends SimpleInteraction { posxxxx += InteractionCameraSettings.computeBytesConsumed(buffer, posxxxx); } - if ((nullBits & 64) != 0) { + if ((nullBits & 128) != 0) { int forcesOffset = buffer.getIntLE(offset + 100); if (forcesOffset < 0) { return ValidationResult.error("Invalid offset for Forces"); diff --git a/src/com/hypixel/hytale/protocol/BlockParticleSet.java b/src/com/hypixel/hytale/protocol/BlockParticleSet.java index 4ef7407..8e398f7 100644 --- a/src/com/hypixel/hytale/protocol/BlockParticleSet.java +++ b/src/com/hypixel/hytale/protocol/BlockParticleSet.java @@ -62,20 +62,20 @@ public class BlockParticleSet { public static BlockParticleSet deserialize(@Nonnull ByteBuf buf, int offset) { BlockParticleSet obj = new BlockParticleSet(); byte nullBits = buf.getByte(offset); - if ((nullBits & 2) != 0) { + if ((nullBits & 1) != 0) { obj.color = Color.deserialize(buf, offset + 1); } obj.scale = buf.getFloatLE(offset + 4); - if ((nullBits & 4) != 0) { + if ((nullBits & 2) != 0) { obj.positionOffset = Vector3f.deserialize(buf, offset + 8); } - if ((nullBits & 8) != 0) { + if ((nullBits & 4) != 0) { obj.rotationOffset = Direction.deserialize(buf, offset + 20); } - if ((nullBits & 1) != 0) { + if ((nullBits & 8) != 0) { int varPos0 = offset + 40 + buf.getIntLE(offset + 32); int idLen = VarInt.peek(buf, varPos0); if (idLen < 0) { @@ -130,7 +130,7 @@ public class BlockParticleSet { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 40; - if ((nullBits & 1) != 0) { + if ((nullBits & 8) != 0) { int fieldOffset0 = buf.getIntLE(offset + 32); int pos0 = offset + 40 + fieldOffset0; int sl = VarInt.peek(buf, pos0); @@ -162,19 +162,19 @@ public class BlockParticleSet { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.id != null) { + if (this.color != null) { nullBits = (byte)(nullBits | 1); } - if (this.color != null) { + if (this.positionOffset != null) { nullBits = (byte)(nullBits | 2); } - if (this.positionOffset != null) { + if (this.rotationOffset != null) { nullBits = (byte)(nullBits | 4); } - if (this.rotationOffset != null) { + if (this.id != null) { nullBits = (byte)(nullBits | 8); } @@ -255,7 +255,7 @@ public class BlockParticleSet { return ValidationResult.error("Buffer too small: expected at least 40 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 8) != 0) { int idOffset = buffer.getIntLE(offset + 32); if (idOffset < 0) { return ValidationResult.error("Invalid offset for Id"); diff --git a/src/com/hypixel/hytale/protocol/BlockSoundSet.java b/src/com/hypixel/hytale/protocol/BlockSoundSet.java index a699f34..5c2425e 100644 --- a/src/com/hypixel/hytale/protocol/BlockSoundSet.java +++ b/src/com/hypixel/hytale/protocol/BlockSoundSet.java @@ -44,11 +44,11 @@ public class BlockSoundSet { public static BlockSoundSet deserialize(@Nonnull ByteBuf buf, int offset) { BlockSoundSet obj = new BlockSoundSet(); byte nullBits = buf.getByte(offset); - if ((nullBits & 4) != 0) { + if ((nullBits & 1) != 0) { obj.moveInRepeatRange = FloatRange.deserialize(buf, offset + 1); } - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int varPos0 = offset + 17 + buf.getIntLE(offset + 9); int idLen = VarInt.peek(buf, varPos0); if (idLen < 0) { @@ -62,7 +62,7 @@ public class BlockSoundSet { obj.id = PacketIO.readVarString(buf, varPos0, PacketIO.UTF8); } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int varPos1 = offset + 17 + buf.getIntLE(offset + 13); int soundEventIndicesCount = VarInt.peek(buf, varPos1); if (soundEventIndicesCount < 0) { @@ -93,7 +93,7 @@ public class BlockSoundSet { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 17; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int fieldOffset0 = buf.getIntLE(offset + 9); int pos0 = offset + 17 + fieldOffset0; int sl = VarInt.peek(buf, pos0); @@ -103,7 +103,7 @@ public class BlockSoundSet { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int fieldOffset1 = buf.getIntLE(offset + 13); int pos1 = offset + 17 + fieldOffset1; int dictLen = VarInt.peek(buf, pos1); @@ -124,15 +124,15 @@ public class BlockSoundSet { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.id != null) { + if (this.moveInRepeatRange != null) { nullBits = (byte)(nullBits | 1); } - if (this.soundEventIndices != null) { + if (this.id != null) { nullBits = (byte)(nullBits | 2); } - if (this.moveInRepeatRange != null) { + if (this.soundEventIndices != null) { nullBits = (byte)(nullBits | 4); } @@ -190,7 +190,7 @@ public class BlockSoundSet { return ValidationResult.error("Buffer too small: expected at least 17 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int idOffset = buffer.getIntLE(offset + 9); if (idOffset < 0) { return ValidationResult.error("Invalid offset for Id"); @@ -217,7 +217,7 @@ public class BlockSoundSet { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int soundEventIndicesOffset = buffer.getIntLE(offset + 13); if (soundEventIndicesOffset < 0) { return ValidationResult.error("Invalid offset for SoundEventIndices"); diff --git a/src/com/hypixel/hytale/protocol/BlockType.java b/src/com/hypixel/hytale/protocol/BlockType.java index 47012cd..854fa7b 100644 --- a/src/com/hypixel/hytale/protocol/BlockType.java +++ b/src/com/hypixel/hytale/protocol/BlockType.java @@ -294,38 +294,38 @@ public class BlockType { obj.rotationYawPlacementOffset = Rotation.fromValue(buf.getByte(offset + 30)); obj.blockSoundSetIndex = buf.getIntLE(offset + 31); obj.ambientSoundEventIndex = buf.getIntLE(offset + 35); - if ((nullBits[1] & 32) != 0) { + if ((nullBits[0] & 1) != 0) { obj.particleColor = Color.deserialize(buf, offset + 39); } - if ((nullBits[1] & 64) != 0) { + if ((nullBits[0] & 2) != 0) { obj.light = ColorLight.deserialize(buf, offset + 42); } - if ((nullBits[1] & 128) != 0) { + if ((nullBits[0] & 4) != 0) { obj.tint = Tint.deserialize(buf, offset + 46); } - if ((nullBits[2] & 1) != 0) { + if ((nullBits[0] & 8) != 0) { obj.biomeTint = Tint.deserialize(buf, offset + 70); } obj.group = buf.getIntLE(offset + 94); - if ((nullBits[2] & 8) != 0) { + if ((nullBits[0] & 16) != 0) { obj.movementSettings = BlockMovementSettings.deserialize(buf, offset + 98); } - if ((nullBits[2] & 16) != 0) { + if ((nullBits[0] & 32) != 0) { obj.flags = BlockFlags.deserialize(buf, offset + 140); } - if ((nullBits[2] & 128) != 0) { + if ((nullBits[0] & 64) != 0) { obj.placementSettings = BlockPlacementSettings.deserialize(buf, offset + 142); } obj.ignoreSupportWhenPlaced = buf.getByte(offset + 158) != 0; obj.transitionToTag = buf.getIntLE(offset + 159); - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 128) != 0) { int varPos0 = offset + 259 + buf.getIntLE(offset + 163); int itemLen = VarInt.peek(buf, varPos0); if (itemLen < 0) { @@ -339,7 +339,7 @@ public class BlockType { obj.item = PacketIO.readVarString(buf, varPos0, PacketIO.UTF8); } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[1] & 1) != 0) { int varPos1 = offset + 259 + buf.getIntLE(offset + 167); int nameLen = VarInt.peek(buf, varPos1); if (nameLen < 0) { @@ -353,7 +353,7 @@ public class BlockType { obj.name = PacketIO.readVarString(buf, varPos1, PacketIO.UTF8); } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[1] & 2) != 0) { int varPos2 = offset + 259 + buf.getIntLE(offset + 171); int shaderEffectCount = VarInt.peek(buf, varPos2); if (shaderEffectCount < 0) { @@ -378,7 +378,7 @@ public class BlockType { } } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[1] & 4) != 0) { int varPos3 = offset + 259 + buf.getIntLE(offset + 175); int modelLen = VarInt.peek(buf, varPos3); if (modelLen < 0) { @@ -392,7 +392,7 @@ public class BlockType { obj.model = PacketIO.readVarString(buf, varPos3, PacketIO.UTF8); } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[1] & 8) != 0) { int varPos4 = offset + 259 + buf.getIntLE(offset + 179); int modelTextureCount = VarInt.peek(buf, varPos4); if (modelTextureCount < 0) { @@ -417,7 +417,7 @@ public class BlockType { } } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[1] & 16) != 0) { int varPos5 = offset + 259 + buf.getIntLE(offset + 183); int modelAnimationLen = VarInt.peek(buf, varPos5); if (modelAnimationLen < 0) { @@ -431,7 +431,7 @@ public class BlockType { obj.modelAnimation = PacketIO.readVarString(buf, varPos5, PacketIO.UTF8); } - if ((nullBits[0] & 64) != 0) { + if ((nullBits[1] & 32) != 0) { int varPos6 = offset + 259 + buf.getIntLE(offset + 187); int supportCount = VarInt.peek(buf, varPos6); if (supportCount < 0) { @@ -476,7 +476,7 @@ public class BlockType { } } - if ((nullBits[0] & 128) != 0) { + if ((nullBits[1] & 64) != 0) { int varPos7 = offset + 259 + buf.getIntLE(offset + 191); int supportingCount = VarInt.peek(buf, varPos7); if (supportingCount < 0) { @@ -521,7 +521,7 @@ public class BlockType { } } - if ((nullBits[1] & 1) != 0) { + if ((nullBits[1] & 128) != 0) { int varPos8 = offset + 259 + buf.getIntLE(offset + 195); int cubeTexturesCount = VarInt.peek(buf, varPos8); if (cubeTexturesCount < 0) { @@ -546,7 +546,7 @@ public class BlockType { } } - if ((nullBits[1] & 2) != 0) { + if ((nullBits[2] & 1) != 0) { int varPos9 = offset + 259 + buf.getIntLE(offset + 199); int cubeSideMaskTextureLen = VarInt.peek(buf, varPos9); if (cubeSideMaskTextureLen < 0) { @@ -560,7 +560,7 @@ public class BlockType { obj.cubeSideMaskTexture = PacketIO.readVarString(buf, varPos9, PacketIO.UTF8); } - if ((nullBits[1] & 4) != 0) { + if ((nullBits[2] & 2) != 0) { int varPos10 = offset + 259 + buf.getIntLE(offset + 203); int particlesCount = VarInt.peek(buf, varPos10); if (particlesCount < 0) { @@ -585,7 +585,7 @@ public class BlockType { } } - if ((nullBits[1] & 8) != 0) { + if ((nullBits[2] & 4) != 0) { int varPos11 = offset + 259 + buf.getIntLE(offset + 207); int blockParticleSetIdLen = VarInt.peek(buf, varPos11); if (blockParticleSetIdLen < 0) { @@ -599,7 +599,7 @@ public class BlockType { obj.blockParticleSetId = PacketIO.readVarString(buf, varPos11, PacketIO.UTF8); } - if ((nullBits[1] & 16) != 0) { + if ((nullBits[2] & 8) != 0) { int varPos12 = offset + 259 + buf.getIntLE(offset + 211); int blockBreakingDecalIdLen = VarInt.peek(buf, varPos12); if (blockBreakingDecalIdLen < 0) { @@ -613,7 +613,7 @@ public class BlockType { obj.blockBreakingDecalId = PacketIO.readVarString(buf, varPos12, PacketIO.UTF8); } - if ((nullBits[2] & 2) != 0) { + if ((nullBits[2] & 16) != 0) { int varPos13 = offset + 259 + buf.getIntLE(offset + 215); int transitionTextureLen = VarInt.peek(buf, varPos13); if (transitionTextureLen < 0) { @@ -627,7 +627,7 @@ public class BlockType { obj.transitionTexture = PacketIO.readVarString(buf, varPos13, PacketIO.UTF8); } - if ((nullBits[2] & 4) != 0) { + if ((nullBits[2] & 32) != 0) { int varPos14 = offset + 259 + buf.getIntLE(offset + 219); int transitionToGroupsCount = VarInt.peek(buf, varPos14); if (transitionToGroupsCount < 0) { @@ -650,7 +650,7 @@ public class BlockType { } } - if ((nullBits[2] & 32) != 0) { + if ((nullBits[2] & 64) != 0) { int varPos15 = offset + 259 + buf.getIntLE(offset + 223); int interactionHintLen = VarInt.peek(buf, varPos15); if (interactionHintLen < 0) { @@ -664,7 +664,7 @@ public class BlockType { obj.interactionHint = PacketIO.readVarString(buf, varPos15, PacketIO.UTF8); } - if ((nullBits[2] & 64) != 0) { + if ((nullBits[2] & 128) != 0) { int varPos16 = offset + 259 + buf.getIntLE(offset + 227); obj.gathering = BlockGathering.deserialize(buf, varPos16); } @@ -779,7 +779,7 @@ public class BlockType { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte[] nullBits = PacketIO.readBytes(buf, offset, 4); int maxEnd = 259; - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 128) != 0) { int fieldOffset0 = buf.getIntLE(offset + 163); int pos0 = offset + 259 + fieldOffset0; int sl = VarInt.peek(buf, pos0); @@ -789,7 +789,7 @@ public class BlockType { } } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[1] & 1) != 0) { int fieldOffset1 = buf.getIntLE(offset + 167); int pos1 = offset + 259 + fieldOffset1; int sl = VarInt.peek(buf, pos1); @@ -799,7 +799,7 @@ public class BlockType { } } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[1] & 2) != 0) { int fieldOffset2 = buf.getIntLE(offset + 171); int pos2 = offset + 259 + fieldOffset2; int arrLen = VarInt.peek(buf, pos2); @@ -809,7 +809,7 @@ public class BlockType { } } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[1] & 4) != 0) { int fieldOffset3 = buf.getIntLE(offset + 175); int pos3 = offset + 259 + fieldOffset3; int sl = VarInt.peek(buf, pos3); @@ -819,7 +819,7 @@ public class BlockType { } } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[1] & 8) != 0) { int fieldOffset4 = buf.getIntLE(offset + 179); int pos4 = offset + 259 + fieldOffset4; int arrLen = VarInt.peek(buf, pos4); @@ -834,7 +834,7 @@ public class BlockType { } } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[1] & 16) != 0) { int fieldOffset5 = buf.getIntLE(offset + 183); int pos5 = offset + 259 + fieldOffset5; int sl = VarInt.peek(buf, pos5); @@ -844,7 +844,7 @@ public class BlockType { } } - if ((nullBits[0] & 64) != 0) { + if ((nullBits[1] & 32) != 0) { int fieldOffset6 = buf.getIntLE(offset + 187); int pos6 = offset + 259 + fieldOffset6; int dictLen = VarInt.peek(buf, pos6); @@ -864,7 +864,7 @@ public class BlockType { } } - if ((nullBits[0] & 128) != 0) { + if ((nullBits[1] & 64) != 0) { int fieldOffset7 = buf.getIntLE(offset + 191); int pos7 = offset + 259 + fieldOffset7; int dictLen = VarInt.peek(buf, pos7); @@ -884,7 +884,7 @@ public class BlockType { } } - if ((nullBits[1] & 1) != 0) { + if ((nullBits[1] & 128) != 0) { int fieldOffset8 = buf.getIntLE(offset + 195); int pos8 = offset + 259 + fieldOffset8; int arrLen = VarInt.peek(buf, pos8); @@ -899,7 +899,7 @@ public class BlockType { } } - if ((nullBits[1] & 2) != 0) { + if ((nullBits[2] & 1) != 0) { int fieldOffset9 = buf.getIntLE(offset + 199); int pos9 = offset + 259 + fieldOffset9; int sl = VarInt.peek(buf, pos9); @@ -909,7 +909,7 @@ public class BlockType { } } - if ((nullBits[1] & 4) != 0) { + if ((nullBits[2] & 2) != 0) { int fieldOffset10 = buf.getIntLE(offset + 203); int pos10 = offset + 259 + fieldOffset10; int arrLen = VarInt.peek(buf, pos10); @@ -924,7 +924,7 @@ public class BlockType { } } - if ((nullBits[1] & 8) != 0) { + if ((nullBits[2] & 4) != 0) { int fieldOffset11 = buf.getIntLE(offset + 207); int pos11 = offset + 259 + fieldOffset11; int sl = VarInt.peek(buf, pos11); @@ -934,7 +934,7 @@ public class BlockType { } } - if ((nullBits[1] & 16) != 0) { + if ((nullBits[2] & 8) != 0) { int fieldOffset12 = buf.getIntLE(offset + 211); int pos12 = offset + 259 + fieldOffset12; int sl = VarInt.peek(buf, pos12); @@ -944,7 +944,7 @@ public class BlockType { } } - if ((nullBits[2] & 2) != 0) { + if ((nullBits[2] & 16) != 0) { int fieldOffset13 = buf.getIntLE(offset + 215); int pos13 = offset + 259 + fieldOffset13; int sl = VarInt.peek(buf, pos13); @@ -954,7 +954,7 @@ public class BlockType { } } - if ((nullBits[2] & 4) != 0) { + if ((nullBits[2] & 32) != 0) { int fieldOffset14 = buf.getIntLE(offset + 219); int pos14 = offset + 259 + fieldOffset14; int arrLen = VarInt.peek(buf, pos14); @@ -964,7 +964,7 @@ public class BlockType { } } - if ((nullBits[2] & 32) != 0) { + if ((nullBits[2] & 64) != 0) { int fieldOffset15 = buf.getIntLE(offset + 223); int pos15 = offset + 259 + fieldOffset15; int sl = VarInt.peek(buf, pos15); @@ -974,7 +974,7 @@ public class BlockType { } } - if ((nullBits[2] & 64) != 0) { + if ((nullBits[2] & 128) != 0) { int fieldOffset16 = buf.getIntLE(offset + 227); int pos16 = offset + 259 + fieldOffset16; pos16 += BlockGathering.computeBytesConsumed(buf, pos16); @@ -1067,99 +1067,99 @@ public class BlockType { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte[] nullBits = new byte[4]; - if (this.item != null) { + if (this.particleColor != null) { nullBits[0] = (byte)(nullBits[0] | 1); } - if (this.name != null) { + if (this.light != null) { nullBits[0] = (byte)(nullBits[0] | 2); } - if (this.shaderEffect != null) { + if (this.tint != null) { nullBits[0] = (byte)(nullBits[0] | 4); } - if (this.model != null) { + if (this.biomeTint != null) { nullBits[0] = (byte)(nullBits[0] | 8); } - if (this.modelTexture != null) { + if (this.movementSettings != null) { nullBits[0] = (byte)(nullBits[0] | 16); } - if (this.modelAnimation != null) { + if (this.flags != null) { nullBits[0] = (byte)(nullBits[0] | 32); } - if (this.support != null) { + if (this.placementSettings != null) { nullBits[0] = (byte)(nullBits[0] | 64); } - if (this.supporting != null) { + if (this.item != null) { nullBits[0] = (byte)(nullBits[0] | 128); } - if (this.cubeTextures != null) { + if (this.name != null) { nullBits[1] = (byte)(nullBits[1] | 1); } - if (this.cubeSideMaskTexture != null) { + if (this.shaderEffect != null) { nullBits[1] = (byte)(nullBits[1] | 2); } - if (this.particles != null) { + if (this.model != null) { nullBits[1] = (byte)(nullBits[1] | 4); } - if (this.blockParticleSetId != null) { + if (this.modelTexture != null) { nullBits[1] = (byte)(nullBits[1] | 8); } - if (this.blockBreakingDecalId != null) { + if (this.modelAnimation != null) { nullBits[1] = (byte)(nullBits[1] | 16); } - if (this.particleColor != null) { + if (this.support != null) { nullBits[1] = (byte)(nullBits[1] | 32); } - if (this.light != null) { + if (this.supporting != null) { nullBits[1] = (byte)(nullBits[1] | 64); } - if (this.tint != null) { + if (this.cubeTextures != null) { nullBits[1] = (byte)(nullBits[1] | 128); } - if (this.biomeTint != null) { + if (this.cubeSideMaskTexture != null) { nullBits[2] = (byte)(nullBits[2] | 1); } - if (this.transitionTexture != null) { + if (this.particles != null) { nullBits[2] = (byte)(nullBits[2] | 2); } - if (this.transitionToGroups != null) { + if (this.blockParticleSetId != null) { nullBits[2] = (byte)(nullBits[2] | 4); } - if (this.movementSettings != null) { + if (this.blockBreakingDecalId != null) { nullBits[2] = (byte)(nullBits[2] | 8); } - if (this.flags != null) { + if (this.transitionTexture != null) { nullBits[2] = (byte)(nullBits[2] | 16); } - if (this.interactionHint != null) { + if (this.transitionToGroups != null) { nullBits[2] = (byte)(nullBits[2] | 32); } - if (this.gathering != null) { + if (this.interactionHint != null) { nullBits[2] = (byte)(nullBits[2] | 64); } - if (this.placementSettings != null) { + if (this.gathering != null) { nullBits[2] = (byte)(nullBits[2] | 128); } @@ -1706,7 +1706,7 @@ public class BlockType { return ValidationResult.error("Buffer too small: expected at least 259 bytes"); } else { byte[] nullBits = PacketIO.readBytes(buffer, offset, 4); - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 128) != 0) { int itemOffset = buffer.getIntLE(offset + 163); if (itemOffset < 0) { return ValidationResult.error("Invalid offset for Item"); @@ -1733,7 +1733,7 @@ public class BlockType { } } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[1] & 1) != 0) { int nameOffset = buffer.getIntLE(offset + 167); if (nameOffset < 0) { return ValidationResult.error("Invalid offset for Name"); @@ -1760,7 +1760,7 @@ public class BlockType { } } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[1] & 2) != 0) { int shaderEffectOffset = buffer.getIntLE(offset + 171); if (shaderEffectOffset < 0) { return ValidationResult.error("Invalid offset for ShaderEffect"); @@ -1787,7 +1787,7 @@ public class BlockType { } } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[1] & 4) != 0) { int modelOffset = buffer.getIntLE(offset + 175); if (modelOffset < 0) { return ValidationResult.error("Invalid offset for Model"); @@ -1814,7 +1814,7 @@ public class BlockType { } } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[1] & 8) != 0) { int modelTextureOffset = buffer.getIntLE(offset + 179); if (modelTextureOffset < 0) { return ValidationResult.error("Invalid offset for ModelTexture"); @@ -1846,7 +1846,7 @@ public class BlockType { } } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[1] & 16) != 0) { int modelAnimationOffset = buffer.getIntLE(offset + 183); if (modelAnimationOffset < 0) { return ValidationResult.error("Invalid offset for ModelAnimation"); @@ -1873,7 +1873,7 @@ public class BlockType { } } - if ((nullBits[0] & 64) != 0) { + if ((nullBits[1] & 32) != 0) { int supportOffset = buffer.getIntLE(offset + 187); if (supportOffset < 0) { return ValidationResult.error("Invalid offset for Support"); @@ -1909,7 +1909,7 @@ public class BlockType { } } - if ((nullBits[0] & 128) != 0) { + if ((nullBits[1] & 64) != 0) { int supportingOffset = buffer.getIntLE(offset + 191); if (supportingOffset < 0) { return ValidationResult.error("Invalid offset for Supporting"); @@ -1945,7 +1945,7 @@ public class BlockType { } } - if ((nullBits[1] & 1) != 0) { + if ((nullBits[1] & 128) != 0) { int cubeTexturesOffset = buffer.getIntLE(offset + 195); if (cubeTexturesOffset < 0) { return ValidationResult.error("Invalid offset for CubeTextures"); @@ -1977,7 +1977,7 @@ public class BlockType { } } - if ((nullBits[1] & 2) != 0) { + if ((nullBits[2] & 1) != 0) { int cubeSideMaskTextureOffset = buffer.getIntLE(offset + 199); if (cubeSideMaskTextureOffset < 0) { return ValidationResult.error("Invalid offset for CubeSideMaskTexture"); @@ -2004,7 +2004,7 @@ public class BlockType { } } - if ((nullBits[1] & 4) != 0) { + if ((nullBits[2] & 2) != 0) { int particlesOffset = buffer.getIntLE(offset + 203); if (particlesOffset < 0) { return ValidationResult.error("Invalid offset for Particles"); @@ -2036,7 +2036,7 @@ public class BlockType { } } - if ((nullBits[1] & 8) != 0) { + if ((nullBits[2] & 4) != 0) { int blockParticleSetIdOffset = buffer.getIntLE(offset + 207); if (blockParticleSetIdOffset < 0) { return ValidationResult.error("Invalid offset for BlockParticleSetId"); @@ -2063,7 +2063,7 @@ public class BlockType { } } - if ((nullBits[1] & 16) != 0) { + if ((nullBits[2] & 8) != 0) { int blockBreakingDecalIdOffset = buffer.getIntLE(offset + 211); if (blockBreakingDecalIdOffset < 0) { return ValidationResult.error("Invalid offset for BlockBreakingDecalId"); @@ -2090,7 +2090,7 @@ public class BlockType { } } - if ((nullBits[2] & 2) != 0) { + if ((nullBits[2] & 16) != 0) { int transitionTextureOffset = buffer.getIntLE(offset + 215); if (transitionTextureOffset < 0) { return ValidationResult.error("Invalid offset for TransitionTexture"); @@ -2117,7 +2117,7 @@ public class BlockType { } } - if ((nullBits[2] & 4) != 0) { + if ((nullBits[2] & 32) != 0) { int transitionToGroupsOffset = buffer.getIntLE(offset + 219); if (transitionToGroupsOffset < 0) { return ValidationResult.error("Invalid offset for TransitionToGroups"); @@ -2144,7 +2144,7 @@ public class BlockType { } } - if ((nullBits[2] & 32) != 0) { + if ((nullBits[2] & 64) != 0) { int interactionHintOffset = buffer.getIntLE(offset + 223); if (interactionHintOffset < 0) { return ValidationResult.error("Invalid offset for InteractionHint"); @@ -2171,7 +2171,7 @@ public class BlockType { } } - if ((nullBits[2] & 64) != 0) { + if ((nullBits[2] & 128) != 0) { int gatheringOffset = buffer.getIntLE(offset + 227); if (gatheringOffset < 0) { return ValidationResult.error("Invalid offset for Gathering"); diff --git a/src/com/hypixel/hytale/protocol/ChargingInteraction.java b/src/com/hypixel/hytale/protocol/ChargingInteraction.java index 8381d6c..b409d31 100644 --- a/src/com/hypixel/hytale/protocol/ChargingInteraction.java +++ b/src/com/hypixel/hytale/protocol/ChargingInteraction.java @@ -114,16 +114,16 @@ public class ChargingInteraction extends Interaction { obj.failOnDamage = buf.getByte(offset + 18) != 0; obj.mouseSensitivityAdjustmentTarget = buf.getFloatLE(offset + 19); obj.mouseSensitivityAdjustmentDuration = buf.getFloatLE(offset + 23); - if ((nullBits & 128) != 0) { + if ((nullBits & 1) != 0) { obj.chargingDelay = ChargingDelay.deserialize(buf, offset + 27); } - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int varPos0 = offset + 75 + buf.getIntLE(offset + 47); obj.effects = InteractionEffects.deserialize(buf, varPos0); } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int varPos1 = offset + 75 + buf.getIntLE(offset + 51); int settingsCount = VarInt.peek(buf, varPos1); if (settingsCount < 0) { @@ -148,12 +148,12 @@ public class ChargingInteraction extends Interaction { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 8) != 0) { int varPos2 = offset + 75 + buf.getIntLE(offset + 55); obj.rules = InteractionRules.deserialize(buf, varPos2); } - if ((nullBits & 8) != 0) { + if ((nullBits & 16) != 0) { int varPos3 = offset + 75 + buf.getIntLE(offset + 59); int tagsCount = VarInt.peek(buf, varPos3); if (tagsCount < 0) { @@ -176,12 +176,12 @@ public class ChargingInteraction extends Interaction { } } - if ((nullBits & 16) != 0) { + if ((nullBits & 32) != 0) { int varPos4 = offset + 75 + buf.getIntLE(offset + 63); obj.camera = InteractionCameraSettings.deserialize(buf, varPos4); } - if ((nullBits & 32) != 0) { + if ((nullBits & 64) != 0) { int varPos5 = offset + 75 + buf.getIntLE(offset + 67); int chargedNextCount = VarInt.peek(buf, varPos5); if (chargedNextCount < 0) { @@ -207,7 +207,7 @@ public class ChargingInteraction extends Interaction { } } - if ((nullBits & 64) != 0) { + if ((nullBits & 128) != 0) { int varPos6 = offset + 75 + buf.getIntLE(offset + 71); int forksCount = VarInt.peek(buf, varPos6); if (forksCount < 0) { @@ -238,7 +238,7 @@ public class ChargingInteraction extends Interaction { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 75; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int fieldOffset0 = buf.getIntLE(offset + 47); int pos0 = offset + 75 + fieldOffset0; pos0 += InteractionEffects.computeBytesConsumed(buf, pos0); @@ -247,7 +247,7 @@ public class ChargingInteraction extends Interaction { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int fieldOffset1 = buf.getIntLE(offset + 51); int pos1 = offset + 75 + fieldOffset1; int dictLen = VarInt.peek(buf, pos1); @@ -262,7 +262,7 @@ public class ChargingInteraction extends Interaction { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 8) != 0) { int fieldOffset2 = buf.getIntLE(offset + 55); int pos2 = offset + 75 + fieldOffset2; pos2 += InteractionRules.computeBytesConsumed(buf, pos2); @@ -271,7 +271,7 @@ public class ChargingInteraction extends Interaction { } } - if ((nullBits & 8) != 0) { + if ((nullBits & 16) != 0) { int fieldOffset3 = buf.getIntLE(offset + 59); int pos3 = offset + 75 + fieldOffset3; int arrLen = VarInt.peek(buf, pos3); @@ -281,7 +281,7 @@ public class ChargingInteraction extends Interaction { } } - if ((nullBits & 16) != 0) { + if ((nullBits & 32) != 0) { int fieldOffset4 = buf.getIntLE(offset + 63); int pos4 = offset + 75 + fieldOffset4; pos4 += InteractionCameraSettings.computeBytesConsumed(buf, pos4); @@ -290,7 +290,7 @@ public class ChargingInteraction extends Interaction { } } - if ((nullBits & 32) != 0) { + if ((nullBits & 64) != 0) { int fieldOffset5 = buf.getIntLE(offset + 67); int pos5 = offset + 75 + fieldOffset5; int dictLen = VarInt.peek(buf, pos5); @@ -306,7 +306,7 @@ public class ChargingInteraction extends Interaction { } } - if ((nullBits & 64) != 0) { + if ((nullBits & 128) != 0) { int fieldOffset6 = buf.getIntLE(offset + 71); int pos6 = offset + 75 + fieldOffset6; int dictLen = VarInt.peek(buf, pos6); @@ -328,35 +328,35 @@ public class ChargingInteraction extends Interaction { public int serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.effects != null) { + if (this.chargingDelay != null) { nullBits = (byte)(nullBits | 1); } - if (this.settings != null) { + if (this.effects != null) { nullBits = (byte)(nullBits | 2); } - if (this.rules != null) { + if (this.settings != null) { nullBits = (byte)(nullBits | 4); } - if (this.tags != null) { + if (this.rules != null) { nullBits = (byte)(nullBits | 8); } - if (this.camera != null) { + if (this.tags != null) { nullBits = (byte)(nullBits | 16); } - if (this.chargedNext != null) { + if (this.camera != null) { nullBits = (byte)(nullBits | 32); } - if (this.forks != null) { + if (this.chargedNext != null) { nullBits = (byte)(nullBits | 64); } - if (this.chargingDelay != null) { + if (this.forks != null) { nullBits = (byte)(nullBits | 128); } @@ -519,7 +519,7 @@ public class ChargingInteraction extends Interaction { return ValidationResult.error("Buffer too small: expected at least 75 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int effectsOffset = buffer.getIntLE(offset + 47); if (effectsOffset < 0) { return ValidationResult.error("Invalid offset for Effects"); @@ -538,7 +538,7 @@ public class ChargingInteraction extends Interaction { pos += InteractionEffects.computeBytesConsumed(buffer, pos); } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int settingsOffset = buffer.getIntLE(offset + 51); if (settingsOffset < 0) { return ValidationResult.error("Invalid offset for Settings"); @@ -566,7 +566,7 @@ public class ChargingInteraction extends Interaction { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 8) != 0) { int rulesOffset = buffer.getIntLE(offset + 55); if (rulesOffset < 0) { return ValidationResult.error("Invalid offset for Rules"); @@ -585,7 +585,7 @@ public class ChargingInteraction extends Interaction { posxx += InteractionRules.computeBytesConsumed(buffer, posxx); } - if ((nullBits & 8) != 0) { + if ((nullBits & 16) != 0) { int tagsOffset = buffer.getIntLE(offset + 59); if (tagsOffset < 0) { return ValidationResult.error("Invalid offset for Tags"); @@ -612,7 +612,7 @@ public class ChargingInteraction extends Interaction { } } - if ((nullBits & 16) != 0) { + if ((nullBits & 32) != 0) { int cameraOffset = buffer.getIntLE(offset + 63); if (cameraOffset < 0) { return ValidationResult.error("Invalid offset for Camera"); @@ -631,7 +631,7 @@ public class ChargingInteraction extends Interaction { posxxxx += InteractionCameraSettings.computeBytesConsumed(buffer, posxxxx); } - if ((nullBits & 32) != 0) { + if ((nullBits & 64) != 0) { int chargedNextOffset = buffer.getIntLE(offset + 67); if (chargedNextOffset < 0) { return ValidationResult.error("Invalid offset for ChargedNext"); @@ -666,7 +666,7 @@ public class ChargingInteraction extends Interaction { } } - if ((nullBits & 64) != 0) { + if ((nullBits & 128) != 0) { int forksOffset = buffer.getIntLE(offset + 71); if (forksOffset < 0) { return ValidationResult.error("Invalid offset for Forks"); diff --git a/src/com/hypixel/hytale/protocol/ComponentUpdate.java b/src/com/hypixel/hytale/protocol/ComponentUpdate.java index 26c1d8a..838efbe 100644 --- a/src/com/hypixel/hytale/protocol/ComponentUpdate.java +++ b/src/com/hypixel/hytale/protocol/ComponentUpdate.java @@ -149,31 +149,31 @@ public class ComponentUpdate { obj.type = ComponentUpdateType.fromValue(buf.getByte(offset + 3)); obj.blockId = buf.getIntLE(offset + 4); obj.entityScale = buf.getFloatLE(offset + 8); - if ((nullBits[1] & 1) != 0) { + if ((nullBits[0] & 1) != 0) { obj.transform = ModelTransform.deserialize(buf, offset + 12); } - if ((nullBits[1] & 2) != 0) { + if ((nullBits[0] & 2) != 0) { obj.movementStates = MovementStates.deserialize(buf, offset + 61); } - if ((nullBits[1] & 16) != 0) { + if ((nullBits[0] & 4) != 0) { obj.dynamicLight = ColorLight.deserialize(buf, offset + 83); } obj.hitboxCollisionConfigIndex = buf.getIntLE(offset + 87); obj.repulsionConfigIndex = buf.getIntLE(offset + 91); obj.predictionId = PacketIO.readUUID(buf, offset + 95); - if ((nullBits[1] & 128) != 0) { + if ((nullBits[0] & 8) != 0) { obj.mounted = MountedUpdate.deserialize(buf, offset + 111); } - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 16) != 0) { int varPos0 = offset + 211 + buf.getIntLE(offset + 159); obj.nameplate = Nameplate.deserialize(buf, varPos0); } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 32) != 0) { int varPos1 = offset + 211 + buf.getIntLE(offset + 163); int entityUIComponentsCount = VarInt.peek(buf, varPos1); if (entityUIComponentsCount < 0) { @@ -196,32 +196,32 @@ public class ComponentUpdate { } } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 64) != 0) { int varPos2 = offset + 211 + buf.getIntLE(offset + 167); obj.combatTextUpdate = CombatTextUpdate.deserialize(buf, varPos2); } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[0] & 128) != 0) { int varPos3 = offset + 211 + buf.getIntLE(offset + 171); obj.model = Model.deserialize(buf, varPos3); } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[1] & 1) != 0) { int varPos4 = offset + 211 + buf.getIntLE(offset + 175); obj.skin = PlayerSkin.deserialize(buf, varPos4); } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[1] & 2) != 0) { int varPos5 = offset + 211 + buf.getIntLE(offset + 179); obj.item = ItemWithAllMetadata.deserialize(buf, varPos5); } - if ((nullBits[0] & 64) != 0) { + if ((nullBits[1] & 4) != 0) { int varPos6 = offset + 211 + buf.getIntLE(offset + 183); obj.equipment = Equipment.deserialize(buf, varPos6); } - if ((nullBits[0] & 128) != 0) { + if ((nullBits[1] & 8) != 0) { int varPos7 = offset + 211 + buf.getIntLE(offset + 187); int entityStatUpdatesCount = VarInt.peek(buf, varPos7); if (entityStatUpdatesCount < 0) { @@ -267,7 +267,7 @@ public class ComponentUpdate { } } - if ((nullBits[1] & 4) != 0) { + if ((nullBits[1] & 16) != 0) { int varPos8 = offset + 211 + buf.getIntLE(offset + 191); int entityEffectUpdatesCount = VarInt.peek(buf, varPos8); if (entityEffectUpdatesCount < 0) { @@ -292,7 +292,7 @@ public class ComponentUpdate { } } - if ((nullBits[1] & 8) != 0) { + if ((nullBits[1] & 32) != 0) { int varPos9 = offset + 211 + buf.getIntLE(offset + 195); int interactionsCount = VarInt.peek(buf, varPos9); if (interactionsCount < 0) { @@ -317,7 +317,7 @@ public class ComponentUpdate { } } - if ((nullBits[1] & 32) != 0) { + if ((nullBits[1] & 64) != 0) { int varPos10 = offset + 211 + buf.getIntLE(offset + 199); int soundEventIdsCount = VarInt.peek(buf, varPos10); if (soundEventIdsCount < 0) { @@ -340,7 +340,7 @@ public class ComponentUpdate { } } - if ((nullBits[1] & 64) != 0) { + if ((nullBits[1] & 128) != 0) { int varPos11 = offset + 211 + buf.getIntLE(offset + 203); int interactionHintLen = VarInt.peek(buf, varPos11); if (interactionHintLen < 0) { @@ -395,7 +395,7 @@ public class ComponentUpdate { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte[] nullBits = PacketIO.readBytes(buf, offset, 3); int maxEnd = 211; - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 16) != 0) { int fieldOffset0 = buf.getIntLE(offset + 159); int pos0 = offset + 211 + fieldOffset0; pos0 += Nameplate.computeBytesConsumed(buf, pos0); @@ -404,7 +404,7 @@ public class ComponentUpdate { } } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 32) != 0) { int fieldOffset1 = buf.getIntLE(offset + 163); int pos1 = offset + 211 + fieldOffset1; int arrLen = VarInt.peek(buf, pos1); @@ -414,7 +414,7 @@ public class ComponentUpdate { } } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 64) != 0) { int fieldOffset2 = buf.getIntLE(offset + 167); int pos2 = offset + 211 + fieldOffset2; pos2 += CombatTextUpdate.computeBytesConsumed(buf, pos2); @@ -423,7 +423,7 @@ public class ComponentUpdate { } } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[0] & 128) != 0) { int fieldOffset3 = buf.getIntLE(offset + 171); int pos3 = offset + 211 + fieldOffset3; pos3 += Model.computeBytesConsumed(buf, pos3); @@ -432,7 +432,7 @@ public class ComponentUpdate { } } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[1] & 1) != 0) { int fieldOffset4 = buf.getIntLE(offset + 175); int pos4 = offset + 211 + fieldOffset4; pos4 += PlayerSkin.computeBytesConsumed(buf, pos4); @@ -441,7 +441,7 @@ public class ComponentUpdate { } } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[1] & 2) != 0) { int fieldOffset5 = buf.getIntLE(offset + 179); int pos5 = offset + 211 + fieldOffset5; pos5 += ItemWithAllMetadata.computeBytesConsumed(buf, pos5); @@ -450,7 +450,7 @@ public class ComponentUpdate { } } - if ((nullBits[0] & 64) != 0) { + if ((nullBits[1] & 4) != 0) { int fieldOffset6 = buf.getIntLE(offset + 183); int pos6 = offset + 211 + fieldOffset6; pos6 += Equipment.computeBytesConsumed(buf, pos6); @@ -459,7 +459,7 @@ public class ComponentUpdate { } } - if ((nullBits[0] & 128) != 0) { + if ((nullBits[1] & 8) != 0) { int fieldOffset7 = buf.getIntLE(offset + 187); int pos7 = offset + 211 + fieldOffset7; int dictLen = VarInt.peek(buf, pos7); @@ -480,7 +480,7 @@ public class ComponentUpdate { } } - if ((nullBits[1] & 4) != 0) { + if ((nullBits[1] & 16) != 0) { int fieldOffset8 = buf.getIntLE(offset + 191); int pos8 = offset + 211 + fieldOffset8; int arrLen = VarInt.peek(buf, pos8); @@ -495,7 +495,7 @@ public class ComponentUpdate { } } - if ((nullBits[1] & 8) != 0) { + if ((nullBits[1] & 32) != 0) { int fieldOffset9 = buf.getIntLE(offset + 195); int pos9 = offset + 211 + fieldOffset9; int dictLen = VarInt.peek(buf, pos9); @@ -510,7 +510,7 @@ public class ComponentUpdate { } } - if ((nullBits[1] & 32) != 0) { + if ((nullBits[1] & 64) != 0) { int fieldOffset10 = buf.getIntLE(offset + 199); int pos10 = offset + 211 + fieldOffset10; int arrLen = VarInt.peek(buf, pos10); @@ -520,7 +520,7 @@ public class ComponentUpdate { } } - if ((nullBits[1] & 64) != 0) { + if ((nullBits[1] & 128) != 0) { int fieldOffset11 = buf.getIntLE(offset + 203); int pos11 = offset + 211 + fieldOffset11; int sl = VarInt.peek(buf, pos11); @@ -557,67 +557,67 @@ public class ComponentUpdate { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte[] nullBits = new byte[3]; - if (this.nameplate != null) { + if (this.transform != null) { nullBits[0] = (byte)(nullBits[0] | 1); } - if (this.entityUIComponents != null) { + if (this.movementStates != null) { nullBits[0] = (byte)(nullBits[0] | 2); } - if (this.combatTextUpdate != null) { + if (this.dynamicLight != null) { nullBits[0] = (byte)(nullBits[0] | 4); } - if (this.model != null) { + if (this.mounted != null) { nullBits[0] = (byte)(nullBits[0] | 8); } - if (this.skin != null) { + if (this.nameplate != null) { nullBits[0] = (byte)(nullBits[0] | 16); } - if (this.item != null) { + if (this.entityUIComponents != null) { nullBits[0] = (byte)(nullBits[0] | 32); } - if (this.equipment != null) { + if (this.combatTextUpdate != null) { nullBits[0] = (byte)(nullBits[0] | 64); } - if (this.entityStatUpdates != null) { + if (this.model != null) { nullBits[0] = (byte)(nullBits[0] | 128); } - if (this.transform != null) { + if (this.skin != null) { nullBits[1] = (byte)(nullBits[1] | 1); } - if (this.movementStates != null) { + if (this.item != null) { nullBits[1] = (byte)(nullBits[1] | 2); } - if (this.entityEffectUpdates != null) { + if (this.equipment != null) { nullBits[1] = (byte)(nullBits[1] | 4); } - if (this.interactions != null) { + if (this.entityStatUpdates != null) { nullBits[1] = (byte)(nullBits[1] | 8); } - if (this.dynamicLight != null) { + if (this.entityEffectUpdates != null) { nullBits[1] = (byte)(nullBits[1] | 16); } - if (this.soundEventIds != null) { + if (this.interactions != null) { nullBits[1] = (byte)(nullBits[1] | 32); } - if (this.interactionHint != null) { + if (this.soundEventIds != null) { nullBits[1] = (byte)(nullBits[1] | 64); } - if (this.mounted != null) { + if (this.interactionHint != null) { nullBits[1] = (byte)(nullBits[1] | 128); } @@ -923,7 +923,7 @@ public class ComponentUpdate { return ValidationResult.error("Buffer too small: expected at least 211 bytes"); } else { byte[] nullBits = PacketIO.readBytes(buffer, offset, 3); - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 16) != 0) { int nameplateOffset = buffer.getIntLE(offset + 159); if (nameplateOffset < 0) { return ValidationResult.error("Invalid offset for Nameplate"); @@ -942,7 +942,7 @@ public class ComponentUpdate { pos += Nameplate.computeBytesConsumed(buffer, pos); } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 32) != 0) { int entityUIComponentsOffset = buffer.getIntLE(offset + 163); if (entityUIComponentsOffset < 0) { return ValidationResult.error("Invalid offset for EntityUIComponents"); @@ -969,7 +969,7 @@ public class ComponentUpdate { } } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 64) != 0) { int combatTextUpdateOffset = buffer.getIntLE(offset + 167); if (combatTextUpdateOffset < 0) { return ValidationResult.error("Invalid offset for CombatTextUpdate"); @@ -988,7 +988,7 @@ public class ComponentUpdate { posxx += CombatTextUpdate.computeBytesConsumed(buffer, posxx); } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[0] & 128) != 0) { int modelOffset = buffer.getIntLE(offset + 171); if (modelOffset < 0) { return ValidationResult.error("Invalid offset for Model"); @@ -1007,7 +1007,7 @@ public class ComponentUpdate { posxxx += Model.computeBytesConsumed(buffer, posxxx); } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[1] & 1) != 0) { int skinOffset = buffer.getIntLE(offset + 175); if (skinOffset < 0) { return ValidationResult.error("Invalid offset for Skin"); @@ -1026,7 +1026,7 @@ public class ComponentUpdate { posxxxx += PlayerSkin.computeBytesConsumed(buffer, posxxxx); } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[1] & 2) != 0) { int itemOffset = buffer.getIntLE(offset + 179); if (itemOffset < 0) { return ValidationResult.error("Invalid offset for Item"); @@ -1045,7 +1045,7 @@ public class ComponentUpdate { posxxxxx += ItemWithAllMetadata.computeBytesConsumed(buffer, posxxxxx); } - if ((nullBits[0] & 64) != 0) { + if ((nullBits[1] & 4) != 0) { int equipmentOffset = buffer.getIntLE(offset + 183); if (equipmentOffset < 0) { return ValidationResult.error("Invalid offset for Equipment"); @@ -1064,7 +1064,7 @@ public class ComponentUpdate { posxxxxxx += Equipment.computeBytesConsumed(buffer, posxxxxxx); } - if ((nullBits[0] & 128) != 0) { + if ((nullBits[1] & 8) != 0) { int entityStatUpdatesOffset = buffer.getIntLE(offset + 187); if (entityStatUpdatesOffset < 0) { return ValidationResult.error("Invalid offset for EntityStatUpdates"); @@ -1105,7 +1105,7 @@ public class ComponentUpdate { } } - if ((nullBits[1] & 4) != 0) { + if ((nullBits[1] & 16) != 0) { int entityEffectUpdatesOffset = buffer.getIntLE(offset + 191); if (entityEffectUpdatesOffset < 0) { return ValidationResult.error("Invalid offset for EntityEffectUpdates"); @@ -1137,7 +1137,7 @@ public class ComponentUpdate { } } - if ((nullBits[1] & 8) != 0) { + if ((nullBits[1] & 32) != 0) { int interactionsOffset = buffer.getIntLE(offset + 195); if (interactionsOffset < 0) { return ValidationResult.error("Invalid offset for Interactions"); @@ -1167,7 +1167,7 @@ public class ComponentUpdate { } } - if ((nullBits[1] & 32) != 0) { + if ((nullBits[1] & 64) != 0) { int soundEventIdsOffset = buffer.getIntLE(offset + 199); if (soundEventIdsOffset < 0) { return ValidationResult.error("Invalid offset for SoundEventIds"); @@ -1194,7 +1194,7 @@ public class ComponentUpdate { } } - if ((nullBits[1] & 64) != 0) { + if ((nullBits[1] & 128) != 0) { int interactionHintOffset = buffer.getIntLE(offset + 203); if (interactionHintOffset < 0) { return ValidationResult.error("Invalid offset for InteractionHint"); diff --git a/src/com/hypixel/hytale/protocol/ConditionInteraction.java b/src/com/hypixel/hytale/protocol/ConditionInteraction.java index 4c7b46a..9dd6c5e 100644 --- a/src/com/hypixel/hytale/protocol/ConditionInteraction.java +++ b/src/com/hypixel/hytale/protocol/ConditionInteraction.java @@ -103,36 +103,36 @@ public class ConditionInteraction extends SimpleInteraction { obj.cancelOnItemChange = buf.getByte(offset + 11) != 0; obj.next = buf.getIntLE(offset + 12); obj.failed = buf.getIntLE(offset + 16); - if ((nullBits[0] & 32) != 0) { + if ((nullBits[0] & 1) != 0) { obj.requiredGameMode = GameMode.fromValue(buf.getByte(offset + 20)); } - if ((nullBits[0] & 64) != 0) { + if ((nullBits[0] & 2) != 0) { obj.jumping = buf.getByte(offset + 21) != 0; } - if ((nullBits[0] & 128) != 0) { + if ((nullBits[0] & 4) != 0) { obj.swimming = buf.getByte(offset + 22) != 0; } - if ((nullBits[1] & 1) != 0) { + if ((nullBits[0] & 8) != 0) { obj.crouching = buf.getByte(offset + 23) != 0; } - if ((nullBits[1] & 2) != 0) { + if ((nullBits[0] & 16) != 0) { obj.running = buf.getByte(offset + 24) != 0; } - if ((nullBits[1] & 4) != 0) { + if ((nullBits[0] & 32) != 0) { obj.flying = buf.getByte(offset + 25) != 0; } - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 64) != 0) { int varPos0 = offset + 46 + buf.getIntLE(offset + 26); obj.effects = InteractionEffects.deserialize(buf, varPos0); } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 128) != 0) { int varPos1 = offset + 46 + buf.getIntLE(offset + 30); int settingsCount = VarInt.peek(buf, varPos1); if (settingsCount < 0) { @@ -157,12 +157,12 @@ public class ConditionInteraction extends SimpleInteraction { } } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[1] & 1) != 0) { int varPos2 = offset + 46 + buf.getIntLE(offset + 34); obj.rules = InteractionRules.deserialize(buf, varPos2); } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[1] & 2) != 0) { int varPos3 = offset + 46 + buf.getIntLE(offset + 38); int tagsCount = VarInt.peek(buf, varPos3); if (tagsCount < 0) { @@ -185,7 +185,7 @@ public class ConditionInteraction extends SimpleInteraction { } } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[1] & 4) != 0) { int varPos4 = offset + 46 + buf.getIntLE(offset + 42); obj.camera = InteractionCameraSettings.deserialize(buf, varPos4); } @@ -196,7 +196,7 @@ public class ConditionInteraction extends SimpleInteraction { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte[] nullBits = PacketIO.readBytes(buf, offset, 2); int maxEnd = 46; - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 64) != 0) { int fieldOffset0 = buf.getIntLE(offset + 26); int pos0 = offset + 46 + fieldOffset0; pos0 += InteractionEffects.computeBytesConsumed(buf, pos0); @@ -205,7 +205,7 @@ public class ConditionInteraction extends SimpleInteraction { } } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 128) != 0) { int fieldOffset1 = buf.getIntLE(offset + 30); int pos1 = offset + 46 + fieldOffset1; int dictLen = VarInt.peek(buf, pos1); @@ -220,7 +220,7 @@ public class ConditionInteraction extends SimpleInteraction { } } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[1] & 1) != 0) { int fieldOffset2 = buf.getIntLE(offset + 34); int pos2 = offset + 46 + fieldOffset2; pos2 += InteractionRules.computeBytesConsumed(buf, pos2); @@ -229,7 +229,7 @@ public class ConditionInteraction extends SimpleInteraction { } } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[1] & 2) != 0) { int fieldOffset3 = buf.getIntLE(offset + 38); int pos3 = offset + 46 + fieldOffset3; int arrLen = VarInt.peek(buf, pos3); @@ -239,7 +239,7 @@ public class ConditionInteraction extends SimpleInteraction { } } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[1] & 4) != 0) { int fieldOffset4 = buf.getIntLE(offset + 42); int pos4 = offset + 46 + fieldOffset4; pos4 += InteractionCameraSettings.computeBytesConsumed(buf, pos4); @@ -255,47 +255,47 @@ public class ConditionInteraction extends SimpleInteraction { public int serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte[] nullBits = new byte[2]; - if (this.effects != null) { + if (this.requiredGameMode != null) { nullBits[0] = (byte)(nullBits[0] | 1); } - if (this.settings != null) { + if (this.jumping != null) { nullBits[0] = (byte)(nullBits[0] | 2); } - if (this.rules != null) { + if (this.swimming != null) { nullBits[0] = (byte)(nullBits[0] | 4); } - if (this.tags != null) { + if (this.crouching != null) { nullBits[0] = (byte)(nullBits[0] | 8); } - if (this.camera != null) { + if (this.running != null) { nullBits[0] = (byte)(nullBits[0] | 16); } - if (this.requiredGameMode != null) { + if (this.flying != null) { nullBits[0] = (byte)(nullBits[0] | 32); } - if (this.jumping != null) { + if (this.effects != null) { nullBits[0] = (byte)(nullBits[0] | 64); } - if (this.swimming != null) { + if (this.settings != null) { nullBits[0] = (byte)(nullBits[0] | 128); } - if (this.crouching != null) { + if (this.rules != null) { nullBits[1] = (byte)(nullBits[1] | 1); } - if (this.running != null) { + if (this.tags != null) { nullBits[1] = (byte)(nullBits[1] | 2); } - if (this.flying != null) { + if (this.camera != null) { nullBits[1] = (byte)(nullBits[1] | 4); } @@ -439,7 +439,7 @@ public class ConditionInteraction extends SimpleInteraction { return ValidationResult.error("Buffer too small: expected at least 46 bytes"); } else { byte[] nullBits = PacketIO.readBytes(buffer, offset, 2); - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 64) != 0) { int effectsOffset = buffer.getIntLE(offset + 26); if (effectsOffset < 0) { return ValidationResult.error("Invalid offset for Effects"); @@ -458,7 +458,7 @@ public class ConditionInteraction extends SimpleInteraction { pos += InteractionEffects.computeBytesConsumed(buffer, pos); } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 128) != 0) { int settingsOffset = buffer.getIntLE(offset + 30); if (settingsOffset < 0) { return ValidationResult.error("Invalid offset for Settings"); @@ -486,7 +486,7 @@ public class ConditionInteraction extends SimpleInteraction { } } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[1] & 1) != 0) { int rulesOffset = buffer.getIntLE(offset + 34); if (rulesOffset < 0) { return ValidationResult.error("Invalid offset for Rules"); @@ -505,7 +505,7 @@ public class ConditionInteraction extends SimpleInteraction { posxx += InteractionRules.computeBytesConsumed(buffer, posxx); } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[1] & 2) != 0) { int tagsOffset = buffer.getIntLE(offset + 38); if (tagsOffset < 0) { return ValidationResult.error("Invalid offset for Tags"); @@ -532,7 +532,7 @@ public class ConditionInteraction extends SimpleInteraction { } } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[1] & 4) != 0) { int cameraOffset = buffer.getIntLE(offset + 42); if (cameraOffset < 0) { return ValidationResult.error("Invalid offset for Camera"); diff --git a/src/com/hypixel/hytale/protocol/EntityStatUpdate.java b/src/com/hypixel/hytale/protocol/EntityStatUpdate.java index 07edfc2..6a2b5ce 100644 --- a/src/com/hypixel/hytale/protocol/EntityStatUpdate.java +++ b/src/com/hypixel/hytale/protocol/EntityStatUpdate.java @@ -64,11 +64,11 @@ public class EntityStatUpdate { obj.op = EntityStatOp.fromValue(buf.getByte(offset + 1)); obj.predictable = buf.getByte(offset + 2) != 0; obj.value = buf.getFloatLE(offset + 3); - if ((nullBits & 4) != 0) { + if ((nullBits & 1) != 0) { obj.modifier = Modifier.deserialize(buf, offset + 7); } - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int varPos0 = offset + 21 + buf.getIntLE(offset + 13); int modifiersCount = VarInt.peek(buf, varPos0); if (modifiersCount < 0) { @@ -104,7 +104,7 @@ public class EntityStatUpdate { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int varPos1 = offset + 21 + buf.getIntLE(offset + 17); int modifierKeyLen = VarInt.peek(buf, varPos1); if (modifierKeyLen < 0) { @@ -124,7 +124,7 @@ public class EntityStatUpdate { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 21; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int fieldOffset0 = buf.getIntLE(offset + 13); int pos0 = offset + 21 + fieldOffset0; int dictLen = VarInt.peek(buf, pos0); @@ -141,7 +141,7 @@ public class EntityStatUpdate { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int fieldOffset1 = buf.getIntLE(offset + 17); int pos1 = offset + 21 + fieldOffset1; int sl = VarInt.peek(buf, pos1); @@ -157,15 +157,15 @@ public class EntityStatUpdate { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.modifiers != null) { + if (this.modifier != null) { nullBits = (byte)(nullBits | 1); } - if (this.modifierKey != null) { + if (this.modifiers != null) { nullBits = (byte)(nullBits | 2); } - if (this.modifier != null) { + if (this.modifierKey != null) { nullBits = (byte)(nullBits | 4); } @@ -232,7 +232,7 @@ public class EntityStatUpdate { return ValidationResult.error("Buffer too small: expected at least 21 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int modifiersOffset = buffer.getIntLE(offset + 13); if (modifiersOffset < 0) { return ValidationResult.error("Invalid offset for Modifiers"); @@ -274,7 +274,7 @@ public class EntityStatUpdate { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int modifierKeyOffset = buffer.getIntLE(offset + 17); if (modifierKeyOffset < 0) { return ValidationResult.error("Invalid offset for ModifierKey"); diff --git a/src/com/hypixel/hytale/protocol/Fluid.java b/src/com/hypixel/hytale/protocol/Fluid.java index 629c81e..4c36ee3 100644 --- a/src/com/hypixel/hytale/protocol/Fluid.java +++ b/src/com/hypixel/hytale/protocol/Fluid.java @@ -90,17 +90,17 @@ public class Fluid { obj.maxFluidLevel = buf.getIntLE(offset + 1); obj.requiresAlphaBlending = buf.getByte(offset + 5) != 0; obj.opacity = Opacity.fromValue(buf.getByte(offset + 6)); - if ((nullBits & 8) != 0) { + if ((nullBits & 1) != 0) { obj.light = ColorLight.deserialize(buf, offset + 7); } obj.fluidFXIndex = buf.getIntLE(offset + 11); obj.blockSoundSetIndex = buf.getIntLE(offset + 15); - if ((nullBits & 32) != 0) { + if ((nullBits & 2) != 0) { obj.particleColor = Color.deserialize(buf, offset + 19); } - if ((nullBits & 1) != 0) { + if ((nullBits & 4) != 0) { int varPos0 = offset + 42 + buf.getIntLE(offset + 22); int idLen = VarInt.peek(buf, varPos0); if (idLen < 0) { @@ -114,7 +114,7 @@ public class Fluid { obj.id = PacketIO.readVarString(buf, varPos0, PacketIO.UTF8); } - if ((nullBits & 2) != 0) { + if ((nullBits & 8) != 0) { int varPos1 = offset + 42 + buf.getIntLE(offset + 26); int cubeTexturesCount = VarInt.peek(buf, varPos1); if (cubeTexturesCount < 0) { @@ -139,7 +139,7 @@ public class Fluid { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 16) != 0) { int varPos2 = offset + 42 + buf.getIntLE(offset + 30); int shaderEffectCount = VarInt.peek(buf, varPos2); if (shaderEffectCount < 0) { @@ -164,7 +164,7 @@ public class Fluid { } } - if ((nullBits & 16) != 0) { + if ((nullBits & 32) != 0) { int varPos3 = offset + 42 + buf.getIntLE(offset + 34); int blockParticleSetIdLen = VarInt.peek(buf, varPos3); if (blockParticleSetIdLen < 0) { @@ -207,7 +207,7 @@ public class Fluid { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 42; - if ((nullBits & 1) != 0) { + if ((nullBits & 4) != 0) { int fieldOffset0 = buf.getIntLE(offset + 22); int pos0 = offset + 42 + fieldOffset0; int sl = VarInt.peek(buf, pos0); @@ -217,7 +217,7 @@ public class Fluid { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 8) != 0) { int fieldOffset1 = buf.getIntLE(offset + 26); int pos1 = offset + 42 + fieldOffset1; int arrLen = VarInt.peek(buf, pos1); @@ -232,7 +232,7 @@ public class Fluid { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 16) != 0) { int fieldOffset2 = buf.getIntLE(offset + 30); int pos2 = offset + 42 + fieldOffset2; int arrLen = VarInt.peek(buf, pos2); @@ -242,7 +242,7 @@ public class Fluid { } } - if ((nullBits & 16) != 0) { + if ((nullBits & 32) != 0) { int fieldOffset3 = buf.getIntLE(offset + 34); int pos3 = offset + 42 + fieldOffset3; int sl = VarInt.peek(buf, pos3); @@ -268,27 +268,27 @@ public class Fluid { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.id != null) { + if (this.light != null) { nullBits = (byte)(nullBits | 1); } - if (this.cubeTextures != null) { + if (this.particleColor != null) { nullBits = (byte)(nullBits | 2); } - if (this.shaderEffect != null) { + if (this.id != null) { nullBits = (byte)(nullBits | 4); } - if (this.light != null) { + if (this.cubeTextures != null) { nullBits = (byte)(nullBits | 8); } - if (this.blockParticleSetId != null) { + if (this.shaderEffect != null) { nullBits = (byte)(nullBits | 16); } - if (this.particleColor != null) { + if (this.blockParticleSetId != null) { nullBits = (byte)(nullBits | 32); } @@ -421,7 +421,7 @@ public class Fluid { return ValidationResult.error("Buffer too small: expected at least 42 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 4) != 0) { int idOffset = buffer.getIntLE(offset + 22); if (idOffset < 0) { return ValidationResult.error("Invalid offset for Id"); @@ -448,7 +448,7 @@ public class Fluid { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 8) != 0) { int cubeTexturesOffset = buffer.getIntLE(offset + 26); if (cubeTexturesOffset < 0) { return ValidationResult.error("Invalid offset for CubeTextures"); @@ -480,7 +480,7 @@ public class Fluid { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 16) != 0) { int shaderEffectOffset = buffer.getIntLE(offset + 30); if (shaderEffectOffset < 0) { return ValidationResult.error("Invalid offset for ShaderEffect"); @@ -507,7 +507,7 @@ public class Fluid { } } - if ((nullBits & 16) != 0) { + if ((nullBits & 32) != 0) { int blockParticleSetIdOffset = buffer.getIntLE(offset + 34); if (blockParticleSetIdOffset < 0) { return ValidationResult.error("Invalid offset for BlockParticleSetId"); diff --git a/src/com/hypixel/hytale/protocol/FluidFX.java b/src/com/hypixel/hytale/protocol/FluidFX.java index d3b216c..dea3e88 100644 --- a/src/com/hypixel/hytale/protocol/FluidFX.java +++ b/src/com/hypixel/hytale/protocol/FluidFX.java @@ -92,28 +92,28 @@ public class FluidFX { byte nullBits = buf.getByte(offset); obj.shader = ShaderType.fromValue(buf.getByte(offset + 1)); obj.fogMode = FluidFog.fromValue(buf.getByte(offset + 2)); - if ((nullBits & 2) != 0) { + if ((nullBits & 1) != 0) { obj.fogColor = Color.deserialize(buf, offset + 3); } - if ((nullBits & 4) != 0) { + if ((nullBits & 2) != 0) { obj.fogDistance = NearFar.deserialize(buf, offset + 6); } obj.fogDepthStart = buf.getFloatLE(offset + 14); obj.fogDepthFalloff = buf.getFloatLE(offset + 18); - if ((nullBits & 8) != 0) { + if ((nullBits & 4) != 0) { obj.colorFilter = Color.deserialize(buf, offset + 22); } obj.colorSaturation = buf.getFloatLE(offset + 25); obj.distortionAmplitude = buf.getFloatLE(offset + 29); obj.distortionFrequency = buf.getFloatLE(offset + 33); - if ((nullBits & 32) != 0) { + if ((nullBits & 8) != 0) { obj.movementSettings = FluidFXMovementSettings.deserialize(buf, offset + 37); } - if ((nullBits & 1) != 0) { + if ((nullBits & 16) != 0) { int varPos0 = offset + 69 + buf.getIntLE(offset + 61); int idLen = VarInt.peek(buf, varPos0); if (idLen < 0) { @@ -127,7 +127,7 @@ public class FluidFX { obj.id = PacketIO.readVarString(buf, varPos0, PacketIO.UTF8); } - if ((nullBits & 16) != 0) { + if ((nullBits & 32) != 0) { int varPos1 = offset + 69 + buf.getIntLE(offset + 65); obj.particle = FluidParticle.deserialize(buf, varPos1); } @@ -138,7 +138,7 @@ public class FluidFX { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 69; - if ((nullBits & 1) != 0) { + if ((nullBits & 16) != 0) { int fieldOffset0 = buf.getIntLE(offset + 61); int pos0 = offset + 69 + fieldOffset0; int sl = VarInt.peek(buf, pos0); @@ -148,7 +148,7 @@ public class FluidFX { } } - if ((nullBits & 16) != 0) { + if ((nullBits & 32) != 0) { int fieldOffset1 = buf.getIntLE(offset + 65); int pos1 = offset + 69 + fieldOffset1; pos1 += FluidParticle.computeBytesConsumed(buf, pos1); @@ -163,27 +163,27 @@ public class FluidFX { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.id != null) { + if (this.fogColor != null) { nullBits = (byte)(nullBits | 1); } - if (this.fogColor != null) { + if (this.fogDistance != null) { nullBits = (byte)(nullBits | 2); } - if (this.fogDistance != null) { + if (this.colorFilter != null) { nullBits = (byte)(nullBits | 4); } - if (this.colorFilter != null) { + if (this.movementSettings != null) { nullBits = (byte)(nullBits | 8); } - if (this.particle != null) { + if (this.id != null) { nullBits = (byte)(nullBits | 16); } - if (this.movementSettings != null) { + if (this.particle != null) { nullBits = (byte)(nullBits | 32); } @@ -257,7 +257,7 @@ public class FluidFX { return ValidationResult.error("Buffer too small: expected at least 69 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 16) != 0) { int idOffset = buffer.getIntLE(offset + 61); if (idOffset < 0) { return ValidationResult.error("Invalid offset for Id"); @@ -284,7 +284,7 @@ public class FluidFX { } } - if ((nullBits & 16) != 0) { + if ((nullBits & 32) != 0) { int particleOffset = buffer.getIntLE(offset + 65); if (particleOffset < 0) { return ValidationResult.error("Invalid offset for Particle"); diff --git a/src/com/hypixel/hytale/protocol/FluidParticle.java b/src/com/hypixel/hytale/protocol/FluidParticle.java index ddaf033..517553d 100644 --- a/src/com/hypixel/hytale/protocol/FluidParticle.java +++ b/src/com/hypixel/hytale/protocol/FluidParticle.java @@ -40,13 +40,13 @@ public class FluidParticle { public static FluidParticle deserialize(@Nonnull ByteBuf buf, int offset) { FluidParticle obj = new FluidParticle(); byte nullBits = buf.getByte(offset); - if ((nullBits & 2) != 0) { + if ((nullBits & 1) != 0) { obj.color = Color.deserialize(buf, offset + 1); } obj.scale = buf.getFloatLE(offset + 4); int pos = offset + 8; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int systemIdLen = VarInt.peek(buf, pos); if (systemIdLen < 0) { throw ProtocolException.negativeLength("SystemId", systemIdLen); @@ -67,7 +67,7 @@ public class FluidParticle { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int pos = offset + 8; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int sl = VarInt.peek(buf, pos); pos += VarInt.length(buf, pos) + sl; } @@ -77,11 +77,11 @@ public class FluidParticle { public void serialize(@Nonnull ByteBuf buf) { byte nullBits = 0; - if (this.systemId != null) { + if (this.color != null) { nullBits = (byte)(nullBits | 1); } - if (this.color != null) { + if (this.systemId != null) { nullBits = (byte)(nullBits | 2); } @@ -113,7 +113,7 @@ public class FluidParticle { } else { byte nullBits = buffer.getByte(offset); int pos = offset + 8; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int systemIdLen = VarInt.peek(buffer, pos); if (systemIdLen < 0) { return ValidationResult.error("Invalid string length for SystemId"); diff --git a/src/com/hypixel/hytale/protocol/Interaction.java b/src/com/hypixel/hytale/protocol/Interaction.java index 3454e0e..73600eb 100644 --- a/src/com/hypixel/hytale/protocol/Interaction.java +++ b/src/com/hypixel/hytale/protocol/Interaction.java @@ -26,9 +26,6 @@ public abstract class Interaction { @Nullable public InteractionCameraSettings camera; - public Interaction() { - } - @Nonnull public static Interaction deserialize(@Nonnull ByteBuf buf, int offset) { int typeId = VarInt.peek(buf, offset); @@ -54,7 +51,7 @@ public abstract class Interaction { case 16 -> ChangeBlockInteraction.deserialize(buf, offset + typeIdLen); case 17 -> ChangeStateInteraction.deserialize(buf, offset + typeIdLen); case 18 -> FirstClickInteraction.deserialize(buf, offset + typeIdLen); - case 19 -> RefillContainerInteraction.deserialize(buf, offset + typeIdLen); + default -> throw ProtocolException.unknownPolymorphicType("Interaction", typeId); case 20 -> SelectInteraction.deserialize(buf, offset + typeIdLen); case 21 -> DamageEntityInteraction.deserialize(buf, offset + typeIdLen); case 22 -> RepeatInteraction.deserialize(buf, offset + typeIdLen); @@ -80,7 +77,6 @@ public abstract class Interaction { case 42 -> SpawnDeployableFromRaycastInteraction.deserialize(buf, offset + typeIdLen); case 43 -> MemoriesConditionInteraction.deserialize(buf, offset + typeIdLen); case 44 -> ToggleGliderInteraction.deserialize(buf, offset + typeIdLen); - default -> throw ProtocolException.unknownPolymorphicType("Interaction", typeId); }); } @@ -108,7 +104,7 @@ public abstract class Interaction { case 16 -> ChangeBlockInteraction.computeBytesConsumed(buf, offset + typeIdLen); case 17 -> ChangeStateInteraction.computeBytesConsumed(buf, offset + typeIdLen); case 18 -> FirstClickInteraction.computeBytesConsumed(buf, offset + typeIdLen); - case 19 -> RefillContainerInteraction.computeBytesConsumed(buf, offset + typeIdLen); + default -> throw ProtocolException.unknownPolymorphicType("Interaction", typeId); case 20 -> SelectInteraction.computeBytesConsumed(buf, offset + typeIdLen); case 21 -> DamageEntityInteraction.computeBytesConsumed(buf, offset + typeIdLen); case 22 -> RepeatInteraction.computeBytesConsumed(buf, offset + typeIdLen); @@ -134,7 +130,6 @@ public abstract class Interaction { case 42 -> SpawnDeployableFromRaycastInteraction.computeBytesConsumed(buf, offset + typeIdLen); case 43 -> MemoriesConditionInteraction.computeBytesConsumed(buf, offset + typeIdLen); case 44 -> ToggleGliderInteraction.computeBytesConsumed(buf, offset + typeIdLen); - default -> throw ProtocolException.unknownPolymorphicType("Interaction", typeId); }; } @@ -151,8 +146,6 @@ public abstract class Interaction { return 16; } else if (this instanceof ChangeStateInteraction sub) { return 17; - } else if (this instanceof RefillContainerInteraction sub) { - return 19; } else if (this instanceof SimpleBlockInteraction sub) { return 0; } else if (this instanceof PlaceBlockInteraction sub) { @@ -273,7 +266,7 @@ public abstract class Interaction { case 16 -> ChangeBlockInteraction.validateStructure(buffer, offset + typeIdLen); case 17 -> ChangeStateInteraction.validateStructure(buffer, offset + typeIdLen); case 18 -> FirstClickInteraction.validateStructure(buffer, offset + typeIdLen); - case 19 -> RefillContainerInteraction.validateStructure(buffer, offset + typeIdLen); + default -> ValidationResult.error("Unknown polymorphic type ID " + typeId + " for Interaction"); case 20 -> SelectInteraction.validateStructure(buffer, offset + typeIdLen); case 21 -> DamageEntityInteraction.validateStructure(buffer, offset + typeIdLen); case 22 -> RepeatInteraction.validateStructure(buffer, offset + typeIdLen); @@ -299,7 +292,6 @@ public abstract class Interaction { case 42 -> SpawnDeployableFromRaycastInteraction.validateStructure(buffer, offset + typeIdLen); case 43 -> MemoriesConditionInteraction.validateStructure(buffer, offset + typeIdLen); case 44 -> ToggleGliderInteraction.validateStructure(buffer, offset + typeIdLen); - default -> ValidationResult.error("Unknown polymorphic type ID " + typeId + " for Interaction"); }; } } diff --git a/src/com/hypixel/hytale/protocol/InteractionChainData.java b/src/com/hypixel/hytale/protocol/InteractionChainData.java index cc34cb7..ec52bb4 100644 --- a/src/com/hypixel/hytale/protocol/InteractionChainData.java +++ b/src/com/hypixel/hytale/protocol/InteractionChainData.java @@ -70,17 +70,17 @@ public class InteractionChainData { obj.hitLocation = Vector3f.deserialize(buf, offset + 21); } - if ((nullBits & 4) != 0) { + if ((nullBits & 2) != 0) { obj.blockPosition = BlockPosition.deserialize(buf, offset + 33); } obj.targetSlot = buf.getIntLE(offset + 45); - if ((nullBits & 8) != 0) { + if ((nullBits & 4) != 0) { obj.hitNormal = Vector3f.deserialize(buf, offset + 49); } int pos = offset + 61; - if ((nullBits & 2) != 0) { + if ((nullBits & 8) != 0) { int hitDetailLen = VarInt.peek(buf, pos); if (hitDetailLen < 0) { throw ProtocolException.negativeLength("HitDetail", hitDetailLen); @@ -101,7 +101,7 @@ public class InteractionChainData { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int pos = offset + 61; - if ((nullBits & 2) != 0) { + if ((nullBits & 8) != 0) { int sl = VarInt.peek(buf, pos); pos += VarInt.length(buf, pos) + sl; } @@ -115,15 +115,15 @@ public class InteractionChainData { nullBits = (byte)(nullBits | 1); } - if (this.hitDetail != null) { + if (this.blockPosition != null) { nullBits = (byte)(nullBits | 2); } - if (this.blockPosition != null) { + if (this.hitNormal != null) { nullBits = (byte)(nullBits | 4); } - if (this.hitNormal != null) { + if (this.hitDetail != null) { nullBits = (byte)(nullBits | 8); } @@ -169,7 +169,7 @@ public class InteractionChainData { } else { byte nullBits = buffer.getByte(offset); int pos = offset + 61; - if ((nullBits & 2) != 0) { + if ((nullBits & 8) != 0) { int hitDetailLen = VarInt.peek(buffer, pos); if (hitDetailLen < 0) { return ValidationResult.error("Invalid string length for HitDetail"); diff --git a/src/com/hypixel/hytale/protocol/InteractionEffects.java b/src/com/hypixel/hytale/protocol/InteractionEffects.java index 5b31d88..08b4f5f 100644 --- a/src/com/hypixel/hytale/protocol/InteractionEffects.java +++ b/src/com/hypixel/hytale/protocol/InteractionEffects.java @@ -96,16 +96,16 @@ public class InteractionEffects { obj.waitForAnimationToFinish = buf.getByte(offset + 9) != 0; obj.clearAnimationOnFinish = buf.getByte(offset + 10) != 0; obj.clearSoundEventOnFinish = buf.getByte(offset + 11) != 0; - if ((nullBits & 32) != 0) { + if ((nullBits & 1) != 0) { obj.cameraShake = CameraShakeEffect.deserialize(buf, offset + 12); } - if ((nullBits & 64) != 0) { + if ((nullBits & 2) != 0) { obj.movementEffects = MovementEffects.deserialize(buf, offset + 21); } obj.startDelay = buf.getFloatLE(offset + 28); - if ((nullBits & 1) != 0) { + if ((nullBits & 4) != 0) { int varPos0 = offset + 52 + buf.getIntLE(offset + 32); int particlesCount = VarInt.peek(buf, varPos0); if (particlesCount < 0) { @@ -130,7 +130,7 @@ public class InteractionEffects { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 8) != 0) { int varPos1 = offset + 52 + buf.getIntLE(offset + 36); int firstPersonParticlesCount = VarInt.peek(buf, varPos1); if (firstPersonParticlesCount < 0) { @@ -155,7 +155,7 @@ public class InteractionEffects { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 16) != 0) { int varPos2 = offset + 52 + buf.getIntLE(offset + 40); int trailsCount = VarInt.peek(buf, varPos2); if (trailsCount < 0) { @@ -180,7 +180,7 @@ public class InteractionEffects { } } - if ((nullBits & 8) != 0) { + if ((nullBits & 32) != 0) { int varPos3 = offset + 52 + buf.getIntLE(offset + 44); int itemPlayerAnimationsIdLen = VarInt.peek(buf, varPos3); if (itemPlayerAnimationsIdLen < 0) { @@ -194,7 +194,7 @@ public class InteractionEffects { obj.itemPlayerAnimationsId = PacketIO.readVarString(buf, varPos3, PacketIO.UTF8); } - if ((nullBits & 16) != 0) { + if ((nullBits & 64) != 0) { int varPos4 = offset + 52 + buf.getIntLE(offset + 48); int itemAnimationIdLen = VarInt.peek(buf, varPos4); if (itemAnimationIdLen < 0) { @@ -214,7 +214,7 @@ public class InteractionEffects { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 52; - if ((nullBits & 1) != 0) { + if ((nullBits & 4) != 0) { int fieldOffset0 = buf.getIntLE(offset + 32); int pos0 = offset + 52 + fieldOffset0; int arrLen = VarInt.peek(buf, pos0); @@ -229,7 +229,7 @@ public class InteractionEffects { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 8) != 0) { int fieldOffset1 = buf.getIntLE(offset + 36); int pos1 = offset + 52 + fieldOffset1; int arrLen = VarInt.peek(buf, pos1); @@ -244,7 +244,7 @@ public class InteractionEffects { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 16) != 0) { int fieldOffset2 = buf.getIntLE(offset + 40); int pos2 = offset + 52 + fieldOffset2; int arrLen = VarInt.peek(buf, pos2); @@ -259,7 +259,7 @@ public class InteractionEffects { } } - if ((nullBits & 8) != 0) { + if ((nullBits & 32) != 0) { int fieldOffset3 = buf.getIntLE(offset + 44); int pos3 = offset + 52 + fieldOffset3; int sl = VarInt.peek(buf, pos3); @@ -269,7 +269,7 @@ public class InteractionEffects { } } - if ((nullBits & 16) != 0) { + if ((nullBits & 64) != 0) { int fieldOffset4 = buf.getIntLE(offset + 48); int pos4 = offset + 52 + fieldOffset4; int sl = VarInt.peek(buf, pos4); @@ -285,31 +285,31 @@ public class InteractionEffects { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.particles != null) { + if (this.cameraShake != null) { nullBits = (byte)(nullBits | 1); } - if (this.firstPersonParticles != null) { + if (this.movementEffects != null) { nullBits = (byte)(nullBits | 2); } - if (this.trails != null) { + if (this.particles != null) { nullBits = (byte)(nullBits | 4); } - if (this.itemPlayerAnimationsId != null) { + if (this.firstPersonParticles != null) { nullBits = (byte)(nullBits | 8); } - if (this.itemAnimationId != null) { + if (this.trails != null) { nullBits = (byte)(nullBits | 16); } - if (this.cameraShake != null) { + if (this.itemPlayerAnimationsId != null) { nullBits = (byte)(nullBits | 32); } - if (this.movementEffects != null) { + if (this.itemAnimationId != null) { nullBits = (byte)(nullBits | 64); } @@ -451,7 +451,7 @@ public class InteractionEffects { return ValidationResult.error("Buffer too small: expected at least 52 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 4) != 0) { int particlesOffset = buffer.getIntLE(offset + 32); if (particlesOffset < 0) { return ValidationResult.error("Invalid offset for Particles"); @@ -483,7 +483,7 @@ public class InteractionEffects { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 8) != 0) { int firstPersonParticlesOffset = buffer.getIntLE(offset + 36); if (firstPersonParticlesOffset < 0) { return ValidationResult.error("Invalid offset for FirstPersonParticles"); @@ -515,7 +515,7 @@ public class InteractionEffects { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 16) != 0) { int trailsOffset = buffer.getIntLE(offset + 40); if (trailsOffset < 0) { return ValidationResult.error("Invalid offset for Trails"); @@ -547,7 +547,7 @@ public class InteractionEffects { } } - if ((nullBits & 8) != 0) { + if ((nullBits & 32) != 0) { int itemPlayerAnimationsIdOffset = buffer.getIntLE(offset + 44); if (itemPlayerAnimationsIdOffset < 0) { return ValidationResult.error("Invalid offset for ItemPlayerAnimationsId"); @@ -574,7 +574,7 @@ public class InteractionEffects { } } - if ((nullBits & 16) != 0) { + if ((nullBits & 64) != 0) { int itemAnimationIdOffset = buffer.getIntLE(offset + 48); if (itemAnimationIdOffset < 0) { return ValidationResult.error("Invalid offset for ItemAnimationId"); diff --git a/src/com/hypixel/hytale/protocol/InteractionSyncData.java b/src/com/hypixel/hytale/protocol/InteractionSyncData.java index 6c344af..7188545 100644 --- a/src/com/hypixel/hytale/protocol/InteractionSyncData.java +++ b/src/com/hypixel/hytale/protocol/InteractionSyncData.java @@ -168,31 +168,31 @@ public class InteractionSyncData { obj.chargeValue = buf.getFloatLE(offset + 47); obj.chainingIndex = buf.getIntLE(offset + 51); obj.flagIndex = buf.getIntLE(offset + 55); - if ((nullBits[0] & 16) != 0) { + if ((nullBits[0] & 4) != 0) { obj.attackerPos = Position.deserialize(buf, offset + 59); } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[0] & 8) != 0) { obj.attackerRot = Direction.deserialize(buf, offset + 83); } - if ((nullBits[0] & 64) != 0) { + if ((nullBits[0] & 16) != 0) { obj.raycastHit = Position.deserialize(buf, offset + 95); } obj.raycastDistance = buf.getFloatLE(offset + 119); - if ((nullBits[0] & 128) != 0) { + if ((nullBits[0] & 32) != 0) { obj.raycastNormal = Vector3f.deserialize(buf, offset + 123); } obj.movementDirection = MovementDirection.fromValue(buf.getByte(offset + 135)); obj.applyForceState = ApplyForceState.fromValue(buf.getByte(offset + 136)); obj.nextLabel = buf.getIntLE(offset + 137); - if ((nullBits[1] & 1) != 0) { + if ((nullBits[0] & 64) != 0) { obj.generatedUUID = PacketIO.readUUID(buf, offset + 141); } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 128) != 0) { int varPos0 = offset + 165 + buf.getIntLE(offset + 157); int forkCountsCount = VarInt.peek(buf, varPos0); if (forkCountsCount < 0) { @@ -217,7 +217,7 @@ public class InteractionSyncData { } } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[1] & 1) != 0) { int varPos1 = offset + 165 + buf.getIntLE(offset + 161); int hitEntitiesCount = VarInt.peek(buf, varPos1); if (hitEntitiesCount < 0) { @@ -248,7 +248,7 @@ public class InteractionSyncData { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte[] nullBits = PacketIO.readBytes(buf, offset, 2); int maxEnd = 165; - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 128) != 0) { int fieldOffset0 = buf.getIntLE(offset + 157); int pos0 = offset + 165 + fieldOffset0; int dictLen = VarInt.peek(buf, pos0); @@ -263,7 +263,7 @@ public class InteractionSyncData { } } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[1] & 1) != 0) { int fieldOffset1 = buf.getIntLE(offset + 161); int pos1 = offset + 165 + fieldOffset1; int arrLen = VarInt.peek(buf, pos1); @@ -292,31 +292,31 @@ public class InteractionSyncData { nullBits[0] = (byte)(nullBits[0] | 2); } - if (this.forkCounts != null) { + if (this.attackerPos != null) { nullBits[0] = (byte)(nullBits[0] | 4); } - if (this.hitEntities != null) { + if (this.attackerRot != null) { nullBits[0] = (byte)(nullBits[0] | 8); } - if (this.attackerPos != null) { + if (this.raycastHit != null) { nullBits[0] = (byte)(nullBits[0] | 16); } - if (this.attackerRot != null) { + if (this.raycastNormal != null) { nullBits[0] = (byte)(nullBits[0] | 32); } - if (this.raycastHit != null) { + if (this.generatedUUID != null) { nullBits[0] = (byte)(nullBits[0] | 64); } - if (this.raycastNormal != null) { + if (this.forkCounts != null) { nullBits[0] = (byte)(nullBits[0] | 128); } - if (this.generatedUUID != null) { + if (this.hitEntities != null) { nullBits[1] = (byte)(nullBits[1] | 1); } @@ -434,7 +434,7 @@ public class InteractionSyncData { return ValidationResult.error("Buffer too small: expected at least 165 bytes"); } else { byte[] nullBits = PacketIO.readBytes(buffer, offset, 2); - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 128) != 0) { int forkCountsOffset = buffer.getIntLE(offset + 157); if (forkCountsOffset < 0) { return ValidationResult.error("Invalid offset for ForkCounts"); @@ -464,7 +464,7 @@ public class InteractionSyncData { } } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[1] & 1) != 0) { int hitEntitiesOffset = buffer.getIntLE(offset + 161); if (hitEntitiesOffset < 0) { return ValidationResult.error("Invalid offset for HitEntities"); diff --git a/src/com/hypixel/hytale/protocol/ItemAppearanceCondition.java b/src/com/hypixel/hytale/protocol/ItemAppearanceCondition.java index 05e7f27..8aba744 100644 --- a/src/com/hypixel/hytale/protocol/ItemAppearanceCondition.java +++ b/src/com/hypixel/hytale/protocol/ItemAppearanceCondition.java @@ -74,14 +74,14 @@ public class ItemAppearanceCondition { public static ItemAppearanceCondition deserialize(@Nonnull ByteBuf buf, int offset) { ItemAppearanceCondition obj = new ItemAppearanceCondition(); byte nullBits = buf.getByte(offset); - if ((nullBits & 32) != 0) { + if ((nullBits & 1) != 0) { obj.condition = FloatRange.deserialize(buf, offset + 1); } obj.conditionValueType = ValueType.fromValue(buf.getByte(offset + 9)); obj.localSoundEventId = buf.getIntLE(offset + 10); obj.worldSoundEventId = buf.getIntLE(offset + 14); - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int varPos0 = offset + 38 + buf.getIntLE(offset + 18); int particlesCount = VarInt.peek(buf, varPos0); if (particlesCount < 0) { @@ -106,7 +106,7 @@ public class ItemAppearanceCondition { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int varPos1 = offset + 38 + buf.getIntLE(offset + 22); int firstPersonParticlesCount = VarInt.peek(buf, varPos1); if (firstPersonParticlesCount < 0) { @@ -131,7 +131,7 @@ public class ItemAppearanceCondition { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 8) != 0) { int varPos2 = offset + 38 + buf.getIntLE(offset + 26); int modelLen = VarInt.peek(buf, varPos2); if (modelLen < 0) { @@ -145,7 +145,7 @@ public class ItemAppearanceCondition { obj.model = PacketIO.readVarString(buf, varPos2, PacketIO.UTF8); } - if ((nullBits & 8) != 0) { + if ((nullBits & 16) != 0) { int varPos3 = offset + 38 + buf.getIntLE(offset + 30); int textureLen = VarInt.peek(buf, varPos3); if (textureLen < 0) { @@ -159,7 +159,7 @@ public class ItemAppearanceCondition { obj.texture = PacketIO.readVarString(buf, varPos3, PacketIO.UTF8); } - if ((nullBits & 16) != 0) { + if ((nullBits & 32) != 0) { int varPos4 = offset + 38 + buf.getIntLE(offset + 34); int modelVFXIdLen = VarInt.peek(buf, varPos4); if (modelVFXIdLen < 0) { @@ -179,7 +179,7 @@ public class ItemAppearanceCondition { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 38; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int fieldOffset0 = buf.getIntLE(offset + 18); int pos0 = offset + 38 + fieldOffset0; int arrLen = VarInt.peek(buf, pos0); @@ -194,7 +194,7 @@ public class ItemAppearanceCondition { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int fieldOffset1 = buf.getIntLE(offset + 22); int pos1 = offset + 38 + fieldOffset1; int arrLen = VarInt.peek(buf, pos1); @@ -209,7 +209,7 @@ public class ItemAppearanceCondition { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 8) != 0) { int fieldOffset2 = buf.getIntLE(offset + 26); int pos2 = offset + 38 + fieldOffset2; int sl = VarInt.peek(buf, pos2); @@ -219,7 +219,7 @@ public class ItemAppearanceCondition { } } - if ((nullBits & 8) != 0) { + if ((nullBits & 16) != 0) { int fieldOffset3 = buf.getIntLE(offset + 30); int pos3 = offset + 38 + fieldOffset3; int sl = VarInt.peek(buf, pos3); @@ -229,7 +229,7 @@ public class ItemAppearanceCondition { } } - if ((nullBits & 16) != 0) { + if ((nullBits & 32) != 0) { int fieldOffset4 = buf.getIntLE(offset + 34); int pos4 = offset + 38 + fieldOffset4; int sl = VarInt.peek(buf, pos4); @@ -245,27 +245,27 @@ public class ItemAppearanceCondition { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.particles != null) { + if (this.condition != null) { nullBits = (byte)(nullBits | 1); } - if (this.firstPersonParticles != null) { + if (this.particles != null) { nullBits = (byte)(nullBits | 2); } - if (this.model != null) { + if (this.firstPersonParticles != null) { nullBits = (byte)(nullBits | 4); } - if (this.texture != null) { + if (this.model != null) { nullBits = (byte)(nullBits | 8); } - if (this.modelVFXId != null) { + if (this.texture != null) { nullBits = (byte)(nullBits | 16); } - if (this.condition != null) { + if (this.modelVFXId != null) { nullBits = (byte)(nullBits | 32); } @@ -384,7 +384,7 @@ public class ItemAppearanceCondition { return ValidationResult.error("Buffer too small: expected at least 38 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int particlesOffset = buffer.getIntLE(offset + 18); if (particlesOffset < 0) { return ValidationResult.error("Invalid offset for Particles"); @@ -416,7 +416,7 @@ public class ItemAppearanceCondition { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int firstPersonParticlesOffset = buffer.getIntLE(offset + 22); if (firstPersonParticlesOffset < 0) { return ValidationResult.error("Invalid offset for FirstPersonParticles"); @@ -448,7 +448,7 @@ public class ItemAppearanceCondition { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 8) != 0) { int modelOffset = buffer.getIntLE(offset + 26); if (modelOffset < 0) { return ValidationResult.error("Invalid offset for Model"); @@ -475,7 +475,7 @@ public class ItemAppearanceCondition { } } - if ((nullBits & 8) != 0) { + if ((nullBits & 16) != 0) { int textureOffset = buffer.getIntLE(offset + 30); if (textureOffset < 0) { return ValidationResult.error("Invalid offset for Texture"); @@ -502,7 +502,7 @@ public class ItemAppearanceCondition { } } - if ((nullBits & 16) != 0) { + if ((nullBits & 32) != 0) { int modelVFXIdOffset = buffer.getIntLE(offset + 34); if (modelVFXIdOffset < 0) { return ValidationResult.error("Invalid offset for ModelVFXId"); diff --git a/src/com/hypixel/hytale/protocol/ItemBase.java b/src/com/hypixel/hytale/protocol/ItemBase.java index 17bdbfd..c355600 100644 --- a/src/com/hypixel/hytale/protocol/ItemBase.java +++ b/src/com/hypixel/hytale/protocol/ItemBase.java @@ -249,7 +249,7 @@ public class ItemBase { obj.usePlayerAnimations = buf.getByte(offset + 8) != 0; obj.maxStack = buf.getIntLE(offset + 9); obj.reticleIndex = buf.getIntLE(offset + 13); - if ((nullBits[0] & 64) != 0) { + if ((nullBits[0] & 1) != 0) { obj.iconProperties = AssetIconProperties.deserialize(buf, offset + 17); } @@ -258,28 +258,28 @@ public class ItemBase { obj.consumable = buf.getByte(offset + 50) != 0; obj.variant = buf.getByte(offset + 51) != 0; obj.blockId = buf.getIntLE(offset + 52); - if ((nullBits[1] & 16) != 0) { + if ((nullBits[0] & 2) != 0) { obj.gliderConfig = ItemGlider.deserialize(buf, offset + 56); } - if ((nullBits[1] & 64) != 0) { + if ((nullBits[0] & 4) != 0) { obj.blockSelectorTool = BlockSelectorToolData.deserialize(buf, offset + 72); } - if ((nullBits[2] & 64) != 0) { + if ((nullBits[0] & 8) != 0) { obj.light = ColorLight.deserialize(buf, offset + 76); } obj.durability = buf.getDoubleLE(offset + 80); obj.soundEventIndex = buf.getIntLE(offset + 88); obj.itemSoundSetIndex = buf.getIntLE(offset + 92); - if ((nullBits[3] & 64) != 0) { + if ((nullBits[0] & 16) != 0) { obj.pullbackConfig = ItemPullbackConfiguration.deserialize(buf, offset + 96); } obj.clipsGeometry = buf.getByte(offset + 145) != 0; obj.renderDeployablePreview = buf.getByte(offset + 146) != 0; - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 32) != 0) { int varPos0 = offset + 251 + buf.getIntLE(offset + 147); int idLen = VarInt.peek(buf, varPos0); if (idLen < 0) { @@ -293,7 +293,7 @@ public class ItemBase { obj.id = PacketIO.readVarString(buf, varPos0, PacketIO.UTF8); } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 64) != 0) { int varPos1 = offset + 251 + buf.getIntLE(offset + 151); int modelLen = VarInt.peek(buf, varPos1); if (modelLen < 0) { @@ -307,7 +307,7 @@ public class ItemBase { obj.model = PacketIO.readVarString(buf, varPos1, PacketIO.UTF8); } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 128) != 0) { int varPos2 = offset + 251 + buf.getIntLE(offset + 155); int textureLen = VarInt.peek(buf, varPos2); if (textureLen < 0) { @@ -321,7 +321,7 @@ public class ItemBase { obj.texture = PacketIO.readVarString(buf, varPos2, PacketIO.UTF8); } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[1] & 1) != 0) { int varPos3 = offset + 251 + buf.getIntLE(offset + 159); int animationLen = VarInt.peek(buf, varPos3); if (animationLen < 0) { @@ -335,7 +335,7 @@ public class ItemBase { obj.animation = PacketIO.readVarString(buf, varPos3, PacketIO.UTF8); } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[1] & 2) != 0) { int varPos4 = offset + 251 + buf.getIntLE(offset + 163); int playerAnimationsIdLen = VarInt.peek(buf, varPos4); if (playerAnimationsIdLen < 0) { @@ -349,7 +349,7 @@ public class ItemBase { obj.playerAnimationsId = PacketIO.readVarString(buf, varPos4, PacketIO.UTF8); } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[1] & 4) != 0) { int varPos5 = offset + 251 + buf.getIntLE(offset + 167); int iconLen = VarInt.peek(buf, varPos5); if (iconLen < 0) { @@ -363,12 +363,12 @@ public class ItemBase { obj.icon = PacketIO.readVarString(buf, varPos5, PacketIO.UTF8); } - if ((nullBits[0] & 128) != 0) { + if ((nullBits[1] & 8) != 0) { int varPos6 = offset + 251 + buf.getIntLE(offset + 171); obj.translationProperties = ItemTranslationProperties.deserialize(buf, varPos6); } - if ((nullBits[1] & 1) != 0) { + if ((nullBits[1] & 16) != 0) { int varPos7 = offset + 251 + buf.getIntLE(offset + 175); int resourceTypesCount = VarInt.peek(buf, varPos7); if (resourceTypesCount < 0) { @@ -393,37 +393,37 @@ public class ItemBase { } } - if ((nullBits[1] & 2) != 0) { + if ((nullBits[1] & 32) != 0) { int varPos8 = offset + 251 + buf.getIntLE(offset + 179); obj.tool = ItemTool.deserialize(buf, varPos8); } - if ((nullBits[1] & 4) != 0) { + if ((nullBits[1] & 64) != 0) { int varPos9 = offset + 251 + buf.getIntLE(offset + 183); obj.weapon = ItemWeapon.deserialize(buf, varPos9); } - if ((nullBits[1] & 8) != 0) { + if ((nullBits[1] & 128) != 0) { int varPos10 = offset + 251 + buf.getIntLE(offset + 187); obj.armor = ItemArmor.deserialize(buf, varPos10); } - if ((nullBits[1] & 32) != 0) { + if ((nullBits[2] & 1) != 0) { int varPos11 = offset + 251 + buf.getIntLE(offset + 191); obj.utility = ItemUtility.deserialize(buf, varPos11); } - if ((nullBits[1] & 128) != 0) { + if ((nullBits[2] & 2) != 0) { int varPos12 = offset + 251 + buf.getIntLE(offset + 195); obj.builderToolData = ItemBuilderToolData.deserialize(buf, varPos12); } - if ((nullBits[2] & 1) != 0) { + if ((nullBits[2] & 4) != 0) { int varPos13 = offset + 251 + buf.getIntLE(offset + 199); obj.itemEntity = ItemEntityConfig.deserialize(buf, varPos13); } - if ((nullBits[2] & 2) != 0) { + if ((nullBits[2] & 8) != 0) { int varPos14 = offset + 251 + buf.getIntLE(offset + 203); int setLen = VarInt.peek(buf, varPos14); if (setLen < 0) { @@ -437,7 +437,7 @@ public class ItemBase { obj.set = PacketIO.readVarString(buf, varPos14, PacketIO.UTF8); } - if ((nullBits[2] & 4) != 0) { + if ((nullBits[2] & 16) != 0) { int varPos15 = offset + 251 + buf.getIntLE(offset + 207); int categoriesCount = VarInt.peek(buf, varPos15); if (categoriesCount < 0) { @@ -472,7 +472,7 @@ public class ItemBase { } } - if ((nullBits[2] & 8) != 0) { + if ((nullBits[2] & 32) != 0) { int varPos16 = offset + 251 + buf.getIntLE(offset + 211); int particlesCount = VarInt.peek(buf, varPos16); if (particlesCount < 0) { @@ -497,7 +497,7 @@ public class ItemBase { } } - if ((nullBits[2] & 16) != 0) { + if ((nullBits[2] & 64) != 0) { int varPos17 = offset + 251 + buf.getIntLE(offset + 215); int firstPersonParticlesCount = VarInt.peek(buf, varPos17); if (firstPersonParticlesCount < 0) { @@ -522,7 +522,7 @@ public class ItemBase { } } - if ((nullBits[2] & 32) != 0) { + if ((nullBits[2] & 128) != 0) { int varPos18 = offset + 251 + buf.getIntLE(offset + 219); int trailsCount = VarInt.peek(buf, varPos18); if (trailsCount < 0) { @@ -547,7 +547,7 @@ public class ItemBase { } } - if ((nullBits[2] & 128) != 0) { + if ((nullBits[3] & 1) != 0) { int varPos19 = offset + 251 + buf.getIntLE(offset + 223); int interactionsCount = VarInt.peek(buf, varPos19); if (interactionsCount < 0) { @@ -572,7 +572,7 @@ public class ItemBase { } } - if ((nullBits[3] & 1) != 0) { + if ((nullBits[3] & 2) != 0) { int varPos20 = offset + 251 + buf.getIntLE(offset + 227); int interactionVarsCount = VarInt.peek(buf, varPos20); if (interactionVarsCount < 0) { @@ -608,12 +608,12 @@ public class ItemBase { } } - if ((nullBits[3] & 2) != 0) { + if ((nullBits[3] & 4) != 0) { int varPos21 = offset + 251 + buf.getIntLE(offset + 231); obj.interactionConfig = InteractionConfiguration.deserialize(buf, varPos21); } - if ((nullBits[3] & 4) != 0) { + if ((nullBits[3] & 8) != 0) { int varPos22 = offset + 251 + buf.getIntLE(offset + 235); int droppedItemAnimationLen = VarInt.peek(buf, varPos22); if (droppedItemAnimationLen < 0) { @@ -627,7 +627,7 @@ public class ItemBase { obj.droppedItemAnimation = PacketIO.readVarString(buf, varPos22, PacketIO.UTF8); } - if ((nullBits[3] & 8) != 0) { + if ((nullBits[3] & 16) != 0) { int varPos23 = offset + 251 + buf.getIntLE(offset + 239); int tagIndexesCount = VarInt.peek(buf, varPos23); if (tagIndexesCount < 0) { @@ -650,7 +650,7 @@ public class ItemBase { } } - if ((nullBits[3] & 16) != 0) { + if ((nullBits[3] & 32) != 0) { int varPos24 = offset + 251 + buf.getIntLE(offset + 243); int itemAppearanceConditionsCount = VarInt.peek(buf, varPos24); if (itemAppearanceConditionsCount < 0) { @@ -696,7 +696,7 @@ public class ItemBase { } } - if ((nullBits[3] & 32) != 0) { + if ((nullBits[3] & 64) != 0) { int varPos25 = offset + 251 + buf.getIntLE(offset + 247); int displayEntityStatsHUDCount = VarInt.peek(buf, varPos25); if (displayEntityStatsHUDCount < 0) { @@ -725,7 +725,7 @@ public class ItemBase { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte[] nullBits = PacketIO.readBytes(buf, offset, 4); int maxEnd = 251; - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 32) != 0) { int fieldOffset0 = buf.getIntLE(offset + 147); int pos0 = offset + 251 + fieldOffset0; int sl = VarInt.peek(buf, pos0); @@ -735,7 +735,7 @@ public class ItemBase { } } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 64) != 0) { int fieldOffset1 = buf.getIntLE(offset + 151); int pos1 = offset + 251 + fieldOffset1; int sl = VarInt.peek(buf, pos1); @@ -745,7 +745,7 @@ public class ItemBase { } } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 128) != 0) { int fieldOffset2 = buf.getIntLE(offset + 155); int pos2 = offset + 251 + fieldOffset2; int sl = VarInt.peek(buf, pos2); @@ -755,7 +755,7 @@ public class ItemBase { } } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[1] & 1) != 0) { int fieldOffset3 = buf.getIntLE(offset + 159); int pos3 = offset + 251 + fieldOffset3; int sl = VarInt.peek(buf, pos3); @@ -765,7 +765,7 @@ public class ItemBase { } } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[1] & 2) != 0) { int fieldOffset4 = buf.getIntLE(offset + 163); int pos4 = offset + 251 + fieldOffset4; int sl = VarInt.peek(buf, pos4); @@ -775,7 +775,7 @@ public class ItemBase { } } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[1] & 4) != 0) { int fieldOffset5 = buf.getIntLE(offset + 167); int pos5 = offset + 251 + fieldOffset5; int sl = VarInt.peek(buf, pos5); @@ -785,7 +785,7 @@ public class ItemBase { } } - if ((nullBits[0] & 128) != 0) { + if ((nullBits[1] & 8) != 0) { int fieldOffset6 = buf.getIntLE(offset + 171); int pos6 = offset + 251 + fieldOffset6; pos6 += ItemTranslationProperties.computeBytesConsumed(buf, pos6); @@ -794,7 +794,7 @@ public class ItemBase { } } - if ((nullBits[1] & 1) != 0) { + if ((nullBits[1] & 16) != 0) { int fieldOffset7 = buf.getIntLE(offset + 175); int pos7 = offset + 251 + fieldOffset7; int arrLen = VarInt.peek(buf, pos7); @@ -809,7 +809,7 @@ public class ItemBase { } } - if ((nullBits[1] & 2) != 0) { + if ((nullBits[1] & 32) != 0) { int fieldOffset8 = buf.getIntLE(offset + 179); int pos8 = offset + 251 + fieldOffset8; pos8 += ItemTool.computeBytesConsumed(buf, pos8); @@ -818,7 +818,7 @@ public class ItemBase { } } - if ((nullBits[1] & 4) != 0) { + if ((nullBits[1] & 64) != 0) { int fieldOffset9 = buf.getIntLE(offset + 183); int pos9 = offset + 251 + fieldOffset9; pos9 += ItemWeapon.computeBytesConsumed(buf, pos9); @@ -827,7 +827,7 @@ public class ItemBase { } } - if ((nullBits[1] & 8) != 0) { + if ((nullBits[1] & 128) != 0) { int fieldOffset10 = buf.getIntLE(offset + 187); int pos10 = offset + 251 + fieldOffset10; pos10 += ItemArmor.computeBytesConsumed(buf, pos10); @@ -836,7 +836,7 @@ public class ItemBase { } } - if ((nullBits[1] & 32) != 0) { + if ((nullBits[2] & 1) != 0) { int fieldOffset11 = buf.getIntLE(offset + 191); int pos11 = offset + 251 + fieldOffset11; pos11 += ItemUtility.computeBytesConsumed(buf, pos11); @@ -845,7 +845,7 @@ public class ItemBase { } } - if ((nullBits[1] & 128) != 0) { + if ((nullBits[2] & 2) != 0) { int fieldOffset12 = buf.getIntLE(offset + 195); int pos12 = offset + 251 + fieldOffset12; pos12 += ItemBuilderToolData.computeBytesConsumed(buf, pos12); @@ -854,7 +854,7 @@ public class ItemBase { } } - if ((nullBits[2] & 1) != 0) { + if ((nullBits[2] & 4) != 0) { int fieldOffset13 = buf.getIntLE(offset + 199); int pos13 = offset + 251 + fieldOffset13; pos13 += ItemEntityConfig.computeBytesConsumed(buf, pos13); @@ -863,7 +863,7 @@ public class ItemBase { } } - if ((nullBits[2] & 2) != 0) { + if ((nullBits[2] & 8) != 0) { int fieldOffset14 = buf.getIntLE(offset + 203); int pos14 = offset + 251 + fieldOffset14; int sl = VarInt.peek(buf, pos14); @@ -873,7 +873,7 @@ public class ItemBase { } } - if ((nullBits[2] & 4) != 0) { + if ((nullBits[2] & 16) != 0) { int fieldOffset15 = buf.getIntLE(offset + 207); int pos15 = offset + 251 + fieldOffset15; int arrLen = VarInt.peek(buf, pos15); @@ -889,7 +889,7 @@ public class ItemBase { } } - if ((nullBits[2] & 8) != 0) { + if ((nullBits[2] & 32) != 0) { int fieldOffset16 = buf.getIntLE(offset + 211); int pos16 = offset + 251 + fieldOffset16; int arrLen = VarInt.peek(buf, pos16); @@ -904,7 +904,7 @@ public class ItemBase { } } - if ((nullBits[2] & 16) != 0) { + if ((nullBits[2] & 64) != 0) { int fieldOffset17 = buf.getIntLE(offset + 215); int pos17 = offset + 251 + fieldOffset17; int arrLen = VarInt.peek(buf, pos17); @@ -919,7 +919,7 @@ public class ItemBase { } } - if ((nullBits[2] & 32) != 0) { + if ((nullBits[2] & 128) != 0) { int fieldOffset18 = buf.getIntLE(offset + 219); int pos18 = offset + 251 + fieldOffset18; int arrLen = VarInt.peek(buf, pos18); @@ -934,7 +934,7 @@ public class ItemBase { } } - if ((nullBits[2] & 128) != 0) { + if ((nullBits[3] & 1) != 0) { int fieldOffset19 = buf.getIntLE(offset + 223); int pos19 = offset + 251 + fieldOffset19; int dictLen = VarInt.peek(buf, pos19); @@ -949,7 +949,7 @@ public class ItemBase { } } - if ((nullBits[3] & 1) != 0) { + if ((nullBits[3] & 2) != 0) { int fieldOffset20 = buf.getIntLE(offset + 227); int pos20 = offset + 251 + fieldOffset20; int dictLen = VarInt.peek(buf, pos20); @@ -966,7 +966,7 @@ public class ItemBase { } } - if ((nullBits[3] & 2) != 0) { + if ((nullBits[3] & 4) != 0) { int fieldOffset21 = buf.getIntLE(offset + 231); int pos21 = offset + 251 + fieldOffset21; pos21 += InteractionConfiguration.computeBytesConsumed(buf, pos21); @@ -975,7 +975,7 @@ public class ItemBase { } } - if ((nullBits[3] & 4) != 0) { + if ((nullBits[3] & 8) != 0) { int fieldOffset22 = buf.getIntLE(offset + 235); int pos22 = offset + 251 + fieldOffset22; int sl = VarInt.peek(buf, pos22); @@ -985,7 +985,7 @@ public class ItemBase { } } - if ((nullBits[3] & 8) != 0) { + if ((nullBits[3] & 16) != 0) { int fieldOffset23 = buf.getIntLE(offset + 239); int pos23 = offset + 251 + fieldOffset23; int arrLen = VarInt.peek(buf, pos23); @@ -995,7 +995,7 @@ public class ItemBase { } } - if ((nullBits[3] & 16) != 0) { + if ((nullBits[3] & 32) != 0) { int fieldOffset24 = buf.getIntLE(offset + 243); int pos24 = offset + 251 + fieldOffset24; int dictLen = VarInt.peek(buf, pos24); @@ -1016,7 +1016,7 @@ public class ItemBase { } } - if ((nullBits[3] & 32) != 0) { + if ((nullBits[3] & 64) != 0) { int fieldOffset25 = buf.getIntLE(offset + 247); int pos25 = offset + 251 + fieldOffset25; int arrLen = VarInt.peek(buf, pos25); @@ -1032,127 +1032,127 @@ public class ItemBase { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte[] nullBits = new byte[4]; - if (this.id != null) { + if (this.iconProperties != null) { nullBits[0] = (byte)(nullBits[0] | 1); } - if (this.model != null) { + if (this.gliderConfig != null) { nullBits[0] = (byte)(nullBits[0] | 2); } - if (this.texture != null) { + if (this.blockSelectorTool != null) { nullBits[0] = (byte)(nullBits[0] | 4); } - if (this.animation != null) { + if (this.light != null) { nullBits[0] = (byte)(nullBits[0] | 8); } - if (this.playerAnimationsId != null) { + if (this.pullbackConfig != null) { nullBits[0] = (byte)(nullBits[0] | 16); } - if (this.icon != null) { + if (this.id != null) { nullBits[0] = (byte)(nullBits[0] | 32); } - if (this.iconProperties != null) { + if (this.model != null) { nullBits[0] = (byte)(nullBits[0] | 64); } - if (this.translationProperties != null) { + if (this.texture != null) { nullBits[0] = (byte)(nullBits[0] | 128); } - if (this.resourceTypes != null) { + if (this.animation != null) { nullBits[1] = (byte)(nullBits[1] | 1); } - if (this.tool != null) { + if (this.playerAnimationsId != null) { nullBits[1] = (byte)(nullBits[1] | 2); } - if (this.weapon != null) { + if (this.icon != null) { nullBits[1] = (byte)(nullBits[1] | 4); } - if (this.armor != null) { + if (this.translationProperties != null) { nullBits[1] = (byte)(nullBits[1] | 8); } - if (this.gliderConfig != null) { + if (this.resourceTypes != null) { nullBits[1] = (byte)(nullBits[1] | 16); } - if (this.utility != null) { + if (this.tool != null) { nullBits[1] = (byte)(nullBits[1] | 32); } - if (this.blockSelectorTool != null) { + if (this.weapon != null) { nullBits[1] = (byte)(nullBits[1] | 64); } - if (this.builderToolData != null) { + if (this.armor != null) { nullBits[1] = (byte)(nullBits[1] | 128); } - if (this.itemEntity != null) { + if (this.utility != null) { nullBits[2] = (byte)(nullBits[2] | 1); } - if (this.set != null) { + if (this.builderToolData != null) { nullBits[2] = (byte)(nullBits[2] | 2); } - if (this.categories != null) { + if (this.itemEntity != null) { nullBits[2] = (byte)(nullBits[2] | 4); } - if (this.particles != null) { + if (this.set != null) { nullBits[2] = (byte)(nullBits[2] | 8); } - if (this.firstPersonParticles != null) { + if (this.categories != null) { nullBits[2] = (byte)(nullBits[2] | 16); } - if (this.trails != null) { + if (this.particles != null) { nullBits[2] = (byte)(nullBits[2] | 32); } - if (this.light != null) { + if (this.firstPersonParticles != null) { nullBits[2] = (byte)(nullBits[2] | 64); } - if (this.interactions != null) { + if (this.trails != null) { nullBits[2] = (byte)(nullBits[2] | 128); } - if (this.interactionVars != null) { + if (this.interactions != null) { nullBits[3] = (byte)(nullBits[3] | 1); } - if (this.interactionConfig != null) { + if (this.interactionVars != null) { nullBits[3] = (byte)(nullBits[3] | 2); } - if (this.droppedItemAnimation != null) { + if (this.interactionConfig != null) { nullBits[3] = (byte)(nullBits[3] | 4); } - if (this.tagIndexes != null) { + if (this.droppedItemAnimation != null) { nullBits[3] = (byte)(nullBits[3] | 8); } - if (this.itemAppearanceConditions != null) { + if (this.tagIndexes != null) { nullBits[3] = (byte)(nullBits[3] | 16); } - if (this.displayEntityStatsHUD != null) { + if (this.itemAppearanceConditions != null) { nullBits[3] = (byte)(nullBits[3] | 32); } - if (this.pullbackConfig != null) { + if (this.displayEntityStatsHUD != null) { nullBits[3] = (byte)(nullBits[3] | 64); } @@ -1680,7 +1680,7 @@ public class ItemBase { return ValidationResult.error("Buffer too small: expected at least 251 bytes"); } else { byte[] nullBits = PacketIO.readBytes(buffer, offset, 4); - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 32) != 0) { int idOffset = buffer.getIntLE(offset + 147); if (idOffset < 0) { return ValidationResult.error("Invalid offset for Id"); @@ -1707,7 +1707,7 @@ public class ItemBase { } } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 64) != 0) { int modelOffset = buffer.getIntLE(offset + 151); if (modelOffset < 0) { return ValidationResult.error("Invalid offset for Model"); @@ -1734,7 +1734,7 @@ public class ItemBase { } } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 128) != 0) { int textureOffset = buffer.getIntLE(offset + 155); if (textureOffset < 0) { return ValidationResult.error("Invalid offset for Texture"); @@ -1761,7 +1761,7 @@ public class ItemBase { } } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[1] & 1) != 0) { int animationOffset = buffer.getIntLE(offset + 159); if (animationOffset < 0) { return ValidationResult.error("Invalid offset for Animation"); @@ -1788,7 +1788,7 @@ public class ItemBase { } } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[1] & 2) != 0) { int playerAnimationsIdOffset = buffer.getIntLE(offset + 163); if (playerAnimationsIdOffset < 0) { return ValidationResult.error("Invalid offset for PlayerAnimationsId"); @@ -1815,7 +1815,7 @@ public class ItemBase { } } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[1] & 4) != 0) { int iconOffset = buffer.getIntLE(offset + 167); if (iconOffset < 0) { return ValidationResult.error("Invalid offset for Icon"); @@ -1842,7 +1842,7 @@ public class ItemBase { } } - if ((nullBits[0] & 128) != 0) { + if ((nullBits[1] & 8) != 0) { int translationPropertiesOffset = buffer.getIntLE(offset + 171); if (translationPropertiesOffset < 0) { return ValidationResult.error("Invalid offset for TranslationProperties"); @@ -1861,7 +1861,7 @@ public class ItemBase { posxxxxxx += ItemTranslationProperties.computeBytesConsumed(buffer, posxxxxxx); } - if ((nullBits[1] & 1) != 0) { + if ((nullBits[1] & 16) != 0) { int resourceTypesOffset = buffer.getIntLE(offset + 175); if (resourceTypesOffset < 0) { return ValidationResult.error("Invalid offset for ResourceTypes"); @@ -1893,7 +1893,7 @@ public class ItemBase { } } - if ((nullBits[1] & 2) != 0) { + if ((nullBits[1] & 32) != 0) { int toolOffset = buffer.getIntLE(offset + 179); if (toolOffset < 0) { return ValidationResult.error("Invalid offset for Tool"); @@ -1912,7 +1912,7 @@ public class ItemBase { posxxxxxxxx += ItemTool.computeBytesConsumed(buffer, posxxxxxxxx); } - if ((nullBits[1] & 4) != 0) { + if ((nullBits[1] & 64) != 0) { int weaponOffset = buffer.getIntLE(offset + 183); if (weaponOffset < 0) { return ValidationResult.error("Invalid offset for Weapon"); @@ -1931,7 +1931,7 @@ public class ItemBase { posxxxxxxxxx += ItemWeapon.computeBytesConsumed(buffer, posxxxxxxxxx); } - if ((nullBits[1] & 8) != 0) { + if ((nullBits[1] & 128) != 0) { int armorOffset = buffer.getIntLE(offset + 187); if (armorOffset < 0) { return ValidationResult.error("Invalid offset for Armor"); @@ -1950,7 +1950,7 @@ public class ItemBase { posxxxxxxxxxx += ItemArmor.computeBytesConsumed(buffer, posxxxxxxxxxx); } - if ((nullBits[1] & 32) != 0) { + if ((nullBits[2] & 1) != 0) { int utilityOffset = buffer.getIntLE(offset + 191); if (utilityOffset < 0) { return ValidationResult.error("Invalid offset for Utility"); @@ -1969,7 +1969,7 @@ public class ItemBase { posxxxxxxxxxxx += ItemUtility.computeBytesConsumed(buffer, posxxxxxxxxxxx); } - if ((nullBits[1] & 128) != 0) { + if ((nullBits[2] & 2) != 0) { int builderToolDataOffset = buffer.getIntLE(offset + 195); if (builderToolDataOffset < 0) { return ValidationResult.error("Invalid offset for BuilderToolData"); @@ -1988,7 +1988,7 @@ public class ItemBase { posxxxxxxxxxxxx += ItemBuilderToolData.computeBytesConsumed(buffer, posxxxxxxxxxxxx); } - if ((nullBits[2] & 1) != 0) { + if ((nullBits[2] & 4) != 0) { int itemEntityOffset = buffer.getIntLE(offset + 199); if (itemEntityOffset < 0) { return ValidationResult.error("Invalid offset for ItemEntity"); @@ -2007,7 +2007,7 @@ public class ItemBase { posxxxxxxxxxxxxx += ItemEntityConfig.computeBytesConsumed(buffer, posxxxxxxxxxxxxx); } - if ((nullBits[2] & 2) != 0) { + if ((nullBits[2] & 8) != 0) { int setOffset = buffer.getIntLE(offset + 203); if (setOffset < 0) { return ValidationResult.error("Invalid offset for Set"); @@ -2034,7 +2034,7 @@ public class ItemBase { } } - if ((nullBits[2] & 4) != 0) { + if ((nullBits[2] & 16) != 0) { int categoriesOffset = buffer.getIntLE(offset + 207); if (categoriesOffset < 0) { return ValidationResult.error("Invalid offset for Categories"); @@ -2070,7 +2070,7 @@ public class ItemBase { } } - if ((nullBits[2] & 8) != 0) { + if ((nullBits[2] & 32) != 0) { int particlesOffset = buffer.getIntLE(offset + 211); if (particlesOffset < 0) { return ValidationResult.error("Invalid offset for Particles"); @@ -2102,7 +2102,7 @@ public class ItemBase { } } - if ((nullBits[2] & 16) != 0) { + if ((nullBits[2] & 64) != 0) { int firstPersonParticlesOffset = buffer.getIntLE(offset + 215); if (firstPersonParticlesOffset < 0) { return ValidationResult.error("Invalid offset for FirstPersonParticles"); @@ -2134,7 +2134,7 @@ public class ItemBase { } } - if ((nullBits[2] & 32) != 0) { + if ((nullBits[2] & 128) != 0) { int trailsOffset = buffer.getIntLE(offset + 219); if (trailsOffset < 0) { return ValidationResult.error("Invalid offset for Trails"); @@ -2166,7 +2166,7 @@ public class ItemBase { } } - if ((nullBits[2] & 128) != 0) { + if ((nullBits[3] & 1) != 0) { int interactionsOffset = buffer.getIntLE(offset + 223); if (interactionsOffset < 0) { return ValidationResult.error("Invalid offset for Interactions"); @@ -2196,7 +2196,7 @@ public class ItemBase { } } - if ((nullBits[3] & 1) != 0) { + if ((nullBits[3] & 2) != 0) { int interactionVarsOffset = buffer.getIntLE(offset + 227); if (interactionVarsOffset < 0) { return ValidationResult.error("Invalid offset for InteractionVars"); @@ -2241,7 +2241,7 @@ public class ItemBase { } } - if ((nullBits[3] & 2) != 0) { + if ((nullBits[3] & 4) != 0) { int interactionConfigOffset = buffer.getIntLE(offset + 231); if (interactionConfigOffset < 0) { return ValidationResult.error("Invalid offset for InteractionConfig"); @@ -2260,7 +2260,7 @@ public class ItemBase { posxxxxxxxxxxxxxxxxxxxxx += InteractionConfiguration.computeBytesConsumed(buffer, posxxxxxxxxxxxxxxxxxxxxx); } - if ((nullBits[3] & 4) != 0) { + if ((nullBits[3] & 8) != 0) { int droppedItemAnimationOffset = buffer.getIntLE(offset + 235); if (droppedItemAnimationOffset < 0) { return ValidationResult.error("Invalid offset for DroppedItemAnimation"); @@ -2287,7 +2287,7 @@ public class ItemBase { } } - if ((nullBits[3] & 8) != 0) { + if ((nullBits[3] & 16) != 0) { int tagIndexesOffset = buffer.getIntLE(offset + 239); if (tagIndexesOffset < 0) { return ValidationResult.error("Invalid offset for TagIndexes"); @@ -2314,7 +2314,7 @@ public class ItemBase { } } - if ((nullBits[3] & 16) != 0) { + if ((nullBits[3] & 32) != 0) { int itemAppearanceConditionsOffset = buffer.getIntLE(offset + 243); if (itemAppearanceConditionsOffset < 0) { return ValidationResult.error("Invalid offset for ItemAppearanceConditions"); @@ -2355,7 +2355,7 @@ public class ItemBase { } } - if ((nullBits[3] & 32) != 0) { + if ((nullBits[3] & 64) != 0) { int displayEntityStatsHUDOffset = buffer.getIntLE(offset + 247); if (displayEntityStatsHUDOffset < 0) { return ValidationResult.error("Invalid offset for DisplayEntityStatsHUD"); diff --git a/src/com/hypixel/hytale/protocol/ItemEntityConfig.java b/src/com/hypixel/hytale/protocol/ItemEntityConfig.java index 2a9069e..1f9a94f 100644 --- a/src/com/hypixel/hytale/protocol/ItemEntityConfig.java +++ b/src/com/hypixel/hytale/protocol/ItemEntityConfig.java @@ -40,13 +40,13 @@ public class ItemEntityConfig { public static ItemEntityConfig deserialize(@Nonnull ByteBuf buf, int offset) { ItemEntityConfig obj = new ItemEntityConfig(); byte nullBits = buf.getByte(offset); - if ((nullBits & 2) != 0) { + if ((nullBits & 1) != 0) { obj.particleColor = Color.deserialize(buf, offset + 1); } obj.showItemParticles = buf.getByte(offset + 4) != 0; int pos = offset + 5; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int particleSystemIdLen = VarInt.peek(buf, pos); if (particleSystemIdLen < 0) { throw ProtocolException.negativeLength("ParticleSystemId", particleSystemIdLen); @@ -67,7 +67,7 @@ public class ItemEntityConfig { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int pos = offset + 5; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int sl = VarInt.peek(buf, pos); pos += VarInt.length(buf, pos) + sl; } @@ -77,11 +77,11 @@ public class ItemEntityConfig { public void serialize(@Nonnull ByteBuf buf) { byte nullBits = 0; - if (this.particleSystemId != null) { + if (this.particleColor != null) { nullBits = (byte)(nullBits | 1); } - if (this.particleColor != null) { + if (this.particleSystemId != null) { nullBits = (byte)(nullBits | 2); } @@ -113,7 +113,7 @@ public class ItemEntityConfig { } else { byte nullBits = buffer.getByte(offset); int pos = offset + 5; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int particleSystemIdLen = VarInt.peek(buffer, pos); if (particleSystemIdLen < 0) { return ValidationResult.error("Invalid string length for ParticleSystemId"); diff --git a/src/com/hypixel/hytale/protocol/ItemPlayerAnimations.java b/src/com/hypixel/hytale/protocol/ItemPlayerAnimations.java index 8fcbbd9..e748e72 100644 --- a/src/com/hypixel/hytale/protocol/ItemPlayerAnimations.java +++ b/src/com/hypixel/hytale/protocol/ItemPlayerAnimations.java @@ -62,16 +62,16 @@ public class ItemPlayerAnimations { public static ItemPlayerAnimations deserialize(@Nonnull ByteBuf buf, int offset) { ItemPlayerAnimations obj = new ItemPlayerAnimations(); byte nullBits = buf.getByte(offset); - if ((nullBits & 4) != 0) { + if ((nullBits & 1) != 0) { obj.wiggleWeights = WiggleWeights.deserialize(buf, offset + 1); } - if ((nullBits & 16) != 0) { + if ((nullBits & 2) != 0) { obj.pullbackConfig = ItemPullbackConfiguration.deserialize(buf, offset + 41); } obj.useFirstPersonOverride = buf.getByte(offset + 90) != 0; - if ((nullBits & 1) != 0) { + if ((nullBits & 4) != 0) { int varPos0 = offset + 103 + buf.getIntLE(offset + 91); int idLen = VarInt.peek(buf, varPos0); if (idLen < 0) { @@ -85,7 +85,7 @@ public class ItemPlayerAnimations { obj.id = PacketIO.readVarString(buf, varPos0, PacketIO.UTF8); } - if ((nullBits & 2) != 0) { + if ((nullBits & 8) != 0) { int varPos1 = offset + 103 + buf.getIntLE(offset + 95); int animationsCount = VarInt.peek(buf, varPos1); if (animationsCount < 0) { @@ -121,7 +121,7 @@ public class ItemPlayerAnimations { } } - if ((nullBits & 8) != 0) { + if ((nullBits & 16) != 0) { int varPos2 = offset + 103 + buf.getIntLE(offset + 99); obj.camera = CameraSettings.deserialize(buf, varPos2); } @@ -132,7 +132,7 @@ public class ItemPlayerAnimations { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 103; - if ((nullBits & 1) != 0) { + if ((nullBits & 4) != 0) { int fieldOffset0 = buf.getIntLE(offset + 91); int pos0 = offset + 103 + fieldOffset0; int sl = VarInt.peek(buf, pos0); @@ -142,7 +142,7 @@ public class ItemPlayerAnimations { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 8) != 0) { int fieldOffset1 = buf.getIntLE(offset + 95); int pos1 = offset + 103 + fieldOffset1; int dictLen = VarInt.peek(buf, pos1); @@ -159,7 +159,7 @@ public class ItemPlayerAnimations { } } - if ((nullBits & 8) != 0) { + if ((nullBits & 16) != 0) { int fieldOffset2 = buf.getIntLE(offset + 99); int pos2 = offset + 103 + fieldOffset2; pos2 += CameraSettings.computeBytesConsumed(buf, pos2); @@ -174,23 +174,23 @@ public class ItemPlayerAnimations { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.id != null) { + if (this.wiggleWeights != null) { nullBits = (byte)(nullBits | 1); } - if (this.animations != null) { + if (this.pullbackConfig != null) { nullBits = (byte)(nullBits | 2); } - if (this.wiggleWeights != null) { + if (this.id != null) { nullBits = (byte)(nullBits | 4); } - if (this.camera != null) { + if (this.animations != null) { nullBits = (byte)(nullBits | 8); } - if (this.pullbackConfig != null) { + if (this.camera != null) { nullBits = (byte)(nullBits | 16); } @@ -274,7 +274,7 @@ public class ItemPlayerAnimations { return ValidationResult.error("Buffer too small: expected at least 103 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 4) != 0) { int idOffset = buffer.getIntLE(offset + 91); if (idOffset < 0) { return ValidationResult.error("Invalid offset for Id"); @@ -301,7 +301,7 @@ public class ItemPlayerAnimations { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 8) != 0) { int animationsOffset = buffer.getIntLE(offset + 95); if (animationsOffset < 0) { return ValidationResult.error("Invalid offset for Animations"); @@ -343,7 +343,7 @@ public class ItemPlayerAnimations { } } - if ((nullBits & 8) != 0) { + if ((nullBits & 16) != 0) { int cameraOffset = buffer.getIntLE(offset + 99); if (cameraOffset < 0) { return ValidationResult.error("Invalid offset for Camera"); diff --git a/src/com/hypixel/hytale/protocol/ItemQuality.java b/src/com/hypixel/hytale/protocol/ItemQuality.java index 6de703a..c6ccc1e 100644 --- a/src/com/hypixel/hytale/protocol/ItemQuality.java +++ b/src/com/hypixel/hytale/protocol/ItemQuality.java @@ -82,14 +82,14 @@ public class ItemQuality { public static ItemQuality deserialize(@Nonnull ByteBuf buf, int offset) { ItemQuality obj = new ItemQuality(); byte nullBits = buf.getByte(offset); - if ((nullBits & 64) != 0) { + if ((nullBits & 1) != 0) { obj.textColor = Color.deserialize(buf, offset + 1); } obj.visibleQualityLabel = buf.getByte(offset + 4) != 0; obj.renderSpecialSlot = buf.getByte(offset + 5) != 0; obj.hideFromSearch = buf.getByte(offset + 6) != 0; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int varPos0 = offset + 35 + buf.getIntLE(offset + 7); int idLen = VarInt.peek(buf, varPos0); if (idLen < 0) { @@ -103,7 +103,7 @@ public class ItemQuality { obj.id = PacketIO.readVarString(buf, varPos0, PacketIO.UTF8); } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int varPos1 = offset + 35 + buf.getIntLE(offset + 11); int itemTooltipTextureLen = VarInt.peek(buf, varPos1); if (itemTooltipTextureLen < 0) { @@ -117,7 +117,7 @@ public class ItemQuality { obj.itemTooltipTexture = PacketIO.readVarString(buf, varPos1, PacketIO.UTF8); } - if ((nullBits & 4) != 0) { + if ((nullBits & 8) != 0) { int varPos2 = offset + 35 + buf.getIntLE(offset + 15); int itemTooltipArrowTextureLen = VarInt.peek(buf, varPos2); if (itemTooltipArrowTextureLen < 0) { @@ -131,7 +131,7 @@ public class ItemQuality { obj.itemTooltipArrowTexture = PacketIO.readVarString(buf, varPos2, PacketIO.UTF8); } - if ((nullBits & 8) != 0) { + if ((nullBits & 16) != 0) { int varPos3 = offset + 35 + buf.getIntLE(offset + 19); int slotTextureLen = VarInt.peek(buf, varPos3); if (slotTextureLen < 0) { @@ -145,7 +145,7 @@ public class ItemQuality { obj.slotTexture = PacketIO.readVarString(buf, varPos3, PacketIO.UTF8); } - if ((nullBits & 16) != 0) { + if ((nullBits & 32) != 0) { int varPos4 = offset + 35 + buf.getIntLE(offset + 23); int blockSlotTextureLen = VarInt.peek(buf, varPos4); if (blockSlotTextureLen < 0) { @@ -159,7 +159,7 @@ public class ItemQuality { obj.blockSlotTexture = PacketIO.readVarString(buf, varPos4, PacketIO.UTF8); } - if ((nullBits & 32) != 0) { + if ((nullBits & 64) != 0) { int varPos5 = offset + 35 + buf.getIntLE(offset + 27); int specialSlotTextureLen = VarInt.peek(buf, varPos5); if (specialSlotTextureLen < 0) { @@ -193,7 +193,7 @@ public class ItemQuality { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 35; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int fieldOffset0 = buf.getIntLE(offset + 7); int pos0 = offset + 35 + fieldOffset0; int sl = VarInt.peek(buf, pos0); @@ -203,7 +203,7 @@ public class ItemQuality { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int fieldOffset1 = buf.getIntLE(offset + 11); int pos1 = offset + 35 + fieldOffset1; int sl = VarInt.peek(buf, pos1); @@ -213,7 +213,7 @@ public class ItemQuality { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 8) != 0) { int fieldOffset2 = buf.getIntLE(offset + 15); int pos2 = offset + 35 + fieldOffset2; int sl = VarInt.peek(buf, pos2); @@ -223,7 +223,7 @@ public class ItemQuality { } } - if ((nullBits & 8) != 0) { + if ((nullBits & 16) != 0) { int fieldOffset3 = buf.getIntLE(offset + 19); int pos3 = offset + 35 + fieldOffset3; int sl = VarInt.peek(buf, pos3); @@ -233,7 +233,7 @@ public class ItemQuality { } } - if ((nullBits & 16) != 0) { + if ((nullBits & 32) != 0) { int fieldOffset4 = buf.getIntLE(offset + 23); int pos4 = offset + 35 + fieldOffset4; int sl = VarInt.peek(buf, pos4); @@ -243,7 +243,7 @@ public class ItemQuality { } } - if ((nullBits & 32) != 0) { + if ((nullBits & 64) != 0) { int fieldOffset5 = buf.getIntLE(offset + 27); int pos5 = offset + 35 + fieldOffset5; int sl = VarInt.peek(buf, pos5); @@ -269,31 +269,31 @@ public class ItemQuality { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.id != null) { + if (this.textColor != null) { nullBits = (byte)(nullBits | 1); } - if (this.itemTooltipTexture != null) { + if (this.id != null) { nullBits = (byte)(nullBits | 2); } - if (this.itemTooltipArrowTexture != null) { + if (this.itemTooltipTexture != null) { nullBits = (byte)(nullBits | 4); } - if (this.slotTexture != null) { + if (this.itemTooltipArrowTexture != null) { nullBits = (byte)(nullBits | 8); } - if (this.blockSlotTexture != null) { + if (this.slotTexture != null) { nullBits = (byte)(nullBits | 16); } - if (this.specialSlotTexture != null) { + if (this.blockSlotTexture != null) { nullBits = (byte)(nullBits | 32); } - if (this.textColor != null) { + if (this.specialSlotTexture != null) { nullBits = (byte)(nullBits | 64); } @@ -414,7 +414,7 @@ public class ItemQuality { return ValidationResult.error("Buffer too small: expected at least 35 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int idOffset = buffer.getIntLE(offset + 7); if (idOffset < 0) { return ValidationResult.error("Invalid offset for Id"); @@ -441,7 +441,7 @@ public class ItemQuality { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int itemTooltipTextureOffset = buffer.getIntLE(offset + 11); if (itemTooltipTextureOffset < 0) { return ValidationResult.error("Invalid offset for ItemTooltipTexture"); @@ -468,7 +468,7 @@ public class ItemQuality { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 8) != 0) { int itemTooltipArrowTextureOffset = buffer.getIntLE(offset + 15); if (itemTooltipArrowTextureOffset < 0) { return ValidationResult.error("Invalid offset for ItemTooltipArrowTexture"); @@ -495,7 +495,7 @@ public class ItemQuality { } } - if ((nullBits & 8) != 0) { + if ((nullBits & 16) != 0) { int slotTextureOffset = buffer.getIntLE(offset + 19); if (slotTextureOffset < 0) { return ValidationResult.error("Invalid offset for SlotTexture"); @@ -522,7 +522,7 @@ public class ItemQuality { } } - if ((nullBits & 16) != 0) { + if ((nullBits & 32) != 0) { int blockSlotTextureOffset = buffer.getIntLE(offset + 23); if (blockSlotTextureOffset < 0) { return ValidationResult.error("Invalid offset for BlockSlotTexture"); @@ -549,7 +549,7 @@ public class ItemQuality { } } - if ((nullBits & 32) != 0) { + if ((nullBits & 64) != 0) { int specialSlotTextureOffset = buffer.getIntLE(offset + 27); if (specialSlotTextureOffset < 0) { return ValidationResult.error("Invalid offset for SpecialSlotTexture"); diff --git a/src/com/hypixel/hytale/protocol/Model.java b/src/com/hypixel/hytale/protocol/Model.java index d154c75..c84a02d 100644 --- a/src/com/hypixel/hytale/protocol/Model.java +++ b/src/com/hypixel/hytale/protocol/Model.java @@ -124,16 +124,16 @@ public class Model { obj.scale = buf.getFloatLE(offset + 2); obj.eyeHeight = buf.getFloatLE(offset + 6); obj.crouchOffset = buf.getFloatLE(offset + 10); - if ((nullBits[1] & 1) != 0) { + if ((nullBits[0] & 1) != 0) { obj.hitbox = Hitbox.deserialize(buf, offset + 14); } - if ((nullBits[1] & 8) != 0) { + if ((nullBits[0] & 2) != 0) { obj.light = ColorLight.deserialize(buf, offset + 38); } obj.phobia = Phobia.fromValue(buf.getByte(offset + 42)); - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 4) != 0) { int varPos0 = offset + 91 + buf.getIntLE(offset + 43); int assetIdLen = VarInt.peek(buf, varPos0); if (assetIdLen < 0) { @@ -147,7 +147,7 @@ public class Model { obj.assetId = PacketIO.readVarString(buf, varPos0, PacketIO.UTF8); } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 8) != 0) { int varPos1 = offset + 91 + buf.getIntLE(offset + 47); int pathLen = VarInt.peek(buf, varPos1); if (pathLen < 0) { @@ -161,7 +161,7 @@ public class Model { obj.path = PacketIO.readVarString(buf, varPos1, PacketIO.UTF8); } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 16) != 0) { int varPos2 = offset + 91 + buf.getIntLE(offset + 51); int textureLen = VarInt.peek(buf, varPos2); if (textureLen < 0) { @@ -175,7 +175,7 @@ public class Model { obj.texture = PacketIO.readVarString(buf, varPos2, PacketIO.UTF8); } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[0] & 32) != 0) { int varPos3 = offset + 91 + buf.getIntLE(offset + 55); int gradientSetLen = VarInt.peek(buf, varPos3); if (gradientSetLen < 0) { @@ -189,7 +189,7 @@ public class Model { obj.gradientSet = PacketIO.readVarString(buf, varPos3, PacketIO.UTF8); } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[0] & 64) != 0) { int varPos4 = offset + 91 + buf.getIntLE(offset + 59); int gradientIdLen = VarInt.peek(buf, varPos4); if (gradientIdLen < 0) { @@ -203,12 +203,12 @@ public class Model { obj.gradientId = PacketIO.readVarString(buf, varPos4, PacketIO.UTF8); } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[0] & 128) != 0) { int varPos5 = offset + 91 + buf.getIntLE(offset + 63); obj.camera = CameraSettings.deserialize(buf, varPos5); } - if ((nullBits[0] & 64) != 0) { + if ((nullBits[1] & 1) != 0) { int varPos6 = offset + 91 + buf.getIntLE(offset + 67); int animationSetsCount = VarInt.peek(buf, varPos6); if (animationSetsCount < 0) { @@ -244,7 +244,7 @@ public class Model { } } - if ((nullBits[0] & 128) != 0) { + if ((nullBits[1] & 2) != 0) { int varPos7 = offset + 91 + buf.getIntLE(offset + 71); int attachmentsCount = VarInt.peek(buf, varPos7); if (attachmentsCount < 0) { @@ -269,7 +269,7 @@ public class Model { } } - if ((nullBits[1] & 2) != 0) { + if ((nullBits[1] & 4) != 0) { int varPos8 = offset + 91 + buf.getIntLE(offset + 75); int particlesCount = VarInt.peek(buf, varPos8); if (particlesCount < 0) { @@ -294,7 +294,7 @@ public class Model { } } - if ((nullBits[1] & 4) != 0) { + if ((nullBits[1] & 8) != 0) { int varPos9 = offset + 91 + buf.getIntLE(offset + 79); int trailsCount = VarInt.peek(buf, varPos9); if (trailsCount < 0) { @@ -386,7 +386,7 @@ public class Model { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte[] nullBits = PacketIO.readBytes(buf, offset, 2); int maxEnd = 91; - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 4) != 0) { int fieldOffset0 = buf.getIntLE(offset + 43); int pos0 = offset + 91 + fieldOffset0; int sl = VarInt.peek(buf, pos0); @@ -396,7 +396,7 @@ public class Model { } } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 8) != 0) { int fieldOffset1 = buf.getIntLE(offset + 47); int pos1 = offset + 91 + fieldOffset1; int sl = VarInt.peek(buf, pos1); @@ -406,7 +406,7 @@ public class Model { } } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 16) != 0) { int fieldOffset2 = buf.getIntLE(offset + 51); int pos2 = offset + 91 + fieldOffset2; int sl = VarInt.peek(buf, pos2); @@ -416,7 +416,7 @@ public class Model { } } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[0] & 32) != 0) { int fieldOffset3 = buf.getIntLE(offset + 55); int pos3 = offset + 91 + fieldOffset3; int sl = VarInt.peek(buf, pos3); @@ -426,7 +426,7 @@ public class Model { } } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[0] & 64) != 0) { int fieldOffset4 = buf.getIntLE(offset + 59); int pos4 = offset + 91 + fieldOffset4; int sl = VarInt.peek(buf, pos4); @@ -436,7 +436,7 @@ public class Model { } } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[0] & 128) != 0) { int fieldOffset5 = buf.getIntLE(offset + 63); int pos5 = offset + 91 + fieldOffset5; pos5 += CameraSettings.computeBytesConsumed(buf, pos5); @@ -445,7 +445,7 @@ public class Model { } } - if ((nullBits[0] & 64) != 0) { + if ((nullBits[1] & 1) != 0) { int fieldOffset6 = buf.getIntLE(offset + 67); int pos6 = offset + 91 + fieldOffset6; int dictLen = VarInt.peek(buf, pos6); @@ -462,7 +462,7 @@ public class Model { } } - if ((nullBits[0] & 128) != 0) { + if ((nullBits[1] & 2) != 0) { int fieldOffset7 = buf.getIntLE(offset + 71); int pos7 = offset + 91 + fieldOffset7; int arrLen = VarInt.peek(buf, pos7); @@ -477,7 +477,7 @@ public class Model { } } - if ((nullBits[1] & 2) != 0) { + if ((nullBits[1] & 4) != 0) { int fieldOffset8 = buf.getIntLE(offset + 75); int pos8 = offset + 91 + fieldOffset8; int arrLen = VarInt.peek(buf, pos8); @@ -492,7 +492,7 @@ public class Model { } } - if ((nullBits[1] & 4) != 0) { + if ((nullBits[1] & 8) != 0) { int fieldOffset9 = buf.getIntLE(offset + 79); int pos9 = offset + 91 + fieldOffset9; int arrLen = VarInt.peek(buf, pos9); @@ -544,51 +544,51 @@ public class Model { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte[] nullBits = new byte[2]; - if (this.assetId != null) { + if (this.hitbox != null) { nullBits[0] = (byte)(nullBits[0] | 1); } - if (this.path != null) { + if (this.light != null) { nullBits[0] = (byte)(nullBits[0] | 2); } - if (this.texture != null) { + if (this.assetId != null) { nullBits[0] = (byte)(nullBits[0] | 4); } - if (this.gradientSet != null) { + if (this.path != null) { nullBits[0] = (byte)(nullBits[0] | 8); } - if (this.gradientId != null) { + if (this.texture != null) { nullBits[0] = (byte)(nullBits[0] | 16); } - if (this.camera != null) { + if (this.gradientSet != null) { nullBits[0] = (byte)(nullBits[0] | 32); } - if (this.animationSets != null) { + if (this.gradientId != null) { nullBits[0] = (byte)(nullBits[0] | 64); } - if (this.attachments != null) { + if (this.camera != null) { nullBits[0] = (byte)(nullBits[0] | 128); } - if (this.hitbox != null) { + if (this.animationSets != null) { nullBits[1] = (byte)(nullBits[1] | 1); } - if (this.particles != null) { + if (this.attachments != null) { nullBits[1] = (byte)(nullBits[1] | 2); } - if (this.trails != null) { + if (this.particles != null) { nullBits[1] = (byte)(nullBits[1] | 4); } - if (this.light != null) { + if (this.trails != null) { nullBits[1] = (byte)(nullBits[1] | 8); } @@ -861,7 +861,7 @@ public class Model { return ValidationResult.error("Buffer too small: expected at least 91 bytes"); } else { byte[] nullBits = PacketIO.readBytes(buffer, offset, 2); - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 4) != 0) { int assetIdOffset = buffer.getIntLE(offset + 43); if (assetIdOffset < 0) { return ValidationResult.error("Invalid offset for AssetId"); @@ -888,7 +888,7 @@ public class Model { } } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 8) != 0) { int pathOffset = buffer.getIntLE(offset + 47); if (pathOffset < 0) { return ValidationResult.error("Invalid offset for Path"); @@ -915,7 +915,7 @@ public class Model { } } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 16) != 0) { int textureOffset = buffer.getIntLE(offset + 51); if (textureOffset < 0) { return ValidationResult.error("Invalid offset for Texture"); @@ -942,7 +942,7 @@ public class Model { } } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[0] & 32) != 0) { int gradientSetOffset = buffer.getIntLE(offset + 55); if (gradientSetOffset < 0) { return ValidationResult.error("Invalid offset for GradientSet"); @@ -969,7 +969,7 @@ public class Model { } } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[0] & 64) != 0) { int gradientIdOffset = buffer.getIntLE(offset + 59); if (gradientIdOffset < 0) { return ValidationResult.error("Invalid offset for GradientId"); @@ -996,7 +996,7 @@ public class Model { } } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[0] & 128) != 0) { int cameraOffset = buffer.getIntLE(offset + 63); if (cameraOffset < 0) { return ValidationResult.error("Invalid offset for Camera"); @@ -1015,7 +1015,7 @@ public class Model { posxxxxx += CameraSettings.computeBytesConsumed(buffer, posxxxxx); } - if ((nullBits[0] & 64) != 0) { + if ((nullBits[1] & 1) != 0) { int animationSetsOffset = buffer.getIntLE(offset + 67); if (animationSetsOffset < 0) { return ValidationResult.error("Invalid offset for AnimationSets"); @@ -1057,7 +1057,7 @@ public class Model { } } - if ((nullBits[0] & 128) != 0) { + if ((nullBits[1] & 2) != 0) { int attachmentsOffset = buffer.getIntLE(offset + 71); if (attachmentsOffset < 0) { return ValidationResult.error("Invalid offset for Attachments"); @@ -1089,7 +1089,7 @@ public class Model { } } - if ((nullBits[1] & 2) != 0) { + if ((nullBits[1] & 4) != 0) { int particlesOffset = buffer.getIntLE(offset + 75); if (particlesOffset < 0) { return ValidationResult.error("Invalid offset for Particles"); @@ -1121,7 +1121,7 @@ public class Model { } } - if ((nullBits[1] & 4) != 0) { + if ((nullBits[1] & 8) != 0) { int trailsOffset = buffer.getIntLE(offset + 79); if (trailsOffset < 0) { return ValidationResult.error("Invalid offset for Trails"); diff --git a/src/com/hypixel/hytale/protocol/ModelDisplay.java b/src/com/hypixel/hytale/protocol/ModelDisplay.java index 1d0de9c..0cfa81b 100644 --- a/src/com/hypixel/hytale/protocol/ModelDisplay.java +++ b/src/com/hypixel/hytale/protocol/ModelDisplay.java @@ -49,19 +49,19 @@ public class ModelDisplay { public static ModelDisplay deserialize(@Nonnull ByteBuf buf, int offset) { ModelDisplay obj = new ModelDisplay(); byte nullBits = buf.getByte(offset); - if ((nullBits & 4) != 0) { + if ((nullBits & 1) != 0) { obj.translation = Vector3f.deserialize(buf, offset + 1); } - if ((nullBits & 8) != 0) { + if ((nullBits & 2) != 0) { obj.rotation = Vector3f.deserialize(buf, offset + 13); } - if ((nullBits & 16) != 0) { + if ((nullBits & 4) != 0) { obj.scale = Vector3f.deserialize(buf, offset + 25); } - if ((nullBits & 1) != 0) { + if ((nullBits & 8) != 0) { int varPos0 = offset + 45 + buf.getIntLE(offset + 37); int nodeLen = VarInt.peek(buf, varPos0); if (nodeLen < 0) { @@ -75,7 +75,7 @@ public class ModelDisplay { obj.node = PacketIO.readVarString(buf, varPos0, PacketIO.UTF8); } - if ((nullBits & 2) != 0) { + if ((nullBits & 16) != 0) { int varPos1 = offset + 45 + buf.getIntLE(offset + 41); int attachToLen = VarInt.peek(buf, varPos1); if (attachToLen < 0) { @@ -95,7 +95,7 @@ public class ModelDisplay { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 45; - if ((nullBits & 1) != 0) { + if ((nullBits & 8) != 0) { int fieldOffset0 = buf.getIntLE(offset + 37); int pos0 = offset + 45 + fieldOffset0; int sl = VarInt.peek(buf, pos0); @@ -105,7 +105,7 @@ public class ModelDisplay { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 16) != 0) { int fieldOffset1 = buf.getIntLE(offset + 41); int pos1 = offset + 45 + fieldOffset1; int sl = VarInt.peek(buf, pos1); @@ -121,23 +121,23 @@ public class ModelDisplay { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.node != null) { + if (this.translation != null) { nullBits = (byte)(nullBits | 1); } - if (this.attachTo != null) { + if (this.rotation != null) { nullBits = (byte)(nullBits | 2); } - if (this.translation != null) { + if (this.scale != null) { nullBits = (byte)(nullBits | 4); } - if (this.rotation != null) { + if (this.node != null) { nullBits = (byte)(nullBits | 8); } - if (this.scale != null) { + if (this.attachTo != null) { nullBits = (byte)(nullBits | 16); } @@ -198,7 +198,7 @@ public class ModelDisplay { return ValidationResult.error("Buffer too small: expected at least 45 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 8) != 0) { int nodeOffset = buffer.getIntLE(offset + 37); if (nodeOffset < 0) { return ValidationResult.error("Invalid offset for Node"); @@ -225,7 +225,7 @@ public class ModelDisplay { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 16) != 0) { int attachToOffset = buffer.getIntLE(offset + 41); if (attachToOffset < 0) { return ValidationResult.error("Invalid offset for AttachTo"); diff --git a/src/com/hypixel/hytale/protocol/ModelParticle.java b/src/com/hypixel/hytale/protocol/ModelParticle.java index f25b815..150c0f7 100644 --- a/src/com/hypixel/hytale/protocol/ModelParticle.java +++ b/src/com/hypixel/hytale/protocol/ModelParticle.java @@ -69,21 +69,21 @@ public class ModelParticle { ModelParticle obj = new ModelParticle(); byte nullBits = buf.getByte(offset); obj.scale = buf.getFloatLE(offset + 1); - if ((nullBits & 2) != 0) { + if ((nullBits & 1) != 0) { obj.color = Color.deserialize(buf, offset + 5); } obj.targetEntityPart = EntityPart.fromValue(buf.getByte(offset + 8)); - if ((nullBits & 8) != 0) { + if ((nullBits & 2) != 0) { obj.positionOffset = Vector3f.deserialize(buf, offset + 9); } - if ((nullBits & 16) != 0) { + if ((nullBits & 4) != 0) { obj.rotationOffset = Direction.deserialize(buf, offset + 21); } obj.detachedFromModel = buf.getByte(offset + 33) != 0; - if ((nullBits & 1) != 0) { + if ((nullBits & 8) != 0) { int varPos0 = offset + 42 + buf.getIntLE(offset + 34); int systemIdLen = VarInt.peek(buf, varPos0); if (systemIdLen < 0) { @@ -97,7 +97,7 @@ public class ModelParticle { obj.systemId = PacketIO.readVarString(buf, varPos0, PacketIO.UTF8); } - if ((nullBits & 4) != 0) { + if ((nullBits & 16) != 0) { int varPos1 = offset + 42 + buf.getIntLE(offset + 38); int targetNodeNameLen = VarInt.peek(buf, varPos1); if (targetNodeNameLen < 0) { @@ -117,7 +117,7 @@ public class ModelParticle { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 42; - if ((nullBits & 1) != 0) { + if ((nullBits & 8) != 0) { int fieldOffset0 = buf.getIntLE(offset + 34); int pos0 = offset + 42 + fieldOffset0; int sl = VarInt.peek(buf, pos0); @@ -127,7 +127,7 @@ public class ModelParticle { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 16) != 0) { int fieldOffset1 = buf.getIntLE(offset + 38); int pos1 = offset + 42 + fieldOffset1; int sl = VarInt.peek(buf, pos1); @@ -143,23 +143,23 @@ public class ModelParticle { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.systemId != null) { + if (this.color != null) { nullBits = (byte)(nullBits | 1); } - if (this.color != null) { + if (this.positionOffset != null) { nullBits = (byte)(nullBits | 2); } - if (this.targetNodeName != null) { + if (this.rotationOffset != null) { nullBits = (byte)(nullBits | 4); } - if (this.positionOffset != null) { + if (this.systemId != null) { nullBits = (byte)(nullBits | 8); } - if (this.rotationOffset != null) { + if (this.targetNodeName != null) { nullBits = (byte)(nullBits | 16); } @@ -223,7 +223,7 @@ public class ModelParticle { return ValidationResult.error("Buffer too small: expected at least 42 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 8) != 0) { int systemIdOffset = buffer.getIntLE(offset + 34); if (systemIdOffset < 0) { return ValidationResult.error("Invalid offset for SystemId"); @@ -250,7 +250,7 @@ public class ModelParticle { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 16) != 0) { int targetNodeNameOffset = buffer.getIntLE(offset + 38); if (targetNodeNameOffset < 0) { return ValidationResult.error("Invalid offset for TargetNodeName"); diff --git a/src/com/hypixel/hytale/protocol/ModelTrail.java b/src/com/hypixel/hytale/protocol/ModelTrail.java index 1b2c683..5cc86ee 100644 --- a/src/com/hypixel/hytale/protocol/ModelTrail.java +++ b/src/com/hypixel/hytale/protocol/ModelTrail.java @@ -60,16 +60,16 @@ public class ModelTrail { ModelTrail obj = new ModelTrail(); byte nullBits = buf.getByte(offset); obj.targetEntityPart = EntityPart.fromValue(buf.getByte(offset + 1)); - if ((nullBits & 4) != 0) { + if ((nullBits & 1) != 0) { obj.positionOffset = Vector3f.deserialize(buf, offset + 2); } - if ((nullBits & 8) != 0) { + if ((nullBits & 2) != 0) { obj.rotationOffset = Direction.deserialize(buf, offset + 14); } obj.fixedRotation = buf.getByte(offset + 26) != 0; - if ((nullBits & 1) != 0) { + if ((nullBits & 4) != 0) { int varPos0 = offset + 35 + buf.getIntLE(offset + 27); int trailIdLen = VarInt.peek(buf, varPos0); if (trailIdLen < 0) { @@ -83,7 +83,7 @@ public class ModelTrail { obj.trailId = PacketIO.readVarString(buf, varPos0, PacketIO.UTF8); } - if ((nullBits & 2) != 0) { + if ((nullBits & 8) != 0) { int varPos1 = offset + 35 + buf.getIntLE(offset + 31); int targetNodeNameLen = VarInt.peek(buf, varPos1); if (targetNodeNameLen < 0) { @@ -103,7 +103,7 @@ public class ModelTrail { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 35; - if ((nullBits & 1) != 0) { + if ((nullBits & 4) != 0) { int fieldOffset0 = buf.getIntLE(offset + 27); int pos0 = offset + 35 + fieldOffset0; int sl = VarInt.peek(buf, pos0); @@ -113,7 +113,7 @@ public class ModelTrail { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 8) != 0) { int fieldOffset1 = buf.getIntLE(offset + 31); int pos1 = offset + 35 + fieldOffset1; int sl = VarInt.peek(buf, pos1); @@ -129,19 +129,19 @@ public class ModelTrail { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.trailId != null) { + if (this.positionOffset != null) { nullBits = (byte)(nullBits | 1); } - if (this.targetNodeName != null) { + if (this.rotationOffset != null) { nullBits = (byte)(nullBits | 2); } - if (this.positionOffset != null) { + if (this.trailId != null) { nullBits = (byte)(nullBits | 4); } - if (this.rotationOffset != null) { + if (this.targetNodeName != null) { nullBits = (byte)(nullBits | 8); } @@ -198,7 +198,7 @@ public class ModelTrail { return ValidationResult.error("Buffer too small: expected at least 35 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 4) != 0) { int trailIdOffset = buffer.getIntLE(offset + 27); if (trailIdOffset < 0) { return ValidationResult.error("Invalid offset for TrailId"); @@ -225,7 +225,7 @@ public class ModelTrail { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 8) != 0) { int targetNodeNameOffset = buffer.getIntLE(offset + 31); if (targetNodeNameOffset < 0) { return ValidationResult.error("Invalid offset for TargetNodeName"); diff --git a/src/com/hypixel/hytale/protocol/ModelVFX.java b/src/com/hypixel/hytale/protocol/ModelVFX.java index 9ff73da..a734cda 100644 --- a/src/com/hypixel/hytale/protocol/ModelVFX.java +++ b/src/com/hypixel/hytale/protocol/ModelVFX.java @@ -103,34 +103,34 @@ public class ModelVFX { obj.switchTo = SwitchTo.fromValue(buf.getByte(offset + 1)); obj.effectDirection = EffectDirection.fromValue(buf.getByte(offset + 2)); obj.animationDuration = buf.getFloatLE(offset + 3); - if ((nullBits & 2) != 0) { + if ((nullBits & 1) != 0) { obj.animationRange = Vector2f.deserialize(buf, offset + 7); } obj.loopOption = LoopOption.fromValue(buf.getByte(offset + 15)); obj.curveType = CurveType.fromValue(buf.getByte(offset + 16)); - if ((nullBits & 4) != 0) { + if ((nullBits & 2) != 0) { obj.highlightColor = Color.deserialize(buf, offset + 17); } obj.highlightThickness = buf.getFloatLE(offset + 20); obj.useBloomOnHighlight = buf.getByte(offset + 24) != 0; obj.useProgessiveHighlight = buf.getByte(offset + 25) != 0; - if ((nullBits & 8) != 0) { + if ((nullBits & 4) != 0) { obj.noiseScale = Vector2f.deserialize(buf, offset + 26); } - if ((nullBits & 16) != 0) { + if ((nullBits & 8) != 0) { obj.noiseScrollSpeed = Vector2f.deserialize(buf, offset + 34); } - if ((nullBits & 32) != 0) { + if ((nullBits & 16) != 0) { obj.postColor = Color.deserialize(buf, offset + 42); } obj.postColorOpacity = buf.getFloatLE(offset + 45); int pos = offset + 49; - if ((nullBits & 1) != 0) { + if ((nullBits & 32) != 0) { int idLen = VarInt.peek(buf, pos); if (idLen < 0) { throw ProtocolException.negativeLength("Id", idLen); @@ -151,7 +151,7 @@ public class ModelVFX { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int pos = offset + 49; - if ((nullBits & 1) != 0) { + if ((nullBits & 32) != 0) { int sl = VarInt.peek(buf, pos); pos += VarInt.length(buf, pos) + sl; } @@ -161,27 +161,27 @@ public class ModelVFX { public void serialize(@Nonnull ByteBuf buf) { byte nullBits = 0; - if (this.id != null) { + if (this.animationRange != null) { nullBits = (byte)(nullBits | 1); } - if (this.animationRange != null) { + if (this.highlightColor != null) { nullBits = (byte)(nullBits | 2); } - if (this.highlightColor != null) { + if (this.noiseScale != null) { nullBits = (byte)(nullBits | 4); } - if (this.noiseScale != null) { + if (this.noiseScrollSpeed != null) { nullBits = (byte)(nullBits | 8); } - if (this.noiseScrollSpeed != null) { + if (this.postColor != null) { nullBits = (byte)(nullBits | 16); } - if (this.postColor != null) { + if (this.id != null) { nullBits = (byte)(nullBits | 32); } @@ -245,7 +245,7 @@ public class ModelVFX { } else { byte nullBits = buffer.getByte(offset); int pos = offset + 49; - if ((nullBits & 1) != 0) { + if ((nullBits & 32) != 0) { int idLen = VarInt.peek(buffer, pos); if (idLen < 0) { return ValidationResult.error("Invalid string length for Id"); diff --git a/src/com/hypixel/hytale/protocol/ModifyInventoryInteraction.java b/src/com/hypixel/hytale/protocol/ModifyInventoryInteraction.java index 3acccf3..ebc122a 100644 --- a/src/com/hypixel/hytale/protocol/ModifyInventoryInteraction.java +++ b/src/com/hypixel/hytale/protocol/ModifyInventoryInteraction.java @@ -101,18 +101,18 @@ public class ModifyInventoryInteraction extends SimpleInteraction { obj.cancelOnItemChange = buf.getByte(offset + 11) != 0; obj.next = buf.getIntLE(offset + 12); obj.failed = buf.getIntLE(offset + 16); - if ((nullBits[0] & 32) != 0) { + if ((nullBits[0] & 1) != 0) { obj.requiredGameMode = GameMode.fromValue(buf.getByte(offset + 20)); } obj.adjustHeldItemQuantity = buf.getIntLE(offset + 21); obj.adjustHeldItemDurability = buf.getDoubleLE(offset + 25); - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 2) != 0) { int varPos0 = offset + 65 + buf.getIntLE(offset + 33); obj.effects = InteractionEffects.deserialize(buf, varPos0); } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 4) != 0) { int varPos1 = offset + 65 + buf.getIntLE(offset + 37); int settingsCount = VarInt.peek(buf, varPos1); if (settingsCount < 0) { @@ -137,12 +137,12 @@ public class ModifyInventoryInteraction extends SimpleInteraction { } } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 8) != 0) { int varPos2 = offset + 65 + buf.getIntLE(offset + 41); obj.rules = InteractionRules.deserialize(buf, varPos2); } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[0] & 16) != 0) { int varPos3 = offset + 65 + buf.getIntLE(offset + 45); int tagsCount = VarInt.peek(buf, varPos3); if (tagsCount < 0) { @@ -165,7 +165,7 @@ public class ModifyInventoryInteraction extends SimpleInteraction { } } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[0] & 32) != 0) { int varPos4 = offset + 65 + buf.getIntLE(offset + 49); obj.camera = InteractionCameraSettings.deserialize(buf, varPos4); } @@ -200,7 +200,7 @@ public class ModifyInventoryInteraction extends SimpleInteraction { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte[] nullBits = PacketIO.readBytes(buf, offset, 2); int maxEnd = 65; - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 2) != 0) { int fieldOffset0 = buf.getIntLE(offset + 33); int pos0 = offset + 65 + fieldOffset0; pos0 += InteractionEffects.computeBytesConsumed(buf, pos0); @@ -209,7 +209,7 @@ public class ModifyInventoryInteraction extends SimpleInteraction { } } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 4) != 0) { int fieldOffset1 = buf.getIntLE(offset + 37); int pos1 = offset + 65 + fieldOffset1; int dictLen = VarInt.peek(buf, pos1); @@ -224,7 +224,7 @@ public class ModifyInventoryInteraction extends SimpleInteraction { } } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 8) != 0) { int fieldOffset2 = buf.getIntLE(offset + 41); int pos2 = offset + 65 + fieldOffset2; pos2 += InteractionRules.computeBytesConsumed(buf, pos2); @@ -233,7 +233,7 @@ public class ModifyInventoryInteraction extends SimpleInteraction { } } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[0] & 16) != 0) { int fieldOffset3 = buf.getIntLE(offset + 45); int pos3 = offset + 65 + fieldOffset3; int arrLen = VarInt.peek(buf, pos3); @@ -243,7 +243,7 @@ public class ModifyInventoryInteraction extends SimpleInteraction { } } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[0] & 32) != 0) { int fieldOffset4 = buf.getIntLE(offset + 49); int pos4 = offset + 65 + fieldOffset4; pos4 += InteractionCameraSettings.computeBytesConsumed(buf, pos4); @@ -287,27 +287,27 @@ public class ModifyInventoryInteraction extends SimpleInteraction { public int serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte[] nullBits = new byte[2]; - if (this.effects != null) { + if (this.requiredGameMode != null) { nullBits[0] = (byte)(nullBits[0] | 1); } - if (this.settings != null) { + if (this.effects != null) { nullBits[0] = (byte)(nullBits[0] | 2); } - if (this.rules != null) { + if (this.settings != null) { nullBits[0] = (byte)(nullBits[0] | 4); } - if (this.tags != null) { + if (this.rules != null) { nullBits[0] = (byte)(nullBits[0] | 8); } - if (this.camera != null) { + if (this.tags != null) { nullBits[0] = (byte)(nullBits[0] | 16); } - if (this.requiredGameMode != null) { + if (this.camera != null) { nullBits[0] = (byte)(nullBits[0] | 32); } @@ -474,7 +474,7 @@ public class ModifyInventoryInteraction extends SimpleInteraction { return ValidationResult.error("Buffer too small: expected at least 65 bytes"); } else { byte[] nullBits = PacketIO.readBytes(buffer, offset, 2); - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 2) != 0) { int effectsOffset = buffer.getIntLE(offset + 33); if (effectsOffset < 0) { return ValidationResult.error("Invalid offset for Effects"); @@ -493,7 +493,7 @@ public class ModifyInventoryInteraction extends SimpleInteraction { pos += InteractionEffects.computeBytesConsumed(buffer, pos); } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 4) != 0) { int settingsOffset = buffer.getIntLE(offset + 37); if (settingsOffset < 0) { return ValidationResult.error("Invalid offset for Settings"); @@ -521,7 +521,7 @@ public class ModifyInventoryInteraction extends SimpleInteraction { } } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 8) != 0) { int rulesOffset = buffer.getIntLE(offset + 41); if (rulesOffset < 0) { return ValidationResult.error("Invalid offset for Rules"); @@ -540,7 +540,7 @@ public class ModifyInventoryInteraction extends SimpleInteraction { posxx += InteractionRules.computeBytesConsumed(buffer, posxx); } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[0] & 16) != 0) { int tagsOffset = buffer.getIntLE(offset + 45); if (tagsOffset < 0) { return ValidationResult.error("Invalid offset for Tags"); @@ -567,7 +567,7 @@ public class ModifyInventoryInteraction extends SimpleInteraction { } } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[0] & 32) != 0) { int cameraOffset = buffer.getIntLE(offset + 49); if (cameraOffset < 0) { return ValidationResult.error("Invalid offset for Camera"); diff --git a/src/com/hypixel/hytale/protocol/MouseMotionEvent.java b/src/com/hypixel/hytale/protocol/MouseMotionEvent.java index b23f7db..b1ab337 100644 --- a/src/com/hypixel/hytale/protocol/MouseMotionEvent.java +++ b/src/com/hypixel/hytale/protocol/MouseMotionEvent.java @@ -37,12 +37,12 @@ public class MouseMotionEvent { public static MouseMotionEvent deserialize(@Nonnull ByteBuf buf, int offset) { MouseMotionEvent obj = new MouseMotionEvent(); byte nullBits = buf.getByte(offset); - if ((nullBits & 2) != 0) { + if ((nullBits & 1) != 0) { obj.relativeMotion = Vector2i.deserialize(buf, offset + 1); } int pos = offset + 9; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int mouseButtonTypeCount = VarInt.peek(buf, pos); if (mouseButtonTypeCount < 0) { throw ProtocolException.negativeLength("MouseButtonType", mouseButtonTypeCount); @@ -72,7 +72,7 @@ public class MouseMotionEvent { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int pos = offset + 9; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int arrLen = VarInt.peek(buf, pos); pos += VarInt.length(buf, pos) + arrLen * 1; } @@ -82,11 +82,11 @@ public class MouseMotionEvent { public void serialize(@Nonnull ByteBuf buf) { byte nullBits = 0; - if (this.mouseButtonType != null) { + if (this.relativeMotion != null) { nullBits = (byte)(nullBits | 1); } - if (this.relativeMotion != null) { + if (this.mouseButtonType != null) { nullBits = (byte)(nullBits | 2); } @@ -125,7 +125,7 @@ public class MouseMotionEvent { } else { byte nullBits = buffer.getByte(offset); int pos = offset + 9; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int mouseButtonTypeCount = VarInt.peek(buffer, pos); if (mouseButtonTypeCount < 0) { return ValidationResult.error("Invalid array count for MouseButtonType"); diff --git a/src/com/hypixel/hytale/protocol/PacketRegistry.java b/src/com/hypixel/hytale/protocol/PacketRegistry.java index bb17cbb..e3e8d3b 100644 --- a/src/com/hypixel/hytale/protocol/PacketRegistry.java +++ b/src/com/hypixel/hytale/protocol/PacketRegistry.java @@ -321,7 +321,7 @@ public final class PacketRegistry { } static { - register(0, "Connect", Connect.class, 82, 38161, false, Connect::validateStructure, Connect::deserialize); + register(0, "Connect", Connect.class, 46, 38013, false, Connect::validateStructure, Connect::deserialize); register(1, "Disconnect", Disconnect.class, 2, 16384007, false, Disconnect::validateStructure, Disconnect::deserialize); register(2, "Ping", Ping.class, 29, 29, false, Ping::validateStructure, Ping::deserialize); register(3, "Pong", Pong.class, 20, 20, false, Pong::validateStructure, Pong::deserialize); @@ -615,7 +615,7 @@ public final class PacketRegistry { register(114, "DisplayDebug", DisplayDebug.class, 19, 32768037, false, DisplayDebug::validateStructure, DisplayDebug::deserialize); register(115, "ClearDebugShapes", ClearDebugShapes.class, 0, 0, false, ClearDebugShapes::validateStructure, ClearDebugShapes::deserialize); register( - 116, "SyncPlayerPreferences", SyncPlayerPreferences.class, 8, 8, false, SyncPlayerPreferences::validateStructure, SyncPlayerPreferences::deserialize + 116, "SyncPlayerPreferences", SyncPlayerPreferences.class, 12, 12, false, SyncPlayerPreferences::validateStructure, SyncPlayerPreferences::deserialize ); register(117, "ClientPlaceBlock", ClientPlaceBlock.class, 20, 20, false, ClientPlaceBlock::validateStructure, ClientPlaceBlock::deserialize); register( diff --git a/src/com/hypixel/hytale/protocol/ParamValue.java b/src/com/hypixel/hytale/protocol/ParamValue.java index 9956b5f..f2d9fb1 100644 --- a/src/com/hypixel/hytale/protocol/ParamValue.java +++ b/src/com/hypixel/hytale/protocol/ParamValue.java @@ -9,9 +9,6 @@ import javax.annotation.Nonnull; public abstract class ParamValue { public static final int MAX_SIZE = 16384011; - public ParamValue() { - } - @Nonnull public static ParamValue deserialize(@Nonnull ByteBuf buf, int offset) { int typeId = VarInt.peek(buf, offset); diff --git a/src/com/hypixel/hytale/protocol/Particle.java b/src/com/hypixel/hytale/protocol/Particle.java index af30391..c3e1946 100644 --- a/src/com/hypixel/hytale/protocol/Particle.java +++ b/src/com/hypixel/hytale/protocol/Particle.java @@ -81,7 +81,7 @@ public class Particle { public static Particle deserialize(@Nonnull ByteBuf buf, int offset) { Particle obj = new Particle(); byte nullBits = buf.getByte(offset); - if ((nullBits & 2) != 0) { + if ((nullBits & 1) != 0) { obj.frameSize = Size.deserialize(buf, offset + 1); } @@ -90,15 +90,15 @@ public class Particle { obj.softParticles = SoftParticle.fromValue(buf.getByte(offset + 11)); obj.softParticlesFadeFactor = buf.getFloatLE(offset + 12); obj.useSpriteBlending = buf.getByte(offset + 16) != 0; - if ((nullBits & 4) != 0) { + if ((nullBits & 2) != 0) { obj.initialAnimationFrame = ParticleAnimationFrame.deserialize(buf, offset + 17); } - if ((nullBits & 8) != 0) { + if ((nullBits & 4) != 0) { obj.collisionAnimationFrame = ParticleAnimationFrame.deserialize(buf, offset + 75); } - if ((nullBits & 1) != 0) { + if ((nullBits & 8) != 0) { int varPos0 = offset + 141 + buf.getIntLE(offset + 133); int texturePathLen = VarInt.peek(buf, varPos0); if (texturePathLen < 0) { @@ -144,7 +144,7 @@ public class Particle { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 141; - if ((nullBits & 1) != 0) { + if ((nullBits & 8) != 0) { int fieldOffset0 = buf.getIntLE(offset + 133); int pos0 = offset + 141 + fieldOffset0; int sl = VarInt.peek(buf, pos0); @@ -176,19 +176,19 @@ public class Particle { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.texturePath != null) { + if (this.frameSize != null) { nullBits = (byte)(nullBits | 1); } - if (this.frameSize != null) { + if (this.initialAnimationFrame != null) { nullBits = (byte)(nullBits | 2); } - if (this.initialAnimationFrame != null) { + if (this.collisionAnimationFrame != null) { nullBits = (byte)(nullBits | 4); } - if (this.collisionAnimationFrame != null) { + if (this.texturePath != null) { nullBits = (byte)(nullBits | 8); } @@ -267,7 +267,7 @@ public class Particle { return ValidationResult.error("Buffer too small: expected at least 141 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 8) != 0) { int texturePathOffset = buffer.getIntLE(offset + 133); if (texturePathOffset < 0) { return ValidationResult.error("Invalid offset for TexturePath"); diff --git a/src/com/hypixel/hytale/protocol/ParticleSpawner.java b/src/com/hypixel/hytale/protocol/ParticleSpawner.java index 37ed7aa..c7897e1 100644 --- a/src/com/hypixel/hytale/protocol/ParticleSpawner.java +++ b/src/com/hypixel/hytale/protocol/ParticleSpawner.java @@ -155,28 +155,28 @@ public class ParticleSpawner { ParticleSpawner obj = new ParticleSpawner(); byte[] nullBits = PacketIO.readBytes(buf, offset, 2); obj.shape = EmitShape.fromValue(buf.getByte(offset + 2)); - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 1) != 0) { obj.emitOffset = RangeVector3f.deserialize(buf, offset + 3); } obj.cameraOffset = buf.getFloatLE(offset + 28); obj.useEmitDirection = buf.getByte(offset + 32) != 0; obj.lifeSpan = buf.getFloatLE(offset + 33); - if ((nullBits[0] & 8) != 0) { + if ((nullBits[0] & 2) != 0) { obj.spawnRate = Rangef.deserialize(buf, offset + 37); } obj.spawnBurst = buf.getByte(offset + 45) != 0; - if ((nullBits[0] & 16) != 0) { + if ((nullBits[0] & 4) != 0) { obj.waveDelay = Rangef.deserialize(buf, offset + 46); } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[0] & 8) != 0) { obj.totalParticles = Range.deserialize(buf, offset + 54); } obj.maxConcurrentParticles = buf.getIntLE(offset + 62); - if ((nullBits[0] & 64) != 0) { + if ((nullBits[0] & 16) != 0) { obj.initialVelocity = InitialVelocity.deserialize(buf, offset + 66); } @@ -186,22 +186,22 @@ public class ParticleSpawner { obj.isLowRes = buf.getByte(offset + 97) != 0; obj.trailSpawnerPositionMultiplier = buf.getFloatLE(offset + 98); obj.trailSpawnerRotationMultiplier = buf.getFloatLE(offset + 102); - if ((nullBits[0] & 128) != 0) { + if ((nullBits[0] & 32) != 0) { obj.particleCollision = ParticleCollision.deserialize(buf, offset + 106); } obj.renderMode = FXRenderMode.fromValue(buf.getByte(offset + 109)); obj.lightInfluence = buf.getFloatLE(offset + 110); obj.linearFiltering = buf.getByte(offset + 114) != 0; - if ((nullBits[1] & 1) != 0) { + if ((nullBits[0] & 64) != 0) { obj.particleLifeSpan = Rangef.deserialize(buf, offset + 115); } - if ((nullBits[1] & 8) != 0) { + if ((nullBits[0] & 128) != 0) { obj.intersectionHighlight = IntersectionHighlight.deserialize(buf, offset + 123); } - if ((nullBits[0] & 1) != 0) { + if ((nullBits[1] & 1) != 0) { int varPos0 = offset + 147 + buf.getIntLE(offset + 131); int idLen = VarInt.peek(buf, varPos0); if (idLen < 0) { @@ -215,17 +215,17 @@ public class ParticleSpawner { obj.id = PacketIO.readVarString(buf, varPos0, PacketIO.UTF8); } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[1] & 2) != 0) { int varPos1 = offset + 147 + buf.getIntLE(offset + 135); obj.particle = Particle.deserialize(buf, varPos1); } - if ((nullBits[1] & 2) != 0) { + if ((nullBits[1] & 4) != 0) { int varPos2 = offset + 147 + buf.getIntLE(offset + 139); obj.uvMotion = UVMotion.deserialize(buf, varPos2); } - if ((nullBits[1] & 4) != 0) { + if ((nullBits[1] & 8) != 0) { int varPos3 = offset + 147 + buf.getIntLE(offset + 143); int attractorsCount = VarInt.peek(buf, varPos3); if (attractorsCount < 0) { @@ -256,7 +256,7 @@ public class ParticleSpawner { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte[] nullBits = PacketIO.readBytes(buf, offset, 2); int maxEnd = 147; - if ((nullBits[0] & 1) != 0) { + if ((nullBits[1] & 1) != 0) { int fieldOffset0 = buf.getIntLE(offset + 131); int pos0 = offset + 147 + fieldOffset0; int sl = VarInt.peek(buf, pos0); @@ -266,7 +266,7 @@ public class ParticleSpawner { } } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[1] & 2) != 0) { int fieldOffset1 = buf.getIntLE(offset + 135); int pos1 = offset + 147 + fieldOffset1; pos1 += Particle.computeBytesConsumed(buf, pos1); @@ -275,7 +275,7 @@ public class ParticleSpawner { } } - if ((nullBits[1] & 2) != 0) { + if ((nullBits[1] & 4) != 0) { int fieldOffset2 = buf.getIntLE(offset + 139); int pos2 = offset + 147 + fieldOffset2; pos2 += UVMotion.computeBytesConsumed(buf, pos2); @@ -284,7 +284,7 @@ public class ParticleSpawner { } } - if ((nullBits[1] & 4) != 0) { + if ((nullBits[1] & 8) != 0) { int fieldOffset3 = buf.getIntLE(offset + 143); int pos3 = offset + 147 + fieldOffset3; int arrLen = VarInt.peek(buf, pos3); @@ -305,51 +305,51 @@ public class ParticleSpawner { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte[] nullBits = new byte[2]; - if (this.id != null) { + if (this.emitOffset != null) { nullBits[0] = (byte)(nullBits[0] | 1); } - if (this.particle != null) { + if (this.spawnRate != null) { nullBits[0] = (byte)(nullBits[0] | 2); } - if (this.emitOffset != null) { + if (this.waveDelay != null) { nullBits[0] = (byte)(nullBits[0] | 4); } - if (this.spawnRate != null) { + if (this.totalParticles != null) { nullBits[0] = (byte)(nullBits[0] | 8); } - if (this.waveDelay != null) { + if (this.initialVelocity != null) { nullBits[0] = (byte)(nullBits[0] | 16); } - if (this.totalParticles != null) { + if (this.particleCollision != null) { nullBits[0] = (byte)(nullBits[0] | 32); } - if (this.initialVelocity != null) { + if (this.particleLifeSpan != null) { nullBits[0] = (byte)(nullBits[0] | 64); } - if (this.particleCollision != null) { + if (this.intersectionHighlight != null) { nullBits[0] = (byte)(nullBits[0] | 128); } - if (this.particleLifeSpan != null) { + if (this.id != null) { nullBits[1] = (byte)(nullBits[1] | 1); } - if (this.uvMotion != null) { + if (this.particle != null) { nullBits[1] = (byte)(nullBits[1] | 2); } - if (this.attractors != null) { + if (this.uvMotion != null) { nullBits[1] = (byte)(nullBits[1] | 4); } - if (this.intersectionHighlight != null) { + if (this.attractors != null) { nullBits[1] = (byte)(nullBits[1] | 8); } @@ -489,7 +489,7 @@ public class ParticleSpawner { return ValidationResult.error("Buffer too small: expected at least 147 bytes"); } else { byte[] nullBits = PacketIO.readBytes(buffer, offset, 2); - if ((nullBits[0] & 1) != 0) { + if ((nullBits[1] & 1) != 0) { int idOffset = buffer.getIntLE(offset + 131); if (idOffset < 0) { return ValidationResult.error("Invalid offset for Id"); @@ -516,7 +516,7 @@ public class ParticleSpawner { } } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[1] & 2) != 0) { int particleOffset = buffer.getIntLE(offset + 135); if (particleOffset < 0) { return ValidationResult.error("Invalid offset for Particle"); @@ -535,7 +535,7 @@ public class ParticleSpawner { posx += Particle.computeBytesConsumed(buffer, posx); } - if ((nullBits[1] & 2) != 0) { + if ((nullBits[1] & 4) != 0) { int uvMotionOffset = buffer.getIntLE(offset + 139); if (uvMotionOffset < 0) { return ValidationResult.error("Invalid offset for UvMotion"); @@ -554,7 +554,7 @@ public class ParticleSpawner { posxx += UVMotion.computeBytesConsumed(buffer, posxx); } - if ((nullBits[1] & 4) != 0) { + if ((nullBits[1] & 8) != 0) { int attractorsOffset = buffer.getIntLE(offset + 143); if (attractorsOffset < 0) { return ValidationResult.error("Invalid offset for Attractors"); diff --git a/src/com/hypixel/hytale/protocol/ParticleSpawnerGroup.java b/src/com/hypixel/hytale/protocol/ParticleSpawnerGroup.java index 6768b57..0eb8cc2 100644 --- a/src/com/hypixel/hytale/protocol/ParticleSpawnerGroup.java +++ b/src/com/hypixel/hytale/protocol/ParticleSpawnerGroup.java @@ -92,39 +92,39 @@ public class ParticleSpawnerGroup { public static ParticleSpawnerGroup deserialize(@Nonnull ByteBuf buf, int offset) { ParticleSpawnerGroup obj = new ParticleSpawnerGroup(); byte[] nullBits = PacketIO.readBytes(buf, offset, 2); - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 1) != 0) { obj.positionOffset = Vector3f.deserialize(buf, offset + 2); } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 2) != 0) { obj.rotationOffset = Direction.deserialize(buf, offset + 14); } obj.fixedRotation = buf.getByte(offset + 26) != 0; obj.startDelay = buf.getFloatLE(offset + 27); - if ((nullBits[0] & 8) != 0) { + if ((nullBits[0] & 4) != 0) { obj.spawnRate = Rangef.deserialize(buf, offset + 31); } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[0] & 8) != 0) { obj.waveDelay = Rangef.deserialize(buf, offset + 39); } obj.totalSpawners = buf.getIntLE(offset + 47); obj.maxConcurrent = buf.getIntLE(offset + 51); - if ((nullBits[0] & 32) != 0) { + if ((nullBits[0] & 16) != 0) { obj.initialVelocity = InitialVelocity.deserialize(buf, offset + 55); } - if ((nullBits[0] & 64) != 0) { + if ((nullBits[0] & 32) != 0) { obj.emitOffset = RangeVector3f.deserialize(buf, offset + 80); } - if ((nullBits[0] & 128) != 0) { + if ((nullBits[0] & 64) != 0) { obj.lifeSpan = Rangef.deserialize(buf, offset + 105); } - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 128) != 0) { int varPos0 = offset + 121 + buf.getIntLE(offset + 113); int spawnerIdLen = VarInt.peek(buf, varPos0); if (spawnerIdLen < 0) { @@ -169,7 +169,7 @@ public class ParticleSpawnerGroup { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte[] nullBits = PacketIO.readBytes(buf, offset, 2); int maxEnd = 121; - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 128) != 0) { int fieldOffset0 = buf.getIntLE(offset + 113); int pos0 = offset + 121 + fieldOffset0; int sl = VarInt.peek(buf, pos0); @@ -200,35 +200,35 @@ public class ParticleSpawnerGroup { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte[] nullBits = new byte[2]; - if (this.spawnerId != null) { + if (this.positionOffset != null) { nullBits[0] = (byte)(nullBits[0] | 1); } - if (this.positionOffset != null) { + if (this.rotationOffset != null) { nullBits[0] = (byte)(nullBits[0] | 2); } - if (this.rotationOffset != null) { + if (this.spawnRate != null) { nullBits[0] = (byte)(nullBits[0] | 4); } - if (this.spawnRate != null) { + if (this.waveDelay != null) { nullBits[0] = (byte)(nullBits[0] | 8); } - if (this.waveDelay != null) { + if (this.initialVelocity != null) { nullBits[0] = (byte)(nullBits[0] | 16); } - if (this.initialVelocity != null) { + if (this.emitOffset != null) { nullBits[0] = (byte)(nullBits[0] | 32); } - if (this.emitOffset != null) { + if (this.lifeSpan != null) { nullBits[0] = (byte)(nullBits[0] | 64); } - if (this.lifeSpan != null) { + if (this.spawnerId != null) { nullBits[0] = (byte)(nullBits[0] | 128); } @@ -329,7 +329,7 @@ public class ParticleSpawnerGroup { return ValidationResult.error("Buffer too small: expected at least 121 bytes"); } else { byte[] nullBits = PacketIO.readBytes(buffer, offset, 2); - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 128) != 0) { int spawnerIdOffset = buffer.getIntLE(offset + 113); if (spawnerIdOffset < 0) { return ValidationResult.error("Invalid offset for SpawnerId"); diff --git a/src/com/hypixel/hytale/protocol/Phobia.java b/src/com/hypixel/hytale/protocol/Phobia.java index 2d566f7..cd67596 100644 --- a/src/com/hypixel/hytale/protocol/Phobia.java +++ b/src/com/hypixel/hytale/protocol/Phobia.java @@ -4,7 +4,8 @@ import com.hypixel.hytale.protocol.io.ProtocolException; public enum Phobia { None(0), - Arachnophobia(1); + Arachnophobia(1), + Ophidiophobia(2); public static final Phobia[] VALUES = values(); private final int value; diff --git a/src/com/hypixel/hytale/protocol/ProjectileConfig.java b/src/com/hypixel/hytale/protocol/ProjectileConfig.java index 61c1362..e65e9ba 100644 --- a/src/com/hypixel/hytale/protocol/ProjectileConfig.java +++ b/src/com/hypixel/hytale/protocol/ProjectileConfig.java @@ -74,17 +74,17 @@ public class ProjectileConfig { } obj.launchForce = buf.getDoubleLE(offset + 123); - if ((nullBits & 4) != 0) { + if ((nullBits & 2) != 0) { obj.spawnOffset = Vector3f.deserialize(buf, offset + 131); } - if ((nullBits & 8) != 0) { + if ((nullBits & 4) != 0) { obj.rotationOffset = Direction.deserialize(buf, offset + 143); } obj.launchLocalSoundEventIndex = buf.getIntLE(offset + 155); obj.projectileSoundEventIndex = buf.getIntLE(offset + 159); - if ((nullBits & 2) != 0) { + if ((nullBits & 8) != 0) { int varPos0 = offset + 171 + buf.getIntLE(offset + 163); obj.model = Model.deserialize(buf, varPos0); } @@ -120,7 +120,7 @@ public class ProjectileConfig { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 171; - if ((nullBits & 2) != 0) { + if ((nullBits & 8) != 0) { int fieldOffset0 = buf.getIntLE(offset + 163); int pos0 = offset + 171 + fieldOffset0; pos0 += Model.computeBytesConsumed(buf, pos0); @@ -154,15 +154,15 @@ public class ProjectileConfig { nullBits = (byte)(nullBits | 1); } - if (this.model != null) { + if (this.spawnOffset != null) { nullBits = (byte)(nullBits | 2); } - if (this.spawnOffset != null) { + if (this.rotationOffset != null) { nullBits = (byte)(nullBits | 4); } - if (this.rotationOffset != null) { + if (this.model != null) { nullBits = (byte)(nullBits | 8); } @@ -239,7 +239,7 @@ public class ProjectileConfig { return ValidationResult.error("Buffer too small: expected at least 171 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 2) != 0) { + if ((nullBits & 8) != 0) { int modelOffset = buffer.getIntLE(offset + 163); if (modelOffset < 0) { return ValidationResult.error("Invalid offset for Model"); diff --git a/src/com/hypixel/hytale/protocol/ProtocolSettings.java b/src/com/hypixel/hytale/protocol/ProtocolSettings.java index ff23d2c..13f2c48 100644 --- a/src/com/hypixel/hytale/protocol/ProtocolSettings.java +++ b/src/com/hypixel/hytale/protocol/ProtocolSettings.java @@ -1,17 +1,18 @@ package com.hypixel.hytale.protocol; public final class ProtocolSettings { - public static final String PROTOCOL_HASH = "6708f121966c1c443f4b0eb525b2f81d0a8dc61f5003a692a8fa157e5e02cea9"; - public static final int PROTOCOL_VERSION = 1; + public static final int PROTOCOL_CRC = 1789265863; + public static final int PROTOCOL_VERSION = 2; + public static final int PROTOCOL_BUILD_NUMBER = 2; public static final int PACKET_COUNT = 268; - public static final int STRUCT_COUNT = 315; + public static final int STRUCT_COUNT = 314; public static final int ENUM_COUNT = 136; public static final int MAX_PACKET_SIZE = 1677721600; private ProtocolSettings() { } - public static boolean validateHash(String hash) { - return "6708f121966c1c443f4b0eb525b2f81d0a8dc61f5003a692a8fa157e5e02cea9".equals(hash); + public static boolean validateCrc(int crc) { + return 1789265863 == crc; } } diff --git a/src/com/hypixel/hytale/protocol/RefillContainerInteraction.java b/src/com/hypixel/hytale/protocol/RefillContainerInteraction.java deleted file mode 100644 index af3211d..0000000 --- a/src/com/hypixel/hytale/protocol/RefillContainerInteraction.java +++ /dev/null @@ -1,605 +0,0 @@ -package com.hypixel.hytale.protocol; - -import com.hypixel.hytale.protocol.io.ProtocolException; -import com.hypixel.hytale.protocol.io.ValidationResult; -import com.hypixel.hytale.protocol.io.VarInt; -import io.netty.buffer.ByteBuf; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Map.Entry; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public class RefillContainerInteraction extends SimpleBlockInteraction { - public static final int NULLABLE_BIT_FIELD_SIZE = 1; - public static final int FIXED_BLOCK_SIZE = 20; - public static final int VARIABLE_FIELD_COUNT = 6; - public static final int VARIABLE_BLOCK_START = 44; - public static final int MAX_SIZE = 1677721600; - @Nullable - public int[] refillFluids; - - public RefillContainerInteraction() { - } - - public RefillContainerInteraction( - @Nonnull WaitForDataFrom waitForDataFrom, - @Nullable InteractionEffects effects, - float horizontalSpeedMultiplier, - float runTime, - boolean cancelOnItemChange, - @Nullable Map settings, - @Nullable InteractionRules rules, - @Nullable int[] tags, - @Nullable InteractionCameraSettings camera, - int next, - int failed, - boolean useLatestTarget, - @Nullable int[] refillFluids - ) { - this.waitForDataFrom = waitForDataFrom; - this.effects = effects; - this.horizontalSpeedMultiplier = horizontalSpeedMultiplier; - this.runTime = runTime; - this.cancelOnItemChange = cancelOnItemChange; - this.settings = settings; - this.rules = rules; - this.tags = tags; - this.camera = camera; - this.next = next; - this.failed = failed; - this.useLatestTarget = useLatestTarget; - this.refillFluids = refillFluids; - } - - public RefillContainerInteraction(@Nonnull RefillContainerInteraction other) { - this.waitForDataFrom = other.waitForDataFrom; - this.effects = other.effects; - this.horizontalSpeedMultiplier = other.horizontalSpeedMultiplier; - this.runTime = other.runTime; - this.cancelOnItemChange = other.cancelOnItemChange; - this.settings = other.settings; - this.rules = other.rules; - this.tags = other.tags; - this.camera = other.camera; - this.next = other.next; - this.failed = other.failed; - this.useLatestTarget = other.useLatestTarget; - this.refillFluids = other.refillFluids; - } - - @Nonnull - public static RefillContainerInteraction deserialize(@Nonnull ByteBuf buf, int offset) { - RefillContainerInteraction obj = new RefillContainerInteraction(); - byte nullBits = buf.getByte(offset); - obj.waitForDataFrom = WaitForDataFrom.fromValue(buf.getByte(offset + 1)); - obj.horizontalSpeedMultiplier = buf.getFloatLE(offset + 2); - obj.runTime = buf.getFloatLE(offset + 6); - obj.cancelOnItemChange = buf.getByte(offset + 10) != 0; - obj.next = buf.getIntLE(offset + 11); - obj.failed = buf.getIntLE(offset + 15); - obj.useLatestTarget = buf.getByte(offset + 19) != 0; - if ((nullBits & 1) != 0) { - int varPos0 = offset + 44 + buf.getIntLE(offset + 20); - obj.effects = InteractionEffects.deserialize(buf, varPos0); - } - - if ((nullBits & 2) != 0) { - int varPos1 = offset + 44 + buf.getIntLE(offset + 24); - int settingsCount = VarInt.peek(buf, varPos1); - if (settingsCount < 0) { - throw ProtocolException.negativeLength("Settings", settingsCount); - } - - if (settingsCount > 4096000) { - throw ProtocolException.dictionaryTooLarge("Settings", settingsCount, 4096000); - } - - int varIntLen = VarInt.length(buf, varPos1); - obj.settings = new HashMap<>(settingsCount); - int dictPos = varPos1 + varIntLen; - - for (int i = 0; i < settingsCount; i++) { - GameMode key = GameMode.fromValue(buf.getByte(dictPos)); - InteractionSettings val = InteractionSettings.deserialize(buf, ++dictPos); - dictPos += InteractionSettings.computeBytesConsumed(buf, dictPos); - if (obj.settings.put(key, val) != null) { - throw ProtocolException.duplicateKey("settings", key); - } - } - } - - if ((nullBits & 4) != 0) { - int varPos2 = offset + 44 + buf.getIntLE(offset + 28); - obj.rules = InteractionRules.deserialize(buf, varPos2); - } - - if ((nullBits & 8) != 0) { - int varPos3 = offset + 44 + buf.getIntLE(offset + 32); - int tagsCount = VarInt.peek(buf, varPos3); - if (tagsCount < 0) { - throw ProtocolException.negativeLength("Tags", tagsCount); - } - - if (tagsCount > 4096000) { - throw ProtocolException.arrayTooLong("Tags", tagsCount, 4096000); - } - - int varIntLen = VarInt.length(buf, varPos3); - if (varPos3 + varIntLen + tagsCount * 4L > buf.readableBytes()) { - throw ProtocolException.bufferTooSmall("Tags", varPos3 + varIntLen + tagsCount * 4, buf.readableBytes()); - } - - obj.tags = new int[tagsCount]; - - for (int ix = 0; ix < tagsCount; ix++) { - obj.tags[ix] = buf.getIntLE(varPos3 + varIntLen + ix * 4); - } - } - - if ((nullBits & 16) != 0) { - int varPos4 = offset + 44 + buf.getIntLE(offset + 36); - obj.camera = InteractionCameraSettings.deserialize(buf, varPos4); - } - - if ((nullBits & 32) != 0) { - int varPos5 = offset + 44 + buf.getIntLE(offset + 40); - int refillFluidsCount = VarInt.peek(buf, varPos5); - if (refillFluidsCount < 0) { - throw ProtocolException.negativeLength("RefillFluids", refillFluidsCount); - } - - if (refillFluidsCount > 4096000) { - throw ProtocolException.arrayTooLong("RefillFluids", refillFluidsCount, 4096000); - } - - int varIntLen = VarInt.length(buf, varPos5); - if (varPos5 + varIntLen + refillFluidsCount * 4L > buf.readableBytes()) { - throw ProtocolException.bufferTooSmall("RefillFluids", varPos5 + varIntLen + refillFluidsCount * 4, buf.readableBytes()); - } - - obj.refillFluids = new int[refillFluidsCount]; - - for (int ix = 0; ix < refillFluidsCount; ix++) { - obj.refillFluids[ix] = buf.getIntLE(varPos5 + varIntLen + ix * 4); - } - } - - return obj; - } - - public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { - byte nullBits = buf.getByte(offset); - int maxEnd = 44; - if ((nullBits & 1) != 0) { - int fieldOffset0 = buf.getIntLE(offset + 20); - int pos0 = offset + 44 + fieldOffset0; - pos0 += InteractionEffects.computeBytesConsumed(buf, pos0); - if (pos0 - offset > maxEnd) { - maxEnd = pos0 - offset; - } - } - - if ((nullBits & 2) != 0) { - int fieldOffset1 = buf.getIntLE(offset + 24); - int pos1 = offset + 44 + fieldOffset1; - int dictLen = VarInt.peek(buf, pos1); - pos1 += VarInt.length(buf, pos1); - - for (int i = 0; i < dictLen; i++) { - pos1 = ++pos1 + InteractionSettings.computeBytesConsumed(buf, pos1); - } - - if (pos1 - offset > maxEnd) { - maxEnd = pos1 - offset; - } - } - - if ((nullBits & 4) != 0) { - int fieldOffset2 = buf.getIntLE(offset + 28); - int pos2 = offset + 44 + fieldOffset2; - pos2 += InteractionRules.computeBytesConsumed(buf, pos2); - if (pos2 - offset > maxEnd) { - maxEnd = pos2 - offset; - } - } - - if ((nullBits & 8) != 0) { - int fieldOffset3 = buf.getIntLE(offset + 32); - int pos3 = offset + 44 + fieldOffset3; - int arrLen = VarInt.peek(buf, pos3); - pos3 += VarInt.length(buf, pos3) + arrLen * 4; - if (pos3 - offset > maxEnd) { - maxEnd = pos3 - offset; - } - } - - if ((nullBits & 16) != 0) { - int fieldOffset4 = buf.getIntLE(offset + 36); - int pos4 = offset + 44 + fieldOffset4; - pos4 += InteractionCameraSettings.computeBytesConsumed(buf, pos4); - if (pos4 - offset > maxEnd) { - maxEnd = pos4 - offset; - } - } - - if ((nullBits & 32) != 0) { - int fieldOffset5 = buf.getIntLE(offset + 40); - int pos5 = offset + 44 + fieldOffset5; - int arrLen = VarInt.peek(buf, pos5); - pos5 += VarInt.length(buf, pos5) + arrLen * 4; - if (pos5 - offset > maxEnd) { - maxEnd = pos5 - offset; - } - } - - return maxEnd; - } - - @Override - public int serialize(@Nonnull ByteBuf buf) { - int startPos = buf.writerIndex(); - byte nullBits = 0; - if (this.effects != null) { - nullBits = (byte)(nullBits | 1); - } - - if (this.settings != null) { - nullBits = (byte)(nullBits | 2); - } - - if (this.rules != null) { - nullBits = (byte)(nullBits | 4); - } - - if (this.tags != null) { - nullBits = (byte)(nullBits | 8); - } - - if (this.camera != null) { - nullBits = (byte)(nullBits | 16); - } - - if (this.refillFluids != null) { - nullBits = (byte)(nullBits | 32); - } - - buf.writeByte(nullBits); - buf.writeByte(this.waitForDataFrom.getValue()); - buf.writeFloatLE(this.horizontalSpeedMultiplier); - buf.writeFloatLE(this.runTime); - buf.writeByte(this.cancelOnItemChange ? 1 : 0); - buf.writeIntLE(this.next); - buf.writeIntLE(this.failed); - buf.writeByte(this.useLatestTarget ? 1 : 0); - int effectsOffsetSlot = buf.writerIndex(); - buf.writeIntLE(0); - int settingsOffsetSlot = buf.writerIndex(); - buf.writeIntLE(0); - int rulesOffsetSlot = buf.writerIndex(); - buf.writeIntLE(0); - int tagsOffsetSlot = buf.writerIndex(); - buf.writeIntLE(0); - int cameraOffsetSlot = buf.writerIndex(); - buf.writeIntLE(0); - int refillFluidsOffsetSlot = buf.writerIndex(); - buf.writeIntLE(0); - int varBlockStart = buf.writerIndex(); - if (this.effects != null) { - buf.setIntLE(effectsOffsetSlot, buf.writerIndex() - varBlockStart); - this.effects.serialize(buf); - } else { - buf.setIntLE(effectsOffsetSlot, -1); - } - - if (this.settings != null) { - buf.setIntLE(settingsOffsetSlot, buf.writerIndex() - varBlockStart); - if (this.settings.size() > 4096000) { - throw ProtocolException.dictionaryTooLarge("Settings", this.settings.size(), 4096000); - } - - VarInt.write(buf, this.settings.size()); - - for (Entry e : this.settings.entrySet()) { - buf.writeByte(e.getKey().getValue()); - e.getValue().serialize(buf); - } - } else { - buf.setIntLE(settingsOffsetSlot, -1); - } - - if (this.rules != null) { - buf.setIntLE(rulesOffsetSlot, buf.writerIndex() - varBlockStart); - this.rules.serialize(buf); - } else { - buf.setIntLE(rulesOffsetSlot, -1); - } - - if (this.tags != null) { - buf.setIntLE(tagsOffsetSlot, buf.writerIndex() - varBlockStart); - if (this.tags.length > 4096000) { - throw ProtocolException.arrayTooLong("Tags", this.tags.length, 4096000); - } - - VarInt.write(buf, this.tags.length); - - for (int item : this.tags) { - buf.writeIntLE(item); - } - } else { - buf.setIntLE(tagsOffsetSlot, -1); - } - - if (this.camera != null) { - buf.setIntLE(cameraOffsetSlot, buf.writerIndex() - varBlockStart); - this.camera.serialize(buf); - } else { - buf.setIntLE(cameraOffsetSlot, -1); - } - - if (this.refillFluids != null) { - buf.setIntLE(refillFluidsOffsetSlot, buf.writerIndex() - varBlockStart); - if (this.refillFluids.length > 4096000) { - throw ProtocolException.arrayTooLong("RefillFluids", this.refillFluids.length, 4096000); - } - - VarInt.write(buf, this.refillFluids.length); - - for (int item : this.refillFluids) { - buf.writeIntLE(item); - } - } else { - buf.setIntLE(refillFluidsOffsetSlot, -1); - } - - return buf.writerIndex() - startPos; - } - - @Override - public int computeSize() { - int size = 44; - if (this.effects != null) { - size += this.effects.computeSize(); - } - - if (this.settings != null) { - size += VarInt.size(this.settings.size()) + this.settings.size() * 2; - } - - if (this.rules != null) { - size += this.rules.computeSize(); - } - - if (this.tags != null) { - size += VarInt.size(this.tags.length) + this.tags.length * 4; - } - - if (this.camera != null) { - size += this.camera.computeSize(); - } - - if (this.refillFluids != null) { - size += VarInt.size(this.refillFluids.length) + this.refillFluids.length * 4; - } - - return size; - } - - public static ValidationResult validateStructure(@Nonnull ByteBuf buffer, int offset) { - if (buffer.readableBytes() - offset < 44) { - return ValidationResult.error("Buffer too small: expected at least 44 bytes"); - } else { - byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { - int effectsOffset = buffer.getIntLE(offset + 20); - if (effectsOffset < 0) { - return ValidationResult.error("Invalid offset for Effects"); - } - - int pos = offset + 44 + effectsOffset; - if (pos >= buffer.writerIndex()) { - return ValidationResult.error("Offset out of bounds for Effects"); - } - - ValidationResult effectsResult = InteractionEffects.validateStructure(buffer, pos); - if (!effectsResult.isValid()) { - return ValidationResult.error("Invalid Effects: " + effectsResult.error()); - } - - pos += InteractionEffects.computeBytesConsumed(buffer, pos); - } - - if ((nullBits & 2) != 0) { - int settingsOffset = buffer.getIntLE(offset + 24); - if (settingsOffset < 0) { - return ValidationResult.error("Invalid offset for Settings"); - } - - int posx = offset + 44 + settingsOffset; - if (posx >= buffer.writerIndex()) { - return ValidationResult.error("Offset out of bounds for Settings"); - } - - int settingsCount = VarInt.peek(buffer, posx); - if (settingsCount < 0) { - return ValidationResult.error("Invalid dictionary count for Settings"); - } - - if (settingsCount > 4096000) { - return ValidationResult.error("Settings exceeds max length 4096000"); - } - - posx += VarInt.length(buffer, posx); - - for (int i = 0; i < settingsCount; i++) { - posx++; - posx++; - } - } - - if ((nullBits & 4) != 0) { - int rulesOffset = buffer.getIntLE(offset + 28); - if (rulesOffset < 0) { - return ValidationResult.error("Invalid offset for Rules"); - } - - int posxx = offset + 44 + rulesOffset; - if (posxx >= buffer.writerIndex()) { - return ValidationResult.error("Offset out of bounds for Rules"); - } - - ValidationResult rulesResult = InteractionRules.validateStructure(buffer, posxx); - if (!rulesResult.isValid()) { - return ValidationResult.error("Invalid Rules: " + rulesResult.error()); - } - - posxx += InteractionRules.computeBytesConsumed(buffer, posxx); - } - - if ((nullBits & 8) != 0) { - int tagsOffset = buffer.getIntLE(offset + 32); - if (tagsOffset < 0) { - return ValidationResult.error("Invalid offset for Tags"); - } - - int posxxx = offset + 44 + tagsOffset; - if (posxxx >= buffer.writerIndex()) { - return ValidationResult.error("Offset out of bounds for Tags"); - } - - int tagsCount = VarInt.peek(buffer, posxxx); - if (tagsCount < 0) { - return ValidationResult.error("Invalid array count for Tags"); - } - - if (tagsCount > 4096000) { - return ValidationResult.error("Tags exceeds max length 4096000"); - } - - posxxx += VarInt.length(buffer, posxxx); - posxxx += tagsCount * 4; - if (posxxx > buffer.writerIndex()) { - return ValidationResult.error("Buffer overflow reading Tags"); - } - } - - if ((nullBits & 16) != 0) { - int cameraOffset = buffer.getIntLE(offset + 36); - if (cameraOffset < 0) { - return ValidationResult.error("Invalid offset for Camera"); - } - - int posxxxx = offset + 44 + cameraOffset; - if (posxxxx >= buffer.writerIndex()) { - return ValidationResult.error("Offset out of bounds for Camera"); - } - - ValidationResult cameraResult = InteractionCameraSettings.validateStructure(buffer, posxxxx); - if (!cameraResult.isValid()) { - return ValidationResult.error("Invalid Camera: " + cameraResult.error()); - } - - posxxxx += InteractionCameraSettings.computeBytesConsumed(buffer, posxxxx); - } - - if ((nullBits & 32) != 0) { - int refillFluidsOffset = buffer.getIntLE(offset + 40); - if (refillFluidsOffset < 0) { - return ValidationResult.error("Invalid offset for RefillFluids"); - } - - int posxxxxx = offset + 44 + refillFluidsOffset; - if (posxxxxx >= buffer.writerIndex()) { - return ValidationResult.error("Offset out of bounds for RefillFluids"); - } - - int refillFluidsCount = VarInt.peek(buffer, posxxxxx); - if (refillFluidsCount < 0) { - return ValidationResult.error("Invalid array count for RefillFluids"); - } - - if (refillFluidsCount > 4096000) { - return ValidationResult.error("RefillFluids exceeds max length 4096000"); - } - - posxxxxx += VarInt.length(buffer, posxxxxx); - posxxxxx += refillFluidsCount * 4; - if (posxxxxx > buffer.writerIndex()) { - return ValidationResult.error("Buffer overflow reading RefillFluids"); - } - } - - return ValidationResult.OK; - } - } - - public RefillContainerInteraction clone() { - RefillContainerInteraction copy = new RefillContainerInteraction(); - copy.waitForDataFrom = this.waitForDataFrom; - copy.effects = this.effects != null ? this.effects.clone() : null; - copy.horizontalSpeedMultiplier = this.horizontalSpeedMultiplier; - copy.runTime = this.runTime; - copy.cancelOnItemChange = this.cancelOnItemChange; - if (this.settings != null) { - Map m = new HashMap<>(); - - for (Entry e : this.settings.entrySet()) { - m.put(e.getKey(), e.getValue().clone()); - } - - copy.settings = m; - } - - copy.rules = this.rules != null ? this.rules.clone() : null; - copy.tags = this.tags != null ? Arrays.copyOf(this.tags, this.tags.length) : null; - copy.camera = this.camera != null ? this.camera.clone() : null; - copy.next = this.next; - copy.failed = this.failed; - copy.useLatestTarget = this.useLatestTarget; - copy.refillFluids = this.refillFluids != null ? Arrays.copyOf(this.refillFluids, this.refillFluids.length) : null; - return copy; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } else { - return !(obj instanceof RefillContainerInteraction other) - ? false - : Objects.equals(this.waitForDataFrom, other.waitForDataFrom) - && Objects.equals(this.effects, other.effects) - && this.horizontalSpeedMultiplier == other.horizontalSpeedMultiplier - && this.runTime == other.runTime - && this.cancelOnItemChange == other.cancelOnItemChange - && Objects.equals(this.settings, other.settings) - && Objects.equals(this.rules, other.rules) - && Arrays.equals(this.tags, other.tags) - && Objects.equals(this.camera, other.camera) - && this.next == other.next - && this.failed == other.failed - && this.useLatestTarget == other.useLatestTarget - && Arrays.equals(this.refillFluids, other.refillFluids); - } - } - - @Override - public int hashCode() { - int result = 1; - result = 31 * result + Objects.hashCode(this.waitForDataFrom); - result = 31 * result + Objects.hashCode(this.effects); - result = 31 * result + Float.hashCode(this.horizontalSpeedMultiplier); - result = 31 * result + Float.hashCode(this.runTime); - result = 31 * result + Boolean.hashCode(this.cancelOnItemChange); - result = 31 * result + Objects.hashCode(this.settings); - result = 31 * result + Objects.hashCode(this.rules); - result = 31 * result + Arrays.hashCode(this.tags); - result = 31 * result + Objects.hashCode(this.camera); - result = 31 * result + Integer.hashCode(this.next); - result = 31 * result + Integer.hashCode(this.failed); - result = 31 * result + Boolean.hashCode(this.useLatestTarget); - return 31 * result + Arrays.hashCode(this.refillFluids); - } -} diff --git a/src/com/hypixel/hytale/protocol/Selector.java b/src/com/hypixel/hytale/protocol/Selector.java index a6b1075..bf90586 100644 --- a/src/com/hypixel/hytale/protocol/Selector.java +++ b/src/com/hypixel/hytale/protocol/Selector.java @@ -9,9 +9,6 @@ import javax.annotation.Nonnull; public abstract class Selector { public static final int MAX_SIZE = 42; - public Selector() { - } - @Nonnull public static Selector deserialize(@Nonnull ByteBuf buf, int offset) { int typeId = VarInt.peek(buf, offset); diff --git a/src/com/hypixel/hytale/protocol/Trail.java b/src/com/hypixel/hytale/protocol/Trail.java index a60a804..5e4afda 100644 --- a/src/com/hypixel/hytale/protocol/Trail.java +++ b/src/com/hypixel/hytale/protocol/Trail.java @@ -92,31 +92,31 @@ public class Trail { byte nullBits = buf.getByte(offset); obj.lifeSpan = buf.getIntLE(offset + 1); obj.roll = buf.getFloatLE(offset + 5); - if ((nullBits & 4) != 0) { + if ((nullBits & 1) != 0) { obj.start = Edge.deserialize(buf, offset + 9); } - if ((nullBits & 8) != 0) { + if ((nullBits & 2) != 0) { obj.end = Edge.deserialize(buf, offset + 18); } obj.lightInfluence = buf.getFloatLE(offset + 27); obj.renderMode = FXRenderMode.fromValue(buf.getByte(offset + 31)); - if ((nullBits & 16) != 0) { + if ((nullBits & 4) != 0) { obj.intersectionHighlight = IntersectionHighlight.deserialize(buf, offset + 32); } obj.smooth = buf.getByte(offset + 40) != 0; - if ((nullBits & 32) != 0) { + if ((nullBits & 8) != 0) { obj.frameSize = Vector2i.deserialize(buf, offset + 41); } - if ((nullBits & 64) != 0) { + if ((nullBits & 16) != 0) { obj.frameRange = Range.deserialize(buf, offset + 49); } obj.frameLifeSpan = buf.getIntLE(offset + 57); - if ((nullBits & 1) != 0) { + if ((nullBits & 32) != 0) { int varPos0 = offset + 69 + buf.getIntLE(offset + 61); int idLen = VarInt.peek(buf, varPos0); if (idLen < 0) { @@ -130,7 +130,7 @@ public class Trail { obj.id = PacketIO.readVarString(buf, varPos0, PacketIO.UTF8); } - if ((nullBits & 2) != 0) { + if ((nullBits & 64) != 0) { int varPos1 = offset + 69 + buf.getIntLE(offset + 65); int textureLen = VarInt.peek(buf, varPos1); if (textureLen < 0) { @@ -150,7 +150,7 @@ public class Trail { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 69; - if ((nullBits & 1) != 0) { + if ((nullBits & 32) != 0) { int fieldOffset0 = buf.getIntLE(offset + 61); int pos0 = offset + 69 + fieldOffset0; int sl = VarInt.peek(buf, pos0); @@ -160,7 +160,7 @@ public class Trail { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 64) != 0) { int fieldOffset1 = buf.getIntLE(offset + 65); int pos1 = offset + 69 + fieldOffset1; int sl = VarInt.peek(buf, pos1); @@ -176,31 +176,31 @@ public class Trail { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.id != null) { + if (this.start != null) { nullBits = (byte)(nullBits | 1); } - if (this.texture != null) { + if (this.end != null) { nullBits = (byte)(nullBits | 2); } - if (this.start != null) { + if (this.intersectionHighlight != null) { nullBits = (byte)(nullBits | 4); } - if (this.end != null) { + if (this.frameSize != null) { nullBits = (byte)(nullBits | 8); } - if (this.intersectionHighlight != null) { + if (this.frameRange != null) { nullBits = (byte)(nullBits | 16); } - if (this.frameSize != null) { + if (this.id != null) { nullBits = (byte)(nullBits | 32); } - if (this.frameRange != null) { + if (this.texture != null) { nullBits = (byte)(nullBits | 64); } @@ -279,7 +279,7 @@ public class Trail { return ValidationResult.error("Buffer too small: expected at least 69 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 32) != 0) { int idOffset = buffer.getIntLE(offset + 61); if (idOffset < 0) { return ValidationResult.error("Invalid offset for Id"); @@ -306,7 +306,7 @@ public class Trail { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 64) != 0) { int textureOffset = buffer.getIntLE(offset + 65); if (textureOffset < 0) { return ValidationResult.error("Invalid offset for Texture"); diff --git a/src/com/hypixel/hytale/protocol/Weather.java b/src/com/hypixel/hytale/protocol/Weather.java index c6ddb25..790a565 100644 --- a/src/com/hypixel/hytale/protocol/Weather.java +++ b/src/com/hypixel/hytale/protocol/Weather.java @@ -164,15 +164,15 @@ public class Weather { public static Weather deserialize(@Nonnull ByteBuf buf, int offset) { Weather obj = new Weather(); byte[] nullBits = PacketIO.readBytes(buf, offset, 4); - if ((nullBits[3] & 1) != 0) { + if ((nullBits[0] & 1) != 0) { obj.fog = NearFar.deserialize(buf, offset + 4); } - if ((nullBits[3] & 2) != 0) { + if ((nullBits[0] & 2) != 0) { obj.fogOptions = FogOptions.deserialize(buf, offset + 12); } - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 4) != 0) { int varPos0 = offset + 126 + buf.getIntLE(offset + 30); int idLen = VarInt.peek(buf, varPos0); if (idLen < 0) { @@ -186,7 +186,7 @@ public class Weather { obj.id = PacketIO.readVarString(buf, varPos0, PacketIO.UTF8); } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 8) != 0) { int varPos1 = offset + 126 + buf.getIntLE(offset + 34); int tagIndexesCount = VarInt.peek(buf, varPos1); if (tagIndexesCount < 0) { @@ -209,7 +209,7 @@ public class Weather { } } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 16) != 0) { int varPos2 = offset + 126 + buf.getIntLE(offset + 38); int starsLen = VarInt.peek(buf, varPos2); if (starsLen < 0) { @@ -223,7 +223,7 @@ public class Weather { obj.stars = PacketIO.readVarString(buf, varPos2, PacketIO.UTF8); } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[0] & 32) != 0) { int varPos3 = offset + 126 + buf.getIntLE(offset + 42); int moonsCount = VarInt.peek(buf, varPos3); if (moonsCount < 0) { @@ -259,7 +259,7 @@ public class Weather { } } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[0] & 64) != 0) { int varPos4 = offset + 126 + buf.getIntLE(offset + 46); int cloudsCount = VarInt.peek(buf, varPos4); if (cloudsCount < 0) { @@ -284,7 +284,7 @@ public class Weather { } } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[0] & 128) != 0) { int varPos5 = offset + 126 + buf.getIntLE(offset + 50); int sunlightDampingMultiplierCount = VarInt.peek(buf, varPos5); if (sunlightDampingMultiplierCount < 0) { @@ -310,7 +310,7 @@ public class Weather { } } - if ((nullBits[0] & 64) != 0) { + if ((nullBits[1] & 1) != 0) { int varPos6 = offset + 126 + buf.getIntLE(offset + 54); int sunlightColorsCount = VarInt.peek(buf, varPos6); if (sunlightColorsCount < 0) { @@ -336,7 +336,7 @@ public class Weather { } } - if ((nullBits[0] & 128) != 0) { + if ((nullBits[1] & 2) != 0) { int varPos7 = offset + 126 + buf.getIntLE(offset + 58); int skyTopColorsCount = VarInt.peek(buf, varPos7); if (skyTopColorsCount < 0) { @@ -362,7 +362,7 @@ public class Weather { } } - if ((nullBits[1] & 1) != 0) { + if ((nullBits[1] & 4) != 0) { int varPos8 = offset + 126 + buf.getIntLE(offset + 62); int skyBottomColorsCount = VarInt.peek(buf, varPos8); if (skyBottomColorsCount < 0) { @@ -388,7 +388,7 @@ public class Weather { } } - if ((nullBits[1] & 2) != 0) { + if ((nullBits[1] & 8) != 0) { int varPos9 = offset + 126 + buf.getIntLE(offset + 66); int skySunsetColorsCount = VarInt.peek(buf, varPos9); if (skySunsetColorsCount < 0) { @@ -414,7 +414,7 @@ public class Weather { } } - if ((nullBits[1] & 4) != 0) { + if ((nullBits[1] & 16) != 0) { int varPos10 = offset + 126 + buf.getIntLE(offset + 70); int sunColorsCount = VarInt.peek(buf, varPos10); if (sunColorsCount < 0) { @@ -440,7 +440,7 @@ public class Weather { } } - if ((nullBits[1] & 8) != 0) { + if ((nullBits[1] & 32) != 0) { int varPos11 = offset + 126 + buf.getIntLE(offset + 74); int sunScalesCount = VarInt.peek(buf, varPos11); if (sunScalesCount < 0) { @@ -466,7 +466,7 @@ public class Weather { } } - if ((nullBits[1] & 16) != 0) { + if ((nullBits[1] & 64) != 0) { int varPos12 = offset + 126 + buf.getIntLE(offset + 78); int sunGlowColorsCount = VarInt.peek(buf, varPos12); if (sunGlowColorsCount < 0) { @@ -492,7 +492,7 @@ public class Weather { } } - if ((nullBits[1] & 32) != 0) { + if ((nullBits[1] & 128) != 0) { int varPos13 = offset + 126 + buf.getIntLE(offset + 82); int moonColorsCount = VarInt.peek(buf, varPos13); if (moonColorsCount < 0) { @@ -518,7 +518,7 @@ public class Weather { } } - if ((nullBits[1] & 64) != 0) { + if ((nullBits[2] & 1) != 0) { int varPos14 = offset + 126 + buf.getIntLE(offset + 86); int moonScalesCount = VarInt.peek(buf, varPos14); if (moonScalesCount < 0) { @@ -544,7 +544,7 @@ public class Weather { } } - if ((nullBits[1] & 128) != 0) { + if ((nullBits[2] & 2) != 0) { int varPos15 = offset + 126 + buf.getIntLE(offset + 90); int moonGlowColorsCount = VarInt.peek(buf, varPos15); if (moonGlowColorsCount < 0) { @@ -570,7 +570,7 @@ public class Weather { } } - if ((nullBits[2] & 1) != 0) { + if ((nullBits[2] & 4) != 0) { int varPos16 = offset + 126 + buf.getIntLE(offset + 94); int fogColorsCount = VarInt.peek(buf, varPos16); if (fogColorsCount < 0) { @@ -596,7 +596,7 @@ public class Weather { } } - if ((nullBits[2] & 2) != 0) { + if ((nullBits[2] & 8) != 0) { int varPos17 = offset + 126 + buf.getIntLE(offset + 98); int fogHeightFalloffsCount = VarInt.peek(buf, varPos17); if (fogHeightFalloffsCount < 0) { @@ -622,7 +622,7 @@ public class Weather { } } - if ((nullBits[2] & 4) != 0) { + if ((nullBits[2] & 16) != 0) { int varPos18 = offset + 126 + buf.getIntLE(offset + 102); int fogDensitiesCount = VarInt.peek(buf, varPos18); if (fogDensitiesCount < 0) { @@ -648,7 +648,7 @@ public class Weather { } } - if ((nullBits[2] & 8) != 0) { + if ((nullBits[2] & 32) != 0) { int varPos19 = offset + 126 + buf.getIntLE(offset + 106); int screenEffectLen = VarInt.peek(buf, varPos19); if (screenEffectLen < 0) { @@ -662,7 +662,7 @@ public class Weather { obj.screenEffect = PacketIO.readVarString(buf, varPos19, PacketIO.UTF8); } - if ((nullBits[2] & 16) != 0) { + if ((nullBits[2] & 64) != 0) { int varPos20 = offset + 126 + buf.getIntLE(offset + 110); int screenEffectColorsCount = VarInt.peek(buf, varPos20); if (screenEffectColorsCount < 0) { @@ -688,7 +688,7 @@ public class Weather { } } - if ((nullBits[2] & 32) != 0) { + if ((nullBits[2] & 128) != 0) { int varPos21 = offset + 126 + buf.getIntLE(offset + 114); int colorFiltersCount = VarInt.peek(buf, varPos21); if (colorFiltersCount < 0) { @@ -714,7 +714,7 @@ public class Weather { } } - if ((nullBits[2] & 64) != 0) { + if ((nullBits[3] & 1) != 0) { int varPos22 = offset + 126 + buf.getIntLE(offset + 118); int waterTintsCount = VarInt.peek(buf, varPos22); if (waterTintsCount < 0) { @@ -740,7 +740,7 @@ public class Weather { } } - if ((nullBits[2] & 128) != 0) { + if ((nullBits[3] & 2) != 0) { int varPos23 = offset + 126 + buf.getIntLE(offset + 122); obj.particle = WeatherParticle.deserialize(buf, varPos23); } @@ -751,7 +751,7 @@ public class Weather { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte[] nullBits = PacketIO.readBytes(buf, offset, 4); int maxEnd = 126; - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 4) != 0) { int fieldOffset0 = buf.getIntLE(offset + 30); int pos0 = offset + 126 + fieldOffset0; int sl = VarInt.peek(buf, pos0); @@ -761,7 +761,7 @@ public class Weather { } } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 8) != 0) { int fieldOffset1 = buf.getIntLE(offset + 34); int pos1 = offset + 126 + fieldOffset1; int arrLen = VarInt.peek(buf, pos1); @@ -771,7 +771,7 @@ public class Weather { } } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 16) != 0) { int fieldOffset2 = buf.getIntLE(offset + 38); int pos2 = offset + 126 + fieldOffset2; int sl = VarInt.peek(buf, pos2); @@ -781,7 +781,7 @@ public class Weather { } } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[0] & 32) != 0) { int fieldOffset3 = buf.getIntLE(offset + 42); int pos3 = offset + 126 + fieldOffset3; int dictLen = VarInt.peek(buf, pos3); @@ -798,7 +798,7 @@ public class Weather { } } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[0] & 64) != 0) { int fieldOffset4 = buf.getIntLE(offset + 46); int pos4 = offset + 126 + fieldOffset4; int arrLen = VarInt.peek(buf, pos4); @@ -813,7 +813,7 @@ public class Weather { } } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[0] & 128) != 0) { int fieldOffset5 = buf.getIntLE(offset + 50); int pos5 = offset + 126 + fieldOffset5; int dictLen = VarInt.peek(buf, pos5); @@ -829,7 +829,7 @@ public class Weather { } } - if ((nullBits[0] & 64) != 0) { + if ((nullBits[1] & 1) != 0) { int fieldOffset6 = buf.getIntLE(offset + 54); int pos6 = offset + 126 + fieldOffset6; int dictLen = VarInt.peek(buf, pos6); @@ -845,7 +845,7 @@ public class Weather { } } - if ((nullBits[0] & 128) != 0) { + if ((nullBits[1] & 2) != 0) { int fieldOffset7 = buf.getIntLE(offset + 58); int pos7 = offset + 126 + fieldOffset7; int dictLen = VarInt.peek(buf, pos7); @@ -861,7 +861,7 @@ public class Weather { } } - if ((nullBits[1] & 1) != 0) { + if ((nullBits[1] & 4) != 0) { int fieldOffset8 = buf.getIntLE(offset + 62); int pos8 = offset + 126 + fieldOffset8; int dictLen = VarInt.peek(buf, pos8); @@ -877,7 +877,7 @@ public class Weather { } } - if ((nullBits[1] & 2) != 0) { + if ((nullBits[1] & 8) != 0) { int fieldOffset9 = buf.getIntLE(offset + 66); int pos9 = offset + 126 + fieldOffset9; int dictLen = VarInt.peek(buf, pos9); @@ -893,7 +893,7 @@ public class Weather { } } - if ((nullBits[1] & 4) != 0) { + if ((nullBits[1] & 16) != 0) { int fieldOffset10 = buf.getIntLE(offset + 70); int pos10 = offset + 126 + fieldOffset10; int dictLen = VarInt.peek(buf, pos10); @@ -909,7 +909,7 @@ public class Weather { } } - if ((nullBits[1] & 8) != 0) { + if ((nullBits[1] & 32) != 0) { int fieldOffset11 = buf.getIntLE(offset + 74); int pos11 = offset + 126 + fieldOffset11; int dictLen = VarInt.peek(buf, pos11); @@ -925,7 +925,7 @@ public class Weather { } } - if ((nullBits[1] & 16) != 0) { + if ((nullBits[1] & 64) != 0) { int fieldOffset12 = buf.getIntLE(offset + 78); int pos12 = offset + 126 + fieldOffset12; int dictLen = VarInt.peek(buf, pos12); @@ -941,7 +941,7 @@ public class Weather { } } - if ((nullBits[1] & 32) != 0) { + if ((nullBits[1] & 128) != 0) { int fieldOffset13 = buf.getIntLE(offset + 82); int pos13 = offset + 126 + fieldOffset13; int dictLen = VarInt.peek(buf, pos13); @@ -957,7 +957,7 @@ public class Weather { } } - if ((nullBits[1] & 64) != 0) { + if ((nullBits[2] & 1) != 0) { int fieldOffset14 = buf.getIntLE(offset + 86); int pos14 = offset + 126 + fieldOffset14; int dictLen = VarInt.peek(buf, pos14); @@ -973,7 +973,7 @@ public class Weather { } } - if ((nullBits[1] & 128) != 0) { + if ((nullBits[2] & 2) != 0) { int fieldOffset15 = buf.getIntLE(offset + 90); int pos15 = offset + 126 + fieldOffset15; int dictLen = VarInt.peek(buf, pos15); @@ -989,7 +989,7 @@ public class Weather { } } - if ((nullBits[2] & 1) != 0) { + if ((nullBits[2] & 4) != 0) { int fieldOffset16 = buf.getIntLE(offset + 94); int pos16 = offset + 126 + fieldOffset16; int dictLen = VarInt.peek(buf, pos16); @@ -1005,7 +1005,7 @@ public class Weather { } } - if ((nullBits[2] & 2) != 0) { + if ((nullBits[2] & 8) != 0) { int fieldOffset17 = buf.getIntLE(offset + 98); int pos17 = offset + 126 + fieldOffset17; int dictLen = VarInt.peek(buf, pos17); @@ -1021,7 +1021,7 @@ public class Weather { } } - if ((nullBits[2] & 4) != 0) { + if ((nullBits[2] & 16) != 0) { int fieldOffset18 = buf.getIntLE(offset + 102); int pos18 = offset + 126 + fieldOffset18; int dictLen = VarInt.peek(buf, pos18); @@ -1037,7 +1037,7 @@ public class Weather { } } - if ((nullBits[2] & 8) != 0) { + if ((nullBits[2] & 32) != 0) { int fieldOffset19 = buf.getIntLE(offset + 106); int pos19 = offset + 126 + fieldOffset19; int sl = VarInt.peek(buf, pos19); @@ -1047,7 +1047,7 @@ public class Weather { } } - if ((nullBits[2] & 16) != 0) { + if ((nullBits[2] & 64) != 0) { int fieldOffset20 = buf.getIntLE(offset + 110); int pos20 = offset + 126 + fieldOffset20; int dictLen = VarInt.peek(buf, pos20); @@ -1063,7 +1063,7 @@ public class Weather { } } - if ((nullBits[2] & 32) != 0) { + if ((nullBits[2] & 128) != 0) { int fieldOffset21 = buf.getIntLE(offset + 114); int pos21 = offset + 126 + fieldOffset21; int dictLen = VarInt.peek(buf, pos21); @@ -1079,7 +1079,7 @@ public class Weather { } } - if ((nullBits[2] & 64) != 0) { + if ((nullBits[3] & 1) != 0) { int fieldOffset22 = buf.getIntLE(offset + 118); int pos22 = offset + 126 + fieldOffset22; int dictLen = VarInt.peek(buf, pos22); @@ -1095,7 +1095,7 @@ public class Weather { } } - if ((nullBits[2] & 128) != 0) { + if ((nullBits[3] & 2) != 0) { int fieldOffset23 = buf.getIntLE(offset + 122); int pos23 = offset + 126 + fieldOffset23; pos23 += WeatherParticle.computeBytesConsumed(buf, pos23); @@ -1110,107 +1110,107 @@ public class Weather { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte[] nullBits = new byte[4]; - if (this.id != null) { + if (this.fog != null) { nullBits[0] = (byte)(nullBits[0] | 1); } - if (this.tagIndexes != null) { + if (this.fogOptions != null) { nullBits[0] = (byte)(nullBits[0] | 2); } - if (this.stars != null) { + if (this.id != null) { nullBits[0] = (byte)(nullBits[0] | 4); } - if (this.moons != null) { + if (this.tagIndexes != null) { nullBits[0] = (byte)(nullBits[0] | 8); } - if (this.clouds != null) { + if (this.stars != null) { nullBits[0] = (byte)(nullBits[0] | 16); } - if (this.sunlightDampingMultiplier != null) { + if (this.moons != null) { nullBits[0] = (byte)(nullBits[0] | 32); } - if (this.sunlightColors != null) { + if (this.clouds != null) { nullBits[0] = (byte)(nullBits[0] | 64); } - if (this.skyTopColors != null) { + if (this.sunlightDampingMultiplier != null) { nullBits[0] = (byte)(nullBits[0] | 128); } - if (this.skyBottomColors != null) { + if (this.sunlightColors != null) { nullBits[1] = (byte)(nullBits[1] | 1); } - if (this.skySunsetColors != null) { + if (this.skyTopColors != null) { nullBits[1] = (byte)(nullBits[1] | 2); } - if (this.sunColors != null) { + if (this.skyBottomColors != null) { nullBits[1] = (byte)(nullBits[1] | 4); } - if (this.sunScales != null) { + if (this.skySunsetColors != null) { nullBits[1] = (byte)(nullBits[1] | 8); } - if (this.sunGlowColors != null) { + if (this.sunColors != null) { nullBits[1] = (byte)(nullBits[1] | 16); } - if (this.moonColors != null) { + if (this.sunScales != null) { nullBits[1] = (byte)(nullBits[1] | 32); } - if (this.moonScales != null) { + if (this.sunGlowColors != null) { nullBits[1] = (byte)(nullBits[1] | 64); } - if (this.moonGlowColors != null) { + if (this.moonColors != null) { nullBits[1] = (byte)(nullBits[1] | 128); } - if (this.fogColors != null) { + if (this.moonScales != null) { nullBits[2] = (byte)(nullBits[2] | 1); } - if (this.fogHeightFalloffs != null) { + if (this.moonGlowColors != null) { nullBits[2] = (byte)(nullBits[2] | 2); } - if (this.fogDensities != null) { + if (this.fogColors != null) { nullBits[2] = (byte)(nullBits[2] | 4); } - if (this.screenEffect != null) { + if (this.fogHeightFalloffs != null) { nullBits[2] = (byte)(nullBits[2] | 8); } - if (this.screenEffectColors != null) { + if (this.fogDensities != null) { nullBits[2] = (byte)(nullBits[2] | 16); } - if (this.colorFilters != null) { + if (this.screenEffect != null) { nullBits[2] = (byte)(nullBits[2] | 32); } - if (this.waterTints != null) { + if (this.screenEffectColors != null) { nullBits[2] = (byte)(nullBits[2] | 64); } - if (this.particle != null) { + if (this.colorFilters != null) { nullBits[2] = (byte)(nullBits[2] | 128); } - if (this.fog != null) { + if (this.waterTints != null) { nullBits[3] = (byte)(nullBits[3] | 1); } - if (this.fogOptions != null) { + if (this.particle != null) { nullBits[3] = (byte)(nullBits[3] | 2); } @@ -1741,7 +1741,7 @@ public class Weather { return ValidationResult.error("Buffer too small: expected at least 126 bytes"); } else { byte[] nullBits = PacketIO.readBytes(buffer, offset, 4); - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 4) != 0) { int idOffset = buffer.getIntLE(offset + 30); if (idOffset < 0) { return ValidationResult.error("Invalid offset for Id"); @@ -1768,7 +1768,7 @@ public class Weather { } } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 8) != 0) { int tagIndexesOffset = buffer.getIntLE(offset + 34); if (tagIndexesOffset < 0) { return ValidationResult.error("Invalid offset for TagIndexes"); @@ -1795,7 +1795,7 @@ public class Weather { } } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 16) != 0) { int starsOffset = buffer.getIntLE(offset + 38); if (starsOffset < 0) { return ValidationResult.error("Invalid offset for Stars"); @@ -1822,7 +1822,7 @@ public class Weather { } } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[0] & 32) != 0) { int moonsOffset = buffer.getIntLE(offset + 42); if (moonsOffset < 0) { return ValidationResult.error("Invalid offset for Moons"); @@ -1867,7 +1867,7 @@ public class Weather { } } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[0] & 64) != 0) { int cloudsOffset = buffer.getIntLE(offset + 46); if (cloudsOffset < 0) { return ValidationResult.error("Invalid offset for Clouds"); @@ -1899,7 +1899,7 @@ public class Weather { } } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[0] & 128) != 0) { int sunlightDampingMultiplierOffset = buffer.getIntLE(offset + 50); if (sunlightDampingMultiplierOffset < 0) { return ValidationResult.error("Invalid offset for SunlightDampingMultiplier"); @@ -1934,7 +1934,7 @@ public class Weather { } } - if ((nullBits[0] & 64) != 0) { + if ((nullBits[1] & 1) != 0) { int sunlightColorsOffset = buffer.getIntLE(offset + 54); if (sunlightColorsOffset < 0) { return ValidationResult.error("Invalid offset for SunlightColors"); @@ -1966,7 +1966,7 @@ public class Weather { } } - if ((nullBits[0] & 128) != 0) { + if ((nullBits[1] & 2) != 0) { int skyTopColorsOffset = buffer.getIntLE(offset + 58); if (skyTopColorsOffset < 0) { return ValidationResult.error("Invalid offset for SkyTopColors"); @@ -1998,7 +1998,7 @@ public class Weather { } } - if ((nullBits[1] & 1) != 0) { + if ((nullBits[1] & 4) != 0) { int skyBottomColorsOffset = buffer.getIntLE(offset + 62); if (skyBottomColorsOffset < 0) { return ValidationResult.error("Invalid offset for SkyBottomColors"); @@ -2030,7 +2030,7 @@ public class Weather { } } - if ((nullBits[1] & 2) != 0) { + if ((nullBits[1] & 8) != 0) { int skySunsetColorsOffset = buffer.getIntLE(offset + 66); if (skySunsetColorsOffset < 0) { return ValidationResult.error("Invalid offset for SkySunsetColors"); @@ -2062,7 +2062,7 @@ public class Weather { } } - if ((nullBits[1] & 4) != 0) { + if ((nullBits[1] & 16) != 0) { int sunColorsOffset = buffer.getIntLE(offset + 70); if (sunColorsOffset < 0) { return ValidationResult.error("Invalid offset for SunColors"); @@ -2094,7 +2094,7 @@ public class Weather { } } - if ((nullBits[1] & 8) != 0) { + if ((nullBits[1] & 32) != 0) { int sunScalesOffset = buffer.getIntLE(offset + 74); if (sunScalesOffset < 0) { return ValidationResult.error("Invalid offset for SunScales"); @@ -2129,7 +2129,7 @@ public class Weather { } } - if ((nullBits[1] & 16) != 0) { + if ((nullBits[1] & 64) != 0) { int sunGlowColorsOffset = buffer.getIntLE(offset + 78); if (sunGlowColorsOffset < 0) { return ValidationResult.error("Invalid offset for SunGlowColors"); @@ -2161,7 +2161,7 @@ public class Weather { } } - if ((nullBits[1] & 32) != 0) { + if ((nullBits[1] & 128) != 0) { int moonColorsOffset = buffer.getIntLE(offset + 82); if (moonColorsOffset < 0) { return ValidationResult.error("Invalid offset for MoonColors"); @@ -2193,7 +2193,7 @@ public class Weather { } } - if ((nullBits[1] & 64) != 0) { + if ((nullBits[2] & 1) != 0) { int moonScalesOffset = buffer.getIntLE(offset + 86); if (moonScalesOffset < 0) { return ValidationResult.error("Invalid offset for MoonScales"); @@ -2228,7 +2228,7 @@ public class Weather { } } - if ((nullBits[1] & 128) != 0) { + if ((nullBits[2] & 2) != 0) { int moonGlowColorsOffset = buffer.getIntLE(offset + 90); if (moonGlowColorsOffset < 0) { return ValidationResult.error("Invalid offset for MoonGlowColors"); @@ -2260,7 +2260,7 @@ public class Weather { } } - if ((nullBits[2] & 1) != 0) { + if ((nullBits[2] & 4) != 0) { int fogColorsOffset = buffer.getIntLE(offset + 94); if (fogColorsOffset < 0) { return ValidationResult.error("Invalid offset for FogColors"); @@ -2292,7 +2292,7 @@ public class Weather { } } - if ((nullBits[2] & 2) != 0) { + if ((nullBits[2] & 8) != 0) { int fogHeightFalloffsOffset = buffer.getIntLE(offset + 98); if (fogHeightFalloffsOffset < 0) { return ValidationResult.error("Invalid offset for FogHeightFalloffs"); @@ -2327,7 +2327,7 @@ public class Weather { } } - if ((nullBits[2] & 4) != 0) { + if ((nullBits[2] & 16) != 0) { int fogDensitiesOffset = buffer.getIntLE(offset + 102); if (fogDensitiesOffset < 0) { return ValidationResult.error("Invalid offset for FogDensities"); @@ -2362,7 +2362,7 @@ public class Weather { } } - if ((nullBits[2] & 8) != 0) { + if ((nullBits[2] & 32) != 0) { int screenEffectOffset = buffer.getIntLE(offset + 106); if (screenEffectOffset < 0) { return ValidationResult.error("Invalid offset for ScreenEffect"); @@ -2389,7 +2389,7 @@ public class Weather { } } - if ((nullBits[2] & 16) != 0) { + if ((nullBits[2] & 64) != 0) { int screenEffectColorsOffset = buffer.getIntLE(offset + 110); if (screenEffectColorsOffset < 0) { return ValidationResult.error("Invalid offset for ScreenEffectColors"); @@ -2421,7 +2421,7 @@ public class Weather { } } - if ((nullBits[2] & 32) != 0) { + if ((nullBits[2] & 128) != 0) { int colorFiltersOffset = buffer.getIntLE(offset + 114); if (colorFiltersOffset < 0) { return ValidationResult.error("Invalid offset for ColorFilters"); @@ -2453,7 +2453,7 @@ public class Weather { } } - if ((nullBits[2] & 64) != 0) { + if ((nullBits[3] & 1) != 0) { int waterTintsOffset = buffer.getIntLE(offset + 118); if (waterTintsOffset < 0) { return ValidationResult.error("Invalid offset for WaterTints"); @@ -2485,7 +2485,7 @@ public class Weather { } } - if ((nullBits[2] & 128) != 0) { + if ((nullBits[3] & 2) != 0) { int particleOffset = buffer.getIntLE(offset + 122); if (particleOffset < 0) { return ValidationResult.error("Invalid offset for Particle"); diff --git a/src/com/hypixel/hytale/protocol/WeatherParticle.java b/src/com/hypixel/hytale/protocol/WeatherParticle.java index 703f65b..4ae56d4 100644 --- a/src/com/hypixel/hytale/protocol/WeatherParticle.java +++ b/src/com/hypixel/hytale/protocol/WeatherParticle.java @@ -46,7 +46,7 @@ public class WeatherParticle { public static WeatherParticle deserialize(@Nonnull ByteBuf buf, int offset) { WeatherParticle obj = new WeatherParticle(); byte nullBits = buf.getByte(offset); - if ((nullBits & 2) != 0) { + if ((nullBits & 1) != 0) { obj.color = Color.deserialize(buf, offset + 1); } @@ -54,7 +54,7 @@ public class WeatherParticle { obj.isOvergroundOnly = buf.getByte(offset + 8) != 0; obj.positionOffsetMultiplier = buf.getFloatLE(offset + 9); int pos = offset + 13; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int systemIdLen = VarInt.peek(buf, pos); if (systemIdLen < 0) { throw ProtocolException.negativeLength("SystemId", systemIdLen); @@ -75,7 +75,7 @@ public class WeatherParticle { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int pos = offset + 13; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int sl = VarInt.peek(buf, pos); pos += VarInt.length(buf, pos) + sl; } @@ -85,11 +85,11 @@ public class WeatherParticle { public void serialize(@Nonnull ByteBuf buf) { byte nullBits = 0; - if (this.systemId != null) { + if (this.color != null) { nullBits = (byte)(nullBits | 1); } - if (this.color != null) { + if (this.systemId != null) { nullBits = (byte)(nullBits | 2); } @@ -123,7 +123,7 @@ public class WeatherParticle { } else { byte nullBits = buffer.getByte(offset); int pos = offset + 13; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int systemIdLen = VarInt.peek(buffer, pos); if (systemIdLen < 0) { return ValidationResult.error("Invalid string length for SystemId"); diff --git a/src/com/hypixel/hytale/protocol/WieldingInteraction.java b/src/com/hypixel/hytale/protocol/WieldingInteraction.java index b22b08f..74e745e 100644 --- a/src/com/hypixel/hytale/protocol/WieldingInteraction.java +++ b/src/com/hypixel/hytale/protocol/WieldingInteraction.java @@ -116,21 +116,21 @@ public class WieldingInteraction extends ChargingInteraction { obj.failOnDamage = buf.getByte(offset + 19) != 0; obj.mouseSensitivityAdjustmentTarget = buf.getFloatLE(offset + 20); obj.mouseSensitivityAdjustmentDuration = buf.getFloatLE(offset + 24); - if ((nullBits[0] & 128) != 0) { + if ((nullBits[0] & 1) != 0) { obj.chargingDelay = ChargingDelay.deserialize(buf, offset + 28); } obj.hasModifiers = buf.getByte(offset + 48) != 0; - if ((nullBits[1] & 2) != 0) { + if ((nullBits[0] & 2) != 0) { obj.angledWielding = AngledWielding.deserialize(buf, offset + 49); } - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 4) != 0) { int varPos0 = offset + 90 + buf.getIntLE(offset + 58); obj.effects = InteractionEffects.deserialize(buf, varPos0); } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 8) != 0) { int varPos1 = offset + 90 + buf.getIntLE(offset + 62); int settingsCount = VarInt.peek(buf, varPos1); if (settingsCount < 0) { @@ -155,12 +155,12 @@ public class WieldingInteraction extends ChargingInteraction { } } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 16) != 0) { int varPos2 = offset + 90 + buf.getIntLE(offset + 66); obj.rules = InteractionRules.deserialize(buf, varPos2); } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[0] & 32) != 0) { int varPos3 = offset + 90 + buf.getIntLE(offset + 70); int tagsCount = VarInt.peek(buf, varPos3); if (tagsCount < 0) { @@ -183,12 +183,12 @@ public class WieldingInteraction extends ChargingInteraction { } } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[0] & 64) != 0) { int varPos4 = offset + 90 + buf.getIntLE(offset + 74); obj.camera = InteractionCameraSettings.deserialize(buf, varPos4); } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[0] & 128) != 0) { int varPos5 = offset + 90 + buf.getIntLE(offset + 78); int chargedNextCount = VarInt.peek(buf, varPos5); if (chargedNextCount < 0) { @@ -214,7 +214,7 @@ public class WieldingInteraction extends ChargingInteraction { } } - if ((nullBits[0] & 64) != 0) { + if ((nullBits[1] & 1) != 0) { int varPos6 = offset + 90 + buf.getIntLE(offset + 82); int forksCount = VarInt.peek(buf, varPos6); if (forksCount < 0) { @@ -239,7 +239,7 @@ public class WieldingInteraction extends ChargingInteraction { } } - if ((nullBits[1] & 1) != 0) { + if ((nullBits[1] & 2) != 0) { int varPos7 = offset + 90 + buf.getIntLE(offset + 86); obj.blockedEffects = DamageEffects.deserialize(buf, varPos7); } @@ -250,7 +250,7 @@ public class WieldingInteraction extends ChargingInteraction { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte[] nullBits = PacketIO.readBytes(buf, offset, 2); int maxEnd = 90; - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 4) != 0) { int fieldOffset0 = buf.getIntLE(offset + 58); int pos0 = offset + 90 + fieldOffset0; pos0 += InteractionEffects.computeBytesConsumed(buf, pos0); @@ -259,7 +259,7 @@ public class WieldingInteraction extends ChargingInteraction { } } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 8) != 0) { int fieldOffset1 = buf.getIntLE(offset + 62); int pos1 = offset + 90 + fieldOffset1; int dictLen = VarInt.peek(buf, pos1); @@ -274,7 +274,7 @@ public class WieldingInteraction extends ChargingInteraction { } } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 16) != 0) { int fieldOffset2 = buf.getIntLE(offset + 66); int pos2 = offset + 90 + fieldOffset2; pos2 += InteractionRules.computeBytesConsumed(buf, pos2); @@ -283,7 +283,7 @@ public class WieldingInteraction extends ChargingInteraction { } } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[0] & 32) != 0) { int fieldOffset3 = buf.getIntLE(offset + 70); int pos3 = offset + 90 + fieldOffset3; int arrLen = VarInt.peek(buf, pos3); @@ -293,7 +293,7 @@ public class WieldingInteraction extends ChargingInteraction { } } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[0] & 64) != 0) { int fieldOffset4 = buf.getIntLE(offset + 74); int pos4 = offset + 90 + fieldOffset4; pos4 += InteractionCameraSettings.computeBytesConsumed(buf, pos4); @@ -302,7 +302,7 @@ public class WieldingInteraction extends ChargingInteraction { } } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[0] & 128) != 0) { int fieldOffset5 = buf.getIntLE(offset + 78); int pos5 = offset + 90 + fieldOffset5; int dictLen = VarInt.peek(buf, pos5); @@ -318,7 +318,7 @@ public class WieldingInteraction extends ChargingInteraction { } } - if ((nullBits[0] & 64) != 0) { + if ((nullBits[1] & 1) != 0) { int fieldOffset6 = buf.getIntLE(offset + 82); int pos6 = offset + 90 + fieldOffset6; int dictLen = VarInt.peek(buf, pos6); @@ -333,7 +333,7 @@ public class WieldingInteraction extends ChargingInteraction { } } - if ((nullBits[1] & 1) != 0) { + if ((nullBits[1] & 2) != 0) { int fieldOffset7 = buf.getIntLE(offset + 86); int pos7 = offset + 90 + fieldOffset7; pos7 += DamageEffects.computeBytesConsumed(buf, pos7); @@ -349,43 +349,43 @@ public class WieldingInteraction extends ChargingInteraction { public int serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte[] nullBits = new byte[2]; - if (this.effects != null) { + if (this.chargingDelay != null) { nullBits[0] = (byte)(nullBits[0] | 1); } - if (this.settings != null) { + if (this.angledWielding != null) { nullBits[0] = (byte)(nullBits[0] | 2); } - if (this.rules != null) { + if (this.effects != null) { nullBits[0] = (byte)(nullBits[0] | 4); } - if (this.tags != null) { + if (this.settings != null) { nullBits[0] = (byte)(nullBits[0] | 8); } - if (this.camera != null) { + if (this.rules != null) { nullBits[0] = (byte)(nullBits[0] | 16); } - if (this.chargedNext != null) { + if (this.tags != null) { nullBits[0] = (byte)(nullBits[0] | 32); } - if (this.forks != null) { + if (this.camera != null) { nullBits[0] = (byte)(nullBits[0] | 64); } - if (this.chargingDelay != null) { + if (this.chargedNext != null) { nullBits[0] = (byte)(nullBits[0] | 128); } - if (this.blockedEffects != null) { + if (this.forks != null) { nullBits[1] = (byte)(nullBits[1] | 1); } - if (this.angledWielding != null) { + if (this.blockedEffects != null) { nullBits[1] = (byte)(nullBits[1] | 2); } @@ -568,7 +568,7 @@ public class WieldingInteraction extends ChargingInteraction { return ValidationResult.error("Buffer too small: expected at least 90 bytes"); } else { byte[] nullBits = PacketIO.readBytes(buffer, offset, 2); - if ((nullBits[0] & 1) != 0) { + if ((nullBits[0] & 4) != 0) { int effectsOffset = buffer.getIntLE(offset + 58); if (effectsOffset < 0) { return ValidationResult.error("Invalid offset for Effects"); @@ -587,7 +587,7 @@ public class WieldingInteraction extends ChargingInteraction { pos += InteractionEffects.computeBytesConsumed(buffer, pos); } - if ((nullBits[0] & 2) != 0) { + if ((nullBits[0] & 8) != 0) { int settingsOffset = buffer.getIntLE(offset + 62); if (settingsOffset < 0) { return ValidationResult.error("Invalid offset for Settings"); @@ -615,7 +615,7 @@ public class WieldingInteraction extends ChargingInteraction { } } - if ((nullBits[0] & 4) != 0) { + if ((nullBits[0] & 16) != 0) { int rulesOffset = buffer.getIntLE(offset + 66); if (rulesOffset < 0) { return ValidationResult.error("Invalid offset for Rules"); @@ -634,7 +634,7 @@ public class WieldingInteraction extends ChargingInteraction { posxx += InteractionRules.computeBytesConsumed(buffer, posxx); } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[0] & 32) != 0) { int tagsOffset = buffer.getIntLE(offset + 70); if (tagsOffset < 0) { return ValidationResult.error("Invalid offset for Tags"); @@ -661,7 +661,7 @@ public class WieldingInteraction extends ChargingInteraction { } } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[0] & 64) != 0) { int cameraOffset = buffer.getIntLE(offset + 74); if (cameraOffset < 0) { return ValidationResult.error("Invalid offset for Camera"); @@ -680,7 +680,7 @@ public class WieldingInteraction extends ChargingInteraction { posxxxx += InteractionCameraSettings.computeBytesConsumed(buffer, posxxxx); } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[0] & 128) != 0) { int chargedNextOffset = buffer.getIntLE(offset + 78); if (chargedNextOffset < 0) { return ValidationResult.error("Invalid offset for ChargedNext"); @@ -715,7 +715,7 @@ public class WieldingInteraction extends ChargingInteraction { } } - if ((nullBits[0] & 64) != 0) { + if ((nullBits[1] & 1) != 0) { int forksOffset = buffer.getIntLE(offset + 82); if (forksOffset < 0) { return ValidationResult.error("Invalid offset for Forks"); @@ -745,7 +745,7 @@ public class WieldingInteraction extends ChargingInteraction { } } - if ((nullBits[1] & 1) != 0) { + if ((nullBits[1] & 2) != 0) { int blockedEffectsOffset = buffer.getIntLE(offset + 86); if (blockedEffectsOffset < 0) { return ValidationResult.error("Invalid offset for BlockedEffects"); diff --git a/src/com/hypixel/hytale/protocol/WorldEnvironment.java b/src/com/hypixel/hytale/protocol/WorldEnvironment.java index 484f271..e3bda5a 100644 --- a/src/com/hypixel/hytale/protocol/WorldEnvironment.java +++ b/src/com/hypixel/hytale/protocol/WorldEnvironment.java @@ -49,11 +49,11 @@ public class WorldEnvironment { public static WorldEnvironment deserialize(@Nonnull ByteBuf buf, int offset) { WorldEnvironment obj = new WorldEnvironment(); byte nullBits = buf.getByte(offset); - if ((nullBits & 2) != 0) { + if ((nullBits & 1) != 0) { obj.waterTint = Color.deserialize(buf, offset + 1); } - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int varPos0 = offset + 16 + buf.getIntLE(offset + 4); int idLen = VarInt.peek(buf, varPos0); if (idLen < 0) { @@ -122,7 +122,7 @@ public class WorldEnvironment { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 16; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int fieldOffset0 = buf.getIntLE(offset + 4); int pos0 = offset + 16 + fieldOffset0; int sl = VarInt.peek(buf, pos0); @@ -164,11 +164,11 @@ public class WorldEnvironment { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.id != null) { + if (this.waterTint != null) { nullBits = (byte)(nullBits | 1); } - if (this.waterTint != null) { + if (this.id != null) { nullBits = (byte)(nullBits | 2); } @@ -261,7 +261,7 @@ public class WorldEnvironment { return ValidationResult.error("Buffer too small: expected at least 16 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int idOffset = buffer.getIntLE(offset + 4); if (idOffset < 0) { return ValidationResult.error("Invalid offset for Id"); diff --git a/src/com/hypixel/hytale/protocol/WorldParticle.java b/src/com/hypixel/hytale/protocol/WorldParticle.java index a9dfc24..bad44ca 100644 --- a/src/com/hypixel/hytale/protocol/WorldParticle.java +++ b/src/com/hypixel/hytale/protocol/WorldParticle.java @@ -49,20 +49,20 @@ public class WorldParticle { WorldParticle obj = new WorldParticle(); byte nullBits = buf.getByte(offset); obj.scale = buf.getFloatLE(offset + 1); - if ((nullBits & 2) != 0) { + if ((nullBits & 1) != 0) { obj.color = Color.deserialize(buf, offset + 5); } - if ((nullBits & 4) != 0) { + if ((nullBits & 2) != 0) { obj.positionOffset = Vector3f.deserialize(buf, offset + 8); } - if ((nullBits & 8) != 0) { + if ((nullBits & 4) != 0) { obj.rotationOffset = Direction.deserialize(buf, offset + 20); } int pos = offset + 32; - if ((nullBits & 1) != 0) { + if ((nullBits & 8) != 0) { int systemIdLen = VarInt.peek(buf, pos); if (systemIdLen < 0) { throw ProtocolException.negativeLength("SystemId", systemIdLen); @@ -83,7 +83,7 @@ public class WorldParticle { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int pos = offset + 32; - if ((nullBits & 1) != 0) { + if ((nullBits & 8) != 0) { int sl = VarInt.peek(buf, pos); pos += VarInt.length(buf, pos) + sl; } @@ -93,19 +93,19 @@ public class WorldParticle { public void serialize(@Nonnull ByteBuf buf) { byte nullBits = 0; - if (this.systemId != null) { + if (this.color != null) { nullBits = (byte)(nullBits | 1); } - if (this.color != null) { + if (this.positionOffset != null) { nullBits = (byte)(nullBits | 2); } - if (this.positionOffset != null) { + if (this.rotationOffset != null) { nullBits = (byte)(nullBits | 4); } - if (this.rotationOffset != null) { + if (this.systemId != null) { nullBits = (byte)(nullBits | 8); } @@ -149,7 +149,7 @@ public class WorldParticle { } else { byte nullBits = buffer.getByte(offset); int pos = offset + 32; - if ((nullBits & 1) != 0) { + if ((nullBits & 8) != 0) { int systemIdLen = VarInt.peek(buffer, pos); if (systemIdLen < 0) { return ValidationResult.error("Invalid string length for SystemId"); diff --git a/src/com/hypixel/hytale/protocol/io/NoopPacketStatsRecorder.java b/src/com/hypixel/hytale/protocol/io/NoopPacketStatsRecorder.java index 99b0c89..f9fab4a 100644 --- a/src/com/hypixel/hytale/protocol/io/NoopPacketStatsRecorder.java +++ b/src/com/hypixel/hytale/protocol/io/NoopPacketStatsRecorder.java @@ -124,9 +124,6 @@ final class NoopPacketStatsRecorder implements PacketStatsRecorder { } }; - NoopPacketStatsRecorder() { - } - @Override public void recordSend(int packetId, int uncompressedSize, int compressedSize) { } diff --git a/src/com/hypixel/hytale/protocol/io/netty/PacketDecoder.java b/src/com/hypixel/hytale/protocol/io/netty/PacketDecoder.java index 5fdd5cf..2f840ba 100644 --- a/src/com/hypixel/hytale/protocol/io/netty/PacketDecoder.java +++ b/src/com/hypixel/hytale/protocol/io/netty/PacketDecoder.java @@ -7,15 +7,70 @@ import com.hypixel.hytale.protocol.io.ProtocolException; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ByteToMessageDecoder; +import io.netty.handler.timeout.ReadTimeoutException; +import java.time.Duration; import java.util.List; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; import javax.annotation.Nonnull; public class PacketDecoder extends ByteToMessageDecoder { private static final int LENGTH_PREFIX_SIZE = 4; private static final int PACKET_ID_SIZE = 4; private static final int MIN_FRAME_SIZE = 8; + private static final long CHECK_INTERVAL_MS = 1000L; + private volatile long lastPacketTimeNanos; + private ScheduledFuture timeoutCheckFuture; - public PacketDecoder() { + @Override + public void handlerAdded(@Nonnull ChannelHandlerContext ctx) throws Exception { + if (ctx.channel().isActive()) { + this.initialize(ctx); + } + + super.handlerAdded(ctx); + } + + @Override + public void channelActive(@Nonnull ChannelHandlerContext ctx) throws Exception { + this.initialize(ctx); + super.channelActive(ctx); + } + + @Override + public void channelInactive(@Nonnull ChannelHandlerContext ctx) throws Exception { + this.cancelTimeoutCheck(); + super.channelInactive(ctx); + } + + private void initialize(@Nonnull ChannelHandlerContext ctx) { + if (this.timeoutCheckFuture == null) { + this.lastPacketTimeNanos = System.nanoTime(); + this.timeoutCheckFuture = ctx.executor().scheduleAtFixedRate(() -> this.checkTimeout(ctx), 1000L, 1000L, TimeUnit.MILLISECONDS); + } + } + + private void cancelTimeoutCheck() { + if (this.timeoutCheckFuture != null) { + this.timeoutCheckFuture.cancel(false); + this.timeoutCheckFuture = null; + } + } + + private void checkTimeout(@Nonnull ChannelHandlerContext ctx) { + if (!ctx.channel().isActive()) { + this.cancelTimeoutCheck(); + } else { + Duration timeout = ctx.channel().attr(ProtocolUtil.PACKET_TIMEOUT_KEY).get(); + if (timeout != null) { + long elapsedNanos = System.nanoTime() - this.lastPacketTimeNanos; + if (elapsedNanos >= timeout.toNanos()) { + this.cancelTimeoutCheck(); + ctx.fireExceptionCaught(ReadTimeoutException.INSTANCE); + ctx.close(); + } + } + } } @Override @@ -42,6 +97,7 @@ public class PacketDecoder extends ByteToMessageDecoder { try { out.add(PacketIO.readFramedPacketWithInfo(in, payloadLength, packetInfo, statsRecorder)); + this.lastPacketTimeNanos = System.nanoTime(); } catch (ProtocolException var9) { in.skipBytes(in.readableBytes()); ProtocolUtil.closeConnection(ctx.channel()); diff --git a/src/com/hypixel/hytale/protocol/io/netty/PacketEncoder.java b/src/com/hypixel/hytale/protocol/io/netty/PacketEncoder.java index 19a1e76..1512980 100644 --- a/src/com/hypixel/hytale/protocol/io/netty/PacketEncoder.java +++ b/src/com/hypixel/hytale/protocol/io/netty/PacketEncoder.java @@ -12,9 +12,6 @@ import javax.annotation.Nonnull; @Sharable public class PacketEncoder extends MessageToByteEncoder { - public PacketEncoder() { - } - protected void encode(@Nonnull ChannelHandlerContext ctx, @Nonnull Packet packet, @Nonnull ByteBuf out) { Class packetClass; if (packet instanceof CachedPacket cached) { diff --git a/src/com/hypixel/hytale/protocol/io/netty/ProtocolUtil.java b/src/com/hypixel/hytale/protocol/io/netty/ProtocolUtil.java index 64b6b6a..8d1db80 100644 --- a/src/com/hypixel/hytale/protocol/io/netty/ProtocolUtil.java +++ b/src/com/hypixel/hytale/protocol/io/netty/ProtocolUtil.java @@ -1,18 +1,26 @@ package com.hypixel.hytale.protocol.io.netty; +import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.handler.codec.quic.QuicChannel; import io.netty.handler.codec.quic.QuicTransportError; +import io.netty.util.AttributeKey; +import java.nio.charset.StandardCharsets; +import java.time.Duration; import javax.annotation.Nonnull; public final class ProtocolUtil { + public static final AttributeKey PACKET_TIMEOUT_KEY = AttributeKey.newInstance("PACKET_TIMEOUT"); public static final int APPLICATION_NO_ERROR = 0; public static final int APPLICATION_RATE_LIMITED = 1; public static final int APPLICATION_AUTH_FAILED = 2; public static final int APPLICATION_INVALID_VERSION = 3; + public static final int APPLICATION_TIMEOUT = 4; + public static final int APPLICATION_CLIENT_OUTDATED = 5; + public static final int APPLICATION_SERVER_OUTDATED = 6; public static final ChannelFutureListener CLOSE_ON_COMPLETE = ProtocolUtil::closeApplicationOnComplete; private ProtocolUtil() { @@ -51,6 +59,20 @@ public final class ProtocolUtil { } } + public static void closeApplicationConnection(@Nonnull Channel channel, int errorCode, @Nonnull String reason) { + ByteBuf reasonBuf = Unpooled.copiedBuffer(reason, StandardCharsets.UTF_8); + if (channel instanceof QuicChannel quicChannel) { + quicChannel.close(true, errorCode, reasonBuf); + } else { + if (channel.parent() instanceof QuicChannel quicChannel) { + quicChannel.close(true, errorCode, reasonBuf); + } else { + reasonBuf.release(); + channel.close(); + } + } + } + private static void closeApplicationOnComplete(ChannelFuture future) { closeApplicationConnection(future.channel()); } diff --git a/src/com/hypixel/hytale/protocol/packets/asseteditor/AssetEditorCreateAsset.java b/src/com/hypixel/hytale/protocol/packets/asseteditor/AssetEditorCreateAsset.java index 5f313f1..2f29509 100644 --- a/src/com/hypixel/hytale/protocol/packets/asseteditor/AssetEditorCreateAsset.java +++ b/src/com/hypixel/hytale/protocol/packets/asseteditor/AssetEditorCreateAsset.java @@ -60,16 +60,16 @@ public class AssetEditorCreateAsset implements Packet { AssetEditorCreateAsset obj = new AssetEditorCreateAsset(); byte nullBits = buf.getByte(offset); obj.token = buf.getIntLE(offset + 1); - if ((nullBits & 4) != 0) { + if ((nullBits & 1) != 0) { obj.rebuildCaches = AssetEditorRebuildCaches.deserialize(buf, offset + 5); } - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int varPos0 = offset + 22 + buf.getIntLE(offset + 10); obj.path = AssetPath.deserialize(buf, varPos0); } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int varPos1 = offset + 22 + buf.getIntLE(offset + 14); int dataCount = VarInt.peek(buf, varPos1); if (dataCount < 0) { @@ -112,7 +112,7 @@ public class AssetEditorCreateAsset implements Packet { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 22; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int fieldOffset0 = buf.getIntLE(offset + 10); int pos0 = offset + 22 + fieldOffset0; pos0 += AssetPath.computeBytesConsumed(buf, pos0); @@ -121,7 +121,7 @@ public class AssetEditorCreateAsset implements Packet { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int fieldOffset1 = buf.getIntLE(offset + 14); int pos1 = offset + 22 + fieldOffset1; int arrLen = VarInt.peek(buf, pos1); @@ -148,15 +148,15 @@ public class AssetEditorCreateAsset implements Packet { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.path != null) { + if (this.rebuildCaches != null) { nullBits = (byte)(nullBits | 1); } - if (this.data != null) { + if (this.path != null) { nullBits = (byte)(nullBits | 2); } - if (this.rebuildCaches != null) { + if (this.data != null) { nullBits = (byte)(nullBits | 4); } @@ -232,7 +232,7 @@ public class AssetEditorCreateAsset implements Packet { return ValidationResult.error("Buffer too small: expected at least 22 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int pathOffset = buffer.getIntLE(offset + 10); if (pathOffset < 0) { return ValidationResult.error("Invalid offset for Path"); @@ -251,7 +251,7 @@ public class AssetEditorCreateAsset implements Packet { pos += AssetPath.computeBytesConsumed(buffer, pos); } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int dataOffset = buffer.getIntLE(offset + 14); if (dataOffset < 0) { return ValidationResult.error("Invalid offset for Data"); diff --git a/src/com/hypixel/hytale/protocol/packets/asseteditor/AssetEditorExportAssetFinalize.java b/src/com/hypixel/hytale/protocol/packets/asseteditor/AssetEditorExportAssetFinalize.java index 2ee553a..ad8a787 100644 --- a/src/com/hypixel/hytale/protocol/packets/asseteditor/AssetEditorExportAssetFinalize.java +++ b/src/com/hypixel/hytale/protocol/packets/asseteditor/AssetEditorExportAssetFinalize.java @@ -14,9 +14,6 @@ public class AssetEditorExportAssetFinalize implements Packet { public static final int VARIABLE_BLOCK_START = 0; public static final int MAX_SIZE = 0; - public AssetEditorExportAssetFinalize() { - } - @Override public int getId() { return 345; diff --git a/src/com/hypixel/hytale/protocol/packets/asseteditor/AssetEditorFetchLastModifiedAssets.java b/src/com/hypixel/hytale/protocol/packets/asseteditor/AssetEditorFetchLastModifiedAssets.java index 3e44c76..e0b86b9 100644 --- a/src/com/hypixel/hytale/protocol/packets/asseteditor/AssetEditorFetchLastModifiedAssets.java +++ b/src/com/hypixel/hytale/protocol/packets/asseteditor/AssetEditorFetchLastModifiedAssets.java @@ -14,9 +14,6 @@ public class AssetEditorFetchLastModifiedAssets implements Packet { public static final int VARIABLE_BLOCK_START = 0; public static final int MAX_SIZE = 0; - public AssetEditorFetchLastModifiedAssets() { - } - @Override public int getId() { return 338; diff --git a/src/com/hypixel/hytale/protocol/packets/asseteditor/AssetEditorInitialize.java b/src/com/hypixel/hytale/protocol/packets/asseteditor/AssetEditorInitialize.java index de06b2b..3088491 100644 --- a/src/com/hypixel/hytale/protocol/packets/asseteditor/AssetEditorInitialize.java +++ b/src/com/hypixel/hytale/protocol/packets/asseteditor/AssetEditorInitialize.java @@ -14,9 +14,6 @@ public class AssetEditorInitialize implements Packet { public static final int VARIABLE_BLOCK_START = 0; public static final int MAX_SIZE = 0; - public AssetEditorInitialize() { - } - @Override public int getId() { return 302; diff --git a/src/com/hypixel/hytale/protocol/packets/asseteditor/AssetEditorUpdateModelPreview.java b/src/com/hypixel/hytale/protocol/packets/asseteditor/AssetEditorUpdateModelPreview.java index 4f3fb2c..2a2e388 100644 --- a/src/com/hypixel/hytale/protocol/packets/asseteditor/AssetEditorUpdateModelPreview.java +++ b/src/com/hypixel/hytale/protocol/packets/asseteditor/AssetEditorUpdateModelPreview.java @@ -54,21 +54,21 @@ public class AssetEditorUpdateModelPreview implements Packet { public static AssetEditorUpdateModelPreview deserialize(@Nonnull ByteBuf buf, int offset) { AssetEditorUpdateModelPreview obj = new AssetEditorUpdateModelPreview(); byte nullBits = buf.getByte(offset); - if ((nullBits & 8) != 0) { + if ((nullBits & 1) != 0) { obj.camera = AssetEditorPreviewCameraSettings.deserialize(buf, offset + 1); } - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int varPos0 = offset + 42 + buf.getIntLE(offset + 30); obj.assetPath = AssetPath.deserialize(buf, varPos0); } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int varPos1 = offset + 42 + buf.getIntLE(offset + 34); obj.model = Model.deserialize(buf, varPos1); } - if ((nullBits & 4) != 0) { + if ((nullBits & 8) != 0) { int varPos2 = offset + 42 + buf.getIntLE(offset + 38); obj.block = BlockType.deserialize(buf, varPos2); } @@ -79,7 +79,7 @@ public class AssetEditorUpdateModelPreview implements Packet { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 42; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int fieldOffset0 = buf.getIntLE(offset + 30); int pos0 = offset + 42 + fieldOffset0; pos0 += AssetPath.computeBytesConsumed(buf, pos0); @@ -88,7 +88,7 @@ public class AssetEditorUpdateModelPreview implements Packet { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int fieldOffset1 = buf.getIntLE(offset + 34); int pos1 = offset + 42 + fieldOffset1; pos1 += Model.computeBytesConsumed(buf, pos1); @@ -97,7 +97,7 @@ public class AssetEditorUpdateModelPreview implements Packet { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 8) != 0) { int fieldOffset2 = buf.getIntLE(offset + 38); int pos2 = offset + 42 + fieldOffset2; pos2 += BlockType.computeBytesConsumed(buf, pos2); @@ -113,19 +113,19 @@ public class AssetEditorUpdateModelPreview implements Packet { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.assetPath != null) { + if (this.camera != null) { nullBits = (byte)(nullBits | 1); } - if (this.model != null) { + if (this.assetPath != null) { nullBits = (byte)(nullBits | 2); } - if (this.block != null) { + if (this.model != null) { nullBits = (byte)(nullBits | 4); } - if (this.camera != null) { + if (this.block != null) { nullBits = (byte)(nullBits | 8); } @@ -188,7 +188,7 @@ public class AssetEditorUpdateModelPreview implements Packet { return ValidationResult.error("Buffer too small: expected at least 42 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int assetPathOffset = buffer.getIntLE(offset + 30); if (assetPathOffset < 0) { return ValidationResult.error("Invalid offset for AssetPath"); @@ -207,7 +207,7 @@ public class AssetEditorUpdateModelPreview implements Packet { pos += AssetPath.computeBytesConsumed(buffer, pos); } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int modelOffset = buffer.getIntLE(offset + 34); if (modelOffset < 0) { return ValidationResult.error("Invalid offset for Model"); @@ -226,7 +226,7 @@ public class AssetEditorUpdateModelPreview implements Packet { posx += Model.computeBytesConsumed(buffer, posx); } - if ((nullBits & 4) != 0) { + if ((nullBits & 8) != 0) { int blockOffset = buffer.getIntLE(offset + 38); if (blockOffset < 0) { return ValidationResult.error("Invalid offset for Block"); diff --git a/src/com/hypixel/hytale/protocol/packets/asseteditor/JsonUpdateCommand.java b/src/com/hypixel/hytale/protocol/packets/asseteditor/JsonUpdateCommand.java index 88bdd6a..a2310b6 100644 --- a/src/com/hypixel/hytale/protocol/packets/asseteditor/JsonUpdateCommand.java +++ b/src/com/hypixel/hytale/protocol/packets/asseteditor/JsonUpdateCommand.java @@ -62,11 +62,11 @@ public class JsonUpdateCommand { JsonUpdateCommand obj = new JsonUpdateCommand(); byte nullBits = buf.getByte(offset); obj.type = JsonUpdateType.fromValue(buf.getByte(offset + 1)); - if ((nullBits & 16) != 0) { + if ((nullBits & 1) != 0) { obj.rebuildCaches = AssetEditorRebuildCaches.deserialize(buf, offset + 2); } - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int varPos0 = offset + 23 + buf.getIntLE(offset + 7); int pathCount = VarInt.peek(buf, varPos0); if (pathCount < 0) { @@ -101,7 +101,7 @@ public class JsonUpdateCommand { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int varPos1 = offset + 23 + buf.getIntLE(offset + 11); int valueLen = VarInt.peek(buf, varPos1); if (valueLen < 0) { @@ -115,7 +115,7 @@ public class JsonUpdateCommand { obj.value = PacketIO.readVarString(buf, varPos1, PacketIO.UTF8); } - if ((nullBits & 4) != 0) { + if ((nullBits & 8) != 0) { int varPos2 = offset + 23 + buf.getIntLE(offset + 15); int previousValueLen = VarInt.peek(buf, varPos2); if (previousValueLen < 0) { @@ -129,7 +129,7 @@ public class JsonUpdateCommand { obj.previousValue = PacketIO.readVarString(buf, varPos2, PacketIO.UTF8); } - if ((nullBits & 8) != 0) { + if ((nullBits & 16) != 0) { int varPos3 = offset + 23 + buf.getIntLE(offset + 19); int firstCreatedPropertyCount = VarInt.peek(buf, varPos3); if (firstCreatedPropertyCount < 0) { @@ -170,7 +170,7 @@ public class JsonUpdateCommand { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 23; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int fieldOffset0 = buf.getIntLE(offset + 7); int pos0 = offset + 23 + fieldOffset0; int arrLen = VarInt.peek(buf, pos0); @@ -186,7 +186,7 @@ public class JsonUpdateCommand { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int fieldOffset1 = buf.getIntLE(offset + 11); int pos1 = offset + 23 + fieldOffset1; int sl = VarInt.peek(buf, pos1); @@ -196,7 +196,7 @@ public class JsonUpdateCommand { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 8) != 0) { int fieldOffset2 = buf.getIntLE(offset + 15); int pos2 = offset + 23 + fieldOffset2; int sl = VarInt.peek(buf, pos2); @@ -206,7 +206,7 @@ public class JsonUpdateCommand { } } - if ((nullBits & 8) != 0) { + if ((nullBits & 16) != 0) { int fieldOffset3 = buf.getIntLE(offset + 19); int pos3 = offset + 23 + fieldOffset3; int arrLen = VarInt.peek(buf, pos3); @@ -228,23 +228,23 @@ public class JsonUpdateCommand { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.path != null) { + if (this.rebuildCaches != null) { nullBits = (byte)(nullBits | 1); } - if (this.value != null) { + if (this.path != null) { nullBits = (byte)(nullBits | 2); } - if (this.previousValue != null) { + if (this.value != null) { nullBits = (byte)(nullBits | 4); } - if (this.firstCreatedProperty != null) { + if (this.previousValue != null) { nullBits = (byte)(nullBits | 8); } - if (this.rebuildCaches != null) { + if (this.firstCreatedProperty != null) { nullBits = (byte)(nullBits | 16); } @@ -348,7 +348,7 @@ public class JsonUpdateCommand { return ValidationResult.error("Buffer too small: expected at least 23 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int pathOffset = buffer.getIntLE(offset + 7); if (pathOffset < 0) { return ValidationResult.error("Invalid offset for Path"); @@ -384,7 +384,7 @@ public class JsonUpdateCommand { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int valueOffset = buffer.getIntLE(offset + 11); if (valueOffset < 0) { return ValidationResult.error("Invalid offset for Value"); @@ -411,7 +411,7 @@ public class JsonUpdateCommand { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 8) != 0) { int previousValueOffset = buffer.getIntLE(offset + 15); if (previousValueOffset < 0) { return ValidationResult.error("Invalid offset for PreviousValue"); @@ -438,7 +438,7 @@ public class JsonUpdateCommand { } } - if ((nullBits & 8) != 0) { + if ((nullBits & 16) != 0) { int firstCreatedPropertyOffset = buffer.getIntLE(offset + 19); if (firstCreatedPropertyOffset < 0) { return ValidationResult.error("Invalid offset for FirstCreatedProperty"); diff --git a/src/com/hypixel/hytale/protocol/packets/asseteditor/SchemaFile.java b/src/com/hypixel/hytale/protocol/packets/asseteditor/SchemaFile.java index 53c1304..b958384 100644 --- a/src/com/hypixel/hytale/protocol/packets/asseteditor/SchemaFile.java +++ b/src/com/hypixel/hytale/protocol/packets/asseteditor/SchemaFile.java @@ -14,7 +14,7 @@ public class SchemaFile { public static final int FIXED_BLOCK_SIZE = 1; public static final int VARIABLE_FIELD_COUNT = 1; public static final int VARIABLE_BLOCK_START = 1; - public static final int MAX_SIZE = 16384006; + public static final int MAX_SIZE = 67108866; @Nullable public String content; @@ -40,8 +40,8 @@ public class SchemaFile { throw ProtocolException.negativeLength("Content", contentLen); } - if (contentLen > 4096000) { - throw ProtocolException.stringTooLong("Content", contentLen, 4096000); + if (contentLen > 16777215) { + throw ProtocolException.stringTooLong("Content", contentLen, 16777215); } int contentVarLen = VarInt.length(buf, pos); @@ -71,7 +71,7 @@ public class SchemaFile { buf.writeByte(nullBits); if (this.content != null) { - PacketIO.writeVarString(buf, this.content, 4096000); + PacketIO.writeVarString(buf, this.content, 16777215); } } @@ -96,8 +96,8 @@ public class SchemaFile { return ValidationResult.error("Invalid string length for Content"); } - if (contentLen > 4096000) { - return ValidationResult.error("Content exceeds max length 4096000"); + if (contentLen > 16777215) { + return ValidationResult.error("Content exceeds max length 16777215"); } pos += VarInt.length(buffer, pos); diff --git a/src/com/hypixel/hytale/protocol/packets/auth/PasswordAccepted.java b/src/com/hypixel/hytale/protocol/packets/auth/PasswordAccepted.java index d35433a..e7acda8 100644 --- a/src/com/hypixel/hytale/protocol/packets/auth/PasswordAccepted.java +++ b/src/com/hypixel/hytale/protocol/packets/auth/PasswordAccepted.java @@ -14,9 +14,6 @@ public class PasswordAccepted implements Packet { public static final int VARIABLE_BLOCK_START = 0; public static final int MAX_SIZE = 0; - public PasswordAccepted() { - } - @Override public int getId() { return 16; diff --git a/src/com/hypixel/hytale/protocol/packets/buildertools/BuilderToolArg.java b/src/com/hypixel/hytale/protocol/packets/buildertools/BuilderToolArg.java index 6c33482..5ffc82a 100644 --- a/src/com/hypixel/hytale/protocol/packets/buildertools/BuilderToolArg.java +++ b/src/com/hypixel/hytale/protocol/packets/buildertools/BuilderToolArg.java @@ -106,33 +106,33 @@ public class BuilderToolArg { obj.intArg = BuilderToolIntArg.deserialize(buf, offset + 17); } - if ((nullBits[0] & 64) != 0) { + if ((nullBits[0] & 8) != 0) { obj.brushShapeArg = BuilderToolBrushShapeArg.deserialize(buf, offset + 29); } - if ((nullBits[0] & 128) != 0) { + if ((nullBits[0] & 16) != 0) { obj.brushOriginArg = BuilderToolBrushOriginArg.deserialize(buf, offset + 30); } - if ((nullBits[1] & 1) != 0) { + if ((nullBits[0] & 32) != 0) { obj.brushAxisArg = BuilderToolBrushAxisArg.deserialize(buf, offset + 31); } - if ((nullBits[1] & 2) != 0) { + if ((nullBits[0] & 64) != 0) { obj.rotationArg = BuilderToolRotationArg.deserialize(buf, offset + 32); } - if ((nullBits[0] & 8) != 0) { + if ((nullBits[0] & 128) != 0) { int varPos0 = offset + 49 + buf.getIntLE(offset + 33); obj.stringArg = BuilderToolStringArg.deserialize(buf, varPos0); } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[1] & 1) != 0) { int varPos1 = offset + 49 + buf.getIntLE(offset + 37); obj.blockArg = BuilderToolBlockArg.deserialize(buf, varPos1); } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[1] & 2) != 0) { int varPos2 = offset + 49 + buf.getIntLE(offset + 41); obj.maskArg = BuilderToolMaskArg.deserialize(buf, varPos2); } @@ -148,7 +148,7 @@ public class BuilderToolArg { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte[] nullBits = PacketIO.readBytes(buf, offset, 2); int maxEnd = 49; - if ((nullBits[0] & 8) != 0) { + if ((nullBits[0] & 128) != 0) { int fieldOffset0 = buf.getIntLE(offset + 33); int pos0 = offset + 49 + fieldOffset0; pos0 += BuilderToolStringArg.computeBytesConsumed(buf, pos0); @@ -157,7 +157,7 @@ public class BuilderToolArg { } } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[1] & 1) != 0) { int fieldOffset1 = buf.getIntLE(offset + 37); int pos1 = offset + 49 + fieldOffset1; pos1 += BuilderToolBlockArg.computeBytesConsumed(buf, pos1); @@ -166,7 +166,7 @@ public class BuilderToolArg { } } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[1] & 2) != 0) { int fieldOffset2 = buf.getIntLE(offset + 41); int pos2 = offset + 49 + fieldOffset2; pos2 += BuilderToolMaskArg.computeBytesConsumed(buf, pos2); @@ -202,31 +202,31 @@ public class BuilderToolArg { nullBits[0] = (byte)(nullBits[0] | 4); } - if (this.stringArg != null) { + if (this.brushShapeArg != null) { nullBits[0] = (byte)(nullBits[0] | 8); } - if (this.blockArg != null) { + if (this.brushOriginArg != null) { nullBits[0] = (byte)(nullBits[0] | 16); } - if (this.maskArg != null) { + if (this.brushAxisArg != null) { nullBits[0] = (byte)(nullBits[0] | 32); } - if (this.brushShapeArg != null) { + if (this.rotationArg != null) { nullBits[0] = (byte)(nullBits[0] | 64); } - if (this.brushOriginArg != null) { + if (this.stringArg != null) { nullBits[0] = (byte)(nullBits[0] | 128); } - if (this.brushAxisArg != null) { + if (this.blockArg != null) { nullBits[1] = (byte)(nullBits[1] | 1); } - if (this.rotationArg != null) { + if (this.maskArg != null) { nullBits[1] = (byte)(nullBits[1] | 2); } @@ -343,7 +343,7 @@ public class BuilderToolArg { return ValidationResult.error("Buffer too small: expected at least 49 bytes"); } else { byte[] nullBits = PacketIO.readBytes(buffer, offset, 2); - if ((nullBits[0] & 8) != 0) { + if ((nullBits[0] & 128) != 0) { int stringArgOffset = buffer.getIntLE(offset + 33); if (stringArgOffset < 0) { return ValidationResult.error("Invalid offset for StringArg"); @@ -362,7 +362,7 @@ public class BuilderToolArg { pos += BuilderToolStringArg.computeBytesConsumed(buffer, pos); } - if ((nullBits[0] & 16) != 0) { + if ((nullBits[1] & 1) != 0) { int blockArgOffset = buffer.getIntLE(offset + 37); if (blockArgOffset < 0) { return ValidationResult.error("Invalid offset for BlockArg"); @@ -381,7 +381,7 @@ public class BuilderToolArg { posx += BuilderToolBlockArg.computeBytesConsumed(buffer, posx); } - if ((nullBits[0] & 32) != 0) { + if ((nullBits[1] & 2) != 0) { int maskArgOffset = buffer.getIntLE(offset + 41); if (maskArgOffset < 0) { return ValidationResult.error("Invalid offset for MaskArg"); diff --git a/src/com/hypixel/hytale/protocol/packets/buildertools/BuilderToolBrushData.java b/src/com/hypixel/hytale/protocol/packets/buildertools/BuilderToolBrushData.java index 67a69ee..ac950c4 100644 --- a/src/com/hypixel/hytale/protocol/packets/buildertools/BuilderToolBrushData.java +++ b/src/com/hypixel/hytale/protocol/packets/buildertools/BuilderToolBrushData.java @@ -176,20 +176,20 @@ public class BuilderToolBrushData { obj.mirrorAxis = BuilderToolBrushAxisArg.deserialize(buf, offset + 45); } - if ((nullBits[2] & 8) != 0) { + if ((nullBits[1] & 4) != 0) { obj.useMaskCommands = BuilderToolBoolArg.deserialize(buf, offset + 46); } - if ((nullBits[2] & 16) != 0) { + if ((nullBits[1] & 8) != 0) { obj.invertMask = BuilderToolBoolArg.deserialize(buf, offset + 47); } - if ((nullBits[1] & 4) != 0) { + if ((nullBits[1] & 16) != 0) { int varPos0 = offset + 84 + buf.getIntLE(offset + 48); obj.material = BuilderToolBlockArg.deserialize(buf, varPos0); } - if ((nullBits[1] & 8) != 0) { + if ((nullBits[1] & 32) != 0) { int varPos1 = offset + 84 + buf.getIntLE(offset + 52); int favoriteMaterialsCount = VarInt.peek(buf, varPos1); if (favoriteMaterialsCount < 0) { @@ -214,37 +214,37 @@ public class BuilderToolBrushData { } } - if ((nullBits[1] & 16) != 0) { + if ((nullBits[1] & 64) != 0) { int varPos2 = offset + 84 + buf.getIntLE(offset + 56); obj.mask = BuilderToolMaskArg.deserialize(buf, varPos2); } - if ((nullBits[1] & 32) != 0) { + if ((nullBits[1] & 128) != 0) { int varPos3 = offset + 84 + buf.getIntLE(offset + 60); obj.maskAbove = BuilderToolMaskArg.deserialize(buf, varPos3); } - if ((nullBits[1] & 64) != 0) { + if ((nullBits[2] & 1) != 0) { int varPos4 = offset + 84 + buf.getIntLE(offset + 64); obj.maskNot = BuilderToolMaskArg.deserialize(buf, varPos4); } - if ((nullBits[1] & 128) != 0) { + if ((nullBits[2] & 2) != 0) { int varPos5 = offset + 84 + buf.getIntLE(offset + 68); obj.maskBelow = BuilderToolMaskArg.deserialize(buf, varPos5); } - if ((nullBits[2] & 1) != 0) { + if ((nullBits[2] & 4) != 0) { int varPos6 = offset + 84 + buf.getIntLE(offset + 72); obj.maskAdjacent = BuilderToolMaskArg.deserialize(buf, varPos6); } - if ((nullBits[2] & 2) != 0) { + if ((nullBits[2] & 8) != 0) { int varPos7 = offset + 84 + buf.getIntLE(offset + 76); obj.maskNeighbor = BuilderToolMaskArg.deserialize(buf, varPos7); } - if ((nullBits[2] & 4) != 0) { + if ((nullBits[2] & 16) != 0) { int varPos8 = offset + 84 + buf.getIntLE(offset + 80); int maskCommandsCount = VarInt.peek(buf, varPos8); if (maskCommandsCount < 0) { @@ -275,7 +275,7 @@ public class BuilderToolBrushData { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte[] nullBits = PacketIO.readBytes(buf, offset, 3); int maxEnd = 84; - if ((nullBits[1] & 4) != 0) { + if ((nullBits[1] & 16) != 0) { int fieldOffset0 = buf.getIntLE(offset + 48); int pos0 = offset + 84 + fieldOffset0; pos0 += BuilderToolBlockArg.computeBytesConsumed(buf, pos0); @@ -284,7 +284,7 @@ public class BuilderToolBrushData { } } - if ((nullBits[1] & 8) != 0) { + if ((nullBits[1] & 32) != 0) { int fieldOffset1 = buf.getIntLE(offset + 52); int pos1 = offset + 84 + fieldOffset1; int arrLen = VarInt.peek(buf, pos1); @@ -299,7 +299,7 @@ public class BuilderToolBrushData { } } - if ((nullBits[1] & 16) != 0) { + if ((nullBits[1] & 64) != 0) { int fieldOffset2 = buf.getIntLE(offset + 56); int pos2 = offset + 84 + fieldOffset2; pos2 += BuilderToolMaskArg.computeBytesConsumed(buf, pos2); @@ -308,7 +308,7 @@ public class BuilderToolBrushData { } } - if ((nullBits[1] & 32) != 0) { + if ((nullBits[1] & 128) != 0) { int fieldOffset3 = buf.getIntLE(offset + 60); int pos3 = offset + 84 + fieldOffset3; pos3 += BuilderToolMaskArg.computeBytesConsumed(buf, pos3); @@ -317,7 +317,7 @@ public class BuilderToolBrushData { } } - if ((nullBits[1] & 64) != 0) { + if ((nullBits[2] & 1) != 0) { int fieldOffset4 = buf.getIntLE(offset + 64); int pos4 = offset + 84 + fieldOffset4; pos4 += BuilderToolMaskArg.computeBytesConsumed(buf, pos4); @@ -326,7 +326,7 @@ public class BuilderToolBrushData { } } - if ((nullBits[1] & 128) != 0) { + if ((nullBits[2] & 2) != 0) { int fieldOffset5 = buf.getIntLE(offset + 68); int pos5 = offset + 84 + fieldOffset5; pos5 += BuilderToolMaskArg.computeBytesConsumed(buf, pos5); @@ -335,7 +335,7 @@ public class BuilderToolBrushData { } } - if ((nullBits[2] & 1) != 0) { + if ((nullBits[2] & 4) != 0) { int fieldOffset6 = buf.getIntLE(offset + 72); int pos6 = offset + 84 + fieldOffset6; pos6 += BuilderToolMaskArg.computeBytesConsumed(buf, pos6); @@ -344,7 +344,7 @@ public class BuilderToolBrushData { } } - if ((nullBits[2] & 2) != 0) { + if ((nullBits[2] & 8) != 0) { int fieldOffset7 = buf.getIntLE(offset + 76); int pos7 = offset + 84 + fieldOffset7; pos7 += BuilderToolMaskArg.computeBytesConsumed(buf, pos7); @@ -353,7 +353,7 @@ public class BuilderToolBrushData { } } - if ((nullBits[2] & 4) != 0) { + if ((nullBits[2] & 16) != 0) { int fieldOffset8 = buf.getIntLE(offset + 80); int pos8 = offset + 84 + fieldOffset8; int arrLen = VarInt.peek(buf, pos8); @@ -414,47 +414,47 @@ public class BuilderToolBrushData { nullBits[1] = (byte)(nullBits[1] | 2); } - if (this.material != null) { + if (this.useMaskCommands != null) { nullBits[1] = (byte)(nullBits[1] | 4); } - if (this.favoriteMaterials != null) { + if (this.invertMask != null) { nullBits[1] = (byte)(nullBits[1] | 8); } - if (this.mask != null) { + if (this.material != null) { nullBits[1] = (byte)(nullBits[1] | 16); } - if (this.maskAbove != null) { + if (this.favoriteMaterials != null) { nullBits[1] = (byte)(nullBits[1] | 32); } - if (this.maskNot != null) { + if (this.mask != null) { nullBits[1] = (byte)(nullBits[1] | 64); } - if (this.maskBelow != null) { + if (this.maskAbove != null) { nullBits[1] = (byte)(nullBits[1] | 128); } - if (this.maskAdjacent != null) { + if (this.maskNot != null) { nullBits[2] = (byte)(nullBits[2] | 1); } - if (this.maskNeighbor != null) { + if (this.maskBelow != null) { nullBits[2] = (byte)(nullBits[2] | 2); } - if (this.maskCommands != null) { + if (this.maskAdjacent != null) { nullBits[2] = (byte)(nullBits[2] | 4); } - if (this.useMaskCommands != null) { + if (this.maskNeighbor != null) { nullBits[2] = (byte)(nullBits[2] | 8); } - if (this.invertMask != null) { + if (this.maskCommands != null) { nullBits[2] = (byte)(nullBits[2] | 16); } @@ -688,7 +688,7 @@ public class BuilderToolBrushData { return ValidationResult.error("Buffer too small: expected at least 84 bytes"); } else { byte[] nullBits = PacketIO.readBytes(buffer, offset, 3); - if ((nullBits[1] & 4) != 0) { + if ((nullBits[1] & 16) != 0) { int materialOffset = buffer.getIntLE(offset + 48); if (materialOffset < 0) { return ValidationResult.error("Invalid offset for Material"); @@ -707,7 +707,7 @@ public class BuilderToolBrushData { pos += BuilderToolBlockArg.computeBytesConsumed(buffer, pos); } - if ((nullBits[1] & 8) != 0) { + if ((nullBits[1] & 32) != 0) { int favoriteMaterialsOffset = buffer.getIntLE(offset + 52); if (favoriteMaterialsOffset < 0) { return ValidationResult.error("Invalid offset for FavoriteMaterials"); @@ -739,7 +739,7 @@ public class BuilderToolBrushData { } } - if ((nullBits[1] & 16) != 0) { + if ((nullBits[1] & 64) != 0) { int maskOffset = buffer.getIntLE(offset + 56); if (maskOffset < 0) { return ValidationResult.error("Invalid offset for Mask"); @@ -758,7 +758,7 @@ public class BuilderToolBrushData { posxx += BuilderToolMaskArg.computeBytesConsumed(buffer, posxx); } - if ((nullBits[1] & 32) != 0) { + if ((nullBits[1] & 128) != 0) { int maskAboveOffset = buffer.getIntLE(offset + 60); if (maskAboveOffset < 0) { return ValidationResult.error("Invalid offset for MaskAbove"); @@ -777,7 +777,7 @@ public class BuilderToolBrushData { posxxx += BuilderToolMaskArg.computeBytesConsumed(buffer, posxxx); } - if ((nullBits[1] & 64) != 0) { + if ((nullBits[2] & 1) != 0) { int maskNotOffset = buffer.getIntLE(offset + 64); if (maskNotOffset < 0) { return ValidationResult.error("Invalid offset for MaskNot"); @@ -796,7 +796,7 @@ public class BuilderToolBrushData { posxxxx += BuilderToolMaskArg.computeBytesConsumed(buffer, posxxxx); } - if ((nullBits[1] & 128) != 0) { + if ((nullBits[2] & 2) != 0) { int maskBelowOffset = buffer.getIntLE(offset + 68); if (maskBelowOffset < 0) { return ValidationResult.error("Invalid offset for MaskBelow"); @@ -815,7 +815,7 @@ public class BuilderToolBrushData { posxxxxx += BuilderToolMaskArg.computeBytesConsumed(buffer, posxxxxx); } - if ((nullBits[2] & 1) != 0) { + if ((nullBits[2] & 4) != 0) { int maskAdjacentOffset = buffer.getIntLE(offset + 72); if (maskAdjacentOffset < 0) { return ValidationResult.error("Invalid offset for MaskAdjacent"); @@ -834,7 +834,7 @@ public class BuilderToolBrushData { posxxxxxx += BuilderToolMaskArg.computeBytesConsumed(buffer, posxxxxxx); } - if ((nullBits[2] & 2) != 0) { + if ((nullBits[2] & 8) != 0) { int maskNeighborOffset = buffer.getIntLE(offset + 76); if (maskNeighborOffset < 0) { return ValidationResult.error("Invalid offset for MaskNeighbor"); @@ -853,7 +853,7 @@ public class BuilderToolBrushData { posxxxxxxx += BuilderToolMaskArg.computeBytesConsumed(buffer, posxxxxxxx); } - if ((nullBits[2] & 4) != 0) { + if ((nullBits[2] & 16) != 0) { int maskCommandsOffset = buffer.getIntLE(offset + 80); if (maskCommandsOffset < 0) { return ValidationResult.error("Invalid offset for MaskCommands"); diff --git a/src/com/hypixel/hytale/protocol/packets/buildertools/BuilderToolHideAnchors.java b/src/com/hypixel/hytale/protocol/packets/buildertools/BuilderToolHideAnchors.java index bb34860..bd367b4 100644 --- a/src/com/hypixel/hytale/protocol/packets/buildertools/BuilderToolHideAnchors.java +++ b/src/com/hypixel/hytale/protocol/packets/buildertools/BuilderToolHideAnchors.java @@ -14,9 +14,6 @@ public class BuilderToolHideAnchors implements Packet { public static final int VARIABLE_BLOCK_START = 0; public static final int MAX_SIZE = 0; - public BuilderToolHideAnchors() { - } - @Override public int getId() { return 416; diff --git a/src/com/hypixel/hytale/protocol/packets/buildertools/BuilderToolSelectionToolAskForClipboard.java b/src/com/hypixel/hytale/protocol/packets/buildertools/BuilderToolSelectionToolAskForClipboard.java index 23c03b7..f5e139d 100644 --- a/src/com/hypixel/hytale/protocol/packets/buildertools/BuilderToolSelectionToolAskForClipboard.java +++ b/src/com/hypixel/hytale/protocol/packets/buildertools/BuilderToolSelectionToolAskForClipboard.java @@ -14,9 +14,6 @@ public class BuilderToolSelectionToolAskForClipboard implements Packet { public static final int VARIABLE_BLOCK_START = 0; public static final int MAX_SIZE = 0; - public BuilderToolSelectionToolAskForClipboard() { - } - @Override public int getId() { return 410; diff --git a/src/com/hypixel/hytale/protocol/packets/buildertools/BuilderToolSelectionTransform.java b/src/com/hypixel/hytale/protocol/packets/buildertools/BuilderToolSelectionTransform.java index 1746e93..4df45c4 100644 --- a/src/com/hypixel/hytale/protocol/packets/buildertools/BuilderToolSelectionTransform.java +++ b/src/com/hypixel/hytale/protocol/packets/buildertools/BuilderToolSelectionTransform.java @@ -77,27 +77,27 @@ public class BuilderToolSelectionTransform implements Packet { public static BuilderToolSelectionTransform deserialize(@Nonnull ByteBuf buf, int offset) { BuilderToolSelectionTransform obj = new BuilderToolSelectionTransform(); byte nullBits = buf.getByte(offset); - if ((nullBits & 2) != 0) { + if ((nullBits & 1) != 0) { obj.initialSelectionMin = BlockPosition.deserialize(buf, offset + 1); } - if ((nullBits & 4) != 0) { + if ((nullBits & 2) != 0) { obj.initialSelectionMax = BlockPosition.deserialize(buf, offset + 13); } - if ((nullBits & 8) != 0) { + if ((nullBits & 4) != 0) { obj.initialRotationOrigin = Vector3f.deserialize(buf, offset + 25); } obj.cutOriginal = buf.getByte(offset + 37) != 0; obj.applyTransformationToSelectionMinMax = buf.getByte(offset + 38) != 0; obj.isExitingTransformMode = buf.getByte(offset + 39) != 0; - if ((nullBits & 16) != 0) { + if ((nullBits & 8) != 0) { obj.initialPastePointForClipboardPaste = BlockPosition.deserialize(buf, offset + 40); } int pos = offset + 52; - if ((nullBits & 1) != 0) { + if ((nullBits & 16) != 0) { int transformationMatrixCount = VarInt.peek(buf, pos); if (transformationMatrixCount < 0) { throw ProtocolException.negativeLength("TransformationMatrix", transformationMatrixCount); @@ -130,7 +130,7 @@ public class BuilderToolSelectionTransform implements Packet { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int pos = offset + 52; - if ((nullBits & 1) != 0) { + if ((nullBits & 16) != 0) { int arrLen = VarInt.peek(buf, pos); pos += VarInt.length(buf, pos) + arrLen * 4; } @@ -141,23 +141,23 @@ public class BuilderToolSelectionTransform implements Packet { @Override public void serialize(@Nonnull ByteBuf buf) { byte nullBits = 0; - if (this.transformationMatrix != null) { + if (this.initialSelectionMin != null) { nullBits = (byte)(nullBits | 1); } - if (this.initialSelectionMin != null) { + if (this.initialSelectionMax != null) { nullBits = (byte)(nullBits | 2); } - if (this.initialSelectionMax != null) { + if (this.initialRotationOrigin != null) { nullBits = (byte)(nullBits | 4); } - if (this.initialRotationOrigin != null) { + if (this.initialPastePointForClipboardPaste != null) { nullBits = (byte)(nullBits | 8); } - if (this.initialPastePointForClipboardPaste != null) { + if (this.transformationMatrix != null) { nullBits = (byte)(nullBits | 16); } @@ -218,7 +218,7 @@ public class BuilderToolSelectionTransform implements Packet { } else { byte nullBits = buffer.getByte(offset); int pos = offset + 52; - if ((nullBits & 1) != 0) { + if ((nullBits & 16) != 0) { int transformationMatrixCount = VarInt.peek(buffer, pos); if (transformationMatrixCount < 0) { return ValidationResult.error("Invalid array count for TransformationMatrix"); diff --git a/src/com/hypixel/hytale/protocol/packets/buildertools/PrefabUnselectPrefab.java b/src/com/hypixel/hytale/protocol/packets/buildertools/PrefabUnselectPrefab.java index 781a8cb..c139346 100644 --- a/src/com/hypixel/hytale/protocol/packets/buildertools/PrefabUnselectPrefab.java +++ b/src/com/hypixel/hytale/protocol/packets/buildertools/PrefabUnselectPrefab.java @@ -14,9 +14,6 @@ public class PrefabUnselectPrefab implements Packet { public static final int VARIABLE_BLOCK_START = 0; public static final int MAX_SIZE = 0; - public PrefabUnselectPrefab() { - } - @Override public int getId() { return 417; diff --git a/src/com/hypixel/hytale/protocol/packets/connection/Connect.java b/src/com/hypixel/hytale/protocol/packets/connection/Connect.java index e7411f6..c561beb 100644 --- a/src/com/hypixel/hytale/protocol/packets/connection/Connect.java +++ b/src/com/hypixel/hytale/protocol/packets/connection/Connect.java @@ -17,23 +17,25 @@ public class Connect implements Packet { public static final int PACKET_ID = 0; public static final boolean IS_COMPRESSED = false; public static final int NULLABLE_BIT_FIELD_SIZE = 1; - public static final int FIXED_BLOCK_SIZE = 82; + public static final int FIXED_BLOCK_SIZE = 46; public static final int VARIABLE_FIELD_COUNT = 5; - public static final int VARIABLE_BLOCK_START = 102; - public static final int MAX_SIZE = 38161; + public static final int VARIABLE_BLOCK_START = 66; + public static final int MAX_SIZE = 38013; + public int protocolCrc; + public int protocolBuildNumber; @Nonnull - public String protocolHash = ""; + public String clientVersion = ""; @Nonnull public ClientType clientType = ClientType.Game; - @Nullable - public String language; - @Nullable - public String identityToken; @Nonnull public UUID uuid = new UUID(0L, 0L); @Nonnull public String username = ""; @Nullable + public String identityToken; + @Nonnull + public String language = ""; + @Nullable public byte[] referralData; @Nullable public HostAddress referralSource; @@ -47,32 +49,38 @@ public class Connect implements Packet { } public Connect( - @Nonnull String protocolHash, + int protocolCrc, + int protocolBuildNumber, + @Nonnull String clientVersion, @Nonnull ClientType clientType, - @Nullable String language, - @Nullable String identityToken, @Nonnull UUID uuid, @Nonnull String username, + @Nullable String identityToken, + @Nonnull String language, @Nullable byte[] referralData, @Nullable HostAddress referralSource ) { - this.protocolHash = protocolHash; + this.protocolCrc = protocolCrc; + this.protocolBuildNumber = protocolBuildNumber; + this.clientVersion = clientVersion; this.clientType = clientType; - this.language = language; - this.identityToken = identityToken; this.uuid = uuid; this.username = username; + this.identityToken = identityToken; + this.language = language; this.referralData = referralData; this.referralSource = referralSource; } public Connect(@Nonnull Connect other) { - this.protocolHash = other.protocolHash; + this.protocolCrc = other.protocolCrc; + this.protocolBuildNumber = other.protocolBuildNumber; + this.clientVersion = other.clientVersion; this.clientType = other.clientType; - this.language = other.language; - this.identityToken = other.identityToken; this.uuid = other.uuid; this.username = other.username; + this.identityToken = other.identityToken; + this.language = other.language; this.referralData = other.referralData; this.referralSource = other.referralSource; } @@ -81,124 +89,119 @@ public class Connect implements Packet { public static Connect deserialize(@Nonnull ByteBuf buf, int offset) { Connect obj = new Connect(); byte nullBits = buf.getByte(offset); - obj.protocolHash = PacketIO.readFixedAsciiString(buf, offset + 1, 64); - obj.clientType = ClientType.fromValue(buf.getByte(offset + 65)); - obj.uuid = PacketIO.readUUID(buf, offset + 66); - if ((nullBits & 1) != 0) { - int varPos0 = offset + 102 + buf.getIntLE(offset + 82); - int languageLen = VarInt.peek(buf, varPos0); - if (languageLen < 0) { - throw ProtocolException.negativeLength("Language", languageLen); - } - - if (languageLen > 128) { - throw ProtocolException.stringTooLong("Language", languageLen, 128); - } - - obj.language = PacketIO.readVarString(buf, varPos0, PacketIO.ASCII); - } - - if ((nullBits & 2) != 0) { - int varPos1 = offset + 102 + buf.getIntLE(offset + 86); - int identityTokenLen = VarInt.peek(buf, varPos1); - if (identityTokenLen < 0) { - throw ProtocolException.negativeLength("IdentityToken", identityTokenLen); - } - - if (identityTokenLen > 8192) { - throw ProtocolException.stringTooLong("IdentityToken", identityTokenLen, 8192); - } - - obj.identityToken = PacketIO.readVarString(buf, varPos1, PacketIO.UTF8); - } - - int varPos2 = offset + 102 + buf.getIntLE(offset + 90); - int usernameLen = VarInt.peek(buf, varPos2); + obj.protocolCrc = buf.getIntLE(offset + 1); + obj.protocolBuildNumber = buf.getIntLE(offset + 5); + obj.clientVersion = PacketIO.readFixedAsciiString(buf, offset + 9, 20); + obj.clientType = ClientType.fromValue(buf.getByte(offset + 29)); + obj.uuid = PacketIO.readUUID(buf, offset + 30); + int varPos0 = offset + 66 + buf.getIntLE(offset + 46); + int usernameLen = VarInt.peek(buf, varPos0); if (usernameLen < 0) { throw ProtocolException.negativeLength("Username", usernameLen); } else if (usernameLen > 16) { throw ProtocolException.stringTooLong("Username", usernameLen, 16); } else { - obj.username = PacketIO.readVarString(buf, varPos2, PacketIO.ASCII); - if ((nullBits & 4) != 0) { - varPos2 = offset + 102 + buf.getIntLE(offset + 94); - usernameLen = VarInt.peek(buf, varPos2); + obj.username = PacketIO.readVarString(buf, varPos0, PacketIO.ASCII); + if ((nullBits & 1) != 0) { + varPos0 = offset + 66 + buf.getIntLE(offset + 50); + usernameLen = VarInt.peek(buf, varPos0); if (usernameLen < 0) { - throw ProtocolException.negativeLength("ReferralData", usernameLen); + throw ProtocolException.negativeLength("IdentityToken", usernameLen); } - if (usernameLen > 4096) { - throw ProtocolException.arrayTooLong("ReferralData", usernameLen, 4096); + if (usernameLen > 8192) { + throw ProtocolException.stringTooLong("IdentityToken", usernameLen, 8192); } - int varIntLen = VarInt.length(buf, varPos2); - if (varPos2 + varIntLen + usernameLen * 1L > buf.readableBytes()) { - throw ProtocolException.bufferTooSmall("ReferralData", varPos2 + varIntLen + usernameLen * 1, buf.readableBytes()); - } - - obj.referralData = new byte[usernameLen]; - - for (int i = 0; i < usernameLen; i++) { - obj.referralData[i] = buf.getByte(varPos2 + varIntLen + i * 1); - } + obj.identityToken = PacketIO.readVarString(buf, varPos0, PacketIO.UTF8); } - if ((nullBits & 8) != 0) { - varPos2 = offset + 102 + buf.getIntLE(offset + 98); - obj.referralSource = HostAddress.deserialize(buf, varPos2); - } + varPos0 = offset + 66 + buf.getIntLE(offset + 54); + usernameLen = VarInt.peek(buf, varPos0); + if (usernameLen < 0) { + throw ProtocolException.negativeLength("Language", usernameLen); + } else if (usernameLen > 16) { + throw ProtocolException.stringTooLong("Language", usernameLen, 16); + } else { + obj.language = PacketIO.readVarString(buf, varPos0, PacketIO.ASCII); + if ((nullBits & 2) != 0) { + varPos0 = offset + 66 + buf.getIntLE(offset + 58); + usernameLen = VarInt.peek(buf, varPos0); + if (usernameLen < 0) { + throw ProtocolException.negativeLength("ReferralData", usernameLen); + } - return obj; + if (usernameLen > 4096) { + throw ProtocolException.arrayTooLong("ReferralData", usernameLen, 4096); + } + + int varIntLen = VarInt.length(buf, varPos0); + if (varPos0 + varIntLen + usernameLen * 1L > buf.readableBytes()) { + throw ProtocolException.bufferTooSmall("ReferralData", varPos0 + varIntLen + usernameLen * 1, buf.readableBytes()); + } + + obj.referralData = new byte[usernameLen]; + + for (int i = 0; i < usernameLen; i++) { + obj.referralData[i] = buf.getByte(varPos0 + varIntLen + i * 1); + } + } + + if ((nullBits & 4) != 0) { + varPos0 = offset + 66 + buf.getIntLE(offset + 62); + obj.referralSource = HostAddress.deserialize(buf, varPos0); + } + + return obj; + } } } public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); - int maxEnd = 102; + int maxEnd = 66; + int fieldOffset0 = buf.getIntLE(offset + 46); + int pos0 = offset + 66 + fieldOffset0; + int sl = VarInt.peek(buf, pos0); + pos0 += VarInt.length(buf, pos0) + sl; + if (pos0 - offset > maxEnd) { + maxEnd = pos0 - offset; + } + if ((nullBits & 1) != 0) { - int fieldOffset0 = buf.getIntLE(offset + 82); - int pos0 = offset + 102 + fieldOffset0; - int sl = VarInt.peek(buf, pos0); + fieldOffset0 = buf.getIntLE(offset + 50); + pos0 = offset + 66 + fieldOffset0; + sl = VarInt.peek(buf, pos0); pos0 += VarInt.length(buf, pos0) + sl; if (pos0 - offset > maxEnd) { maxEnd = pos0 - offset; } } - if ((nullBits & 2) != 0) { - int fieldOffset1 = buf.getIntLE(offset + 86); - int pos1 = offset + 102 + fieldOffset1; - int sl = VarInt.peek(buf, pos1); - pos1 += VarInt.length(buf, pos1) + sl; - if (pos1 - offset > maxEnd) { - maxEnd = pos1 - offset; - } + fieldOffset0 = buf.getIntLE(offset + 54); + pos0 = offset + 66 + fieldOffset0; + sl = VarInt.peek(buf, pos0); + pos0 += VarInt.length(buf, pos0) + sl; + if (pos0 - offset > maxEnd) { + maxEnd = pos0 - offset; } - int fieldOffset2 = buf.getIntLE(offset + 90); - int pos2 = offset + 102 + fieldOffset2; - int sl = VarInt.peek(buf, pos2); - pos2 += VarInt.length(buf, pos2) + sl; - if (pos2 - offset > maxEnd) { - maxEnd = pos2 - offset; + if ((nullBits & 2) != 0) { + fieldOffset0 = buf.getIntLE(offset + 58); + pos0 = offset + 66 + fieldOffset0; + sl = VarInt.peek(buf, pos0); + pos0 += VarInt.length(buf, pos0) + sl * 1; + if (pos0 - offset > maxEnd) { + maxEnd = pos0 - offset; + } } if ((nullBits & 4) != 0) { - fieldOffset2 = buf.getIntLE(offset + 94); - pos2 = offset + 102 + fieldOffset2; - sl = VarInt.peek(buf, pos2); - pos2 += VarInt.length(buf, pos2) + sl * 1; - if (pos2 - offset > maxEnd) { - maxEnd = pos2 - offset; - } - } - - if ((nullBits & 8) != 0) { - fieldOffset2 = buf.getIntLE(offset + 98); - pos2 = offset + 102 + fieldOffset2; - pos2 += HostAddress.computeBytesConsumed(buf, pos2); - if (pos2 - offset > maxEnd) { - maxEnd = pos2 - offset; + fieldOffset0 = buf.getIntLE(offset + 62); + pos0 = offset + 66 + fieldOffset0; + pos0 += HostAddress.computeBytesConsumed(buf, pos0); + if (pos0 - offset > maxEnd) { + maxEnd = pos0 - offset; } } @@ -209,44 +212,37 @@ public class Connect implements Packet { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.language != null) { + if (this.identityToken != null) { nullBits = (byte)(nullBits | 1); } - if (this.identityToken != null) { + if (this.referralData != null) { nullBits = (byte)(nullBits | 2); } - if (this.referralData != null) { + if (this.referralSource != null) { nullBits = (byte)(nullBits | 4); } - if (this.referralSource != null) { - nullBits = (byte)(nullBits | 8); - } - buf.writeByte(nullBits); - PacketIO.writeFixedAsciiString(buf, this.protocolHash, 64); + buf.writeIntLE(this.protocolCrc); + buf.writeIntLE(this.protocolBuildNumber); + PacketIO.writeFixedAsciiString(buf, this.clientVersion, 20); buf.writeByte(this.clientType.getValue()); PacketIO.writeUUID(buf, this.uuid); - int languageOffsetSlot = buf.writerIndex(); + int usernameOffsetSlot = buf.writerIndex(); buf.writeIntLE(0); int identityTokenOffsetSlot = buf.writerIndex(); buf.writeIntLE(0); - int usernameOffsetSlot = buf.writerIndex(); + int languageOffsetSlot = buf.writerIndex(); buf.writeIntLE(0); int referralDataOffsetSlot = buf.writerIndex(); buf.writeIntLE(0); int referralSourceOffsetSlot = buf.writerIndex(); buf.writeIntLE(0); int varBlockStart = buf.writerIndex(); - if (this.language != null) { - buf.setIntLE(languageOffsetSlot, buf.writerIndex() - varBlockStart); - PacketIO.writeVarAsciiString(buf, this.language, 128); - } else { - buf.setIntLE(languageOffsetSlot, -1); - } - + buf.setIntLE(usernameOffsetSlot, buf.writerIndex() - varBlockStart); + PacketIO.writeVarAsciiString(buf, this.username, 16); if (this.identityToken != null) { buf.setIntLE(identityTokenOffsetSlot, buf.writerIndex() - varBlockStart); PacketIO.writeVarString(buf, this.identityToken, 8192); @@ -254,8 +250,8 @@ public class Connect implements Packet { buf.setIntLE(identityTokenOffsetSlot, -1); } - buf.setIntLE(usernameOffsetSlot, buf.writerIndex() - varBlockStart); - PacketIO.writeVarAsciiString(buf, this.username, 16); + buf.setIntLE(languageOffsetSlot, buf.writerIndex() - varBlockStart); + PacketIO.writeVarAsciiString(buf, this.language, 16); if (this.referralData != null) { buf.setIntLE(referralDataOffsetSlot, buf.writerIndex() - varBlockStart); if (this.referralData.length > 4096) { @@ -281,16 +277,13 @@ public class Connect implements Packet { @Override public int computeSize() { - int size = 102; - if (this.language != null) { - size += VarInt.size(this.language.length()) + this.language.length(); - } - + int size = 66; + size += VarInt.size(this.username.length()) + this.username.length(); if (this.identityToken != null) { size += PacketIO.stringSize(this.identityToken); } - size += VarInt.size(this.username.length()) + this.username.length(); + size += VarInt.size(this.language.length()) + this.language.length(); if (this.referralData != null) { size += VarInt.size(this.referralData.length) + this.referralData.length * 1; } @@ -303,130 +296,126 @@ public class Connect implements Packet { } public static ValidationResult validateStructure(@Nonnull ByteBuf buffer, int offset) { - if (buffer.readableBytes() - offset < 102) { - return ValidationResult.error("Buffer too small: expected at least 102 bytes"); + if (buffer.readableBytes() - offset < 66) { + return ValidationResult.error("Buffer too small: expected at least 66 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { - int languageOffset = buffer.getIntLE(offset + 82); - if (languageOffset < 0) { - return ValidationResult.error("Invalid offset for Language"); - } - - int pos = offset + 102 + languageOffset; - if (pos >= buffer.writerIndex()) { - return ValidationResult.error("Offset out of bounds for Language"); - } - - int languageLen = VarInt.peek(buffer, pos); - if (languageLen < 0) { - return ValidationResult.error("Invalid string length for Language"); - } - - if (languageLen > 128) { - return ValidationResult.error("Language exceeds max length 128"); - } - - pos += VarInt.length(buffer, pos); - pos += languageLen; - if (pos > buffer.writerIndex()) { - return ValidationResult.error("Buffer overflow reading Language"); - } - } - - if ((nullBits & 2) != 0) { - int identityTokenOffset = buffer.getIntLE(offset + 86); - if (identityTokenOffset < 0) { - return ValidationResult.error("Invalid offset for IdentityToken"); - } - - int posx = offset + 102 + identityTokenOffset; - if (posx >= buffer.writerIndex()) { - return ValidationResult.error("Offset out of bounds for IdentityToken"); - } - - int identityTokenLen = VarInt.peek(buffer, posx); - if (identityTokenLen < 0) { - return ValidationResult.error("Invalid string length for IdentityToken"); - } - - if (identityTokenLen > 8192) { - return ValidationResult.error("IdentityToken exceeds max length 8192"); - } - - posx += VarInt.length(buffer, posx); - posx += identityTokenLen; - if (posx > buffer.writerIndex()) { - return ValidationResult.error("Buffer overflow reading IdentityToken"); - } - } - - int usernameOffset = buffer.getIntLE(offset + 90); + int usernameOffset = buffer.getIntLE(offset + 46); if (usernameOffset < 0) { return ValidationResult.error("Invalid offset for Username"); } else { - int posxx = offset + 102 + usernameOffset; - if (posxx >= buffer.writerIndex()) { + int pos = offset + 66 + usernameOffset; + if (pos >= buffer.writerIndex()) { return ValidationResult.error("Offset out of bounds for Username"); } else { - int usernameLen = VarInt.peek(buffer, posxx); + int usernameLen = VarInt.peek(buffer, pos); if (usernameLen < 0) { return ValidationResult.error("Invalid string length for Username"); } else if (usernameLen > 16) { return ValidationResult.error("Username exceeds max length 16"); } else { - posxx += VarInt.length(buffer, posxx); - posxx += usernameLen; - if (posxx > buffer.writerIndex()) { + pos += VarInt.length(buffer, pos); + pos += usernameLen; + if (pos > buffer.writerIndex()) { return ValidationResult.error("Buffer overflow reading Username"); } else { - if ((nullBits & 4) != 0) { - usernameOffset = buffer.getIntLE(offset + 94); + if ((nullBits & 1) != 0) { + usernameOffset = buffer.getIntLE(offset + 50); if (usernameOffset < 0) { - return ValidationResult.error("Invalid offset for ReferralData"); + return ValidationResult.error("Invalid offset for IdentityToken"); } - posxx = offset + 102 + usernameOffset; - if (posxx >= buffer.writerIndex()) { - return ValidationResult.error("Offset out of bounds for ReferralData"); + pos = offset + 66 + usernameOffset; + if (pos >= buffer.writerIndex()) { + return ValidationResult.error("Offset out of bounds for IdentityToken"); } - usernameLen = VarInt.peek(buffer, posxx); + usernameLen = VarInt.peek(buffer, pos); if (usernameLen < 0) { - return ValidationResult.error("Invalid array count for ReferralData"); + return ValidationResult.error("Invalid string length for IdentityToken"); } - if (usernameLen > 4096) { - return ValidationResult.error("ReferralData exceeds max length 4096"); + if (usernameLen > 8192) { + return ValidationResult.error("IdentityToken exceeds max length 8192"); } - posxx += VarInt.length(buffer, posxx); - posxx += usernameLen * 1; - if (posxx > buffer.writerIndex()) { - return ValidationResult.error("Buffer overflow reading ReferralData"); + pos += VarInt.length(buffer, pos); + pos += usernameLen; + if (pos > buffer.writerIndex()) { + return ValidationResult.error("Buffer overflow reading IdentityToken"); } } - if ((nullBits & 8) != 0) { - usernameOffset = buffer.getIntLE(offset + 98); - if (usernameOffset < 0) { - return ValidationResult.error("Invalid offset for ReferralSource"); - } + usernameOffset = buffer.getIntLE(offset + 54); + if (usernameOffset < 0) { + return ValidationResult.error("Invalid offset for Language"); + } else { + pos = offset + 66 + usernameOffset; + if (pos >= buffer.writerIndex()) { + return ValidationResult.error("Offset out of bounds for Language"); + } else { + usernameLen = VarInt.peek(buffer, pos); + if (usernameLen < 0) { + return ValidationResult.error("Invalid string length for Language"); + } else if (usernameLen > 16) { + return ValidationResult.error("Language exceeds max length 16"); + } else { + pos += VarInt.length(buffer, pos); + pos += usernameLen; + if (pos > buffer.writerIndex()) { + return ValidationResult.error("Buffer overflow reading Language"); + } else { + if ((nullBits & 2) != 0) { + usernameOffset = buffer.getIntLE(offset + 58); + if (usernameOffset < 0) { + return ValidationResult.error("Invalid offset for ReferralData"); + } - posxx = offset + 102 + usernameOffset; - if (posxx >= buffer.writerIndex()) { - return ValidationResult.error("Offset out of bounds for ReferralSource"); - } + pos = offset + 66 + usernameOffset; + if (pos >= buffer.writerIndex()) { + return ValidationResult.error("Offset out of bounds for ReferralData"); + } - ValidationResult referralSourceResult = HostAddress.validateStructure(buffer, posxx); - if (!referralSourceResult.isValid()) { - return ValidationResult.error("Invalid ReferralSource: " + referralSourceResult.error()); - } + usernameLen = VarInt.peek(buffer, pos); + if (usernameLen < 0) { + return ValidationResult.error("Invalid array count for ReferralData"); + } - posxx += HostAddress.computeBytesConsumed(buffer, posxx); + if (usernameLen > 4096) { + return ValidationResult.error("ReferralData exceeds max length 4096"); + } + + pos += VarInt.length(buffer, pos); + pos += usernameLen * 1; + if (pos > buffer.writerIndex()) { + return ValidationResult.error("Buffer overflow reading ReferralData"); + } + } + + if ((nullBits & 4) != 0) { + usernameOffset = buffer.getIntLE(offset + 62); + if (usernameOffset < 0) { + return ValidationResult.error("Invalid offset for ReferralSource"); + } + + pos = offset + 66 + usernameOffset; + if (pos >= buffer.writerIndex()) { + return ValidationResult.error("Offset out of bounds for ReferralSource"); + } + + ValidationResult referralSourceResult = HostAddress.validateStructure(buffer, pos); + if (!referralSourceResult.isValid()) { + return ValidationResult.error("Invalid ReferralSource: " + referralSourceResult.error()); + } + + pos += HostAddress.computeBytesConsumed(buffer, pos); + } + + return ValidationResult.OK; + } + } + } } - - return ValidationResult.OK; } } } @@ -436,12 +425,14 @@ public class Connect implements Packet { public Connect clone() { Connect copy = new Connect(); - copy.protocolHash = this.protocolHash; + copy.protocolCrc = this.protocolCrc; + copy.protocolBuildNumber = this.protocolBuildNumber; + copy.clientVersion = this.clientVersion; copy.clientType = this.clientType; - copy.language = this.language; - copy.identityToken = this.identityToken; copy.uuid = this.uuid; copy.username = this.username; + copy.identityToken = this.identityToken; + copy.language = this.language; copy.referralData = this.referralData != null ? Arrays.copyOf(this.referralData, this.referralData.length) : null; copy.referralSource = this.referralSource != null ? this.referralSource.clone() : null; return copy; @@ -454,12 +445,14 @@ public class Connect implements Packet { } else { return !(obj instanceof Connect other) ? false - : Objects.equals(this.protocolHash, other.protocolHash) + : this.protocolCrc == other.protocolCrc + && this.protocolBuildNumber == other.protocolBuildNumber + && Objects.equals(this.clientVersion, other.clientVersion) && Objects.equals(this.clientType, other.clientType) - && Objects.equals(this.language, other.language) - && Objects.equals(this.identityToken, other.identityToken) && Objects.equals(this.uuid, other.uuid) && Objects.equals(this.username, other.username) + && Objects.equals(this.identityToken, other.identityToken) + && Objects.equals(this.language, other.language) && Arrays.equals(this.referralData, other.referralData) && Objects.equals(this.referralSource, other.referralSource); } @@ -468,12 +461,14 @@ public class Connect implements Packet { @Override public int hashCode() { int result = 1; - result = 31 * result + Objects.hashCode(this.protocolHash); + result = 31 * result + Integer.hashCode(this.protocolCrc); + result = 31 * result + Integer.hashCode(this.protocolBuildNumber); + result = 31 * result + Objects.hashCode(this.clientVersion); result = 31 * result + Objects.hashCode(this.clientType); - result = 31 * result + Objects.hashCode(this.language); - result = 31 * result + Objects.hashCode(this.identityToken); result = 31 * result + Objects.hashCode(this.uuid); result = 31 * result + Objects.hashCode(this.username); + result = 31 * result + Objects.hashCode(this.identityToken); + result = 31 * result + Objects.hashCode(this.language); result = 31 * result + Arrays.hashCode(this.referralData); return 31 * result + Objects.hashCode(this.referralSource); } diff --git a/src/com/hypixel/hytale/protocol/packets/interaction/DismountNPC.java b/src/com/hypixel/hytale/protocol/packets/interaction/DismountNPC.java index 69a1775..eafb20d 100644 --- a/src/com/hypixel/hytale/protocol/packets/interaction/DismountNPC.java +++ b/src/com/hypixel/hytale/protocol/packets/interaction/DismountNPC.java @@ -14,9 +14,6 @@ public class DismountNPC implements Packet { public static final int VARIABLE_BLOCK_START = 0; public static final int MAX_SIZE = 0; - public DismountNPC() { - } - @Override public int getId() { return 294; diff --git a/src/com/hypixel/hytale/protocol/packets/interface_/ResetUserInterfaceState.java b/src/com/hypixel/hytale/protocol/packets/interface_/ResetUserInterfaceState.java index ccf1d40..88d8d41 100644 --- a/src/com/hypixel/hytale/protocol/packets/interface_/ResetUserInterfaceState.java +++ b/src/com/hypixel/hytale/protocol/packets/interface_/ResetUserInterfaceState.java @@ -14,9 +14,6 @@ public class ResetUserInterfaceState implements Packet { public static final int VARIABLE_BLOCK_START = 0; public static final int MAX_SIZE = 0; - public ResetUserInterfaceState() { - } - @Override public int getId() { return 231; diff --git a/src/com/hypixel/hytale/protocol/packets/interface_/ServerPlayerListPlayer.java b/src/com/hypixel/hytale/protocol/packets/interface_/ServerPlayerListPlayer.java index f40193d..9cc8dd5 100644 --- a/src/com/hypixel/hytale/protocol/packets/interface_/ServerPlayerListPlayer.java +++ b/src/com/hypixel/hytale/protocol/packets/interface_/ServerPlayerListPlayer.java @@ -46,13 +46,13 @@ public class ServerPlayerListPlayer { ServerPlayerListPlayer obj = new ServerPlayerListPlayer(); byte nullBits = buf.getByte(offset); obj.uuid = PacketIO.readUUID(buf, offset + 1); - if ((nullBits & 2) != 0) { + if ((nullBits & 1) != 0) { obj.worldUuid = PacketIO.readUUID(buf, offset + 17); } obj.ping = buf.getIntLE(offset + 33); int pos = offset + 37; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int usernameLen = VarInt.peek(buf, pos); if (usernameLen < 0) { throw ProtocolException.negativeLength("Username", usernameLen); @@ -73,7 +73,7 @@ public class ServerPlayerListPlayer { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int pos = offset + 37; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int sl = VarInt.peek(buf, pos); pos += VarInt.length(buf, pos) + sl; } @@ -83,11 +83,11 @@ public class ServerPlayerListPlayer { public void serialize(@Nonnull ByteBuf buf) { byte nullBits = 0; - if (this.username != null) { + if (this.worldUuid != null) { nullBits = (byte)(nullBits | 1); } - if (this.worldUuid != null) { + if (this.username != null) { nullBits = (byte)(nullBits | 2); } @@ -120,7 +120,7 @@ public class ServerPlayerListPlayer { } else { byte nullBits = buffer.getByte(offset); int pos = offset + 37; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int usernameLen = VarInt.peek(buffer, pos); if (usernameLen < 0) { return ValidationResult.error("Invalid string length for Username"); diff --git a/src/com/hypixel/hytale/protocol/packets/player/ClearDebugShapes.java b/src/com/hypixel/hytale/protocol/packets/player/ClearDebugShapes.java index b05fd8c..dbec88f 100644 --- a/src/com/hypixel/hytale/protocol/packets/player/ClearDebugShapes.java +++ b/src/com/hypixel/hytale/protocol/packets/player/ClearDebugShapes.java @@ -14,9 +14,6 @@ public class ClearDebugShapes implements Packet { public static final int VARIABLE_BLOCK_START = 0; public static final int MAX_SIZE = 0; - public ClearDebugShapes() { - } - @Override public int getId() { return 115; diff --git a/src/com/hypixel/hytale/protocol/packets/player/DisplayDebug.java b/src/com/hypixel/hytale/protocol/packets/player/DisplayDebug.java index d875030..d9a943a 100644 --- a/src/com/hypixel/hytale/protocol/packets/player/DisplayDebug.java +++ b/src/com/hypixel/hytale/protocol/packets/player/DisplayDebug.java @@ -64,13 +64,13 @@ public class DisplayDebug implements Packet { DisplayDebug obj = new DisplayDebug(); byte nullBits = buf.getByte(offset); obj.shape = DebugShape.fromValue(buf.getByte(offset + 1)); - if ((nullBits & 2) != 0) { + if ((nullBits & 1) != 0) { obj.color = Vector3f.deserialize(buf, offset + 2); } obj.time = buf.getFloatLE(offset + 14); obj.fade = buf.getByte(offset + 18) != 0; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int varPos0 = offset + 27 + buf.getIntLE(offset + 19); int matrixCount = VarInt.peek(buf, varPos0); if (matrixCount < 0) { @@ -122,7 +122,7 @@ public class DisplayDebug implements Packet { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 27; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int fieldOffset0 = buf.getIntLE(offset + 19); int pos0 = offset + 27 + fieldOffset0; int arrLen = VarInt.peek(buf, pos0); @@ -149,11 +149,11 @@ public class DisplayDebug implements Packet { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.matrix != null) { + if (this.color != null) { nullBits = (byte)(nullBits | 1); } - if (this.color != null) { + if (this.matrix != null) { nullBits = (byte)(nullBits | 2); } @@ -226,7 +226,7 @@ public class DisplayDebug implements Packet { return ValidationResult.error("Buffer too small: expected at least 27 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int matrixOffset = buffer.getIntLE(offset + 19); if (matrixOffset < 0) { return ValidationResult.error("Invalid offset for Matrix"); diff --git a/src/com/hypixel/hytale/protocol/packets/player/MouseInteraction.java b/src/com/hypixel/hytale/protocol/packets/player/MouseInteraction.java index 78f2354..494452d 100644 --- a/src/com/hypixel/hytale/protocol/packets/player/MouseInteraction.java +++ b/src/com/hypixel/hytale/protocol/packets/player/MouseInteraction.java @@ -77,19 +77,19 @@ public class MouseInteraction implements Packet { byte nullBits = buf.getByte(offset); obj.clientTimestamp = buf.getLongLE(offset + 1); obj.activeSlot = buf.getIntLE(offset + 9); - if ((nullBits & 2) != 0) { + if ((nullBits & 1) != 0) { obj.screenPoint = Vector2f.deserialize(buf, offset + 13); } - if ((nullBits & 4) != 0) { + if ((nullBits & 2) != 0) { obj.mouseButton = MouseButtonEvent.deserialize(buf, offset + 21); } - if ((nullBits & 16) != 0) { + if ((nullBits & 4) != 0) { obj.worldInteraction = WorldInteraction.deserialize(buf, offset + 24); } - if ((nullBits & 1) != 0) { + if ((nullBits & 8) != 0) { int varPos0 = offset + 52 + buf.getIntLE(offset + 44); int itemInHandIdLen = VarInt.peek(buf, varPos0); if (itemInHandIdLen < 0) { @@ -103,7 +103,7 @@ public class MouseInteraction implements Packet { obj.itemInHandId = PacketIO.readVarString(buf, varPos0, PacketIO.UTF8); } - if ((nullBits & 8) != 0) { + if ((nullBits & 16) != 0) { int varPos1 = offset + 52 + buf.getIntLE(offset + 48); obj.mouseMotion = MouseMotionEvent.deserialize(buf, varPos1); } @@ -114,7 +114,7 @@ public class MouseInteraction implements Packet { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 52; - if ((nullBits & 1) != 0) { + if ((nullBits & 8) != 0) { int fieldOffset0 = buf.getIntLE(offset + 44); int pos0 = offset + 52 + fieldOffset0; int sl = VarInt.peek(buf, pos0); @@ -124,7 +124,7 @@ public class MouseInteraction implements Packet { } } - if ((nullBits & 8) != 0) { + if ((nullBits & 16) != 0) { int fieldOffset1 = buf.getIntLE(offset + 48); int pos1 = offset + 52 + fieldOffset1; pos1 += MouseMotionEvent.computeBytesConsumed(buf, pos1); @@ -140,23 +140,23 @@ public class MouseInteraction implements Packet { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.itemInHandId != null) { + if (this.screenPoint != null) { nullBits = (byte)(nullBits | 1); } - if (this.screenPoint != null) { + if (this.mouseButton != null) { nullBits = (byte)(nullBits | 2); } - if (this.mouseButton != null) { + if (this.worldInteraction != null) { nullBits = (byte)(nullBits | 4); } - if (this.mouseMotion != null) { + if (this.itemInHandId != null) { nullBits = (byte)(nullBits | 8); } - if (this.worldInteraction != null) { + if (this.mouseMotion != null) { nullBits = (byte)(nullBits | 16); } @@ -220,7 +220,7 @@ public class MouseInteraction implements Packet { return ValidationResult.error("Buffer too small: expected at least 52 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 8) != 0) { int itemInHandIdOffset = buffer.getIntLE(offset + 44); if (itemInHandIdOffset < 0) { return ValidationResult.error("Invalid offset for ItemInHandId"); @@ -247,7 +247,7 @@ public class MouseInteraction implements Packet { } } - if ((nullBits & 8) != 0) { + if ((nullBits & 16) != 0) { int mouseMotionOffset = buffer.getIntLE(offset + 48); if (mouseMotionOffset < 0) { return ValidationResult.error("Invalid offset for MouseMotion"); diff --git a/src/com/hypixel/hytale/protocol/packets/player/SyncPlayerPreferences.java b/src/com/hypixel/hytale/protocol/packets/player/SyncPlayerPreferences.java index d0619ff..88fffd1 100644 --- a/src/com/hypixel/hytale/protocol/packets/player/SyncPlayerPreferences.java +++ b/src/com/hypixel/hytale/protocol/packets/player/SyncPlayerPreferences.java @@ -11,10 +11,10 @@ public class SyncPlayerPreferences implements Packet { public static final int PACKET_ID = 116; public static final boolean IS_COMPRESSED = false; public static final int NULLABLE_BIT_FIELD_SIZE = 0; - public static final int FIXED_BLOCK_SIZE = 8; + public static final int FIXED_BLOCK_SIZE = 12; public static final int VARIABLE_FIELD_COUNT = 0; - public static final int VARIABLE_BLOCK_START = 8; - public static final int MAX_SIZE = 8; + public static final int VARIABLE_BLOCK_START = 12; + public static final int MAX_SIZE = 12; public boolean showEntityMarkers; @Nonnull public PickupLocation armorItemsPreferredPickupLocation = PickupLocation.Hotbar; @@ -28,6 +28,10 @@ public class SyncPlayerPreferences implements Packet { public PickupLocation miscItemsPreferredPickupLocation = PickupLocation.Hotbar; public boolean allowNPCDetection; public boolean respondToHit; + public boolean hideHelmet; + public boolean hideCuirass; + public boolean hideGauntlets; + public boolean hidePants; @Override public int getId() { @@ -45,7 +49,11 @@ public class SyncPlayerPreferences implements Packet { @Nonnull PickupLocation solidBlockItemsPreferredPickupLocation, @Nonnull PickupLocation miscItemsPreferredPickupLocation, boolean allowNPCDetection, - boolean respondToHit + boolean respondToHit, + boolean hideHelmet, + boolean hideCuirass, + boolean hideGauntlets, + boolean hidePants ) { this.showEntityMarkers = showEntityMarkers; this.armorItemsPreferredPickupLocation = armorItemsPreferredPickupLocation; @@ -55,6 +63,10 @@ public class SyncPlayerPreferences implements Packet { this.miscItemsPreferredPickupLocation = miscItemsPreferredPickupLocation; this.allowNPCDetection = allowNPCDetection; this.respondToHit = respondToHit; + this.hideHelmet = hideHelmet; + this.hideCuirass = hideCuirass; + this.hideGauntlets = hideGauntlets; + this.hidePants = hidePants; } public SyncPlayerPreferences(@Nonnull SyncPlayerPreferences other) { @@ -66,6 +78,10 @@ public class SyncPlayerPreferences implements Packet { this.miscItemsPreferredPickupLocation = other.miscItemsPreferredPickupLocation; this.allowNPCDetection = other.allowNPCDetection; this.respondToHit = other.respondToHit; + this.hideHelmet = other.hideHelmet; + this.hideCuirass = other.hideCuirass; + this.hideGauntlets = other.hideGauntlets; + this.hidePants = other.hidePants; } @Nonnull @@ -79,11 +95,15 @@ public class SyncPlayerPreferences implements Packet { obj.miscItemsPreferredPickupLocation = PickupLocation.fromValue(buf.getByte(offset + 5)); obj.allowNPCDetection = buf.getByte(offset + 6) != 0; obj.respondToHit = buf.getByte(offset + 7) != 0; + obj.hideHelmet = buf.getByte(offset + 8) != 0; + obj.hideCuirass = buf.getByte(offset + 9) != 0; + obj.hideGauntlets = buf.getByte(offset + 10) != 0; + obj.hidePants = buf.getByte(offset + 11) != 0; return obj; } public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { - return 8; + return 12; } @Override @@ -96,15 +116,19 @@ public class SyncPlayerPreferences implements Packet { buf.writeByte(this.miscItemsPreferredPickupLocation.getValue()); buf.writeByte(this.allowNPCDetection ? 1 : 0); buf.writeByte(this.respondToHit ? 1 : 0); + buf.writeByte(this.hideHelmet ? 1 : 0); + buf.writeByte(this.hideCuirass ? 1 : 0); + buf.writeByte(this.hideGauntlets ? 1 : 0); + buf.writeByte(this.hidePants ? 1 : 0); } @Override public int computeSize() { - return 8; + return 12; } public static ValidationResult validateStructure(@Nonnull ByteBuf buffer, int offset) { - return buffer.readableBytes() - offset < 8 ? ValidationResult.error("Buffer too small: expected at least 8 bytes") : ValidationResult.OK; + return buffer.readableBytes() - offset < 12 ? ValidationResult.error("Buffer too small: expected at least 12 bytes") : ValidationResult.OK; } public SyncPlayerPreferences clone() { @@ -117,6 +141,10 @@ public class SyncPlayerPreferences implements Packet { copy.miscItemsPreferredPickupLocation = this.miscItemsPreferredPickupLocation; copy.allowNPCDetection = this.allowNPCDetection; copy.respondToHit = this.respondToHit; + copy.hideHelmet = this.hideHelmet; + copy.hideCuirass = this.hideCuirass; + copy.hideGauntlets = this.hideGauntlets; + copy.hidePants = this.hidePants; return copy; } @@ -134,7 +162,11 @@ public class SyncPlayerPreferences implements Packet { && Objects.equals(this.solidBlockItemsPreferredPickupLocation, other.solidBlockItemsPreferredPickupLocation) && Objects.equals(this.miscItemsPreferredPickupLocation, other.miscItemsPreferredPickupLocation) && this.allowNPCDetection == other.allowNPCDetection - && this.respondToHit == other.respondToHit; + && this.respondToHit == other.respondToHit + && this.hideHelmet == other.hideHelmet + && this.hideCuirass == other.hideCuirass + && this.hideGauntlets == other.hideGauntlets + && this.hidePants == other.hidePants; } } @@ -148,7 +180,11 @@ public class SyncPlayerPreferences implements Packet { this.solidBlockItemsPreferredPickupLocation, this.miscItemsPreferredPickupLocation, this.allowNPCDetection, - this.respondToHit + this.respondToHit, + this.hideHelmet, + this.hideCuirass, + this.hideGauntlets, + this.hidePants ); } } diff --git a/src/com/hypixel/hytale/protocol/packets/setup/AssetFinalize.java b/src/com/hypixel/hytale/protocol/packets/setup/AssetFinalize.java index 084d6f9..b7ab6fc 100644 --- a/src/com/hypixel/hytale/protocol/packets/setup/AssetFinalize.java +++ b/src/com/hypixel/hytale/protocol/packets/setup/AssetFinalize.java @@ -14,9 +14,6 @@ public class AssetFinalize implements Packet { public static final int VARIABLE_BLOCK_START = 0; public static final int MAX_SIZE = 0; - public AssetFinalize() { - } - @Override public int getId() { return 26; diff --git a/src/com/hypixel/hytale/protocol/packets/setup/ClientFeature.java b/src/com/hypixel/hytale/protocol/packets/setup/ClientFeature.java index bd48869..c6f8f86 100644 --- a/src/com/hypixel/hytale/protocol/packets/setup/ClientFeature.java +++ b/src/com/hypixel/hytale/protocol/packets/setup/ClientFeature.java @@ -9,7 +9,11 @@ public enum ClientFeature { CrouchSlide(3), SafetyRoll(4), DisplayHealthBars(5), - DisplayCombatText(6); + DisplayCombatText(6), + CanHideHelmet(7), + CanHideCuirass(8), + CanHideGauntlets(9), + CanHidePants(10); public static final ClientFeature[] VALUES = values(); private final int value; diff --git a/src/com/hypixel/hytale/protocol/packets/setup/RequestCommonAssetsRebuild.java b/src/com/hypixel/hytale/protocol/packets/setup/RequestCommonAssetsRebuild.java index ad23429..1cf30bd 100644 --- a/src/com/hypixel/hytale/protocol/packets/setup/RequestCommonAssetsRebuild.java +++ b/src/com/hypixel/hytale/protocol/packets/setup/RequestCommonAssetsRebuild.java @@ -14,9 +14,6 @@ public class RequestCommonAssetsRebuild implements Packet { public static final int VARIABLE_BLOCK_START = 0; public static final int MAX_SIZE = 0; - public RequestCommonAssetsRebuild() { - } - @Override public int getId() { return 28; diff --git a/src/com/hypixel/hytale/protocol/packets/setup/WorldLoadFinished.java b/src/com/hypixel/hytale/protocol/packets/setup/WorldLoadFinished.java index efb18c9..4b66c09 100644 --- a/src/com/hypixel/hytale/protocol/packets/setup/WorldLoadFinished.java +++ b/src/com/hypixel/hytale/protocol/packets/setup/WorldLoadFinished.java @@ -14,9 +14,6 @@ public class WorldLoadFinished implements Packet { public static final int VARIABLE_BLOCK_START = 0; public static final int MAX_SIZE = 0; - public WorldLoadFinished() { - } - @Override public int getId() { return 22; diff --git a/src/com/hypixel/hytale/protocol/packets/window/CancelCraftingAction.java b/src/com/hypixel/hytale/protocol/packets/window/CancelCraftingAction.java index 28c1a65..b381108 100644 --- a/src/com/hypixel/hytale/protocol/packets/window/CancelCraftingAction.java +++ b/src/com/hypixel/hytale/protocol/packets/window/CancelCraftingAction.java @@ -11,9 +11,6 @@ public class CancelCraftingAction extends WindowAction { public static final int VARIABLE_BLOCK_START = 0; public static final int MAX_SIZE = 0; - public CancelCraftingAction() { - } - @Nonnull public static CancelCraftingAction deserialize(@Nonnull ByteBuf buf, int offset) { return new CancelCraftingAction(); diff --git a/src/com/hypixel/hytale/protocol/packets/window/CraftItemAction.java b/src/com/hypixel/hytale/protocol/packets/window/CraftItemAction.java index 657b5c3..379844b 100644 --- a/src/com/hypixel/hytale/protocol/packets/window/CraftItemAction.java +++ b/src/com/hypixel/hytale/protocol/packets/window/CraftItemAction.java @@ -11,9 +11,6 @@ public class CraftItemAction extends WindowAction { public static final int VARIABLE_BLOCK_START = 0; public static final int MAX_SIZE = 0; - public CraftItemAction() { - } - @Nonnull public static CraftItemAction deserialize(@Nonnull ByteBuf buf, int offset) { return new CraftItemAction(); diff --git a/src/com/hypixel/hytale/protocol/packets/window/TierUpgradeAction.java b/src/com/hypixel/hytale/protocol/packets/window/TierUpgradeAction.java index 3df1f56..3cce66f 100644 --- a/src/com/hypixel/hytale/protocol/packets/window/TierUpgradeAction.java +++ b/src/com/hypixel/hytale/protocol/packets/window/TierUpgradeAction.java @@ -11,9 +11,6 @@ public class TierUpgradeAction extends WindowAction { public static final int VARIABLE_BLOCK_START = 0; public static final int MAX_SIZE = 0; - public TierUpgradeAction() { - } - @Nonnull public static TierUpgradeAction deserialize(@Nonnull ByteBuf buf, int offset) { return new TierUpgradeAction(); diff --git a/src/com/hypixel/hytale/protocol/packets/window/WindowAction.java b/src/com/hypixel/hytale/protocol/packets/window/WindowAction.java index 8b9c3bc..db3cee8 100644 --- a/src/com/hypixel/hytale/protocol/packets/window/WindowAction.java +++ b/src/com/hypixel/hytale/protocol/packets/window/WindowAction.java @@ -9,9 +9,6 @@ import javax.annotation.Nonnull; public abstract class WindowAction { public static final int MAX_SIZE = 32768023; - public WindowAction() { - } - @Nonnull public static WindowAction deserialize(@Nonnull ByteBuf buf, int offset) { int typeId = VarInt.peek(buf, offset); diff --git a/src/com/hypixel/hytale/protocol/packets/world/ClearEditorTimeOverride.java b/src/com/hypixel/hytale/protocol/packets/world/ClearEditorTimeOverride.java index ae5b30b..98ed3ad 100644 --- a/src/com/hypixel/hytale/protocol/packets/world/ClearEditorTimeOverride.java +++ b/src/com/hypixel/hytale/protocol/packets/world/ClearEditorTimeOverride.java @@ -14,9 +14,6 @@ public class ClearEditorTimeOverride implements Packet { public static final int VARIABLE_BLOCK_START = 0; public static final int MAX_SIZE = 0; - public ClearEditorTimeOverride() { - } - @Override public int getId() { return 148; diff --git a/src/com/hypixel/hytale/protocol/packets/world/SpawnParticleSystem.java b/src/com/hypixel/hytale/protocol/packets/world/SpawnParticleSystem.java index 7f2430b..e870116 100644 --- a/src/com/hypixel/hytale/protocol/packets/world/SpawnParticleSystem.java +++ b/src/com/hypixel/hytale/protocol/packets/world/SpawnParticleSystem.java @@ -59,21 +59,21 @@ public class SpawnParticleSystem implements Packet { public static SpawnParticleSystem deserialize(@Nonnull ByteBuf buf, int offset) { SpawnParticleSystem obj = new SpawnParticleSystem(); byte nullBits = buf.getByte(offset); - if ((nullBits & 2) != 0) { + if ((nullBits & 1) != 0) { obj.position = Position.deserialize(buf, offset + 1); } - if ((nullBits & 4) != 0) { + if ((nullBits & 2) != 0) { obj.rotation = Direction.deserialize(buf, offset + 25); } obj.scale = buf.getFloatLE(offset + 37); - if ((nullBits & 8) != 0) { + if ((nullBits & 4) != 0) { obj.color = Color.deserialize(buf, offset + 41); } int pos = offset + 44; - if ((nullBits & 1) != 0) { + if ((nullBits & 8) != 0) { int particleSystemIdLen = VarInt.peek(buf, pos); if (particleSystemIdLen < 0) { throw ProtocolException.negativeLength("ParticleSystemId", particleSystemIdLen); @@ -94,7 +94,7 @@ public class SpawnParticleSystem implements Packet { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int pos = offset + 44; - if ((nullBits & 1) != 0) { + if ((nullBits & 8) != 0) { int sl = VarInt.peek(buf, pos); pos += VarInt.length(buf, pos) + sl; } @@ -105,19 +105,19 @@ public class SpawnParticleSystem implements Packet { @Override public void serialize(@Nonnull ByteBuf buf) { byte nullBits = 0; - if (this.particleSystemId != null) { + if (this.position != null) { nullBits = (byte)(nullBits | 1); } - if (this.position != null) { + if (this.rotation != null) { nullBits = (byte)(nullBits | 2); } - if (this.rotation != null) { + if (this.color != null) { nullBits = (byte)(nullBits | 4); } - if (this.color != null) { + if (this.particleSystemId != null) { nullBits = (byte)(nullBits | 8); } @@ -162,7 +162,7 @@ public class SpawnParticleSystem implements Packet { } else { byte nullBits = buffer.getByte(offset); int pos = offset + 44; - if ((nullBits & 1) != 0) { + if ((nullBits & 8) != 0) { int particleSystemIdLen = VarInt.peek(buffer, pos); if (particleSystemIdLen < 0) { return ValidationResult.error("Invalid string length for ParticleSystemId"); diff --git a/src/com/hypixel/hytale/protocol/packets/worldmap/ClearWorldMap.java b/src/com/hypixel/hytale/protocol/packets/worldmap/ClearWorldMap.java index 916016d..0151a2e 100644 --- a/src/com/hypixel/hytale/protocol/packets/worldmap/ClearWorldMap.java +++ b/src/com/hypixel/hytale/protocol/packets/worldmap/ClearWorldMap.java @@ -14,9 +14,6 @@ public class ClearWorldMap implements Packet { public static final int VARIABLE_BLOCK_START = 0; public static final int MAX_SIZE = 0; - public ClearWorldMap() { - } - @Override public int getId() { return 242; diff --git a/src/com/hypixel/hytale/protocol/packets/worldmap/MapMarker.java b/src/com/hypixel/hytale/protocol/packets/worldmap/MapMarker.java index 7b9abbc..2544b4f 100644 --- a/src/com/hypixel/hytale/protocol/packets/worldmap/MapMarker.java +++ b/src/com/hypixel/hytale/protocol/packets/worldmap/MapMarker.java @@ -53,11 +53,11 @@ public class MapMarker { public static MapMarker deserialize(@Nonnull ByteBuf buf, int offset) { MapMarker obj = new MapMarker(); byte nullBits = buf.getByte(offset); - if ((nullBits & 8) != 0) { + if ((nullBits & 1) != 0) { obj.transform = Transform.deserialize(buf, offset + 1); } - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int varPos0 = offset + 54 + buf.getIntLE(offset + 38); int idLen = VarInt.peek(buf, varPos0); if (idLen < 0) { @@ -71,7 +71,7 @@ public class MapMarker { obj.id = PacketIO.readVarString(buf, varPos0, PacketIO.UTF8); } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int varPos1 = offset + 54 + buf.getIntLE(offset + 42); int nameLen = VarInt.peek(buf, varPos1); if (nameLen < 0) { @@ -85,7 +85,7 @@ public class MapMarker { obj.name = PacketIO.readVarString(buf, varPos1, PacketIO.UTF8); } - if ((nullBits & 4) != 0) { + if ((nullBits & 8) != 0) { int varPos2 = offset + 54 + buf.getIntLE(offset + 46); int markerImageLen = VarInt.peek(buf, varPos2); if (markerImageLen < 0) { @@ -130,7 +130,7 @@ public class MapMarker { public static int computeBytesConsumed(@Nonnull ByteBuf buf, int offset) { byte nullBits = buf.getByte(offset); int maxEnd = 54; - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int fieldOffset0 = buf.getIntLE(offset + 38); int pos0 = offset + 54 + fieldOffset0; int sl = VarInt.peek(buf, pos0); @@ -140,7 +140,7 @@ public class MapMarker { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int fieldOffset1 = buf.getIntLE(offset + 42); int pos1 = offset + 54 + fieldOffset1; int sl = VarInt.peek(buf, pos1); @@ -150,7 +150,7 @@ public class MapMarker { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 8) != 0) { int fieldOffset2 = buf.getIntLE(offset + 46); int pos2 = offset + 54 + fieldOffset2; int sl = VarInt.peek(buf, pos2); @@ -181,19 +181,19 @@ public class MapMarker { public void serialize(@Nonnull ByteBuf buf) { int startPos = buf.writerIndex(); byte nullBits = 0; - if (this.id != null) { + if (this.transform != null) { nullBits = (byte)(nullBits | 1); } - if (this.name != null) { + if (this.id != null) { nullBits = (byte)(nullBits | 2); } - if (this.markerImage != null) { + if (this.name != null) { nullBits = (byte)(nullBits | 4); } - if (this.transform != null) { + if (this.markerImage != null) { nullBits = (byte)(nullBits | 8); } @@ -286,7 +286,7 @@ public class MapMarker { return ValidationResult.error("Buffer too small: expected at least 54 bytes"); } else { byte nullBits = buffer.getByte(offset); - if ((nullBits & 1) != 0) { + if ((nullBits & 2) != 0) { int idOffset = buffer.getIntLE(offset + 38); if (idOffset < 0) { return ValidationResult.error("Invalid offset for Id"); @@ -313,7 +313,7 @@ public class MapMarker { } } - if ((nullBits & 2) != 0) { + if ((nullBits & 4) != 0) { int nameOffset = buffer.getIntLE(offset + 42); if (nameOffset < 0) { return ValidationResult.error("Invalid offset for Name"); @@ -340,7 +340,7 @@ public class MapMarker { } } - if ((nullBits & 4) != 0) { + if ((nullBits & 8) != 0) { int markerImageOffset = buffer.getIntLE(offset + 46); if (markerImageOffset < 0) { return ValidationResult.error("Invalid offset for MarkerImage"); diff --git a/src/com/hypixel/hytale/server/core/Constants.java b/src/com/hypixel/hytale/server/core/Constants.java index 89b14a0..e47428d 100644 --- a/src/com/hypixel/hytale/server/core/Constants.java +++ b/src/com/hypixel/hytale/server/core/Constants.java @@ -34,6 +34,7 @@ import com.hypixel.hytale.server.core.permissions.PermissionsModule; import com.hypixel.hytale.server.core.universe.Universe; import com.hypixel.hytale.server.core.universe.world.connectedblocks.ConnectedBlocksModule; import com.hypixel.hytale.server.core.universe.world.meta.BlockStateModule; +import com.hypixel.hytale.server.core.update.UpdateModule; import java.nio.file.Files; import java.nio.file.Path; import javax.annotation.Nonnull; @@ -51,6 +52,7 @@ public final class Constants { public static final PluginManifest[] CORE_PLUGINS = new PluginManifest[]{ ConsoleModule.MANIFEST, PermissionsModule.MANIFEST, + UpdateModule.MANIFEST, FlyCameraModule.MANIFEST, AssetModule.MANIFEST, CommonAssetModule.MANIFEST, @@ -84,9 +86,6 @@ public final class Constants { ConnectedBlocksModule.MANIFEST }; - public Constants() { - } - public static void init() { } diff --git a/src/com/hypixel/hytale/server/core/HytaleServer.java b/src/com/hypixel/hytale/server/core/HytaleServer.java index f1566c3..5cafb93 100644 --- a/src/com/hypixel/hytale/server/core/HytaleServer.java +++ b/src/com/hypixel/hytale/server/core/HytaleServer.java @@ -1,5 +1,6 @@ package com.hypixel.hytale.server.core; +import com.hypixel.hytale.assetstore.AssetPack; import com.hypixel.hytale.codec.Codec; import com.hypixel.hytale.common.plugin.PluginManifest; import com.hypixel.hytale.common.thread.HytaleForkJoinThreadFactory; @@ -17,9 +18,11 @@ import com.hypixel.hytale.math.util.TrigMathUtil; import com.hypixel.hytale.metrics.JVMMetrics; import com.hypixel.hytale.metrics.MetricsRegistry; import com.hypixel.hytale.plugin.early.EarlyPluginLoader; +import com.hypixel.hytale.server.core.asset.AssetModule; import com.hypixel.hytale.server.core.asset.AssetRegistryLoader; import com.hypixel.hytale.server.core.asset.LoadAssetEvent; import com.hypixel.hytale.server.core.auth.ServerAuthManager; +import com.hypixel.hytale.server.core.auth.SessionServiceClient; import com.hypixel.hytale.server.core.command.system.CommandManager; import com.hypixel.hytale.server.core.console.ConsoleSender; import com.hypixel.hytale.server.core.event.events.BootEvent; @@ -35,11 +38,14 @@ import com.hypixel.hytale.server.core.universe.Universe; import com.hypixel.hytale.server.core.universe.datastore.DataStoreProvider; import com.hypixel.hytale.server.core.universe.datastore.DiskDataStoreProvider; import com.hypixel.hytale.server.core.universe.world.World; +import com.hypixel.hytale.server.core.update.UpdateModule; import com.hypixel.hytale.server.core.util.concurrent.ThreadUtil; import io.netty.handler.codec.quic.Quic; import io.sentry.Sentry; import io.sentry.SentryOptions; import io.sentry.protocol.Contexts; +import io.sentry.protocol.OperatingSystem; +import io.sentry.protocol.User; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import java.io.IOException; import java.time.Instant; @@ -147,14 +153,50 @@ public class HytaleServer { HashMap pluginsContext = new HashMap<>(); for (PluginBase plugin : this.pluginManager.getPlugins()) { - PluginManifest manifestx = plugin.getManifest(); + PluginManifest manifestxx = plugin.getManifest(); HashMap pluginInfo = new HashMap<>(); - pluginInfo.put("version", manifestx.getVersion().toString()); + pluginInfo.put("version", manifestxx.getVersion().toString()); pluginInfo.put("state", plugin.getState().name()); pluginsContext.put(plugin.getIdentifier().toString(), pluginInfo); } contexts.put("plugins", pluginsContext); + AssetModule assetModule = AssetModule.get(); + if (assetModule != null) { + HashMap packsContext = new HashMap<>(); + + for (AssetPack pack : assetModule.getAssetPacks()) { + HashMap packInfo = new HashMap<>(); + PluginManifest manifestx = pack.getManifest(); + if (manifestx != null && manifestx.getVersion() != null) { + packInfo.put("version", manifestx.getVersion().toString()); + } + + packInfo.put("immutable", pack.isImmutable()); + packsContext.put(pack.getName(), packInfo); + } + + contexts.put("packs", packsContext); + } + + User user = new User(); + HashMap unknown = new HashMap<>(); + user.setUnknown(unknown); + UUID hardwareUUID = HardwareUtil.getUUID(); + if (hardwareUUID != null) { + unknown.put("hardware-uuid", hardwareUUID.toString()); + } + + ServerAuthManager authManager = ServerAuthManager.getInstance(); + unknown.put("auth-mode", authManager.getAuthMode().toString()); + SessionServiceClient.GameProfile profile = authManager.getSelectedProfile(); + if (profile != null) { + user.setUsername(profile.username); + user.setId(profile.uuid.toString()); + } + + user.setIpAddress("{{auto}}"); + event.setUser(user); return event; } }); @@ -166,6 +208,10 @@ public class HytaleServer { scope.setContexts("hardware", Map.of("uuid", hardwareUUID.toString())); } + OperatingSystem os = new OperatingSystem(); + os.setName(System.getProperty("os.name")); + os.setVersion(System.getProperty("os.version")); + scope.getContexts().setOperatingSystem(os); scope.setContexts( "build", Map.of( @@ -189,6 +235,7 @@ public class HytaleServer { HytaleLogger.getLogger().setSentryClient(Sentry.getCurrentScopes()); } + ServerAuthManager.getInstance().checkPendingFatalError(); NettyUtil.init(); float sin = TrigMathUtil.sin(0.0F); float atan2 = TrigMathUtil.atan2(0.0F, 0.0F); @@ -293,9 +340,9 @@ public class HytaleServer { } this.sendSingleplayerSignal("-=|Enabled|0"); - } catch (Throwable var5) { - LOGGER.at(Level.SEVERE).withCause(var5).log("Failed to boot HytaleServer!"); - Throwable t = var5; + } catch (Throwable var6) { + LOGGER.at(Level.SEVERE).withCause(var6).log("Failed to boot HytaleServer!"); + Throwable t = var6; while (t.getCause() != null) { t = t.getCause(); @@ -349,6 +396,11 @@ public class HytaleServer { FormatUtil.nanosToString(System.nanoTime() - this.bootStart) ); LOGGER.at(Level.INFO).log("\u001b[0;32m==============================================================================================="); + UpdateModule updateModule = UpdateModule.get(); + if (updateModule != null) { + updateModule.onServerReady(); + } + ServerAuthManager authManager = ServerAuthManager.getInstance(); if (!authManager.isSingleplayer() && authManager.getAuthMode() == ServerAuthManager.AuthMode.NONE) { LOGGER.at(Level.WARNING).log("%sNo server tokens configured. Use /auth login to authenticate.", "\u001b[0;31m"); diff --git a/src/com/hypixel/hytale/server/core/HytaleServerConfig.java b/src/com/hypixel/hytale/server/core/HytaleServerConfig.java index bb7beec..de96474 100644 --- a/src/com/hypixel/hytale/server/core/HytaleServerConfig.java +++ b/src/com/hypixel/hytale/server/core/HytaleServerConfig.java @@ -5,6 +5,7 @@ import com.hypixel.hytale.codec.DocumentContainingCodec; import com.hypixel.hytale.codec.ExtraInfo; import com.hypixel.hytale.codec.KeyedCodec; import com.hypixel.hytale.codec.builder.BuilderCodec; +import com.hypixel.hytale.codec.codecs.EnumCodec; import com.hypixel.hytale.codec.codecs.map.MapCodec; import com.hypixel.hytale.codec.codecs.map.ObjectMapCodec; import com.hypixel.hytale.codec.lookup.Priority; @@ -23,7 +24,6 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import java.nio.file.Files; import java.nio.file.Path; import java.time.Duration; -import java.time.temporal.ChronoUnit; import java.util.Collections; import java.util.Map; import java.util.Optional; @@ -55,13 +55,9 @@ public class HytaleServerConfig { .add() .append(new KeyedCodec<>("MaxViewRadius", Codec.INTEGER), (o, i) -> o.maxViewRadius = i, o -> o.maxViewRadius) .add() - .append(new KeyedCodec<>("LocalCompressionEnabled", Codec.BOOLEAN), (o, i) -> o.localCompressionEnabled = i, o -> o.localCompressionEnabled) - .add() .append(new KeyedCodec<>("Defaults", HytaleServerConfig.Defaults.CODEC), (o, obj) -> o.defaults = obj, o -> o.defaults) .add() - .append( - new KeyedCodec<>("ConnectionTimeouts", HytaleServerConfig.ConnectionTimeouts.CODEC), (o, m) -> o.connectionTimeouts = m, o -> o.connectionTimeouts - ) + .append(new KeyedCodec<>("ConnectionTimeouts", HytaleServerConfig.TimeoutProfile.CODEC), (o, m) -> o.connectionTimeouts = m, o -> o.connectionTimeouts) .add() .append(new KeyedCodec<>("RateLimit", HytaleServerConfig.RateLimitConfig.CODEC), (o, m) -> o.rateLimitConfig = m, o -> o.rateLimitConfig) .add() @@ -106,10 +102,13 @@ public class HytaleServerConfig { .add() .append(new KeyedCodec<>("AuthCredentialStore", Codec.BSON_DOCUMENT), (o, value) -> o.authCredentialStoreConfig = value, o -> o.authCredentialStoreConfig) .add() + .append(new KeyedCodec<>("Update", HytaleServerConfig.UpdateConfig.CODEC), (o, value) -> o.updateConfig = value, o -> o.updateConfig) + .add() .afterDecode(config -> { config.defaults.hytaleServerConfig = config; - config.connectionTimeouts.hytaleServerConfig = config; + config.connectionTimeouts.setHytaleServerConfig(config); config.rateLimitConfig.hytaleServerConfig = config; + config.updateConfig.hytaleServerConfig = config; config.modules.values().forEach(m -> m.setHytaleServerConfig(config)); if (config.legacyPluginConfig != null && !config.legacyPluginConfig.isEmpty()) { for (Entry entry : config.legacyPluginConfig.entrySet()) { @@ -128,11 +127,10 @@ public class HytaleServerConfig { private String password = ""; private int maxPlayers = 100; private int maxViewRadius = 32; - private boolean localCompressionEnabled; @Nonnull private HytaleServerConfig.Defaults defaults = new HytaleServerConfig.Defaults(this); @Nonnull - private HytaleServerConfig.ConnectionTimeouts connectionTimeouts = new HytaleServerConfig.ConnectionTimeouts(this); + private HytaleServerConfig.TimeoutProfile connectionTimeouts = new HytaleServerConfig.TimeoutProfile(this); @Nonnull private HytaleServerConfig.RateLimitConfig rateLimitConfig = new HytaleServerConfig.RateLimitConfig(this); @Nonnull @@ -154,9 +152,8 @@ public class HytaleServerConfig { @Nullable private transient AuthCredentialStoreProvider authCredentialStoreProvider = null; private boolean displayTmpTagsInStrings; - - public HytaleServerConfig() { - } + @Nonnull + private HytaleServerConfig.UpdateConfig updateConfig = new HytaleServerConfig.UpdateConfig(this); public String getServerName() { return this.serverName; @@ -211,15 +208,6 @@ public class HytaleServerConfig { this.markChanged(); } - public boolean isLocalCompressionEnabled() { - return this.localCompressionEnabled; - } - - public void setLocalCompressionEnabled(boolean localCompression) { - this.localCompressionEnabled = localCompression; - this.markChanged(); - } - @Nonnull public HytaleServerConfig.Defaults getDefaults() { return this.defaults; @@ -231,11 +219,11 @@ public class HytaleServerConfig { } @Nonnull - public HytaleServerConfig.ConnectionTimeouts getConnectionTimeouts() { + public HytaleServerConfig.TimeoutProfile getConnectionTimeouts() { return this.connectionTimeouts; } - public void setConnectionTimeouts(@Nonnull HytaleServerConfig.ConnectionTimeouts connectionTimeouts) { + public void setConnectionTimeouts(@Nonnull HytaleServerConfig.TimeoutProfile connectionTimeouts) { this.connectionTimeouts = connectionTimeouts; this.markChanged(); } @@ -316,6 +304,16 @@ public class HytaleServerConfig { this.markChanged(); } + @Nonnull + public HytaleServerConfig.UpdateConfig getUpdateConfig() { + return this.updateConfig; + } + + public void setUpdateConfig(@Nonnull HytaleServerConfig.UpdateConfig updateConfig) { + this.updateConfig = updateConfig; + this.markChanged(); + } + public void removeModule(@Nonnull String module) { this.modules.remove(module); this.markChanged(); @@ -379,73 +377,6 @@ public class HytaleServerConfig { ); } - public static class ConnectionTimeouts { - public static final Duration DEFAULT_INITIAL_TIMEOUT = Duration.of(10L, ChronoUnit.SECONDS); - public static final Duration DEFAULT_AUTH_TIMEOUT = Duration.of(30L, ChronoUnit.SECONDS); - public static final Duration DEFAULT_PLAY_TIMEOUT = Duration.of(1L, ChronoUnit.MINUTES); - public static final Codec CODEC = BuilderCodec.builder( - HytaleServerConfig.ConnectionTimeouts.class, HytaleServerConfig.ConnectionTimeouts::new - ) - .addField(new KeyedCodec<>("InitialTimeout", Codec.DURATION), (o, d) -> o.initialTimeout = d, o -> o.initialTimeout) - .addField(new KeyedCodec<>("AuthTimeout", Codec.DURATION), (o, d) -> o.authTimeout = d, o -> o.authTimeout) - .addField(new KeyedCodec<>("PlayTimeout", Codec.DURATION), (o, d) -> o.playTimeout = d, o -> o.playTimeout) - .addField( - new KeyedCodec<>("JoinTimeouts", new MapCodec<>(Codec.DURATION, ConcurrentHashMap::new, false)), (o, m) -> o.joinTimeouts = m, o -> o.joinTimeouts - ) - .build(); - private Duration initialTimeout; - private Duration authTimeout; - private Duration playTimeout; - private Map joinTimeouts = new ConcurrentHashMap<>(); - @Nonnull - private Map unmodifiableJoinTimeouts = Collections.unmodifiableMap(this.joinTimeouts); - private transient HytaleServerConfig hytaleServerConfig; - - public ConnectionTimeouts() { - } - - public ConnectionTimeouts(HytaleServerConfig hytaleServerConfig) { - this.hytaleServerConfig = hytaleServerConfig; - } - - public Duration getInitialTimeout() { - return this.initialTimeout != null ? this.initialTimeout : DEFAULT_INITIAL_TIMEOUT; - } - - public void setInitialTimeout(Duration initialTimeout) { - this.initialTimeout = initialTimeout; - this.hytaleServerConfig.markChanged(); - } - - public Duration getAuthTimeout() { - return this.authTimeout != null ? this.authTimeout : DEFAULT_AUTH_TIMEOUT; - } - - public void setAuthTimeout(Duration authTimeout) { - this.authTimeout = authTimeout; - this.hytaleServerConfig.markChanged(); - } - - public Duration getPlayTimeout() { - return this.playTimeout != null ? this.playTimeout : DEFAULT_PLAY_TIMEOUT; - } - - public void setPlayTimeout(Duration playTimeout) { - this.playTimeout = playTimeout; - this.hytaleServerConfig.markChanged(); - } - - @Nonnull - public Map getJoinTimeouts() { - return this.unmodifiableJoinTimeouts; - } - - public void setJoinTimeouts(Map joinTimeouts) { - this.joinTimeouts = joinTimeouts; - this.hytaleServerConfig.markChanged(); - } - } - public static class Defaults { public static final KeyedCodec WORLD = new KeyedCodec<>("World", Codec.STRING); public static final KeyedCodec GAMEMODE = new KeyedCodec<>("GameMode", ProtocolCodecs.GAMEMODE_LEGACY); @@ -503,9 +434,6 @@ public class HytaleServerConfig { @Nullable private SemverRange requiredVersion; - public ModConfig() { - } - @Nullable public Boolean getEnabled() { return this.enabled; @@ -682,4 +610,338 @@ public class HytaleServerConfig { } } } + + public static class TimeoutProfile { + private static final HytaleServerConfig.TimeoutProfile SINGLEPLAYER_DEFAULTS = new HytaleServerConfig.TimeoutProfile( + Duration.ofSeconds(30L), + Duration.ofSeconds(60L), + Duration.ofSeconds(60L), + Duration.ofSeconds(60L), + Duration.ofSeconds(30L), + Duration.ofSeconds(60L), + Duration.ofSeconds(120L), + Duration.ofSeconds(30L), + Duration.ofSeconds(300L), + Duration.ofSeconds(300L), + Duration.ofSeconds(120L) + ); + private static final HytaleServerConfig.TimeoutProfile MULTIPLAYER_DEFAULTS = new HytaleServerConfig.TimeoutProfile( + Duration.ofSeconds(15L), + Duration.ofSeconds(30L), + Duration.ofSeconds(30L), + Duration.ofSeconds(30L), + Duration.ofSeconds(15L), + Duration.ofSeconds(45L), + Duration.ofSeconds(60L), + Duration.ofSeconds(15L), + Duration.ofSeconds(120L), + Duration.ofSeconds(120L), + Duration.ofSeconds(60L) + ); + public static final Codec CODEC = BuilderCodec.builder( + HytaleServerConfig.TimeoutProfile.class, HytaleServerConfig.TimeoutProfile::new + ) + .addField(new KeyedCodec<>("InitialTimeout", Codec.DURATION), (o, d) -> o.initial = d, o -> o.initial) + .addField(new KeyedCodec<>("AuthTimeout", Codec.DURATION), (o, d) -> o.auth = d, o -> o.auth) + .addField(new KeyedCodec<>("AuthGrantTimeout", Codec.DURATION), (o, d) -> o.authGrant = d, o -> o.authGrant) + .addField(new KeyedCodec<>("AuthTokenTimeout", Codec.DURATION), (o, d) -> o.authToken = d, o -> o.authToken) + .addField(new KeyedCodec<>("AuthServerExchangeTimeout", Codec.DURATION), (o, d) -> o.authServerExchange = d, o -> o.authServerExchange) + .addField(new KeyedCodec<>("PasswordTimeout", Codec.DURATION), (o, d) -> o.password = d, o -> o.password) + .addField(new KeyedCodec<>("PlayTimeout", Codec.DURATION), (o, d) -> o.play = d, o -> o.play) + .addField(new KeyedCodec<>("SetupWorldSettings", Codec.DURATION), (o, d) -> o.setupWorldSettings = d, o -> o.setupWorldSettings) + .addField(new KeyedCodec<>("SetupAssetsRequest", Codec.DURATION), (o, d) -> o.setupAssetsRequest = d, o -> o.setupAssetsRequest) + .addField(new KeyedCodec<>("SetupSendAssets", Codec.DURATION), (o, d) -> o.setupSendAssets = d, o -> o.setupSendAssets) + .addField(new KeyedCodec<>("SetupAddToUniverse", Codec.DURATION), (o, d) -> o.setupAddToUniverse = d, o -> o.setupAddToUniverse) + .build(); + private Duration initial; + private Duration auth; + private Duration authGrant; + private Duration authToken; + private Duration authServerExchange; + private Duration password; + private Duration play; + private Duration setupWorldSettings; + private Duration setupAssetsRequest; + private Duration setupSendAssets; + private Duration setupAddToUniverse; + private transient HytaleServerConfig hytaleServerConfig; + + public static HytaleServerConfig.TimeoutProfile defaults() { + return Constants.SINGLEPLAYER ? SINGLEPLAYER_DEFAULTS : MULTIPLAYER_DEFAULTS; + } + + public TimeoutProfile() { + } + + public TimeoutProfile(HytaleServerConfig hytaleServerConfig) { + this.hytaleServerConfig = hytaleServerConfig; + } + + private TimeoutProfile( + Duration initial, + Duration auth, + Duration authGrant, + Duration authToken, + Duration authServerExchange, + Duration password, + Duration play, + Duration worldSettings, + Duration assetsRequest, + Duration sendAssets, + Duration addToUniverse + ) { + this.initial = initial; + this.auth = auth; + this.authGrant = authGrant; + this.authToken = authToken; + this.authServerExchange = authServerExchange; + this.password = password; + this.play = play; + this.setupWorldSettings = worldSettings; + this.setupAssetsRequest = assetsRequest; + this.setupSendAssets = sendAssets; + this.setupAddToUniverse = addToUniverse; + } + + public Duration getInitial() { + return this.initial != null ? this.initial : defaults().initial; + } + + public void setInitial(Duration d) { + this.initial = d; + this.markChanged(); + } + + public Duration getAuth() { + return this.auth != null ? this.auth : defaults().auth; + } + + public void setAuth(Duration d) { + this.auth = d; + this.markChanged(); + } + + public Duration getAuthGrant() { + return this.authGrant != null ? this.authGrant : defaults().authGrant; + } + + public void setAuthGrant(Duration d) { + this.authGrant = d; + this.markChanged(); + } + + public Duration getAuthToken() { + return this.authToken != null ? this.authToken : defaults().authToken; + } + + public void setAuthToken(Duration d) { + this.authToken = d; + this.markChanged(); + } + + public Duration getAuthServerExchange() { + return this.authServerExchange != null ? this.authServerExchange : defaults().authServerExchange; + } + + public void setAuthServerExchange(Duration d) { + this.authServerExchange = d; + this.markChanged(); + } + + public Duration getPassword() { + return this.password != null ? this.password : defaults().password; + } + + public void setPassword(Duration d) { + this.password = d; + this.markChanged(); + } + + public Duration getPlay() { + return this.play != null ? this.play : defaults().play; + } + + public void setPlay(Duration d) { + this.play = d; + this.markChanged(); + } + + public Duration getSetupWorldSettings() { + return this.setupWorldSettings != null ? this.setupWorldSettings : defaults().setupWorldSettings; + } + + public void setSetupWorldSettings(Duration d) { + this.setupWorldSettings = d; + this.markChanged(); + } + + public Duration getSetupAssetsRequest() { + return this.setupAssetsRequest != null ? this.setupAssetsRequest : defaults().setupAssetsRequest; + } + + public void setSetupAssetsRequest(Duration d) { + this.setupAssetsRequest = d; + this.markChanged(); + } + + public Duration getSetupSendAssets() { + return this.setupSendAssets != null ? this.setupSendAssets : defaults().setupSendAssets; + } + + public void setSetupSendAssets(Duration d) { + this.setupSendAssets = d; + this.markChanged(); + } + + public Duration getSetupAddToUniverse() { + return this.setupAddToUniverse != null ? this.setupAddToUniverse : defaults().setupAddToUniverse; + } + + public void setSetupAddToUniverse(Duration d) { + this.setupAddToUniverse = d; + this.markChanged(); + } + + private void markChanged() { + if (this.hytaleServerConfig != null) { + this.hytaleServerConfig.markChanged(); + } + } + + void setHytaleServerConfig(HytaleServerConfig hytaleServerConfig) { + this.hytaleServerConfig = hytaleServerConfig; + } + } + + public static class UpdateConfig { + public static final int DEFAULT_CHECK_INTERVAL_SECONDS = 3600; + public static final Codec CODEC = BuilderCodec.builder( + HytaleServerConfig.UpdateConfig.class, HytaleServerConfig.UpdateConfig::new + ) + .addField(new KeyedCodec<>("Enabled", Codec.BOOLEAN), (o, b) -> o.enabled = b, o -> o.enabled) + .addField(new KeyedCodec<>("CheckIntervalSeconds", Codec.INTEGER), (o, i) -> o.checkIntervalSeconds = i, o -> o.checkIntervalSeconds) + .addField(new KeyedCodec<>("NotifyPlayersOnAvailable", Codec.BOOLEAN), (o, b) -> o.notifyPlayersOnAvailable = b, o -> o.notifyPlayersOnAvailable) + .addField(new KeyedCodec<>("Patchline", Codec.STRING), (o, s) -> o.patchline = s, o -> o.patchline) + .addField(new KeyedCodec<>("RunBackupBeforeUpdate", Codec.BOOLEAN), (o, b) -> o.runBackupBeforeUpdate = b, o -> o.runBackupBeforeUpdate) + .addField(new KeyedCodec<>("BackupConfigBeforeUpdate", Codec.BOOLEAN), (o, b) -> o.backupConfigBeforeUpdate = b, o -> o.backupConfigBeforeUpdate) + .addField( + new KeyedCodec<>("AutoApplyMode", new EnumCodec<>(HytaleServerConfig.UpdateConfig.AutoApplyMode.class)), + (o, m) -> o.autoApplyMode = m, + o -> o.autoApplyMode + ) + .addField(new KeyedCodec<>("AutoApplyDelayMinutes", Codec.INTEGER), (o, i) -> o.autoApplyDelayMinutes = i, o -> o.autoApplyDelayMinutes) + .build(); + private Boolean enabled; + private Integer checkIntervalSeconds; + private Boolean notifyPlayersOnAvailable; + private String patchline; + private Boolean runBackupBeforeUpdate; + private Boolean backupConfigBeforeUpdate; + private HytaleServerConfig.UpdateConfig.AutoApplyMode autoApplyMode; + private Integer autoApplyDelayMinutes; + transient HytaleServerConfig hytaleServerConfig; + + public UpdateConfig() { + } + + public UpdateConfig(HytaleServerConfig hytaleServerConfig) { + this.hytaleServerConfig = hytaleServerConfig; + } + + public boolean isEnabled() { + return this.enabled != null ? this.enabled : true; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + if (this.hytaleServerConfig != null) { + this.hytaleServerConfig.markChanged(); + } + } + + public int getCheckIntervalSeconds() { + return this.checkIntervalSeconds != null ? this.checkIntervalSeconds : 3600; + } + + public void setCheckIntervalSeconds(int checkIntervalSeconds) { + this.checkIntervalSeconds = checkIntervalSeconds; + if (this.hytaleServerConfig != null) { + this.hytaleServerConfig.markChanged(); + } + } + + public boolean isNotifyPlayersOnAvailable() { + return this.notifyPlayersOnAvailable != null ? this.notifyPlayersOnAvailable : true; + } + + public void setNotifyPlayersOnAvailable(boolean notifyPlayersOnAvailable) { + this.notifyPlayersOnAvailable = notifyPlayersOnAvailable; + if (this.hytaleServerConfig != null) { + this.hytaleServerConfig.markChanged(); + } + } + + @Nullable + public String getPatchline() { + return this.patchline; + } + + public void setPatchline(@Nullable String patchline) { + this.patchline = patchline; + if (this.hytaleServerConfig != null) { + this.hytaleServerConfig.markChanged(); + } + } + + public boolean isRunBackupBeforeUpdate() { + return this.runBackupBeforeUpdate != null ? this.runBackupBeforeUpdate : true; + } + + public void setRunBackupBeforeUpdate(boolean runBackupBeforeUpdate) { + this.runBackupBeforeUpdate = runBackupBeforeUpdate; + if (this.hytaleServerConfig != null) { + this.hytaleServerConfig.markChanged(); + } + } + + public boolean isBackupConfigBeforeUpdate() { + return this.backupConfigBeforeUpdate != null ? this.backupConfigBeforeUpdate : true; + } + + public void setBackupConfigBeforeUpdate(boolean backupConfigBeforeUpdate) { + this.backupConfigBeforeUpdate = backupConfigBeforeUpdate; + if (this.hytaleServerConfig != null) { + this.hytaleServerConfig.markChanged(); + } + } + + @Nonnull + public HytaleServerConfig.UpdateConfig.AutoApplyMode getAutoApplyMode() { + return this.autoApplyMode != null ? this.autoApplyMode : HytaleServerConfig.UpdateConfig.AutoApplyMode.DISABLED; + } + + public void setAutoApplyMode(@Nonnull HytaleServerConfig.UpdateConfig.AutoApplyMode autoApplyMode) { + this.autoApplyMode = autoApplyMode; + if (this.hytaleServerConfig != null) { + this.hytaleServerConfig.markChanged(); + } + } + + public int getAutoApplyDelayMinutes() { + return this.autoApplyDelayMinutes != null ? this.autoApplyDelayMinutes : 30; + } + + public void setAutoApplyDelayMinutes(int autoApplyDelayMinutes) { + this.autoApplyDelayMinutes = autoApplyDelayMinutes; + if (this.hytaleServerConfig != null) { + this.hytaleServerConfig.markChanged(); + } + } + + public static enum AutoApplyMode { + DISABLED, + WHEN_EMPTY, + SCHEDULED; + } + } } diff --git a/src/com/hypixel/hytale/server/core/Message.java b/src/com/hypixel/hytale/server/core/Message.java index ba1b415..22dc2dd 100644 --- a/src/com/hypixel/hytale/server/core/Message.java +++ b/src/com/hypixel/hytale/server/core/Message.java @@ -46,8 +46,6 @@ import org.bson.BsonInt64; import org.bson.BsonNull; import org.bson.BsonString; import org.bson.BsonValue; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; public class Message { private static final BuilderCodec.Builder MESSAGE_CODEC_BUILDER = BuilderCodec.builder(FormattedMessage.class, FormattedMessage::new); @@ -386,9 +384,6 @@ public class Message { } private static class MaybeBoolCodec implements Codec { - private MaybeBoolCodec() { - } - @Nullable public MaybeBool decode(BsonValue bsonValue, ExtraInfo extraInfo) { if (bsonValue.isNull()) { @@ -406,8 +401,8 @@ public class Message { }); } - @NullableDecl - public MaybeBool decodeJson(@NonNullDecl RawJsonReader reader, ExtraInfo extraInfo) throws IOException { + @Nullable + public MaybeBool decodeJson(@Nonnull RawJsonReader reader, ExtraInfo extraInfo) throws IOException { if (reader.peekFor('n')) { if (!reader.tryConsume("null")) { throw new IllegalArgumentException("Invalid null value"); @@ -433,9 +428,6 @@ public class Message { } private static class ParamValueCodec implements Codec { - private ParamValueCodec() { - } - @Nullable public ParamValue decode(BsonValue bsonValue, ExtraInfo extraInfo) { return (ParamValue)(switch (bsonValue.getBsonType()) { diff --git a/src/com/hypixel/hytale/server/core/Options.java b/src/com/hypixel/hytale/server/core/Options.java index 851251e..0dbba4a 100644 --- a/src/com/hypixel/hytale/server/core/Options.java +++ b/src/com/hypixel/hytale/server/core/Options.java @@ -130,9 +130,6 @@ public class Options { public static final OptionSpec IDENTITY_TOKEN = PARSER.accepts("identity-token", "Identity token (JWT)").withRequiredArg().ofType(String.class); private static OptionSet optionSet; - public Options() { - } - public static OptionSet getOptionSet() { return optionSet; } @@ -179,15 +176,9 @@ public class Options { AUTHENTICATED, OFFLINE, INSECURE; - - private AuthMode() { - } } private static class AuthModeConverter implements ValueConverter { - private AuthModeConverter() { - } - public Options.AuthMode convert(String value) { return Options.AuthMode.valueOf(value.toUpperCase()); } @@ -206,9 +197,6 @@ public class Options { public static class LevelValueConverter implements ValueConverter> { private static final Entry ENTRY = Map.entry("", Level.ALL); - public LevelValueConverter() { - } - @Nonnull public Entry convert(@Nonnull String value) { if (!value.contains(":")) { @@ -285,16 +273,10 @@ public class Options { DIR, DIR_OR_ZIP, ANY; - - private PathType() { - } } } public static class SocketAddressValueConverter implements ValueConverter { - public SocketAddressValueConverter() { - } - @Nonnull public InetSocketAddress convert(@Nonnull String value) { if (value.contains(":")) { @@ -325,9 +307,6 @@ public class Options { public static class StringToPathMapConverter implements ValueConverter> { private static final Map MAP = new Object2ObjectOpenHashMap<>(); - public StringToPathMapConverter() { - } - @Nonnull public Map convert(@Nonnull String value) { HashMap map = new HashMap<>(); @@ -366,9 +345,6 @@ public class Options { } public static class UUIDConverter implements ValueConverter { - public UUIDConverter() { - } - @Nonnull public UUID convert(@Nonnull String s) { return UUID.fromString(s); diff --git a/src/com/hypixel/hytale/server/core/ShutdownReason.java b/src/com/hypixel/hytale/server/core/ShutdownReason.java index b931ad4..c63b32a 100644 --- a/src/com/hypixel/hytale/server/core/ShutdownReason.java +++ b/src/com/hypixel/hytale/server/core/ShutdownReason.java @@ -11,6 +11,8 @@ public class ShutdownReason { public static final ShutdownReason CLIENT_GONE = new ShutdownReason(4); public static final ShutdownReason MISSING_REQUIRED_PLUGIN = new ShutdownReason(5); public static final ShutdownReason VALIDATE_ERROR = new ShutdownReason(6); + public static final ShutdownReason MISSING_ASSETS = new ShutdownReason(7); + public static final ShutdownReason UPDATE = new ShutdownReason(8); private final int exitCode; private final String message; diff --git a/src/com/hypixel/hytale/server/core/asset/AssetModule.java b/src/com/hypixel/hytale/server/core/asset/AssetModule.java index 598a4b4..bffe73a 100644 --- a/src/com/hypixel/hytale/server/core/asset/AssetModule.java +++ b/src/com/hypixel/hytale/server/core/asset/AssetModule.java @@ -18,6 +18,7 @@ import com.hypixel.hytale.logger.HytaleLogger; import com.hypixel.hytale.server.core.HytaleServer; import com.hypixel.hytale.server.core.HytaleServerConfig; import com.hypixel.hytale.server.core.Options; +import com.hypixel.hytale.server.core.ShutdownReason; import com.hypixel.hytale.server.core.asset.monitor.AssetMonitor; import com.hypixel.hytale.server.core.asset.type.gameplay.respawn.HomeOrSpawnPoint; import com.hypixel.hytale.server.core.asset.type.gameplay.respawn.RespawnController; @@ -93,52 +94,56 @@ public class AssetModule extends JavaPlugin { this.loadPacksFromDirectory(modsPath); } - this.getEventRegistry().register((short)-16, LoadAssetEvent.class, event -> { - if (this.hasLoaded) { - throw new IllegalStateException("LoadAssetEvent has already been dispatched"); - } else { - AssetRegistry.ASSET_LOCK.writeLock().lock(); + if (this.assetPacks.isEmpty()) { + HytaleServer.get().shutdownServer(ShutdownReason.MISSING_ASSETS.withMessage("Failed to load any asset packs")); + } else { + this.getEventRegistry().register((short)-16, LoadAssetEvent.class, event -> { + if (this.hasLoaded) { + throw new IllegalStateException("LoadAssetEvent has already been dispatched"); + } else { + AssetRegistry.ASSET_LOCK.writeLock().lock(); - try { - this.hasLoaded = true; - AssetRegistryLoader.preLoadAssets(event); + try { + this.hasLoaded = true; + AssetRegistryLoader.preLoadAssets(event); - for (AssetPack pack : this.assetPacks) { - AssetRegistryLoader.loadAssets(event, pack); + for (AssetPack pack : this.assetPacks) { + AssetRegistryLoader.loadAssets(event, pack); + } + } finally { + AssetRegistry.ASSET_LOCK.writeLock().unlock(); } - } finally { - AssetRegistry.ASSET_LOCK.writeLock().unlock(); } - } - }); - this.getEventRegistry().register((short)-16, AssetPackRegisterEvent.class, event -> AssetRegistryLoader.loadAssets(null, event.getAssetPack())); - this.getEventRegistry().register(AssetPackUnregisterEvent.class, event -> { - for (AssetStore assetStore : AssetRegistry.getStoreMap().values()) { - assetStore.removeAssetPack(event.getAssetPack().getName()); - } - }); - this.getEventRegistry().register(LoadAssetEvent.class, AssetModule::validateWorldGen); - this.getEventRegistry().register(EventPriority.FIRST, LoadAssetEvent.class, SneakyThrow.sneakyConsumer(AssetRegistryLoader::writeSchemas)); - this.getEventRegistry().register(RegisterAssetStoreEvent.class, this::onNewStore); - this.getEventRegistry().register(RemoveAssetStoreEvent.class, this::onRemoveStore); - this.getEventRegistry().registerGlobal(BootEvent.class, event -> { - StringBuilder sb = new StringBuilder("Total Loaded Assets: "); - AssetStore[] assetStores = AssetRegistry.getStoreMap().values().toArray(AssetStore[]::new); - Arrays.sort(assetStores, Comparator.comparingInt(o -> o.getAssetMap().getAssetCount())); + }); + this.getEventRegistry().register((short)-16, AssetPackRegisterEvent.class, event -> AssetRegistryLoader.loadAssets(null, event.getAssetPack())); + this.getEventRegistry().register(AssetPackUnregisterEvent.class, event -> { + for (AssetStore assetStore : AssetRegistry.getStoreMap().values()) { + assetStore.removeAssetPack(event.getAssetPack().getName()); + } + }); + this.getEventRegistry().register(LoadAssetEvent.class, AssetModule::validateWorldGen); + this.getEventRegistry().register(EventPriority.FIRST, LoadAssetEvent.class, SneakyThrow.sneakyConsumer(AssetRegistryLoader::writeSchemas)); + this.getEventRegistry().register(RegisterAssetStoreEvent.class, this::onNewStore); + this.getEventRegistry().register(RemoveAssetStoreEvent.class, this::onRemoveStore); + this.getEventRegistry().registerGlobal(BootEvent.class, event -> { + StringBuilder sb = new StringBuilder("Total Loaded Assets: "); + AssetStore[] assetStores = AssetRegistry.getStoreMap().values().toArray(AssetStore[]::new); + Arrays.sort(assetStores, Comparator.comparingInt(o -> o.getAssetMap().getAssetCount())); - for (int i = assetStores.length - 1; i >= 0; i--) { - AssetStore assetStore = assetStores[i]; - String simpleName = assetStore.getAssetClass().getSimpleName(); - int assetCount = assetStore.getAssetMap().getAssetCount(); - sb.append(simpleName).append(": ").append(assetCount).append(", "); - } + for (int i = assetStores.length - 1; i >= 0; i--) { + AssetStore assetStore = assetStores[i]; + String simpleName = assetStore.getAssetClass().getSimpleName(); + int assetCount = assetStore.getAssetMap().getAssetCount(); + sb.append(simpleName).append(": ").append(assetCount).append(", "); + } - sb.setLength(sb.length() - 2); - this.getLogger().at(Level.INFO).log(sb.toString()); - }); - RespawnController.CODEC.register("HomeOrSpawnPoint", HomeOrSpawnPoint.class, HomeOrSpawnPoint.CODEC); - RespawnController.CODEC.register("WorldSpawnPoint", WorldSpawnPoint.class, WorldSpawnPoint.CODEC); - this.getCommandRegistry().registerCommand(new DroplistCommand()); + sb.setLength(sb.length() - 2); + this.getLogger().at(Level.INFO).log(sb.toString()); + }); + RespawnController.CODEC.register("HomeOrSpawnPoint", HomeOrSpawnPoint.class, HomeOrSpawnPoint.CODEC); + RespawnController.CODEC.register("WorldSpawnPoint", WorldSpawnPoint.class, WorldSpawnPoint.CODEC); + this.getCommandRegistry().registerCommand(new DroplistCommand()); + } } @Override @@ -181,7 +186,7 @@ public class AssetModule extends JavaPlugin { path = path.toAbsolutePath().normalize(); for (AssetPack pack : this.assetPacks) { - if (path.startsWith(pack.getRoot())) { + if (path.getFileSystem() == pack.getRoot().getFileSystem() && path.startsWith(pack.getRoot())) { return pack; } } diff --git a/src/com/hypixel/hytale/server/core/asset/AssetNotifications.java b/src/com/hypixel/hytale/server/core/asset/AssetNotifications.java index a3a1744..2065b12 100644 --- a/src/com/hypixel/hytale/server/core/asset/AssetNotifications.java +++ b/src/com/hypixel/hytale/server/core/asset/AssetNotifications.java @@ -11,7 +11,4 @@ public class AssetNotifications { public static final String ASSET_ADDED_COLOR = "#06EE92"; public static final String ASSET_DELETED_COLOR = "#FF3874"; public static final String ASSET_RELOADED_COLOR = "#A7AfA7"; - - public AssetNotifications() { - } } diff --git a/src/com/hypixel/hytale/server/core/asset/AssetRegistryLoader.java b/src/com/hypixel/hytale/server/core/asset/AssetRegistryLoader.java index 2af4cce..5b4c0b6 100644 --- a/src/com/hypixel/hytale/server/core/asset/AssetRegistryLoader.java +++ b/src/com/hypixel/hytale/server/core/asset/AssetRegistryLoader.java @@ -144,9 +144,6 @@ import org.bson.BsonValue; public class AssetRegistryLoader { public static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); - public AssetRegistryLoader() { - } - public static void init() { } diff --git a/src/com/hypixel/hytale/server/core/asset/common/BlockyAnimationCache.java b/src/com/hypixel/hytale/server/core/asset/common/BlockyAnimationCache.java index a77a7ae..78c5b3f 100644 --- a/src/com/hypixel/hytale/server/core/asset/common/BlockyAnimationCache.java +++ b/src/com/hypixel/hytale/server/core/asset/common/BlockyAnimationCache.java @@ -20,9 +20,6 @@ public class BlockyAnimationCache { public static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); private static final Map animations = new ConcurrentHashMap<>(); - public BlockyAnimationCache() { - } - @Nonnull public static CompletableFuture get(String name) { BlockyAnimationCache.BlockyAnimation animationData = animations.get(name); @@ -92,9 +89,6 @@ public class BlockyAnimationCache { public static final double FRAMES_PER_SECOND = 60.0; private int duration; - public BlockyAnimation() { - } - public int getDurationFrames() { return this.duration; } diff --git a/src/com/hypixel/hytale/server/core/asset/common/CommonAssetRegistry.java b/src/com/hypixel/hytale/server/core/asset/common/CommonAssetRegistry.java index 414ca4c..2abda31 100644 --- a/src/com/hypixel/hytale/server/core/asset/common/CommonAssetRegistry.java +++ b/src/com/hypixel/hytale/server/core/asset/common/CommonAssetRegistry.java @@ -25,9 +25,6 @@ public class CommonAssetRegistry { assetByNameMap.values() ); - public CommonAssetRegistry() { - } - public static int getDuplicateAssetCount() { return duplicateAssetCount.get(); } @@ -193,9 +190,6 @@ public class CommonAssetRegistry { private CommonAssetRegistry.PackAsset[] previousHashAssets; private int duplicateAssetId; - public AddCommonAssetResult() { - } - public CommonAssetRegistry.PackAsset getNewPackAsset() { return this.newPackAsset; } diff --git a/src/com/hypixel/hytale/server/core/asset/common/HytaleFileTypes.java b/src/com/hypixel/hytale/server/core/asset/common/HytaleFileTypes.java index 45a27c7..8603fe5 100644 --- a/src/com/hypixel/hytale/server/core/asset/common/HytaleFileTypes.java +++ b/src/com/hypixel/hytale/server/core/asset/common/HytaleFileTypes.java @@ -7,7 +7,4 @@ public class HytaleFileTypes { static final String MODEL_FILE_TYPE = "blockymodel"; static final String OGG_FILE_TYPE = "ogg"; static final String JSON_FILE_TYPE = "json"; - - public HytaleFileTypes() { - } } diff --git a/src/com/hypixel/hytale/server/core/asset/common/OggVorbisInfoCache.java b/src/com/hypixel/hytale/server/core/asset/common/OggVorbisInfoCache.java index 55b39a2..6796b19 100644 --- a/src/com/hypixel/hytale/server/core/asset/common/OggVorbisInfoCache.java +++ b/src/com/hypixel/hytale/server/core/asset/common/OggVorbisInfoCache.java @@ -14,9 +14,6 @@ public class OggVorbisInfoCache { public static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); private static final Map vorbisFiles = new ConcurrentHashMap<>(); - public OggVorbisInfoCache() { - } - @Nonnull public static CompletableFuture get(String name) { OggVorbisInfoCache.OggVorbisInfo info = vorbisFiles.get(name); diff --git a/src/com/hypixel/hytale/server/core/asset/common/SoundFileValidators.java b/src/com/hypixel/hytale/server/core/asset/common/SoundFileValidators.java index edacb65..20979ae 100644 --- a/src/com/hypixel/hytale/server/core/asset/common/SoundFileValidators.java +++ b/src/com/hypixel/hytale/server/core/asset/common/SoundFileValidators.java @@ -13,9 +13,6 @@ public class SoundFileValidators { private static final String MONO_STRING = "Mono"; private static final String STEREO_STRING = "Stereo"; - public SoundFileValidators() { - } - @Nonnull public static String getEncoding(int channelCount) { return switch (channelCount) { diff --git a/src/com/hypixel/hytale/server/core/asset/monitor/EventKind.java b/src/com/hypixel/hytale/server/core/asset/monitor/EventKind.java index 7dee84b..2cbc04e 100644 --- a/src/com/hypixel/hytale/server/core/asset/monitor/EventKind.java +++ b/src/com/hypixel/hytale/server/core/asset/monitor/EventKind.java @@ -10,9 +10,6 @@ public enum EventKind { ENTRY_DELETE, ENTRY_MODIFY; - private EventKind() { - } - @Nonnull public static EventKind parse(Kind kind) { if (kind == StandardWatchEventKinds.ENTRY_CREATE) { diff --git a/src/com/hypixel/hytale/server/core/asset/packet/AssetPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/packet/AssetPacketGenerator.java index 88b6024..d0c01fb 100644 --- a/src/com/hypixel/hytale/server/core/asset/packet/AssetPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/packet/AssetPacketGenerator.java @@ -10,9 +10,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public abstract class AssetPacketGenerator, M extends AssetMap> { - public AssetPacketGenerator() { - } - public abstract Packet generateInitPacket(M var1, Map var2); public abstract Packet generateUpdatePacket(M var1, Map var2, @Nonnull AssetUpdateQuery var3); diff --git a/src/com/hypixel/hytale/server/core/asset/packet/DefaultAssetPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/packet/DefaultAssetPacketGenerator.java index cbe1cdf..fc9284f 100644 --- a/src/com/hypixel/hytale/server/core/asset/packet/DefaultAssetPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/packet/DefaultAssetPacketGenerator.java @@ -9,9 +9,6 @@ import javax.annotation.Nullable; public abstract class DefaultAssetPacketGenerator>> extends SimpleAssetPacketGenerator> { - public DefaultAssetPacketGenerator() { - } - public abstract Packet generateInitPacket(DefaultAssetMap var1, Map var2); public abstract Packet generateUpdatePacket(Map var1); diff --git a/src/com/hypixel/hytale/server/core/asset/packet/SimpleAssetPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/packet/SimpleAssetPacketGenerator.java index 6e0afb7..fae7f1a 100644 --- a/src/com/hypixel/hytale/server/core/asset/packet/SimpleAssetPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/packet/SimpleAssetPacketGenerator.java @@ -10,9 +10,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public abstract class SimpleAssetPacketGenerator, M extends AssetMap> extends AssetPacketGenerator { - public SimpleAssetPacketGenerator() { - } - @Override public abstract Packet generateInitPacket(M var1, Map var2); diff --git a/src/com/hypixel/hytale/server/core/asset/type/ambiencefx/AmbienceFXPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/ambiencefx/AmbienceFXPacketGenerator.java index 104a1f8..f690eeb 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/ambiencefx/AmbienceFXPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/ambiencefx/AmbienceFXPacketGenerator.java @@ -13,9 +13,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class AmbienceFXPacketGenerator extends SimpleAssetPacketGenerator> { - public AmbienceFXPacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedAssetMap assetMap, @Nonnull Map assets) { UpdateAmbienceFX packet = new UpdateAmbienceFX(); diff --git a/src/com/hypixel/hytale/server/core/asset/type/audiocategory/AudioCategoryPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/audiocategory/AudioCategoryPacketGenerator.java index 7819733..9422f9c 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/audiocategory/AudioCategoryPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/audiocategory/AudioCategoryPacketGenerator.java @@ -13,9 +13,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class AudioCategoryPacketGenerator extends SimpleAssetPacketGenerator> { - public AudioCategoryPacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedLookupTableAssetMap assetMap, @Nonnull Map assets) { UpdateAudioCategories packet = new UpdateAudioCategories(); diff --git a/src/com/hypixel/hytale/server/core/asset/type/blockbreakingdecal/BlockBreakingDecalPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/blockbreakingdecal/BlockBreakingDecalPacketGenerator.java index 6802f28..77171d7 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/blockbreakingdecal/BlockBreakingDecalPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/blockbreakingdecal/BlockBreakingDecalPacketGenerator.java @@ -15,9 +15,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class BlockBreakingDecalPacketGenerator extends DefaultAssetPacketGenerator { - public BlockBreakingDecalPacketGenerator() { - } - @Nonnull @Override public Packet generateInitPacket(@Nonnull DefaultAssetMap assetMap, Map assets) { diff --git a/src/com/hypixel/hytale/server/core/asset/type/blockhitbox/BlockBoundingBoxesPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/blockhitbox/BlockBoundingBoxesPacketGenerator.java index 7fb2270..71af9b7 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/blockhitbox/BlockBoundingBoxesPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/blockhitbox/BlockBoundingBoxesPacketGenerator.java @@ -14,9 +14,6 @@ import javax.annotation.Nonnull; public class BlockBoundingBoxesPacketGenerator extends SimpleAssetPacketGenerator> { - public BlockBoundingBoxesPacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedLookupTableAssetMap assetMap, @Nonnull Map assets) { UpdateBlockHitboxes packet = new UpdateBlockHitboxes(); diff --git a/src/com/hypixel/hytale/server/core/asset/type/blockparticle/BlockParticleSetPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/blockparticle/BlockParticleSetPacketGenerator.java index 93ae518..9dfb925 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/blockparticle/BlockParticleSetPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/blockparticle/BlockParticleSetPacketGenerator.java @@ -13,9 +13,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class BlockParticleSetPacketGenerator extends DefaultAssetPacketGenerator { - public BlockParticleSetPacketGenerator() { - } - @Nonnull @Override public Packet generateInitPacket(DefaultAssetMap assetMap, @Nonnull Map assets) { diff --git a/src/com/hypixel/hytale/server/core/asset/type/blockset/BlockSetPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/blockset/BlockSetPacketGenerator.java index 1a3ffe2..78c8d67 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/blockset/BlockSetPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/blockset/BlockSetPacketGenerator.java @@ -16,9 +16,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class BlockSetPacketGenerator extends AssetPacketGenerator> { - public BlockSetPacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedLookupTableAssetMap assetMap, Map assets) { UpdateBlockSets packet = new UpdateBlockSets(); diff --git a/src/com/hypixel/hytale/server/core/asset/type/blocksound/BlockSoundSetPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/blocksound/BlockSoundSetPacketGenerator.java index 47f6bee..552b4d8 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/blocksound/BlockSoundSetPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/blocksound/BlockSoundSetPacketGenerator.java @@ -13,9 +13,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class BlockSoundSetPacketGenerator extends SimpleAssetPacketGenerator> { - public BlockSoundSetPacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedLookupTableAssetMap assetMap, @Nonnull Map assets) { UpdateBlockSoundSets packet = new UpdateBlockSoundSets(); diff --git a/src/com/hypixel/hytale/server/core/asset/type/blocktick/BlockTickStrategy.java b/src/com/hypixel/hytale/server/core/asset/type/blocktick/BlockTickStrategy.java index 2bd383f..47e335f 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/blocktick/BlockTickStrategy.java +++ b/src/com/hypixel/hytale/server/core/asset/type/blocktick/BlockTickStrategy.java @@ -5,7 +5,4 @@ public enum BlockTickStrategy { IGNORED, SLEEP, WAIT_FOR_ADJACENT_CHUNK_LOAD; - - private BlockTickStrategy() { - } } diff --git a/src/com/hypixel/hytale/server/core/asset/type/blocktick/config/TickProcedure.java b/src/com/hypixel/hytale/server/core/asset/type/blocktick/config/TickProcedure.java index 0955da0..ffce125 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/blocktick/config/TickProcedure.java +++ b/src/com/hypixel/hytale/server/core/asset/type/blocktick/config/TickProcedure.java @@ -13,9 +13,6 @@ public abstract class TickProcedure { protected static final SplittableRandom BASE_RANDOM = new SplittableRandom(); protected static final ThreadLocal RANDOM = ThreadLocal.withInitial(BASE_RANDOM::split); - public TickProcedure() { - } - protected SplittableRandom getRandom() { return RANDOM.get(); } diff --git a/src/com/hypixel/hytale/server/core/asset/type/blocktype/BlockGroupPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/blocktype/BlockGroupPacketGenerator.java index 5311274..c23805a 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/blocktype/BlockGroupPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/blocktype/BlockGroupPacketGenerator.java @@ -15,9 +15,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class BlockGroupPacketGenerator extends DefaultAssetPacketGenerator { - public BlockGroupPacketGenerator() { - } - @Nonnull @Override public Packet generateInitPacket(@Nonnull DefaultAssetMap assetMap, Map assets) { diff --git a/src/com/hypixel/hytale/server/core/asset/type/blocktype/BlockTypePacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/blocktype/BlockTypePacketGenerator.java index 57d686e..cfb8617 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/blocktype/BlockTypePacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/blocktype/BlockTypePacketGenerator.java @@ -15,9 +15,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class BlockTypePacketGenerator extends AssetPacketGenerator> { - public BlockTypePacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull BlockTypeAssetMap assetMap, @Nonnull Map assets) { UpdateBlockTypes packet = new UpdateBlockTypes(); diff --git a/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/BlockFace.java b/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/BlockFace.java index 7fca7e3..0d49019 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/BlockFace.java +++ b/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/BlockFace.java @@ -228,8 +228,5 @@ public enum BlockFace { ROTATE_Y, ROTATE_Z, ROTATE_ALL; - - private FaceConnectionType() { - } } } diff --git a/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/BlockFlipType.java b/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/BlockFlipType.java index 52d6d4c..8a6253e 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/BlockFlipType.java +++ b/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/BlockFlipType.java @@ -7,9 +7,6 @@ public enum BlockFlipType { ORTHOGONAL, SYMMETRIC; - private BlockFlipType() { - } - public Rotation flipYaw(@Nonnull Rotation rotation, Axis axis) { if (axis == Axis.Y) { return rotation; diff --git a/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/BlockGathering.java b/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/BlockGathering.java index 3e3498e..7d039c8 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/BlockGathering.java +++ b/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/BlockGathering.java @@ -158,9 +158,6 @@ public class BlockGathering implements NetworkSerializable CODEC = new EnumCodec<>(BlockPlacementSettings.BlockPreviewVisibility.class); - - private BlockPreviewVisibility() { - } } public static enum RotationMode { @@ -245,8 +242,5 @@ public class BlockPlacementSettings implements NetworkSerializable CODEC = new EnumCodec<>(BlockPlacementSettings.RotationMode.class); - - private RotationMode() { - } } } diff --git a/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/BlockSupportsRequiredForType.java b/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/BlockSupportsRequiredForType.java index cea900a..390314d 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/BlockSupportsRequiredForType.java +++ b/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/BlockSupportsRequiredForType.java @@ -3,7 +3,4 @@ package com.hypixel.hytale.server.core.asset.type.blocktype.config; public enum BlockSupportsRequiredForType { Any, All; - - private BlockSupportsRequiredForType() { - } } diff --git a/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/BlockType.java b/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/BlockType.java index eda5706..30c38a3 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/BlockType.java +++ b/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/BlockType.java @@ -1725,7 +1725,7 @@ public class BlockType implements JsonAssetWithMap CODEC = new EnumCodec<>(RequiredBlockFaceSupport.Match.class); - - private Match() { - } } } diff --git a/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/RequiredBlockFaceSupportValidator.java b/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/RequiredBlockFaceSupportValidator.java index 7f40738..875cf5b 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/RequiredBlockFaceSupportValidator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/RequiredBlockFaceSupportValidator.java @@ -10,9 +10,6 @@ import javax.annotation.Nullable; class RequiredBlockFaceSupportValidator implements LegacyValidator> { static final RequiredBlockFaceSupportValidator INSTANCE = new RequiredBlockFaceSupportValidator(); - RequiredBlockFaceSupportValidator() { - } - public void accept(@Nullable Map support, @Nonnull ValidationResults results) { if (support != null) { for (Entry entry : support.entrySet()) { diff --git a/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/SupportDropType.java b/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/SupportDropType.java index 87576cc..0fd7d8e 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/SupportDropType.java +++ b/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/SupportDropType.java @@ -7,7 +7,4 @@ public enum SupportDropType { DESTROY; public static final EnumCodec CODEC = new EnumCodec<>(SupportDropType.class); - - private SupportDropType() { - } } diff --git a/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/bench/Bench.java b/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/bench/Bench.java index 1db0180..cff891f 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/bench/Bench.java +++ b/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/bench/Bench.java @@ -123,9 +123,6 @@ public abstract class Bench implements NetworkSerializable(); diff --git a/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/farming/FarmingData.java b/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/farming/FarmingData.java index f1083f0..76ae08d 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/farming/FarmingData.java +++ b/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/farming/FarmingData.java @@ -61,9 +61,6 @@ public class FarmingData { @Nullable protected FarmingData.SoilConfig soilConfig; - public FarmingData() { - } - @Nullable public Map getStages() { return this.stages; @@ -118,9 +115,6 @@ public class FarmingData { protected String targetBlock; protected Rangef lifetime; - public SoilConfig() { - } - public String getTargetBlock() { return this.targetBlock; } diff --git a/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/farming/FarmingStageData.java b/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/farming/FarmingStageData.java index d3ac3ab..cd5382e 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/farming/FarmingStageData.java +++ b/src/com/hypixel/hytale/server/core/asset/type/blocktype/config/farming/FarmingStageData.java @@ -47,9 +47,6 @@ public abstract class FarmingStageData { protected String soundEventId = null; protected transient int soundEventIndex = 0; - public FarmingStageData() { - } - @Nullable public Rangef getDuration() { return this.duration; diff --git a/src/com/hypixel/hytale/server/core/asset/type/buildertool/config/BlockTypeListAsset.java b/src/com/hypixel/hytale/server/core/asset/type/buildertool/config/BlockTypeListAsset.java index 028fcf5..c0f5a1e 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/buildertool/config/BlockTypeListAsset.java +++ b/src/com/hypixel/hytale/server/core/asset/type/buildertool/config/BlockTypeListAsset.java @@ -53,9 +53,6 @@ public class BlockTypeListAsset implements JsonAssetWithMap> getAssetStore() { if (ASSET_STORE == null) { ASSET_STORE = AssetRegistry.getAssetStore(BlockTypeListAsset.class); diff --git a/src/com/hypixel/hytale/server/core/asset/type/buildertool/config/BuilderTool.java b/src/com/hypixel/hytale/server/core/asset/type/buildertool/config/BuilderTool.java index bf97f36..db71601 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/buildertool/config/BuilderTool.java +++ b/src/com/hypixel/hytale/server/core/asset/type/buildertool/config/BuilderTool.java @@ -64,9 +64,6 @@ public class BuilderTool implements JsonAssetWithMap argsCodec; private SoftReference cachedPacket; - public BuilderTool() { - } - public static DefaultAssetMap getAssetMap() { if (ASSET_MAP == null) { ASSET_MAP = (DefaultAssetMap)AssetRegistry.getAssetStore(BuilderTool.class).getAssetMap(); diff --git a/src/com/hypixel/hytale/server/core/asset/type/buildertool/config/PrefabListAsset.java b/src/com/hypixel/hytale/server/core/asset/type/buildertool/config/PrefabListAsset.java index da2eb22..f38af83 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/buildertool/config/PrefabListAsset.java +++ b/src/com/hypixel/hytale/server/core/asset/type/buildertool/config/PrefabListAsset.java @@ -51,9 +51,6 @@ public class PrefabListAsset implements JsonAssetWithMap> getAssetStore() { if (ASSET_STORE == null) { ASSET_STORE = AssetRegistry.getAssetStore(PrefabListAsset.class); @@ -126,9 +123,6 @@ public class PrefabListAsset implements JsonAssetWithMap prefabPaths = new ObjectArrayList<>(); - public PrefabReference() { - } - public void processPrefabPath() { if (this.unprocessedPrefabPath != null) { this.unprocessedPrefabPath = this.unprocessedPrefabPath.replace('\\', '/'); diff --git a/src/com/hypixel/hytale/server/core/asset/type/buildertool/config/args/ToolArg.java b/src/com/hypixel/hytale/server/core/asset/type/buildertool/config/args/ToolArg.java index 7015a3a..49d7007 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/buildertool/config/args/ToolArg.java +++ b/src/com/hypixel/hytale/server/core/asset/type/buildertool/config/args/ToolArg.java @@ -16,9 +16,6 @@ public abstract class ToolArg implements NetworkSerializable protected boolean required = true; protected T value; - public ToolArg() { - } - public T getValue() { return this.value; } diff --git a/src/com/hypixel/hytale/server/core/asset/type/camera/CameraEffect.java b/src/com/hypixel/hytale/server/core/asset/type/camera/CameraEffect.java index 1904055..22ce052 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/camera/CameraEffect.java +++ b/src/com/hypixel/hytale/server/core/asset/type/camera/CameraEffect.java @@ -26,9 +26,6 @@ public abstract class CameraEffect implements JsonAssetWithMap> getAssetStore() { if (ASSET_STORE == null) { diff --git a/src/com/hypixel/hytale/server/core/asset/type/entityeffect/EntityEffectPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/entityeffect/EntityEffectPacketGenerator.java index 2a82054..87519c6 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/entityeffect/EntityEffectPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/entityeffect/EntityEffectPacketGenerator.java @@ -13,9 +13,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class EntityEffectPacketGenerator extends SimpleAssetPacketGenerator> { - public EntityEffectPacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedLookupTableAssetMap assetMap, @Nonnull Map assets) { UpdateEntityEffects packet = new UpdateEntityEffects(); diff --git a/src/com/hypixel/hytale/server/core/asset/type/entityeffect/config/OverlapBehavior.java b/src/com/hypixel/hytale/server/core/asset/type/entityeffect/config/OverlapBehavior.java index f194280..23f03ad 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/entityeffect/config/OverlapBehavior.java +++ b/src/com/hypixel/hytale/server/core/asset/type/entityeffect/config/OverlapBehavior.java @@ -10,7 +10,4 @@ public enum OverlapBehavior { @Nonnull public static final EnumCodec CODEC = new EnumCodec<>(OverlapBehavior.class); - - private OverlapBehavior() { - } } diff --git a/src/com/hypixel/hytale/server/core/asset/type/entityeffect/config/RemovalBehavior.java b/src/com/hypixel/hytale/server/core/asset/type/entityeffect/config/RemovalBehavior.java index e44862a..00fc99c 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/entityeffect/config/RemovalBehavior.java +++ b/src/com/hypixel/hytale/server/core/asset/type/entityeffect/config/RemovalBehavior.java @@ -10,7 +10,4 @@ public enum RemovalBehavior { @Nonnull public static final EnumCodec CODEC = new EnumCodec<>(RemovalBehavior.class); - - private RemovalBehavior() { - } } diff --git a/src/com/hypixel/hytale/server/core/asset/type/environment/EnvironmentPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/environment/EnvironmentPacketGenerator.java index 4b209ef..d591419 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/environment/EnvironmentPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/environment/EnvironmentPacketGenerator.java @@ -14,9 +14,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class EnvironmentPacketGenerator extends AssetPacketGenerator> { - public EnvironmentPacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedLookupTableAssetMap assetMap, @Nonnull Map assets) { Map assetsFromMap = assetMap.getAssetMap(); diff --git a/src/com/hypixel/hytale/server/core/asset/type/equalizereffect/EqualizerEffectPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/equalizereffect/EqualizerEffectPacketGenerator.java index 1510243..dc9aad6 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/equalizereffect/EqualizerEffectPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/equalizereffect/EqualizerEffectPacketGenerator.java @@ -13,9 +13,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class EqualizerEffectPacketGenerator extends SimpleAssetPacketGenerator> { - public EqualizerEffectPacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedLookupTableAssetMap assetMap, @Nonnull Map assets) { UpdateEqualizerEffects packet = new UpdateEqualizerEffects(); diff --git a/src/com/hypixel/hytale/server/core/asset/type/fluid/DefaultFluidTicker.java b/src/com/hypixel/hytale/server/core/asset/type/fluid/DefaultFluidTicker.java index 5ac48cc..4ec5645 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/fluid/DefaultFluidTicker.java +++ b/src/com/hypixel/hytale/server/core/asset/type/fluid/DefaultFluidTicker.java @@ -53,9 +53,6 @@ public class DefaultFluidTicker extends FluidTicker { @Nullable private transient Int2ObjectMap collisionMap = null; - public DefaultFluidTicker() { - } - @Nonnull @Override protected BlockTickStrategy spread( @@ -86,24 +83,8 @@ public class DefaultFluidTicker extends FluidTicker { int spreadFluidId = this.getSpreadFluidId(fluidId); int blockIdBelow = blockSectionBelow.get(worldX, worldY - 1, worldZ); BlockType blockBelow = blockMap.getAsset(blockIdBelow); - if (!isSolid(blockBelow)) { - DefaultFluidTicker.FluidCollisionConfig config = this.getCollisionMap().get(fluidBelowId); - if (config != null && !executeCollision(world, accessor, fluidSectionBelow, blockSectionBelow, config, worldX, worldY - 1, worldZ)) { - return BlockTickStrategy.CONTINUE; - } else { - if (fluidBelowId == 0 && !isSolid(blockBelow) || fluidBelowId == spreadFluidId && fluidLevelBelow < fluidBelow.getMaxFluidLevel()) { - int spreadId = this.getSpreadFluidId(fluidId); - Fluid spreadFluid = fluidMap.getAsset(spreadId); - boolean changed = fluidSectionBelow.setFluid(worldX, worldY - 1, worldZ, spreadId, (byte)spreadFluid.getMaxFluidLevel()); - if (changed) { - blockSectionBelow.setTicking(worldX, worldY - 1, worldZ, true); - } - } - - return BlockTickStrategy.SLEEP; - } - } else { - if (fluidBelowId == 0) { + if (isSolid(blockBelow) || fluidBelowId != 0 && fluidBelowId != spreadFluidId && fluidBelowId == fluidId) { + if (fluidBelowId == 0 || fluidBelowId != spreadFluidId) { if (fluidLevel == 1 && fluid.getMaxFluidLevel() != 1) { return BlockTickStrategy.SLEEP; } @@ -165,6 +146,22 @@ public class DefaultFluidTicker extends FluidTicker { } return BlockTickStrategy.SLEEP; + } else { + DefaultFluidTicker.FluidCollisionConfig config = this.getCollisionMap().get(fluidBelowId); + if (config != null && !executeCollision(world, accessor, fluidSectionBelow, blockSectionBelow, config, worldX, worldY - 1, worldZ)) { + return BlockTickStrategy.CONTINUE; + } else { + if (fluidBelowId == 0 && !isSolid(blockBelow) || fluidBelowId == spreadFluidId && fluidLevelBelow < fluidBelow.getMaxFluidLevel()) { + int spreadId = this.getSpreadFluidId(fluidId); + Fluid spreadFluid = fluidMap.getAsset(spreadId); + boolean changed = fluidSectionBelow.setFluid(worldX, worldY - 1, worldZ, spreadId, (byte)spreadFluid.getMaxFluidLevel()); + if (changed) { + blockSectionBelow.setTicking(worldX, worldY - 1, worldZ, true); + } + } + + return BlockTickStrategy.SLEEP; + } } } else { return BlockTickStrategy.SLEEP; @@ -258,9 +255,6 @@ public class DefaultFluidTicker extends FluidTicker { private String soundEvent; private int soundEventIndex = Integer.MIN_VALUE; - public FluidCollisionConfig() { - } - public int getBlockToPlaceIndex() { if (this.blockToPlaceIndex == Integer.MIN_VALUE && this.blockToPlace != null) { this.blockToPlaceIndex = BlockType.getBlockIdOrUnknown(this.blockToPlace, "Unknown block type %s", this.blockToPlace); diff --git a/src/com/hypixel/hytale/server/core/asset/type/fluid/FiniteFluidTicker.java b/src/com/hypixel/hytale/server/core/asset/type/fluid/FiniteFluidTicker.java index 56ab11d..1e2e038 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/fluid/FiniteFluidTicker.java +++ b/src/com/hypixel/hytale/server/core/asset/type/fluid/FiniteFluidTicker.java @@ -28,9 +28,6 @@ public class FiniteFluidTicker extends FluidTicker { private static final List> OFFSETS_LISTS = new ObjectArrayList<>(); private static final int RANDOM_VARIANTS = 16; - public FiniteFluidTicker() { - } - @Nonnull @Override protected FluidTicker.AliveStatus isAlive( @@ -376,8 +373,5 @@ public class FiniteFluidTicker extends FluidTicker { private static enum SpreadOutcome { SUCCESS, UNLOADED_CHUNK; - - private SpreadOutcome() { - } } } diff --git a/src/com/hypixel/hytale/server/core/asset/type/fluid/Fluid.java b/src/com/hypixel/hytale/server/core/asset/type/fluid/Fluid.java index e4db086..0304778 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/fluid/Fluid.java +++ b/src/com/hypixel/hytale/server/core/asset/type/fluid/Fluid.java @@ -264,6 +264,20 @@ public class Fluid implements JsonAssetWithMap> { - public FluidTypePacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedLookupTableAssetMap assetMap, @Nonnull Map assets) { UpdateFluids packet = new UpdateFluids(); diff --git a/src/com/hypixel/hytale/server/core/asset/type/fluidfx/FluidFXPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/fluidfx/FluidFXPacketGenerator.java index d064693..013f17b 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/fluidfx/FluidFXPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/fluidfx/FluidFXPacketGenerator.java @@ -13,9 +13,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class FluidFXPacketGenerator extends SimpleAssetPacketGenerator> { - public FluidFXPacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedLookupTableAssetMap assetMap, @Nonnull Map assets) { UpdateFluidFX packet = new UpdateFluidFX(); diff --git a/src/com/hypixel/hytale/server/core/asset/type/gameplay/BrokenPenalties.java b/src/com/hypixel/hytale/server/core/asset/type/gameplay/BrokenPenalties.java index ca07c1f..a816949 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/gameplay/BrokenPenalties.java +++ b/src/com/hypixel/hytale/server/core/asset/type/gameplay/BrokenPenalties.java @@ -17,9 +17,6 @@ public class BrokenPenalties { private Double armor; private Double weapon; - public BrokenPenalties() { - } - public double getTool(double defaultValue) { return this.tool == null ? defaultValue : this.tool; } diff --git a/src/com/hypixel/hytale/server/core/asset/type/gameplay/CameraEffectsConfig.java b/src/com/hypixel/hytale/server/core/asset/type/gameplay/CameraEffectsConfig.java index 568f892..913561f 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/gameplay/CameraEffectsConfig.java +++ b/src/com/hypixel/hytale/server/core/asset/type/gameplay/CameraEffectsConfig.java @@ -42,9 +42,6 @@ public class CameraEffectsConfig { @Nonnull protected transient Int2IntMap damageEffectIndices = Int2IntMaps.EMPTY_MAP; - public CameraEffectsConfig() { - } - public int getCameraEffectIndex(int damageCauseIndex) { return this.damageEffectIndices.getOrDefault(damageCauseIndex, Integer.MIN_VALUE); } diff --git a/src/com/hypixel/hytale/server/core/asset/type/gameplay/CraftingConfig.java b/src/com/hypixel/hytale/server/core/asset/type/gameplay/CraftingConfig.java index 66c92ef..268065c 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/gameplay/CraftingConfig.java +++ b/src/com/hypixel/hytale/server/core/asset/type/gameplay/CraftingConfig.java @@ -15,7 +15,7 @@ public class CraftingConfig { gameplayConfig -> gameplayConfig.benchMaterialHorizontalChestSearchRadius, (gameplayConfig, parent) -> gameplayConfig.benchMaterialHorizontalChestSearchRadius = parent.benchMaterialHorizontalChestSearchRadius ) - .addValidator(Validators.range(0, 7)) + .addValidator(Validators.range(0, 14)) .documentation("The horizontal radius of search around a bench to use materials from the chests") .add() .appendInherited( @@ -24,7 +24,7 @@ public class CraftingConfig { gameplayConfig -> gameplayConfig.benchMaterialVerticalChestSearchRadius, (gameplayConfig, parent) -> gameplayConfig.benchMaterialVerticalChestSearchRadius = parent.benchMaterialVerticalChestSearchRadius ) - .addValidator(Validators.range(0, 7)) + .addValidator(Validators.range(0, 14)) .documentation("The vertical radius of search around a bench to use materials from the chests") .add() .appendInherited( @@ -37,13 +37,10 @@ public class CraftingConfig { .documentation("The maximum number of chests a crafting bench will draw materials from") .add() .build(); - protected int benchMaterialHorizontalChestSearchRadius = 7; - protected int benchMaterialVerticalChestSearchRadius = 3; + protected int benchMaterialHorizontalChestSearchRadius = 14; + protected int benchMaterialVerticalChestSearchRadius = 6; protected int benchMaterialChestLimit = 100; - public CraftingConfig() { - } - public int getBenchMaterialHorizontalChestSearchRadius() { return this.benchMaterialHorizontalChestSearchRadius; } diff --git a/src/com/hypixel/hytale/server/core/asset/type/gameplay/DeathConfig.java b/src/com/hypixel/hytale/server/core/asset/type/gameplay/DeathConfig.java index 06409e3..93b4a8b 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/gameplay/DeathConfig.java +++ b/src/com/hypixel/hytale/server/core/asset/type/gameplay/DeathConfig.java @@ -57,9 +57,6 @@ public class DeathConfig { protected double itemsAmountLossPercentage = 10.0; protected double itemsDurabilityLossPercentage = 10.0; - public DeathConfig() { - } - @Nonnull public RespawnController getRespawnController() { return this.respawnController; @@ -81,8 +78,5 @@ public class DeathConfig { NONE, ALL, CONFIGURED; - - private ItemsLossMode() { - } } } diff --git a/src/com/hypixel/hytale/server/core/asset/type/gameplay/GameplayConfig.java b/src/com/hypixel/hytale/server/core/asset/type/gameplay/GameplayConfig.java index d5fc6bc..25cb8b7 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/gameplay/GameplayConfig.java +++ b/src/com/hypixel/hytale/server/core/asset/type/gameplay/GameplayConfig.java @@ -171,9 +171,6 @@ public class GameplayConfig implements JsonAssetWithMap> getAssetStore() { if (ASSET_STORE == null) { ASSET_STORE = AssetRegistry.getAssetStore(GameplayConfig.class); diff --git a/src/com/hypixel/hytale/server/core/asset/type/gameplay/GatheringConfig.java b/src/com/hypixel/hytale/server/core/asset/type/gameplay/GatheringConfig.java index b58e8ec..de1bafe 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/gameplay/GatheringConfig.java +++ b/src/com/hypixel/hytale/server/core/asset/type/gameplay/GatheringConfig.java @@ -27,9 +27,6 @@ public class GatheringConfig { @Nonnull protected GatheringEffectsConfig incorrectToolConfig = new GatheringEffectsConfig(); - public GatheringConfig() { - } - @Nonnull public GatheringEffectsConfig getUnbreakableBlockConfig() { return this.unbreakableBlockConfig; diff --git a/src/com/hypixel/hytale/server/core/asset/type/gameplay/GatheringEffectsConfig.java b/src/com/hypixel/hytale/server/core/asset/type/gameplay/GatheringEffectsConfig.java index 73fe746..e4baf5c 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/gameplay/GatheringEffectsConfig.java +++ b/src/com/hypixel/hytale/server/core/asset/type/gameplay/GatheringEffectsConfig.java @@ -30,9 +30,6 @@ public class GatheringEffectsConfig { protected String soundEventId; protected transient int soundEventIndex; - public GatheringEffectsConfig() { - } - public String getParticleSystemId() { return this.particleSystemId; } diff --git a/src/com/hypixel/hytale/server/core/asset/type/gameplay/ItemDurabilityConfig.java b/src/com/hypixel/hytale/server/core/asset/type/gameplay/ItemDurabilityConfig.java index 9f89d4a..4a3d59a 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/gameplay/ItemDurabilityConfig.java +++ b/src/com/hypixel/hytale/server/core/asset/type/gameplay/ItemDurabilityConfig.java @@ -20,9 +20,6 @@ public class ItemDurabilityConfig { @Nonnull protected BrokenPenalties brokenPenalties = BrokenPenalties.DEFAULT; - public ItemDurabilityConfig() { - } - @Nonnull public BrokenPenalties getBrokenPenalties() { return this.brokenPenalties; diff --git a/src/com/hypixel/hytale/server/core/asset/type/gameplay/PlayerConfig.java b/src/com/hypixel/hytale/server/core/asset/type/gameplay/PlayerConfig.java index 68ed8ee..206adf1 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/gameplay/PlayerConfig.java +++ b/src/com/hypixel/hytale/server/core/asset/type/gameplay/PlayerConfig.java @@ -3,6 +3,7 @@ package com.hypixel.hytale.server.core.asset.type.gameplay; import com.hypixel.hytale.codec.Codec; import com.hypixel.hytale.codec.KeyedCodec; import com.hypixel.hytale.codec.builder.BuilderCodec; +import com.hypixel.hytale.codec.codecs.EnumCodec; import com.hypixel.hytale.server.core.entity.entities.player.movement.MovementConfig; import com.hypixel.hytale.server.core.modules.entity.hitboxcollision.HitboxCollisionConfig; import com.hypixel.hytale.server.core.modules.entity.repulsion.RepulsionConfig; @@ -45,6 +46,13 @@ public class PlayerConfig { (playerConfig, parent) -> playerConfig.maxDeployableEntities = parent.maxDeployableEntities ) .add() + .appendInherited( + new KeyedCodec<>("ArmorVisibilityOption", new EnumCodec<>(PlayerConfig.ArmorVisibilityOption.class)), + (playerConfig, armorVisibilityOption1) -> playerConfig.armorVisibilityOption = armorVisibilityOption1, + playerConfig -> playerConfig.armorVisibilityOption, + (playerConfig, parent) -> playerConfig.armorVisibilityOption = parent.armorVisibilityOption + ) + .add() .afterDecode(playerConfig -> { if (playerConfig.hitboxCollisionConfigId != null) { playerConfig.hitboxCollisionConfigIndex = HitboxCollisionConfig.getAssetMap().getIndexOrDefault(playerConfig.hitboxCollisionConfigId, -1); @@ -66,9 +74,7 @@ public class PlayerConfig { protected int repulsionConfigIndex = -1; protected int movementConfigIndex = 0; protected int maxDeployableEntities = -1; - - public PlayerConfig() { - } + protected PlayerConfig.ArmorVisibilityOption armorVisibilityOption = PlayerConfig.ArmorVisibilityOption.ALL; public int getHitboxCollisionConfigIndex() { return this.hitboxCollisionConfigIndex; @@ -89,4 +95,42 @@ public class PlayerConfig { public int getMaxDeployableEntities() { return this.maxDeployableEntities; } + + public PlayerConfig.ArmorVisibilityOption getArmorVisibilityOption() { + return this.armorVisibilityOption; + } + + public static enum ArmorVisibilityOption { + ALL(true, true, true, true), + HELMET_ONLY(true, false, false, false), + NONE(false, false, false, false); + + private final boolean canHideHelmet; + private final boolean canHideCuirass; + private final boolean canHideGauntlets; + private final boolean canHidePants; + + private ArmorVisibilityOption(boolean canHideHelmet, boolean canHideCuirass, boolean canHideGauntlets, boolean canHidePants) { + this.canHideHelmet = canHideHelmet; + this.canHideCuirass = canHideCuirass; + this.canHideGauntlets = canHideGauntlets; + this.canHidePants = canHidePants; + } + + public boolean canHideHelmet() { + return this.canHideHelmet; + } + + public boolean canHideCuirass() { + return this.canHideCuirass; + } + + public boolean canHideGauntlets() { + return this.canHideGauntlets; + } + + public boolean canHidePants() { + return this.canHidePants; + } + } } diff --git a/src/com/hypixel/hytale/server/core/asset/type/gameplay/RespawnConfig.java b/src/com/hypixel/hytale/server/core/asset/type/gameplay/RespawnConfig.java index bbf8628..deb5cbb 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/gameplay/RespawnConfig.java +++ b/src/com/hypixel/hytale/server/core/asset/type/gameplay/RespawnConfig.java @@ -27,9 +27,6 @@ public class RespawnConfig { protected int radiusLimitRespawnPoint = 500; protected int maxRespawnPointsPerPlayer = 3; - public RespawnConfig() { - } - public int getRadiusLimitRespawnPoint() { return this.radiusLimitRespawnPoint; } diff --git a/src/com/hypixel/hytale/server/core/asset/type/gameplay/SleepConfig.java b/src/com/hypixel/hytale/server/core/asset/type/gameplay/SleepConfig.java index 868033f..71aec8c 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/gameplay/SleepConfig.java +++ b/src/com/hypixel/hytale/server/core/asset/type/gameplay/SleepConfig.java @@ -27,9 +27,6 @@ public class SleepConfig { private float wakeUpHour = 5.5F; private double[] allowedSleepHoursRange; - public SleepConfig() { - } - public float getWakeUpHour() { return this.wakeUpHour; } diff --git a/src/com/hypixel/hytale/server/core/asset/type/gameplay/SpawnConfig.java b/src/com/hypixel/hytale/server/core/asset/type/gameplay/SpawnConfig.java index d043cb2..dd4f81d 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/gameplay/SpawnConfig.java +++ b/src/com/hypixel/hytale/server/core/asset/type/gameplay/SpawnConfig.java @@ -28,9 +28,6 @@ public class SpawnConfig { protected WorldParticle[] firstSpawnParticles; protected WorldParticle[] spawnParticles; - public SpawnConfig() { - } - @Nullable public WorldParticle[] getFirstSpawnParticles() { return this.firstSpawnParticles; diff --git a/src/com/hypixel/hytale/server/core/asset/type/gameplay/WorldConfig.java b/src/com/hypixel/hytale/server/core/asset/type/gameplay/WorldConfig.java index 1f99299..457f3cb 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/gameplay/WorldConfig.java +++ b/src/com/hypixel/hytale/server/core/asset/type/gameplay/WorldConfig.java @@ -67,9 +67,6 @@ public class WorldConfig { protected float blockPlacementFragilityTimer; private SleepConfig sleepConfig = SleepConfig.DEFAULT; - public WorldConfig() { - } - public boolean isBlockBreakingAllowed() { return this.allowBlockBreaking; } diff --git a/src/com/hypixel/hytale/server/core/asset/type/gameplay/WorldMapConfig.java b/src/com/hypixel/hytale/server/core/asset/type/gameplay/WorldMapConfig.java index c142c81..f78ad33 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/gameplay/WorldMapConfig.java +++ b/src/com/hypixel/hytale/server/core/asset/type/gameplay/WorldMapConfig.java @@ -34,9 +34,6 @@ public class WorldMapConfig { protected boolean displayDeathMarker = true; protected boolean displayPlayers = true; - public WorldMapConfig() { - } - public boolean isDisplaySpawn() { return this.displaySpawn; } diff --git a/src/com/hypixel/hytale/server/core/asset/type/gameplay/respawn/HomeOrSpawnPoint.java b/src/com/hypixel/hytale/server/core/asset/type/gameplay/respawn/HomeOrSpawnPoint.java index a467dc4..640a053 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/gameplay/respawn/HomeOrSpawnPoint.java +++ b/src/com/hypixel/hytale/server/core/asset/type/gameplay/respawn/HomeOrSpawnPoint.java @@ -1,13 +1,13 @@ package com.hypixel.hytale.server.core.asset.type.gameplay.respawn; import com.hypixel.hytale.codec.builder.BuilderCodec; -import com.hypixel.hytale.component.CommandBuffer; +import com.hypixel.hytale.component.ComponentAccessor; import com.hypixel.hytale.component.Ref; -import com.hypixel.hytale.math.vector.Transform; import com.hypixel.hytale.server.core.entity.entities.Player; import com.hypixel.hytale.server.core.modules.entity.teleport.Teleport; import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; +import java.util.concurrent.CompletableFuture; import javax.annotation.Nonnull; public class HomeOrSpawnPoint implements RespawnController { @@ -16,12 +16,15 @@ public class HomeOrSpawnPoint implements RespawnController { @Nonnull public static final BuilderCodec CODEC = BuilderCodec.builder(HomeOrSpawnPoint.class, () -> INSTANCE).build(); - public HomeOrSpawnPoint() { - } - @Override - public void respawnPlayer(@Nonnull World world, @Nonnull Ref playerReference, @Nonnull CommandBuffer commandBuffer) { - Transform homePosition = Player.getRespawnPosition(playerReference, world.getName(), commandBuffer); - commandBuffer.addComponent(playerReference, Teleport.getComponentType(), new Teleport(null, homePosition)); + public CompletableFuture respawnPlayer( + @Nonnull World world, @Nonnull Ref playerReference, @Nonnull ComponentAccessor commandBuffer + ) { + return Player.getRespawnPosition(playerReference, world.getName(), commandBuffer).thenAcceptAsync(homeTransform -> { + if (playerReference.isValid()) { + Teleport teleportComponent = Teleport.createForPlayer(homeTransform); + playerReference.getStore().addComponent(playerReference, Teleport.getComponentType(), teleportComponent); + } + }, world); } } diff --git a/src/com/hypixel/hytale/server/core/asset/type/gameplay/respawn/RespawnController.java b/src/com/hypixel/hytale/server/core/asset/type/gameplay/respawn/RespawnController.java index f386f02..59a16e6 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/gameplay/respawn/RespawnController.java +++ b/src/com/hypixel/hytale/server/core/asset/type/gameplay/respawn/RespawnController.java @@ -1,15 +1,16 @@ package com.hypixel.hytale.server.core.asset.type.gameplay.respawn; import com.hypixel.hytale.codec.lookup.CodecMapCodec; -import com.hypixel.hytale.component.CommandBuffer; +import com.hypixel.hytale.component.ComponentAccessor; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; +import java.util.concurrent.CompletableFuture; import javax.annotation.Nonnull; public interface RespawnController { @Nonnull CodecMapCodec CODEC = new CodecMapCodec<>("Type"); - void respawnPlayer(@Nonnull World var1, @Nonnull Ref var2, @Nonnull CommandBuffer var3); + CompletableFuture respawnPlayer(@Nonnull World var1, @Nonnull Ref var2, @Nonnull ComponentAccessor var3); } diff --git a/src/com/hypixel/hytale/server/core/asset/type/gameplay/respawn/WorldSpawnPoint.java b/src/com/hypixel/hytale/server/core/asset/type/gameplay/respawn/WorldSpawnPoint.java index c8f4179..a0f44ff 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/gameplay/respawn/WorldSpawnPoint.java +++ b/src/com/hypixel/hytale/server/core/asset/type/gameplay/respawn/WorldSpawnPoint.java @@ -1,26 +1,32 @@ package com.hypixel.hytale.server.core.asset.type.gameplay.respawn; import com.hypixel.hytale.codec.builder.BuilderCodec; -import com.hypixel.hytale.component.CommandBuffer; +import com.hypixel.hytale.component.ComponentAccessor; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.math.vector.Transform; import com.hypixel.hytale.server.core.modules.entity.teleport.Teleport; import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.spawn.ISpawnProvider; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; +import java.util.concurrent.CompletableFuture; +import javax.annotation.Nonnull; public class WorldSpawnPoint implements RespawnController { public static final WorldSpawnPoint INSTANCE = new WorldSpawnPoint(); + @Nonnull public static final BuilderCodec CODEC = BuilderCodec.builder(WorldSpawnPoint.class, () -> INSTANCE).build(); - public WorldSpawnPoint() { - } - @Override - public void respawnPlayer(@NonNullDecl World world, @NonNullDecl Ref playerReference, @NonNullDecl CommandBuffer commandBuffer) { + public CompletableFuture respawnPlayer( + @Nonnull World world, @Nonnull Ref playerReference, @Nonnull ComponentAccessor commandBuffer + ) { ISpawnProvider spawnProvider = world.getWorldConfig().getSpawnProvider(); + + assert spawnProvider != null; + Transform spawnPoint = spawnProvider.getSpawnPoint(playerReference, commandBuffer); - commandBuffer.addComponent(playerReference, Teleport.getComponentType(), new Teleport(null, spawnPoint)); + Teleport teleportComponent = Teleport.createForPlayer(spawnPoint); + commandBuffer.addComponent(playerReference, Teleport.getComponentType(), teleportComponent); + return CompletableFuture.completedFuture(null); } } diff --git a/src/com/hypixel/hytale/server/core/asset/type/item/DroplistCommand.java b/src/com/hypixel/hytale/server/core/asset/type/item/DroplistCommand.java index 81cfc1d..fec19db 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/item/DroplistCommand.java +++ b/src/com/hypixel/hytale/server/core/asset/type/item/DroplistCommand.java @@ -13,7 +13,6 @@ import com.hypixel.hytale.server.core.modules.item.ItemModule; import java.util.LinkedHashMap; import java.util.Map.Entry; import javax.annotation.Nonnull; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class DroplistCommand extends CommandBase { @Nonnull @@ -26,7 +25,7 @@ public class DroplistCommand extends CommandBase { } @Override - protected void executeSync(@NonNullDecl CommandContext context) { + protected void executeSync(@Nonnull CommandContext context) { String droplistId = this.itemDroplistArg.get(context); ItemDropList itemDropList = ItemDropList.getAssetMap().getAsset(droplistId); if (itemDropList == null) { diff --git a/src/com/hypixel/hytale/server/core/asset/type/item/FieldcraftCategoryPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/item/FieldcraftCategoryPacketGenerator.java index 0b497fa..624ba0d 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/item/FieldcraftCategoryPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/item/FieldcraftCategoryPacketGenerator.java @@ -12,9 +12,6 @@ import java.util.Set; import javax.annotation.Nonnull; public class FieldcraftCategoryPacketGenerator extends DefaultAssetPacketGenerator { - public FieldcraftCategoryPacketGenerator() { - } - @Nonnull @Override public Packet generateInitPacket(@Nonnull DefaultAssetMap assetMap, @Nonnull Map assets) { diff --git a/src/com/hypixel/hytale/server/core/asset/type/item/ItemCategoryPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/item/ItemCategoryPacketGenerator.java index 7a669db..55c5fe5 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/item/ItemCategoryPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/item/ItemCategoryPacketGenerator.java @@ -11,9 +11,6 @@ import java.util.Set; import javax.annotation.Nonnull; public class ItemCategoryPacketGenerator extends DefaultAssetPacketGenerator { - public ItemCategoryPacketGenerator() { - } - @Nonnull @Override public Packet generateInitPacket(@Nonnull DefaultAssetMap assetMap, @Nonnull Map assets) { diff --git a/src/com/hypixel/hytale/server/core/asset/type/item/ResourceTypePacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/item/ResourceTypePacketGenerator.java index 665ed97..38e0422 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/item/ResourceTypePacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/item/ResourceTypePacketGenerator.java @@ -13,9 +13,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class ResourceTypePacketGenerator extends DefaultAssetPacketGenerator { - public ResourceTypePacketGenerator() { - } - @Nonnull @Override public Packet generateInitPacket(@Nonnull DefaultAssetMap assetMap, @Nonnull Map assets) { diff --git a/src/com/hypixel/hytale/server/core/asset/type/item/config/BlockGroup.java b/src/com/hypixel/hytale/server/core/asset/type/item/config/BlockGroup.java index 111e415..ac142f2 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/item/config/BlockGroup.java +++ b/src/com/hypixel/hytale/server/core/asset/type/item/config/BlockGroup.java @@ -25,9 +25,6 @@ public class BlockGroup implements JsonAssetWithMap getAssetMap() { return (DefaultAssetMap)getAssetStore().getAssetMap(); } diff --git a/src/com/hypixel/hytale/server/core/asset/type/item/config/Item.java b/src/com/hypixel/hytale/server/core/asset/type/item/config/Item.java index fa2b921..12892a8 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/item/config/Item.java +++ b/src/com/hypixel/hytale/server/core/asset/type/item/config/Item.java @@ -1070,7 +1070,7 @@ public class Item implements JsonAssetWithMap getStatModifiers() { return this.statModifiers; diff --git a/src/com/hypixel/hytale/server/core/asset/type/item/config/PortalKey.java b/src/com/hypixel/hytale/server/core/asset/type/item/config/PortalKey.java index 0bfc46d..491ad85 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/item/config/PortalKey.java +++ b/src/com/hypixel/hytale/server/core/asset/type/item/config/PortalKey.java @@ -29,9 +29,6 @@ public class PortalKey { private String portalTypeId; private int timeLimitSeconds = -1; - public PortalKey() { - } - public String getPortalTypeId() { return this.portalTypeId; } diff --git a/src/com/hypixel/hytale/server/core/asset/type/item/config/container/DroplistItemDropContainer.java b/src/com/hypixel/hytale/server/core/asset/type/item/config/container/DroplistItemDropContainer.java index a799805..6b9077e 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/item/config/container/DroplistItemDropContainer.java +++ b/src/com/hypixel/hytale/server/core/asset/type/item/config/container/DroplistItemDropContainer.java @@ -25,9 +25,6 @@ public class DroplistItemDropContainer extends ItemDropContainer { .build(); String droplistId; - public DroplistItemDropContainer() { - } - @Override protected void populateDrops(List drops, DoubleSupplier chanceProvider, Set droplistReferences) { if (droplistReferences.add(this.droplistId)) { diff --git a/src/com/hypixel/hytale/server/core/asset/type/item/config/container/EmptyItemDropContainer.java b/src/com/hypixel/hytale/server/core/asset/type/item/config/container/EmptyItemDropContainer.java index 2703348..bfdf2cc 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/item/config/container/EmptyItemDropContainer.java +++ b/src/com/hypixel/hytale/server/core/asset/type/item/config/container/EmptyItemDropContainer.java @@ -13,9 +13,6 @@ public class EmptyItemDropContainer extends ItemDropContainer { ) .build(); - public EmptyItemDropContainer() { - } - @Override protected void populateDrops(List drops, @Nonnull DoubleSupplier chanceProvider, Set droplistReferences) { } diff --git a/src/com/hypixel/hytale/server/core/asset/type/item/config/metadata/AdventureMetadata.java b/src/com/hypixel/hytale/server/core/asset/type/item/config/metadata/AdventureMetadata.java index 5775902..3b46b35 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/item/config/metadata/AdventureMetadata.java +++ b/src/com/hypixel/hytale/server/core/asset/type/item/config/metadata/AdventureMetadata.java @@ -18,9 +18,6 @@ public class AdventureMetadata { public static final KeyedCodec KEYED_CODEC = new KeyedCodec<>("Adventure", CODEC); private boolean cursed; - public AdventureMetadata() { - } - public boolean isCursed() { return this.cursed; } diff --git a/src/com/hypixel/hytale/server/core/asset/type/itemanimation/ItemPlayerAnimationsPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/itemanimation/ItemPlayerAnimationsPacketGenerator.java index 8a7b823..3fd7626 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/itemanimation/ItemPlayerAnimationsPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/itemanimation/ItemPlayerAnimationsPacketGenerator.java @@ -12,9 +12,6 @@ import java.util.Set; import javax.annotation.Nonnull; public class ItemPlayerAnimationsPacketGenerator extends DefaultAssetPacketGenerator { - public ItemPlayerAnimationsPacketGenerator() { - } - @Nonnull @Override public Packet generateInitPacket(DefaultAssetMap assetMap, @Nonnull Map assets) { diff --git a/src/com/hypixel/hytale/server/core/asset/type/itemsound/ItemSoundSetPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/itemsound/ItemSoundSetPacketGenerator.java index 95fde9d..47ade80 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/itemsound/ItemSoundSetPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/itemsound/ItemSoundSetPacketGenerator.java @@ -13,9 +13,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class ItemSoundSetPacketGenerator extends SimpleAssetPacketGenerator> { - public ItemSoundSetPacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedLookupTableAssetMap assetMap, @Nonnull Map assets) { UpdateItemSoundSets packet = new UpdateItemSoundSets(); diff --git a/src/com/hypixel/hytale/server/core/asset/type/model/config/ModelAsset.java b/src/com/hypixel/hytale/server/core/asset/type/model/config/ModelAsset.java index a7b0fa3..e50114c 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/model/config/ModelAsset.java +++ b/src/com/hypixel/hytale/server/core/asset/type/model/config/ModelAsset.java @@ -315,9 +315,6 @@ public class ModelAsset implements JsonAssetWithMap> getAssetStore() { if (ASSET_STORE == null) { ASSET_STORE = AssetRegistry.getAssetStore(ModelAsset.class); diff --git a/src/com/hypixel/hytale/server/core/asset/type/modelvfx/ModelVFXPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/modelvfx/ModelVFXPacketGenerator.java index 96c3f11..81720e0 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/modelvfx/ModelVFXPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/modelvfx/ModelVFXPacketGenerator.java @@ -13,9 +13,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class ModelVFXPacketGenerator extends SimpleAssetPacketGenerator> { - public ModelVFXPacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedLookupTableAssetMap assetMap, @Nonnull Map assets) { UpdateModelvfxs packet = new UpdateModelvfxs(); diff --git a/src/com/hypixel/hytale/server/core/asset/type/particle/ParticleSpawnerPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/particle/ParticleSpawnerPacketGenerator.java index 5219809..caeef11 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/particle/ParticleSpawnerPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/particle/ParticleSpawnerPacketGenerator.java @@ -13,9 +13,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class ParticleSpawnerPacketGenerator extends DefaultAssetPacketGenerator { - public ParticleSpawnerPacketGenerator() { - } - @Nonnull @Override public Packet generateInitPacket(DefaultAssetMap assetMap, @Nonnull Map assets) { diff --git a/src/com/hypixel/hytale/server/core/asset/type/particle/ParticleSystemPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/particle/ParticleSystemPacketGenerator.java index e869720..f9fd8db 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/particle/ParticleSystemPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/particle/ParticleSystemPacketGenerator.java @@ -13,9 +13,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class ParticleSystemPacketGenerator extends DefaultAssetPacketGenerator { - public ParticleSystemPacketGenerator() { - } - @Nonnull @Override public Packet generateInitPacket(DefaultAssetMap assetMap, @Nonnull Map assets) { diff --git a/src/com/hypixel/hytale/server/core/asset/type/particle/pages/ParticleSpawnPage.java b/src/com/hypixel/hytale/server/core/asset/type/particle/pages/ParticleSpawnPage.java index 0b91f35..6639f84 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/particle/pages/ParticleSpawnPage.java +++ b/src/com/hypixel/hytale/server/core/asset/type/particle/pages/ParticleSpawnPage.java @@ -268,8 +268,5 @@ public class ParticleSpawnPage extends InteractiveCustomUIPage cursedItems = Collections.emptySet(); - public PortalType() { - } - public static AssetStore> getAssetStore() { if (ASSET_STORE == null) { ASSET_STORE = AssetRegistry.getAssetStore(PortalType.class); diff --git a/src/com/hypixel/hytale/server/core/asset/type/reverbeffect/ReverbEffectPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/reverbeffect/ReverbEffectPacketGenerator.java index 100d212..188ae96 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/reverbeffect/ReverbEffectPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/reverbeffect/ReverbEffectPacketGenerator.java @@ -13,9 +13,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class ReverbEffectPacketGenerator extends SimpleAssetPacketGenerator> { - public ReverbEffectPacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedLookupTableAssetMap assetMap, @Nonnull Map assets) { UpdateReverbEffects packet = new UpdateReverbEffects(); diff --git a/src/com/hypixel/hytale/server/core/asset/type/soundevent/SoundEventPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/soundevent/SoundEventPacketGenerator.java index 8daa71e..c79227a 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/soundevent/SoundEventPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/soundevent/SoundEventPacketGenerator.java @@ -13,9 +13,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class SoundEventPacketGenerator extends SimpleAssetPacketGenerator> { - public SoundEventPacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedLookupTableAssetMap assetMap, @Nonnull Map assets) { UpdateSoundEvents packet = new UpdateSoundEvents(); diff --git a/src/com/hypixel/hytale/server/core/asset/type/soundevent/config/SoundEventLayer.java b/src/com/hypixel/hytale/server/core/asset/type/soundevent/config/SoundEventLayer.java index 7894a7d..5469711 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/soundevent/config/SoundEventLayer.java +++ b/src/com/hypixel/hytale/server/core/asset/type/soundevent/config/SoundEventLayer.java @@ -248,9 +248,6 @@ public class SoundEventLayer implements NetworkSerializable STEREO_VALIDATOR_CACHE = new ValidatorCache<>(STEREO); public static final ValidatorCache ONESHOT_VALIDATOR_CACHE = new ValidatorCache<>(ONESHOT); - public SoundEventValidators() { - } - public static class ChannelValidator implements Validator { private final int channelCount; diff --git a/src/com/hypixel/hytale/server/core/asset/type/soundset/SoundSetPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/soundset/SoundSetPacketGenerator.java index 90f4178..eae4c5a 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/soundset/SoundSetPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/soundset/SoundSetPacketGenerator.java @@ -13,9 +13,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class SoundSetPacketGenerator extends SimpleAssetPacketGenerator> { - public SoundSetPacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedLookupTableAssetMap assetMap, @Nonnull Map assets) { UpdateSoundSets packet = new UpdateSoundSets(); diff --git a/src/com/hypixel/hytale/server/core/asset/type/tagpattern/TagPatternPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/tagpattern/TagPatternPacketGenerator.java index 4ea2480..4054cfe 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/tagpattern/TagPatternPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/tagpattern/TagPatternPacketGenerator.java @@ -13,9 +13,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class TagPatternPacketGenerator extends SimpleAssetPacketGenerator> { - public TagPatternPacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedLookupTableAssetMap assetMap, @Nonnull Map assets) { UpdateTagPatterns packet = new UpdateTagPatterns(); diff --git a/src/com/hypixel/hytale/server/core/asset/type/tagpattern/config/AndPatternOp.java b/src/com/hypixel/hytale/server/core/asset/type/tagpattern/config/AndPatternOp.java index 5292dd0..75ef262 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/tagpattern/config/AndPatternOp.java +++ b/src/com/hypixel/hytale/server/core/asset/type/tagpattern/config/AndPatternOp.java @@ -11,9 +11,6 @@ public class AndPatternOp extends MultiplePatternOp { @Nonnull public static BuilderCodec CODEC = BuilderCodec.builder(AndPatternOp.class, AndPatternOp::new, MultiplePatternOp.CODEC).build(); - public AndPatternOp() { - } - @Override public boolean test(Int2ObjectMap tags) { for (int i = 0; i < this.patterns.length; i++) { diff --git a/src/com/hypixel/hytale/server/core/asset/type/tagpattern/config/MultiplePatternOp.java b/src/com/hypixel/hytale/server/core/asset/type/tagpattern/config/MultiplePatternOp.java index 5ccf844..d4add0f 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/tagpattern/config/MultiplePatternOp.java +++ b/src/com/hypixel/hytale/server/core/asset/type/tagpattern/config/MultiplePatternOp.java @@ -20,9 +20,6 @@ public abstract class MultiplePatternOp extends TagPattern { .build(); protected TagPattern[] patterns; - public MultiplePatternOp() { - } - public com.hypixel.hytale.protocol.TagPattern toPacket() { com.hypixel.hytale.protocol.TagPattern packet = new com.hypixel.hytale.protocol.TagPattern(); packet.operands = new com.hypixel.hytale.protocol.TagPattern[this.patterns.length]; diff --git a/src/com/hypixel/hytale/server/core/asset/type/tagpattern/config/NotPatternOp.java b/src/com/hypixel/hytale/server/core/asset/type/tagpattern/config/NotPatternOp.java index e9fbda5..5b38e05 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/tagpattern/config/NotPatternOp.java +++ b/src/com/hypixel/hytale/server/core/asset/type/tagpattern/config/NotPatternOp.java @@ -18,9 +18,6 @@ public class NotPatternOp extends TagPattern { .build(); protected TagPattern pattern; - public NotPatternOp() { - } - @Override public boolean test(Int2ObjectMap tags) { return !this.pattern.test(tags); diff --git a/src/com/hypixel/hytale/server/core/asset/type/tagpattern/config/OrPatternOp.java b/src/com/hypixel/hytale/server/core/asset/type/tagpattern/config/OrPatternOp.java index 09599b8..2dca913 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/tagpattern/config/OrPatternOp.java +++ b/src/com/hypixel/hytale/server/core/asset/type/tagpattern/config/OrPatternOp.java @@ -11,9 +11,6 @@ public class OrPatternOp extends MultiplePatternOp { @Nonnull public static BuilderCodec CODEC = BuilderCodec.builder(OrPatternOp.class, OrPatternOp::new, MultiplePatternOp.CODEC).build(); - public OrPatternOp() { - } - @Override public boolean test(Int2ObjectMap tags) { for (int i = 0; i < this.patterns.length; i++) { diff --git a/src/com/hypixel/hytale/server/core/asset/type/tagpattern/config/TagPattern.java b/src/com/hypixel/hytale/server/core/asset/type/tagpattern/config/TagPattern.java index 9b4f352..4286c9a 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/tagpattern/config/TagPattern.java +++ b/src/com/hypixel/hytale/server/core/asset/type/tagpattern/config/TagPattern.java @@ -31,9 +31,6 @@ public abstract class TagPattern protected String id; protected SoftReference cachedPacket; - public TagPattern() { - } - public static AssetStore> getAssetStore() { if (ASSET_STORE == null) { ASSET_STORE = AssetRegistry.getAssetStore(TagPattern.class); diff --git a/src/com/hypixel/hytale/server/core/asset/type/trail/TrailPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/trail/TrailPacketGenerator.java index 83db34f..1697485 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/trail/TrailPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/trail/TrailPacketGenerator.java @@ -13,9 +13,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class TrailPacketGenerator extends DefaultAssetPacketGenerator { - public TrailPacketGenerator() { - } - @Nonnull @Override public Packet generateInitPacket(DefaultAssetMap assetMap, @Nonnull Map assets) { diff --git a/src/com/hypixel/hytale/server/core/asset/type/trail/config/Animation.java b/src/com/hypixel/hytale/server/core/asset/type/trail/config/Animation.java index 2fa463e..9259ef0 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/trail/config/Animation.java +++ b/src/com/hypixel/hytale/server/core/asset/type/trail/config/Animation.java @@ -36,9 +36,6 @@ public class Animation { private Range frameRange; private int frameLifeSpan; - public Animation() { - } - public Vector2i getFrameSize() { return this.frameSize; } diff --git a/src/com/hypixel/hytale/server/core/asset/type/trail/config/Edge.java b/src/com/hypixel/hytale/server/core/asset/type/trail/config/Edge.java index 850b67b..a461d44 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/trail/config/Edge.java +++ b/src/com/hypixel/hytale/server/core/asset/type/trail/config/Edge.java @@ -24,9 +24,6 @@ public class Edge { private float width; private ColorAlpha color = new ColorAlpha((byte)-1, (byte)-1, (byte)-1, (byte)-1); - public Edge() { - } - @Nonnull public com.hypixel.hytale.protocol.Edge toPacket() { com.hypixel.hytale.protocol.Edge packet = new com.hypixel.hytale.protocol.Edge(); diff --git a/src/com/hypixel/hytale/server/core/asset/type/weather/WeatherPacketGenerator.java b/src/com/hypixel/hytale/server/core/asset/type/weather/WeatherPacketGenerator.java index 20035d9..4d024ce 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/weather/WeatherPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/asset/type/weather/WeatherPacketGenerator.java @@ -13,9 +13,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class WeatherPacketGenerator extends SimpleAssetPacketGenerator> { - public WeatherPacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedLookupTableAssetMap assetMap, @Nonnull Map assets) { UpdateWeathers packet = new UpdateWeathers(); diff --git a/src/com/hypixel/hytale/server/core/asset/type/weather/config/FogOptions.java b/src/com/hypixel/hytale/server/core/asset/type/weather/config/FogOptions.java index 350ce75..d6c4f39 100644 --- a/src/com/hypixel/hytale/server/core/asset/type/weather/config/FogOptions.java +++ b/src/com/hypixel/hytale/server/core/asset/type/weather/config/FogOptions.java @@ -51,9 +51,6 @@ public class FogOptions { private Float fogHeightCameraFixed = null; private float fogHeightCameraOffset = 0.0F; - public FogOptions() { - } - public boolean isIgnoreFogLimits() { return this.ignoreFogLimits; } diff --git a/src/com/hypixel/hytale/server/core/asset/util/ColorParseUtil.java b/src/com/hypixel/hytale/server/core/asset/util/ColorParseUtil.java index 27d46c8..ddd1c52 100644 --- a/src/com/hypixel/hytale/server/core/asset/util/ColorParseUtil.java +++ b/src/com/hypixel/hytale/server/core/asset/util/ColorParseUtil.java @@ -18,9 +18,6 @@ public class ColorParseUtil { public static final Pattern RGBA_COLOR_PATTERN = Pattern.compile("^\\s*rgba\\((\\s*[0-9]{1,3}\\s*,){3}\\s*[0,1](.[0-9]*)?\\s*\\)\\s*$"); public static final Pattern RGBA_HEX_COLOR_PATTERN = Pattern.compile("^\\s*rgba\\(\\s*#([0-9a-fA-F]{3}){1,2}\\s*,\\s*[0,1](.[0-9]*)?\\s*\\)\\s*$"); - public ColorParseUtil() { - } - @Nullable public static ColorAlpha readColorAlpha(@Nonnull RawJsonReader reader) throws IOException { reader.consumeWhiteSpace(); diff --git a/src/com/hypixel/hytale/server/core/auth/AuthConfig.java b/src/com/hypixel/hytale/server/core/auth/AuthConfig.java index 4a74f5d..c87aae0 100644 --- a/src/com/hypixel/hytale/server/core/auth/AuthConfig.java +++ b/src/com/hypixel/hytale/server/core/auth/AuthConfig.java @@ -18,7 +18,7 @@ public class AuthConfig { public static final String SCOPE_SERVER = "hytale:server"; public static final String SCOPE_EDITOR = "hytale:editor"; public static final int HTTP_TIMEOUT_SECONDS = 10; - public static final int DEVICE_POLL_INTERVAL_SECONDS = 5; + public static final int DEVICE_POLL_INTERVAL_SECONDS = 15; public static final String ENV_SERVER_AUDIENCE = "HYTALE_SERVER_AUDIENCE"; public static final String ENV_SERVER_IDENTITY_TOKEN = "HYTALE_SERVER_IDENTITY_TOKEN"; public static final String ENV_SERVER_SESSION_TOKEN = "HYTALE_SERVER_SESSION_TOKEN"; diff --git a/src/com/hypixel/hytale/server/core/auth/CertificateUtil.java b/src/com/hypixel/hytale/server/core/auth/CertificateUtil.java index 7fdc32d..bba63f9 100644 --- a/src/com/hypixel/hytale/server/core/auth/CertificateUtil.java +++ b/src/com/hypixel/hytale/server/core/auth/CertificateUtil.java @@ -14,9 +14,6 @@ import javax.annotation.Nullable; public class CertificateUtil { private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); - public CertificateUtil() { - } - @Nullable public static String computeCertificateFingerprint(@Nonnull X509Certificate certificate) { try { diff --git a/src/com/hypixel/hytale/server/core/auth/DefaultAuthCredentialStore.java b/src/com/hypixel/hytale/server/core/auth/DefaultAuthCredentialStore.java index 9b3eb93..85c51c3 100644 --- a/src/com/hypixel/hytale/server/core/auth/DefaultAuthCredentialStore.java +++ b/src/com/hypixel/hytale/server/core/auth/DefaultAuthCredentialStore.java @@ -9,9 +9,6 @@ public class DefaultAuthCredentialStore implements IAuthCredentialStore { @Nullable private UUID profile; - public DefaultAuthCredentialStore() { - } - @Override public void setTokens(@Nonnull IAuthCredentialStore.OAuthTokens tokens) { this.tokens = tokens; diff --git a/src/com/hypixel/hytale/server/core/auth/EncryptedAuthCredentialStore.java b/src/com/hypixel/hytale/server/core/auth/EncryptedAuthCredentialStore.java index 2ae8aa5..585aa3c 100644 --- a/src/com/hypixel/hytale/server/core/auth/EncryptedAuthCredentialStore.java +++ b/src/com/hypixel/hytale/server/core/auth/EncryptedAuthCredentialStore.java @@ -222,8 +222,5 @@ public class EncryptedAuthCredentialStore implements IAuthCredentialStore { Instant expiresAt; @Nullable UUID profileUuid; - - private StoredCredentials() { - } } } diff --git a/src/com/hypixel/hytale/server/core/auth/EncryptedAuthCredentialStoreProvider.java b/src/com/hypixel/hytale/server/core/auth/EncryptedAuthCredentialStoreProvider.java index dd78035..4d6f7f1 100644 --- a/src/com/hypixel/hytale/server/core/auth/EncryptedAuthCredentialStoreProvider.java +++ b/src/com/hypixel/hytale/server/core/auth/EncryptedAuthCredentialStoreProvider.java @@ -17,9 +17,6 @@ public class EncryptedAuthCredentialStoreProvider implements AuthCredentialStore .build(); private String path = "auth.enc"; - public EncryptedAuthCredentialStoreProvider() { - } - @Nonnull @Override public IAuthCredentialStore createStore() { diff --git a/src/com/hypixel/hytale/server/core/auth/JWTValidator.java b/src/com/hypixel/hytale/server/core/auth/JWTValidator.java index 5f63504..b9f5f73 100644 --- a/src/com/hypixel/hytale/server/core/auth/JWTValidator.java +++ b/src/com/hypixel/hytale/server/core/auth/JWTValidator.java @@ -12,6 +12,7 @@ import java.security.cert.X509Certificate; import java.text.ParseException; import java.time.Instant; import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.UUID; import java.util.concurrent.CompletableFuture; @@ -23,7 +24,10 @@ import javax.annotation.Nullable; public class JWTValidator { private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); + private static final long CLOCK_SKEW_SECONDS = 300L; private static final JWSAlgorithm SUPPORTED_ALGORITHM = JWSAlgorithm.EdDSA; + private static final int MIN_SIGNATURE_LENGTH = 80; + private static final int MAX_SIGNATURE_LENGTH = 90; private final SessionServiceClient sessionServiceClient; private final String expectedIssuer; private final String expectedAudience; @@ -39,10 +43,28 @@ public class JWTValidator { this.expectedAudience = expectedAudience; } + @Nullable + private static String validateJwtStructure(@Nonnull String token, @Nonnull String tokenType) { + if (token.isEmpty()) { + return tokenType + " is empty"; + } else { + String[] parts = token.split("\\.", -1); + if (parts.length != 3) { + return String.format("%s has invalid format (expected 3 parts, got %d)", tokenType, parts.length); + } else if (parts[2].isEmpty()) { + return tokenType + " has empty signature - possible signature stripping attack"; + } else { + int sigLen = parts[2].length(); + return sigLen >= 80 && sigLen <= 90 ? null : String.format("%s has invalid signature length: %d (expected %d-%d)", tokenType, sigLen, 80, 90); + } + } + } + @Nullable public JWTValidator.JWTClaims validateToken(@Nonnull String accessToken, @Nullable X509Certificate clientCert) { - if (accessToken.isEmpty()) { - LOGGER.at(Level.WARNING).log("Access token is empty"); + String structError = validateJwtStructure(accessToken, "Access token"); + if (structError != null) { + LOGGER.at(Level.WARNING).log(structError); return null; } else { try { @@ -78,27 +100,35 @@ public class JWTValidator { return null; } else { long nowSeconds = Instant.now().getEpochSecond(); - long clockSkewSeconds = 60L; - if (claims.expiresAt != null && nowSeconds >= claims.expiresAt + clockSkewSeconds) { + if (claims.expiresAt == null) { + LOGGER.at(Level.WARNING).log("Access token missing expiration claim"); + return null; + } else if (nowSeconds >= claims.expiresAt + 300L) { LOGGER.at(Level.WARNING).log("Token expired (exp: %d, now: %d)", claims.expiresAt, nowSeconds); return null; - } else if (claims.notBefore != null && nowSeconds < claims.notBefore - clockSkewSeconds) { + } else if (claims.notBefore != null && nowSeconds < claims.notBefore - 300L) { LOGGER.at(Level.WARNING).log("Token not yet valid (nbf: %d, now: %d)", claims.notBefore, nowSeconds); return null; + } else if (claims.issuedAt != null && claims.issuedAt > nowSeconds + 300L) { + LOGGER.at(Level.WARNING).log("Token issued in the future (iat: %d, now: %d)", claims.issuedAt, nowSeconds); + return null; } else if (!CertificateUtil.validateCertificateBinding(claims.certificateFingerprint, clientCert)) { LOGGER.at(Level.WARNING).log("Certificate binding validation failed"); return null; + } else if (claims.getSubjectAsUUID() == null) { + LOGGER.at(Level.WARNING).log("Access token has invalid or missing subject UUID"); + return null; } else { LOGGER.at(Level.INFO).log("JWT validated successfully for user %s (UUID: %s)", claims.username, claims.subject); return claims; } } } - } catch (ParseException var12) { - LOGGER.at(Level.WARNING).withCause(var12).log("Failed to parse JWT"); + } catch (ParseException var11) { + LOGGER.at(Level.WARNING).withCause(var11).log("Failed to parse JWT"); return null; - } catch (Exception var13) { - LOGGER.at(Level.WARNING).withCause(var13).log("JWT validation error"); + } catch (Exception var12) { + LOGGER.at(Level.WARNING).withCause(var12).log("JWT validation error"); return null; } } @@ -255,8 +285,9 @@ public class JWTValidator { @Nullable public JWTValidator.IdentityTokenClaims validateIdentityToken(@Nonnull String identityToken) { - if (identityToken.isEmpty()) { - LOGGER.at(Level.WARNING).log("Identity token is empty"); + String structError = validateJwtStructure(identityToken, "Identity token"); + if (structError != null) { + LOGGER.at(Level.WARNING).log(structError); return null; } else { try { @@ -273,27 +304,34 @@ public class JWTValidator { JWTValidator.IdentityTokenClaims claims = new JWTValidator.IdentityTokenClaims(); claims.issuer = claimsSet.getIssuer(); claims.subject = claimsSet.getSubject(); - claims.username = claimsSet.getStringClaim("username"); claims.issuedAt = claimsSet.getIssueTime() != null ? claimsSet.getIssueTime().toInstant().getEpochSecond() : null; claims.expiresAt = claimsSet.getExpirationTime() != null ? claimsSet.getExpirationTime().toInstant().getEpochSecond() : null; claims.notBefore = claimsSet.getNotBeforeTime() != null ? claimsSet.getNotBeforeTime().toInstant().getEpochSecond() : null; claims.scope = claimsSet.getStringClaim("scope"); + Map profile = claimsSet.getJSONObjectClaim("profile"); + if (profile != null) { + claims.username = (String)profile.get("username"); + claims.skin = (String)profile.get("skin"); + if (profile.get("entitlements") instanceof List list) { + claims.entitlements = list.stream().filter(String.class::isInstance).map(String.class::cast).toArray(String[]::new); + } + } + if (!this.expectedIssuer.equals(claims.issuer)) { LOGGER.at(Level.WARNING).log("Invalid identity token issuer: expected %s, got %s", this.expectedIssuer, claims.issuer); return null; } else { long nowSeconds = Instant.now().getEpochSecond(); - long clockSkewSeconds = 60L; if (claims.expiresAt == null) { LOGGER.at(Level.WARNING).log("Identity token missing expiration claim"); return null; - } else if (nowSeconds >= claims.expiresAt + clockSkewSeconds) { + } else if (nowSeconds >= claims.expiresAt + 300L) { LOGGER.at(Level.WARNING).log("Identity token expired (exp: %d, now: %d)", claims.expiresAt, nowSeconds); return null; - } else if (claims.notBefore != null && nowSeconds < claims.notBefore - clockSkewSeconds) { + } else if (claims.notBefore != null && nowSeconds < claims.notBefore - 300L) { LOGGER.at(Level.WARNING).log("Identity token not yet valid (nbf: %d, now: %d)", claims.notBefore, nowSeconds); return null; - } else if (claims.issuedAt != null && claims.issuedAt > nowSeconds + clockSkewSeconds) { + } else if (claims.issuedAt != null && claims.issuedAt > nowSeconds + 300L) { LOGGER.at(Level.WARNING).log("Identity token issued in the future (iat: %d, now: %d)", claims.issuedAt, nowSeconds); return null; } else if (claims.getSubjectAsUUID() == null) { @@ -317,8 +355,9 @@ public class JWTValidator { @Nullable public JWTValidator.SessionTokenClaims validateSessionToken(@Nonnull String sessionToken) { - if (sessionToken.isEmpty()) { - LOGGER.at(Level.WARNING).log("Session token is empty"); + String structError = validateJwtStructure(sessionToken, "Session token"); + if (structError != null) { + LOGGER.at(Level.WARNING).log(structError); return null; } else { try { @@ -338,32 +377,38 @@ public class JWTValidator { claims.issuedAt = claimsSet.getIssueTime() != null ? claimsSet.getIssueTime().toInstant().getEpochSecond() : null; claims.expiresAt = claimsSet.getExpirationTime() != null ? claimsSet.getExpirationTime().toInstant().getEpochSecond() : null; claims.notBefore = claimsSet.getNotBeforeTime() != null ? claimsSet.getNotBeforeTime().toInstant().getEpochSecond() : null; + claims.scope = claimsSet.getStringClaim("scope"); if (!this.expectedIssuer.equals(claims.issuer)) { LOGGER.at(Level.WARNING).log("Invalid session token issuer: expected %s, got %s", this.expectedIssuer, claims.issuer); return null; } else { long nowSeconds = Instant.now().getEpochSecond(); - long clockSkewSeconds = 60L; if (claims.expiresAt == null) { LOGGER.at(Level.WARNING).log("Session token missing expiration claim"); return null; - } else if (nowSeconds >= claims.expiresAt + clockSkewSeconds) { + } else if (nowSeconds >= claims.expiresAt + 300L) { LOGGER.at(Level.WARNING).log("Session token expired (exp: %d, now: %d)", claims.expiresAt, nowSeconds); return null; - } else if (claims.notBefore != null && nowSeconds < claims.notBefore - clockSkewSeconds) { + } else if (claims.notBefore != null && nowSeconds < claims.notBefore - 300L) { LOGGER.at(Level.WARNING).log("Session token not yet valid (nbf: %d, now: %d)", claims.notBefore, nowSeconds); return null; + } else if (claims.issuedAt != null && claims.issuedAt > nowSeconds + 300L) { + LOGGER.at(Level.WARNING).log("Session token issued in the future (iat: %d, now: %d)", claims.issuedAt, nowSeconds); + return null; + } else if (claims.getSubjectAsUUID() == null) { + LOGGER.at(Level.WARNING).log("Session token has invalid or missing subject UUID"); + return null; } else { - LOGGER.at(Level.INFO).log("Session token validated successfully"); + LOGGER.at(Level.INFO).log("Session token validated successfully (UUID: %s)", claims.subject); return claims; } } } - } catch (ParseException var10) { - LOGGER.at(Level.WARNING).withCause(var10).log("Failed to parse session token"); + } catch (ParseException var9) { + LOGGER.at(Level.WARNING).withCause(var9).log("Failed to parse session token"); return null; - } catch (Exception var11) { - LOGGER.at(Level.WARNING).withCause(var11).log("Session token validation error"); + } catch (Exception var10) { + LOGGER.at(Level.WARNING).withCause(var10).log("Session token validation error"); return null; } } @@ -373,14 +418,13 @@ public class JWTValidator { public String issuer; public String subject; public String username; + public String[] entitlements; + public String skin; public Long issuedAt; public Long expiresAt; public Long notBefore; public String scope; - public IdentityTokenClaims() { - } - @Nullable public UUID getSubjectAsUUID() { if (this.subject == null) { @@ -421,9 +465,6 @@ public class JWTValidator { public Long notBefore; public String certificateFingerprint; - public JWTClaims() { - } - @Nullable public UUID getSubjectAsUUID() { if (this.subject == null) { @@ -444,8 +485,34 @@ public class JWTValidator { public Long issuedAt; public Long expiresAt; public Long notBefore; + public String scope; - public SessionTokenClaims() { + @Nullable + public UUID getSubjectAsUUID() { + if (this.subject == null) { + return null; + } else { + try { + return UUID.fromString(this.subject); + } catch (IllegalArgumentException var2) { + return null; + } + } + } + + @Nonnull + public String[] getScopes() { + return this.scope != null && !this.scope.isEmpty() ? this.scope.split(" ") : new String[0]; + } + + public boolean hasScope(@Nonnull String targetScope) { + for (String s : this.getScopes()) { + if (s.equals(targetScope)) { + return true; + } + } + + return false; } } } diff --git a/src/com/hypixel/hytale/server/core/auth/MemoryAuthCredentialStoreProvider.java b/src/com/hypixel/hytale/server/core/auth/MemoryAuthCredentialStoreProvider.java index ed4d4c3..98c7bfc 100644 --- a/src/com/hypixel/hytale/server/core/auth/MemoryAuthCredentialStoreProvider.java +++ b/src/com/hypixel/hytale/server/core/auth/MemoryAuthCredentialStoreProvider.java @@ -10,9 +10,6 @@ public class MemoryAuthCredentialStoreProvider implements AuthCredentialStorePro ) .build(); - public MemoryAuthCredentialStoreProvider() { - } - @Nonnull @Override public IAuthCredentialStore createStore() { diff --git a/src/com/hypixel/hytale/server/core/auth/ProfileServiceClient.java b/src/com/hypixel/hytale/server/core/auth/ProfileServiceClient.java new file mode 100644 index 0000000..2c9dc26 --- /dev/null +++ b/src/com/hypixel/hytale/server/core/auth/ProfileServiceClient.java @@ -0,0 +1,161 @@ +package com.hypixel.hytale.server.core.auth; + +import com.hypixel.hytale.codec.Codec; +import com.hypixel.hytale.codec.EmptyExtraInfo; +import com.hypixel.hytale.codec.KeyedCodec; +import com.hypixel.hytale.codec.builder.BuilderCodec; +import com.hypixel.hytale.codec.util.RawJsonReader; +import com.hypixel.hytale.logger.HytaleLogger; +import java.io.IOException; +import java.net.URI; +import java.net.URLEncoder; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.http.HttpResponse.BodyHandlers; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import java.util.logging.Level; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class ProfileServiceClient { + private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); + private static final Duration REQUEST_TIMEOUT = Duration.ofSeconds(5L); + private final HttpClient httpClient; + private final String profileServiceUrl; + + public ProfileServiceClient(@Nonnull String profileServiceUrl) { + if (profileServiceUrl != null && !profileServiceUrl.isEmpty()) { + this.profileServiceUrl = profileServiceUrl.endsWith("/") ? profileServiceUrl.substring(0, profileServiceUrl.length() - 1) : profileServiceUrl; + this.httpClient = HttpClient.newBuilder().connectTimeout(REQUEST_TIMEOUT).build(); + LOGGER.at(Level.INFO).log("Profile Service client initialized for: %s", this.profileServiceUrl); + } else { + throw new IllegalArgumentException("Profile Service URL cannot be null or empty"); + } + } + + @Nullable + public ProfileServiceClient.PublicGameProfile getProfileByUuid(@Nonnull UUID uuid, @Nonnull String bearerToken) { + try { + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create(this.profileServiceUrl + "/profile/uuid/" + uuid.toString())) + .header("Accept", "application/json") + .header("Authorization", "Bearer " + bearerToken) + .header("User-Agent", AuthConfig.USER_AGENT) + .timeout(REQUEST_TIMEOUT) + .GET() + .build(); + LOGGER.at(Level.FINE).log("Fetching profile by UUID: %s", uuid); + HttpResponse response = this.httpClient.send(request, BodyHandlers.ofString()); + if (response.statusCode() != 200) { + LOGGER.at(Level.WARNING).log("Failed to fetch profile by UUID: HTTP %d - %s", response.statusCode(), response.body()); + return null; + } else { + ProfileServiceClient.PublicGameProfile profile = ProfileServiceClient.PublicGameProfile.CODEC + .decodeJson(new RawJsonReader(response.body().toCharArray()), EmptyExtraInfo.EMPTY); + if (profile == null) { + LOGGER.at(Level.WARNING).log("Profile Service returned invalid response for UUID: %s", uuid); + return null; + } else { + LOGGER.at(Level.FINE).log("Successfully fetched profile: %s (%s)", profile.getUsername(), profile.getUuid()); + return profile; + } + } + } catch (IOException var6) { + LOGGER.at(Level.WARNING).log("IO error while fetching profile by UUID: %s", var6.getMessage()); + return null; + } catch (InterruptedException var7) { + LOGGER.at(Level.WARNING).log("Request interrupted while fetching profile by UUID"); + Thread.currentThread().interrupt(); + return null; + } catch (Exception var8) { + LOGGER.at(Level.WARNING).log("Unexpected error fetching profile by UUID: %s", var8.getMessage()); + return null; + } + } + + public CompletableFuture getProfileByUuidAsync(@Nonnull UUID uuid, @Nonnull String bearerToken) { + return CompletableFuture.supplyAsync(() -> this.getProfileByUuid(uuid, bearerToken)); + } + + @Nullable + public ProfileServiceClient.PublicGameProfile getProfileByUsername(@Nonnull String username, @Nonnull String bearerToken) { + try { + String encodedUsername = URLEncoder.encode(username, StandardCharsets.UTF_8); + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create(this.profileServiceUrl + "/profile/username/" + encodedUsername)) + .header("Accept", "application/json") + .header("Authorization", "Bearer " + bearerToken) + .header("User-Agent", AuthConfig.USER_AGENT) + .timeout(REQUEST_TIMEOUT) + .GET() + .build(); + LOGGER.at(Level.FINE).log("Fetching profile by username: %s", username); + HttpResponse response = this.httpClient.send(request, BodyHandlers.ofString()); + if (response.statusCode() != 200) { + LOGGER.at(Level.WARNING).log("Failed to fetch profile by username: HTTP %d - %s", response.statusCode(), response.body()); + return null; + } else { + ProfileServiceClient.PublicGameProfile profile = ProfileServiceClient.PublicGameProfile.CODEC + .decodeJson(new RawJsonReader(response.body().toCharArray()), EmptyExtraInfo.EMPTY); + if (profile == null) { + LOGGER.at(Level.WARNING).log("Profile Service returned invalid response for username: %s", username); + return null; + } else { + LOGGER.at(Level.FINE).log("Successfully fetched profile: %s (%s)", profile.getUsername(), profile.getUuid()); + return profile; + } + } + } catch (IOException var7) { + LOGGER.at(Level.WARNING).log("IO error while fetching profile by username: %s", var7.getMessage()); + return null; + } catch (InterruptedException var8) { + LOGGER.at(Level.WARNING).log("Request interrupted while fetching profile by username"); + Thread.currentThread().interrupt(); + return null; + } catch (Exception var9) { + LOGGER.at(Level.WARNING).log("Unexpected error fetching profile by username: %s", var9.getMessage()); + return null; + } + } + + public CompletableFuture getProfileByUsernameAsync(@Nonnull String username, @Nonnull String bearerToken) { + return CompletableFuture.supplyAsync(() -> this.getProfileByUsername(username, bearerToken)); + } + + private static KeyedCodec externalKey(String key, Codec codec) { + return new KeyedCodec<>(key, codec, false, true); + } + + public static class PublicGameProfile { + public static final BuilderCodec CODEC = BuilderCodec.builder( + ProfileServiceClient.PublicGameProfile.class, ProfileServiceClient.PublicGameProfile::new + ) + .append(ProfileServiceClient.externalKey("uuid", Codec.UUID_STRING), (p, v) -> p.uuid = v, ProfileServiceClient.PublicGameProfile::getUuid) + .add() + .append(ProfileServiceClient.externalKey("username", Codec.STRING), (p, v) -> p.username = v, ProfileServiceClient.PublicGameProfile::getUsername) + .add() + .build(); + private UUID uuid; + private String username; + + public PublicGameProfile() { + } + + public PublicGameProfile(UUID uuid, String username) { + this.uuid = uuid; + this.username = username; + } + + public UUID getUuid() { + return this.uuid; + } + + public String getUsername() { + return this.username; + } + } +} diff --git a/src/com/hypixel/hytale/server/core/auth/ServerAuthManager.java b/src/com/hypixel/hytale/server/core/auth/ServerAuthManager.java index 141be5b..99e0d5b 100644 --- a/src/com/hypixel/hytale/server/core/auth/ServerAuthManager.java +++ b/src/com/hypixel/hytale/server/core/auth/ServerAuthManager.java @@ -6,6 +6,7 @@ import com.hypixel.hytale.codec.lookup.Priority; import com.hypixel.hytale.logger.HytaleLogger; import com.hypixel.hytale.server.core.HytaleServer; import com.hypixel.hytale.server.core.Options; +import com.hypixel.hytale.server.core.ShutdownReason; import com.hypixel.hytale.server.core.auth.oauth.OAuthBrowserFlow; import com.hypixel.hytale.server.core.auth.oauth.OAuthClient; import com.hypixel.hytale.server.core.auth.oauth.OAuthDeviceFlow; @@ -26,7 +27,6 @@ import java.util.logging.Level; import javax.annotation.Nonnull; import javax.annotation.Nullable; import joptsimple.OptionSet; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; public class ServerAuthManager { private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); @@ -37,11 +37,14 @@ public class ServerAuthManager { private final AtomicReference gameSession = new AtomicReference<>(); private final AtomicReference credentialStore = new AtomicReference<>(new DefaultAuthCredentialStore()); private final Map availableProfiles = new ConcurrentHashMap<>(); + private volatile SessionServiceClient.GameProfile[] pendingProfiles; + private volatile ServerAuthManager.AuthMode pendingAuthMode; private final AtomicReference serverCertificate = new AtomicReference<>(); private final UUID serverSessionId = UUID.randomUUID(); private volatile boolean isSingleplayer; private OAuthClient oauthClient; private volatile SessionServiceClient sessionServiceClient; + private volatile ProfileServiceClient profileServiceClient; private final ScheduledExecutorService refreshScheduler = Executors.newSingleThreadScheduledExecutor(r -> { Thread t = new Thread(r, "TokenRefresh"); t.setDaemon(true); @@ -49,12 +52,36 @@ public class ServerAuthManager { }); private ScheduledFuture refreshTask; private Runnable cancelActiveFlow; - private volatile SessionServiceClient.GameProfile[] pendingProfiles; - private volatile ServerAuthManager.AuthMode pendingAuthMode; + private volatile String pendingFatalError; private ServerAuthManager() { } + public static ServerAuthManager getInstance() { + if (instance == null) { + synchronized (ServerAuthManager.class) { + if (instance == null) { + instance = new ServerAuthManager(); + } + } + } + + return instance; + } + + @Nonnull + public ProfileServiceClient getProfileServiceClient() { + if (this.profileServiceClient == null) { + synchronized (this) { + if (this.profileServiceClient == null) { + this.profileServiceClient = new ProfileServiceClient("https://account-data.hytale.com"); + } + } + } + + return this.profileServiceClient; + } + public void initialize() { OptionSet optionSet = Options.getOptionSet(); if (optionSet == null) { @@ -103,7 +130,8 @@ public class ServerAuthManager { this.gameSession.set(session); hasCliTokens = true; } else { - LOGGER.at(Level.WARNING).log("Token validation failed. Server starting unauthenticated. Use /auth login to authenticate."); + this.pendingFatalError = "Token validation failed. Provided tokens may be expired, tampered, or malformed. Remove invalid tokens or provide valid ones."; + LOGGER.at(Level.SEVERE).log(this.pendingFatalError); } } @@ -132,6 +160,12 @@ public class ServerAuthManager { } } + public void checkPendingFatalError() { + if (this.pendingFatalError != null) { + HytaleServer.get().shutdownServer(ShutdownReason.AUTH_FAILED.withMessage(this.pendingFatalError)); + } + } + public void initializeCredentialStore() { AuthCredentialStoreProvider provider = HytaleServer.get().getConfig().getAuthCredentialStoreProvider(); this.credentialStore.set(provider.createStore()); @@ -152,16 +186,40 @@ public class ServerAuthManager { } } - public static ServerAuthManager getInstance() { - if (instance == null) { - synchronized (ServerAuthManager.class) { - if (instance == null) { - instance = new ServerAuthManager(); - } - } + public void shutdown() { + this.cancelActiveFlow(); + if (this.refreshTask != null) { + this.refreshTask.cancel(false); } - return instance; + this.refreshScheduler.shutdown(); + if (this.isSingleplayer()) { + String currentSessionToken = this.getSessionToken(); + if (currentSessionToken != null && !currentSessionToken.isEmpty()) { + if (this.sessionServiceClient == null) { + this.sessionServiceClient = new SessionServiceClient("https://sessions.hytale.com"); + } + + this.sessionServiceClient.terminateSession(currentSessionToken); + } + } + } + + public void logout() { + this.cancelActiveFlow(); + if (this.refreshTask != null) { + this.refreshTask.cancel(false); + this.refreshTask = null; + } + + this.gameSession.set(null); + this.credentialStore.get().clear(); + this.availableProfiles.clear(); + this.pendingProfiles = null; + this.pendingAuthMode = null; + this.tokenExpiry = null; + this.authMode = ServerAuthManager.AuthMode.NONE; + LOGGER.at(Level.INFO).log("Server logged out"); } @Nullable @@ -169,6 +227,11 @@ public class ServerAuthManager { return this.gameSession.get(); } + public void setGameSession(@Nonnull SessionServiceClient.GameSessionResponse session) { + this.gameSession.set(session); + LOGGER.at(Level.FINE).log("Game session updated"); + } + @Nullable public String getIdentityToken() { SessionServiceClient.GameSessionResponse session = this.gameSession.get(); @@ -181,11 +244,6 @@ public class ServerAuthManager { return session != null ? session.sessionToken : null; } - public void setGameSession(@Nonnull SessionServiceClient.GameSessionResponse session) { - this.gameSession.set(session); - LOGGER.at(Level.FINE).log("Game session updated"); - } - public boolean hasIdentityToken() { SessionServiceClient.GameSessionResponse session = this.gameSession.get(); return session != null && session.identityToken != null; @@ -196,6 +254,16 @@ public class ServerAuthManager { return session != null && session.sessionToken != null; } + @Nullable + public String getOAuthAccessToken() { + if (!this.refreshOAuthTokens()) { + return null; + } else { + IAuthCredentialStore store = this.credentialStore.get(); + return store.getTokens().accessToken(); + } + } + public void setServerCertificate(@Nonnull X509Certificate certificate) { this.serverCertificate.set(certificate); LOGGER.at(Level.INFO).log("Server certificate set: %s", certificate.getSubjectX500Principal()); @@ -217,6 +285,53 @@ public class ServerAuthManager { return this.serverSessionId; } + public ServerAuthManager.AuthMode getAuthMode() { + return this.authMode; + } + + public boolean isSingleplayer() { + return this.isSingleplayer; + } + + public boolean isOwner(@Nullable UUID playerUuid) { + UUID profileUuid = this.credentialStore.get().getProfile(); + return profileUuid != null && profileUuid.equals(playerUuid); + } + + @Nullable + public SessionServiceClient.GameProfile getSelectedProfile() { + UUID profileUuid = this.credentialStore.get().getProfile(); + return profileUuid == null ? null : this.availableProfiles.get(profileUuid); + } + + @Nullable + public Instant getTokenExpiry() { + return this.tokenExpiry; + } + + public String getAuthStatus() { + StringBuilder sb = new StringBuilder(); + sb.append(this.authMode.name()); + if (this.hasSessionToken() && this.hasIdentityToken()) { + sb.append(" (authenticated)"); + } else if (!this.hasSessionToken() && !this.hasIdentityToken()) { + sb.append(" (no tokens)"); + } else { + sb.append(" (partial)"); + } + + if (this.tokenExpiry != null) { + long secondsRemaining = this.tokenExpiry.getEpochSecond() - Instant.now().getEpochSecond(); + if (secondsRemaining > 0L) { + sb.append(String.format(" [expires in %dm %ds]", secondsRemaining / 60L, secondsRemaining % 60L)); + } else { + sb.append(" [EXPIRED]"); + } + } + + return sb.toString(); + } + public CompletableFuture startFlowAsync(@Nonnull OAuthBrowserFlow flow) { if (this.isSingleplayer) { return CompletableFuture.completedFuture(ServerAuthManager.AuthResult.FAILED); @@ -303,6 +418,130 @@ public class ServerAuthManager { LOGGER.at(Level.INFO).log("Swapped credential store to: %s", provider.getClass().getSimpleName()); } + public boolean cancelActiveFlow() { + if (this.cancelActiveFlow != null) { + this.cancelActiveFlow.run(); + this.cancelActiveFlow = null; + return true; + } else { + return false; + } + } + + @Nullable + public SessionServiceClient.GameProfile[] getPendingProfiles() { + return this.pendingProfiles; + } + + public boolean hasPendingProfiles() { + return this.pendingProfiles != null && this.pendingProfiles.length > 0; + } + + public boolean selectPendingProfile(int index) { + SessionServiceClient.GameProfile[] profiles = this.pendingProfiles; + ServerAuthManager.AuthMode mode = this.pendingAuthMode; + if (profiles == null || profiles.length == 0) { + LOGGER.at(Level.WARNING).log("No pending profiles to select"); + return false; + } else if (index >= 1 && index <= profiles.length) { + SessionServiceClient.GameProfile selected = profiles[index - 1]; + LOGGER.at(Level.INFO).log("Selected profile: %s (%s)", selected.username, selected.uuid); + return this.completeAuthWithProfile(selected, mode != null ? mode : ServerAuthManager.AuthMode.OAUTH_BROWSER); + } else { + LOGGER.at(Level.WARNING).log("Invalid profile index: %d (valid range: 1-%d)", index, profiles.length); + return false; + } + } + + public boolean selectPendingProfileByUsername(String username) { + SessionServiceClient.GameProfile[] profiles = this.pendingProfiles; + ServerAuthManager.AuthMode mode = this.pendingAuthMode; + if (profiles != null && profiles.length != 0) { + for (SessionServiceClient.GameProfile profile : profiles) { + if (profile.username != null && profile.username.equalsIgnoreCase(username)) { + LOGGER.at(Level.INFO).log("Selected profile: %s (%s)", profile.username, profile.uuid); + return this.completeAuthWithProfile(profile, mode != null ? mode : ServerAuthManager.AuthMode.OAUTH_BROWSER); + } + } + + LOGGER.at(Level.WARNING).log("No profile found with username: %s", username); + return false; + } else { + LOGGER.at(Level.WARNING).log("No pending profiles to select"); + return false; + } + } + + public void clearPendingProfiles() { + this.pendingProfiles = null; + this.pendingAuthMode = null; + } + + private boolean validateInitialTokens(@Nullable String sessionToken, @Nullable String identityToken) { + if (sessionToken == null && identityToken == null) { + return false; + } else { + if (this.sessionServiceClient == null) { + this.sessionServiceClient = new SessionServiceClient("https://sessions.hytale.com"); + } + + JWTValidator validator = new JWTValidator(this.sessionServiceClient, "https://sessions.hytale.com", ""); + boolean valid = true; + OptionSet optionSet = Options.getOptionSet(); + UUID expectedOwnerUuid = optionSet != null && optionSet.has(Options.OWNER_UUID) ? optionSet.valueOf(Options.OWNER_UUID) : null; + String expectedOwnerName = optionSet != null && optionSet.has(Options.OWNER_NAME) ? optionSet.valueOf(Options.OWNER_NAME) : null; + if (identityToken != null) { + JWTValidator.IdentityTokenClaims claims = validator.validateIdentityToken(identityToken); + if (claims == null) { + LOGGER.at(Level.WARNING).log("Identity token validation failed"); + valid = false; + } else if (!claims.hasScope("hytale:server")) { + LOGGER.at(Level.WARNING).log("Identity token missing required scope: expected %s, got %s", "hytale:server", claims.scope); + valid = false; + } else { + if (expectedOwnerUuid != null) { + UUID tokenUuid = claims.getSubjectAsUUID(); + if (tokenUuid == null || !tokenUuid.equals(expectedOwnerUuid)) { + LOGGER.at(Level.WARNING).log("Identity token UUID mismatch: token has %s, expected %s", claims.subject, expectedOwnerUuid); + valid = false; + } + } + + if (expectedOwnerName != null && claims.username != null && !claims.username.equals(expectedOwnerName)) { + LOGGER.at(Level.WARNING).log("Identity token username mismatch: token has '%s', expected '%s'", claims.username, expectedOwnerName); + valid = false; + } + + if (valid) { + LOGGER.at(Level.INFO).log("Identity token validated for %s (%s)", claims.username, claims.subject); + } + } + } + + if (sessionToken != null) { + JWTValidator.SessionTokenClaims claims = validator.validateSessionToken(sessionToken); + if (claims == null) { + LOGGER.at(Level.WARNING).log("Session token validation failed"); + valid = false; + } else { + if (expectedOwnerUuid != null) { + UUID tokenUuid = claims.getSubjectAsUUID(); + if (tokenUuid == null || !tokenUuid.equals(expectedOwnerUuid)) { + LOGGER.at(Level.WARNING).log("Session token UUID mismatch: token has %s, expected %s", claims.subject, expectedOwnerUuid); + valid = false; + } + } + + if (valid) { + LOGGER.at(Level.INFO).log("Session token validated"); + } + } + } + + return valid; + } + } + private ServerAuthManager.AuthResult createGameSessionFromOAuth(ServerAuthManager.AuthMode mode) { if (!this.refreshOAuthTokens()) { LOGGER.at(Level.WARNING).log("No valid OAuth tokens to create game session"); @@ -403,7 +642,7 @@ public class ServerAuthManager { if (profileUuid != null) { for (SessionServiceClient.GameProfile profilex : profiles) { if (profilex.uuid.equals(profileUuid)) { - LOGGER.at(Level.INFO).log("Auto-selected profile from stroage: %s (%s)", profilex.username, profilex.uuid); + LOGGER.at(Level.INFO).log("Auto-selected profile from storage: %s (%s)", profilex.username, profilex.uuid); return profilex; } } @@ -424,13 +663,9 @@ public class ServerAuthManager { this.cancelActiveFlow = null; this.pendingProfiles = null; this.pendingAuthMode = null; - Instant expiresAtInstant = newSession.getExpiresAtInstant(); - if (expiresAtInstant != null) { - this.tokenExpiry = expiresAtInstant; - long secondsUntilExpiry = expiresAtInstant.getEpochSecond() - Instant.now().getEpochSecond(); - if (secondsUntilExpiry > 300L) { - this.scheduleRefresh((int)secondsUntilExpiry); - } + Instant effectiveExpiry = this.getEffectiveExpiry(newSession); + if (effectiveExpiry != null) { + this.setExpiryAndScheduleRefresh(effectiveExpiry); } LOGGER.at(Level.INFO).log("Authentication successful! Mode: %s", mode); @@ -439,226 +674,6 @@ public class ServerAuthManager { } @Nullable - public SessionServiceClient.GameProfile[] getPendingProfiles() { - return this.pendingProfiles; - } - - public boolean hasPendingProfiles() { - return this.pendingProfiles != null && this.pendingProfiles.length > 0; - } - - public boolean selectPendingProfile(int index) { - SessionServiceClient.GameProfile[] profiles = this.pendingProfiles; - ServerAuthManager.AuthMode mode = this.pendingAuthMode; - if (profiles == null || profiles.length == 0) { - LOGGER.at(Level.WARNING).log("No pending profiles to select"); - return false; - } else if (index >= 1 && index <= profiles.length) { - SessionServiceClient.GameProfile selected = profiles[index - 1]; - LOGGER.at(Level.INFO).log("Selected profile: %s (%s)", selected.username, selected.uuid); - return this.completeAuthWithProfile(selected, mode != null ? mode : ServerAuthManager.AuthMode.OAUTH_BROWSER); - } else { - LOGGER.at(Level.WARNING).log("Invalid profile index: %d (valid range: 1-%d)", index, profiles.length); - return false; - } - } - - public boolean selectPendingProfileByUsername(String username) { - SessionServiceClient.GameProfile[] profiles = this.pendingProfiles; - ServerAuthManager.AuthMode mode = this.pendingAuthMode; - if (profiles != null && profiles.length != 0) { - for (SessionServiceClient.GameProfile profile : profiles) { - if (profile.username != null && profile.username.equalsIgnoreCase(username)) { - LOGGER.at(Level.INFO).log("Selected profile: %s (%s)", profile.username, profile.uuid); - return this.completeAuthWithProfile(profile, mode != null ? mode : ServerAuthManager.AuthMode.OAUTH_BROWSER); - } - } - - LOGGER.at(Level.WARNING).log("No profile found with username: %s", username); - return false; - } else { - LOGGER.at(Level.WARNING).log("No pending profiles to select"); - return false; - } - } - - public void clearPendingProfiles() { - this.pendingProfiles = null; - this.pendingAuthMode = null; - } - - public boolean cancelActiveFlow() { - if (this.cancelActiveFlow != null) { - this.cancelActiveFlow.run(); - this.cancelActiveFlow = null; - return true; - } else { - return false; - } - } - - private boolean validateInitialTokens(@Nullable String sessionToken, @Nullable String identityToken) { - if (sessionToken == null && identityToken == null) { - return false; - } else { - if (this.sessionServiceClient == null) { - this.sessionServiceClient = new SessionServiceClient("https://sessions.hytale.com"); - } - - JWTValidator validator = new JWTValidator(this.sessionServiceClient, "https://sessions.hytale.com", ""); - boolean valid = true; - if (identityToken != null) { - JWTValidator.IdentityTokenClaims claims = validator.validateIdentityToken(identityToken); - if (claims == null) { - LOGGER.at(Level.WARNING).log("Identity token validation failed"); - valid = false; - } else if (!claims.hasScope("hytale:server")) { - LOGGER.at(Level.WARNING).log("Identity token missing required scope: expected %s, got %s", "hytale:server", claims.scope); - valid = false; - } else { - LOGGER.at(Level.INFO).log("Identity token validated for %s (%s)", claims.username, claims.subject); - } - } - - if (sessionToken != null) { - JWTValidator.SessionTokenClaims claims = validator.validateSessionToken(sessionToken); - if (claims == null) { - LOGGER.at(Level.WARNING).log("Session token validation failed"); - valid = false; - } else { - LOGGER.at(Level.INFO).log("Session token validated"); - } - } - - return valid; - } - } - - private void parseAndScheduleRefresh() { - SessionServiceClient.GameSessionResponse session = this.gameSession.get(); - if (session != null) { - Instant expiry = session.getExpiresAtInstant(); - if (expiry != null) { - this.tokenExpiry = expiry; - long secondsUntilExpiry = expiry.getEpochSecond() - Instant.now().getEpochSecond(); - if (secondsUntilExpiry > 300L) { - this.scheduleRefresh((int)secondsUntilExpiry); - } - - return; - } - } - - String idToken = this.getIdentityToken(); - if (idToken != null) { - try { - String[] parts = idToken.split("\\."); - if (parts.length != 3) { - return; - } - - String payload = new String(Base64.getUrlDecoder().decode(parts[1]), StandardCharsets.UTF_8); - JsonObject json = JsonParser.parseString(payload).getAsJsonObject(); - if (json.has("exp")) { - long exp = json.get("exp").getAsLong(); - this.tokenExpiry = Instant.ofEpochSecond(exp); - long secondsUntilExpiry = exp - Instant.now().getEpochSecond(); - if (secondsUntilExpiry > 300L) { - this.scheduleRefresh((int)secondsUntilExpiry); - } - } - } catch (Exception var10) { - LOGGER.at(Level.WARNING).withCause(var10).log("Failed to parse token expiry"); - } - } - } - - private void scheduleRefresh(int expiresInSeconds) { - if (this.refreshTask != null) { - this.refreshTask.cancel(false); - } - - long refreshDelay = Math.max(expiresInSeconds - 300, 60); - LOGGER.at(Level.INFO).log("Token refresh scheduled in %d seconds", refreshDelay); - this.refreshTask = this.refreshScheduler.schedule(this::doRefresh, refreshDelay, TimeUnit.SECONDS); - } - - private void doRefresh() { - String currentSessionToken = this.getSessionToken(); - if (currentSessionToken == null || !this.refreshGameSession(currentSessionToken)) { - LOGGER.at(Level.INFO).log("Game session refresh failed, attempting OAuth refresh..."); - if (!this.refreshGameSessionViaOAuth()) { - LOGGER.at(Level.WARNING).log("All refresh attempts failed. Server may lose authentication."); - } - } - } - - private boolean refreshGameSession(String currentSessionToken) { - LOGGER.at(Level.INFO).log("Refreshing game session with Session Service..."); - if (this.sessionServiceClient == null) { - this.sessionServiceClient = new SessionServiceClient("https://sessions.hytale.com"); - } - - try { - SessionServiceClient.GameSessionResponse response = this.sessionServiceClient.refreshSessionAsync(currentSessionToken).join(); - if (response != null) { - this.gameSession.set(response); - Instant expiresAtInstant = response.getExpiresAtInstant(); - if (expiresAtInstant != null) { - this.tokenExpiry = expiresAtInstant; - long secondsUntilExpiry = expiresAtInstant.getEpochSecond() - Instant.now().getEpochSecond(); - if (secondsUntilExpiry > 300L) { - this.scheduleRefresh((int)secondsUntilExpiry); - } - } - - LOGGER.at(Level.INFO).log("Game session refresh successful"); - return true; - } - } catch (Exception var6) { - LOGGER.at(Level.WARNING).log("Session Service refresh failed: %s", var6.getMessage()); - } - - return false; - } - - private boolean refreshGameSessionViaOAuth() { - boolean supported = switch (this.authMode) { - case OAUTH_BROWSER, OAUTH_DEVICE, OAUTH_STORE -> true; - default -> false; - }; - if (!supported) { - LOGGER.at(Level.WARNING).log("Refresh via OAuth not supported for current Auth Mode"); - return false; - } else { - UUID currentProfile = this.credentialStore.get().getProfile(); - if (currentProfile == null) { - LOGGER.at(Level.WARNING).log("No current profile, cannot refresh game session"); - return false; - } else { - SessionServiceClient.GameSessionResponse newSession = this.createGameSession(currentProfile); - if (newSession == null) { - LOGGER.at(Level.WARNING).log("Failed to create new game session"); - return false; - } else { - this.gameSession.set(newSession); - Instant expiresAtInstant = newSession.getExpiresAtInstant(); - if (expiresAtInstant != null) { - this.tokenExpiry = expiresAtInstant; - long secondsUntilExpiry = expiresAtInstant.getEpochSecond() - Instant.now().getEpochSecond(); - if (secondsUntilExpiry > 300L) { - this.scheduleRefresh((int)secondsUntilExpiry); - } - } - - LOGGER.at(Level.INFO).log("New game session created via OAuth refresh"); - return true; - } - } - } - } - - @NullableDecl private SessionServiceClient.GameSessionResponse createGameSession(UUID profileUuid) { if (this.sessionServiceClient == null) { this.sessionServiceClient = new SessionServiceClient("https://sessions.hytale.com"); @@ -690,84 +705,127 @@ public class ServerAuthManager { } } - public void logout() { - this.cancelActiveFlow(); - if (this.refreshTask != null) { - this.refreshTask.cancel(false); - this.refreshTask = null; + private void parseAndScheduleRefresh() { + SessionServiceClient.GameSessionResponse session = this.gameSession.get(); + Instant effectiveExpiry = this.getEffectiveExpiry(session); + if (effectiveExpiry != null) { + this.setExpiryAndScheduleRefresh(effectiveExpiry); } - - this.gameSession.set(null); - this.credentialStore.get().clear(); - this.availableProfiles.clear(); - this.pendingProfiles = null; - this.pendingAuthMode = null; - this.tokenExpiry = null; - this.authMode = ServerAuthManager.AuthMode.NONE; - LOGGER.at(Level.INFO).log("Server logged out"); - } - - public ServerAuthManager.AuthMode getAuthMode() { - return this.authMode; - } - - public boolean isSingleplayer() { - return this.isSingleplayer; - } - - public boolean isOwner(@Nullable UUID playerUuid) { - UUID profileUuid = this.credentialStore.get().getProfile(); - return profileUuid != null && profileUuid.equals(playerUuid); } @Nullable - public SessionServiceClient.GameProfile getSelectedProfile() { - UUID profileUuid = this.credentialStore.get().getProfile(); - return profileUuid == null ? null : this.availableProfiles.get(profileUuid); - } - - @Nullable - public Instant getTokenExpiry() { - return this.tokenExpiry; - } - - public String getAuthStatus() { - StringBuilder sb = new StringBuilder(); - sb.append(this.authMode.name()); - if (this.hasSessionToken() && this.hasIdentityToken()) { - sb.append(" (authenticated)"); - } else if (!this.hasSessionToken() && !this.hasIdentityToken()) { - sb.append(" (no tokens)"); + private Instant getEffectiveExpiry(@Nullable SessionServiceClient.GameSessionResponse session) { + Instant sessionExpiry = session != null ? session.getExpiresAtInstant() : null; + Instant identityExpiry = this.parseIdentityTokenExpiry(session != null ? session.identityToken : this.getIdentityToken()); + if (sessionExpiry != null && identityExpiry != null) { + return sessionExpiry.isBefore(identityExpiry) ? sessionExpiry : identityExpiry; } else { - sb.append(" (partial)"); + return sessionExpiry != null ? sessionExpiry : identityExpiry; } - - if (this.tokenExpiry != null) { - long secondsRemaining = this.tokenExpiry.getEpochSecond() - Instant.now().getEpochSecond(); - if (secondsRemaining > 0L) { - sb.append(String.format(" [expires in %dm %ds]", secondsRemaining / 60L, secondsRemaining % 60L)); - } else { - sb.append(" [EXPIRED]"); - } - } - - return sb.toString(); } - public void shutdown() { - this.cancelActiveFlow(); + @Nullable + private Instant parseIdentityTokenExpiry(@Nullable String idToken) { + if (idToken == null) { + return null; + } else { + try { + String[] parts = idToken.split("\\."); + if (parts.length != 3) { + return null; + } + + String payload = new String(Base64.getUrlDecoder().decode(parts[1]), StandardCharsets.UTF_8); + JsonObject json = JsonParser.parseString(payload).getAsJsonObject(); + if (json.has("exp")) { + return Instant.ofEpochSecond(json.get("exp").getAsLong()); + } + } catch (Exception var5) { + LOGGER.at(Level.WARNING).withCause(var5).log("Failed to parse identity token expiry"); + } + + return null; + } + } + + private void setExpiryAndScheduleRefresh(@Nonnull Instant expiry) { + this.tokenExpiry = expiry; if (this.refreshTask != null) { this.refreshTask.cancel(false); } - this.refreshScheduler.shutdown(); - String currentSessionToken = this.getSessionToken(); - if (currentSessionToken != null && !currentSessionToken.isEmpty()) { - if (this.sessionServiceClient == null) { - this.sessionServiceClient = new SessionServiceClient("https://sessions.hytale.com"); - } + long secondsUntilExpiry = expiry.getEpochSecond() - Instant.now().getEpochSecond(); + if (secondsUntilExpiry > 300L) { + long refreshDelay = Math.max(secondsUntilExpiry - 300L, 60L); + LOGGER.at(Level.INFO).log("Token refresh scheduled in %d seconds", refreshDelay); + this.refreshTask = this.refreshScheduler.schedule(this::doRefresh, refreshDelay, TimeUnit.SECONDS); + } + } - this.sessionServiceClient.terminateSession(currentSessionToken); + private void doRefresh() { + String currentSessionToken = this.getSessionToken(); + if (currentSessionToken == null || !this.refreshGameSession(currentSessionToken)) { + LOGGER.at(Level.INFO).log("Game session refresh failed, attempting OAuth refresh..."); + if (!this.refreshGameSessionViaOAuth()) { + LOGGER.at(Level.WARNING).log("All refresh attempts failed. Server may lose authentication."); + } + } + } + + private boolean refreshGameSession(String currentSessionToken) { + LOGGER.at(Level.INFO).log("Refreshing game session with Session Service..."); + if (this.sessionServiceClient == null) { + this.sessionServiceClient = new SessionServiceClient("https://sessions.hytale.com"); + } + + try { + SessionServiceClient.GameSessionResponse response = this.sessionServiceClient.refreshSessionAsync(currentSessionToken).join(); + if (response != null) { + this.gameSession.set(response); + Instant effectiveExpiry = this.getEffectiveExpiry(response); + if (effectiveExpiry != null) { + this.setExpiryAndScheduleRefresh(effectiveExpiry); + } + + LOGGER.at(Level.INFO).log("Game session refresh successful"); + return true; + } + } catch (Exception var4) { + LOGGER.at(Level.WARNING).log("Session Service refresh failed: %s", var4.getMessage()); + } + + return false; + } + + private boolean refreshGameSessionViaOAuth() { + boolean supported = switch (this.authMode) { + case OAUTH_BROWSER, OAUTH_DEVICE, OAUTH_STORE -> true; + default -> false; + }; + if (!supported) { + LOGGER.at(Level.WARNING).log("Refresh via OAuth not supported for current Auth Mode"); + return false; + } else { + UUID currentProfile = this.credentialStore.get().getProfile(); + if (currentProfile == null) { + LOGGER.at(Level.WARNING).log("No current profile, cannot refresh game session"); + return false; + } else { + SessionServiceClient.GameSessionResponse newSession = this.createGameSession(currentProfile); + if (newSession == null) { + LOGGER.at(Level.WARNING).log("Failed to create new game session"); + return false; + } else { + this.gameSession.set(newSession); + Instant effectiveExpiry = this.getEffectiveExpiry(newSession); + if (effectiveExpiry != null) { + this.setExpiryAndScheduleRefresh(effectiveExpiry); + } + + LOGGER.at(Level.INFO).log("New game session created via OAuth refresh"); + return true; + } + } } } @@ -783,17 +841,11 @@ public class ServerAuthManager { OAUTH_BROWSER, OAUTH_DEVICE, OAUTH_STORE; - - private AuthMode() { - } } public static enum AuthResult { SUCCESS, PENDING_PROFILE_SELECTION, FAILED; - - private AuthResult() { - } } } diff --git a/src/com/hypixel/hytale/server/core/auth/SessionServiceClient.java b/src/com/hypixel/hytale/server/core/auth/SessionServiceClient.java index e6d244d..d6eb0c4 100644 --- a/src/com/hypixel/hytale/server/core/auth/SessionServiceClient.java +++ b/src/com/hypixel/hytale/server/core/auth/SessionServiceClient.java @@ -340,9 +340,6 @@ public class SessionServiceClient { .append(SessionServiceClient.externalKey("accessToken", Codec.STRING), (r, v) -> r.accessToken = v, r -> r.accessToken) .add() .build(); - - public AccessTokenResponse() { - } } public static class AuthGrantResponse { @@ -353,9 +350,6 @@ public class SessionServiceClient { .append(SessionServiceClient.externalKey("authorizationGrant", Codec.STRING), (r, v) -> r.authorizationGrant = v, r -> r.authorizationGrant) .add() .build(); - - public AuthGrantResponse() { - } } public static class GameProfile { @@ -369,9 +363,6 @@ public class SessionServiceClient { .append(SessionServiceClient.externalKey("username", Codec.STRING), (p, v) -> p.username = v, p -> p.username) .add() .build(); - - public GameProfile() { - } } public static class GameSessionResponse { @@ -389,9 +380,6 @@ public class SessionServiceClient { .add() .build(); - public GameSessionResponse() { - } - public Instant getExpiresAtInstant() { if (this.expiresAt == null) { return null; @@ -437,9 +425,6 @@ public class SessionServiceClient { .append(SessionServiceClient.externalKey("e", Codec.STRING), (k, v) -> k.e = v, k -> k.e) .add() .build(); - - public JwkKey() { - } } public static class JwksResponse { @@ -454,9 +439,6 @@ public class SessionServiceClient { ) .add() .build(); - - public JwksResponse() { - } } public static class LauncherDataResponse { @@ -474,8 +456,5 @@ public class SessionServiceClient { ) .add() .build(); - - public LauncherDataResponse() { - } } } diff --git a/src/com/hypixel/hytale/server/core/auth/oauth/OAuthBrowserFlow.java b/src/com/hypixel/hytale/server/core/auth/oauth/OAuthBrowserFlow.java index 3348903..30f6f80 100644 --- a/src/com/hypixel/hytale/server/core/auth/oauth/OAuthBrowserFlow.java +++ b/src/com/hypixel/hytale/server/core/auth/oauth/OAuthBrowserFlow.java @@ -1,8 +1,5 @@ package com.hypixel.hytale.server.core.auth.oauth; public abstract class OAuthBrowserFlow extends OAuthFlow { - public OAuthBrowserFlow() { - } - public abstract void onFlowInfo(String var1); } diff --git a/src/com/hypixel/hytale/server/core/auth/oauth/OAuthClient.java b/src/com/hypixel/hytale/server/core/auth/oauth/OAuthClient.java index f6e7443..097b609 100644 --- a/src/com/hypixel/hytale/server/core/auth/oauth/OAuthClient.java +++ b/src/com/hypixel/hytale/server/core/auth/oauth/OAuthClient.java @@ -36,9 +36,6 @@ public class OAuthClient { private static final SecureRandom RANDOM = new SecureRandom(); private final HttpClient httpClient = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(10L)).build(); - public OAuthClient() { - } - public Runnable startFlow(@Nonnull OAuthBrowserFlow flow) { AtomicBoolean cancelled = new AtomicBoolean(false); CompletableFuture.runAsync( @@ -154,7 +151,7 @@ public class OAuthClient { } flow.onFlowInfo(deviceAuth.userCode(), deviceAuth.verificationUri(), deviceAuth.verificationUriComplete(), deviceAuth.expiresIn()); - int pollInterval = Math.max(deviceAuth.interval, 5); + int pollInterval = Math.max(deviceAuth.interval, 15); long deadline = System.currentTimeMillis() + deviceAuth.expiresIn * 1000L; while (System.currentTimeMillis() < deadline && !cancelled.get()) { diff --git a/src/com/hypixel/hytale/server/core/auth/oauth/OAuthDeviceFlow.java b/src/com/hypixel/hytale/server/core/auth/oauth/OAuthDeviceFlow.java index 87cfb0c..a7d57e9 100644 --- a/src/com/hypixel/hytale/server/core/auth/oauth/OAuthDeviceFlow.java +++ b/src/com/hypixel/hytale/server/core/auth/oauth/OAuthDeviceFlow.java @@ -1,8 +1,5 @@ package com.hypixel.hytale.server.core.auth.oauth; public abstract class OAuthDeviceFlow extends OAuthFlow { - public OAuthDeviceFlow() { - } - public abstract void onFlowInfo(String var1, String var2, String var3, int var4); } diff --git a/src/com/hypixel/hytale/server/core/auth/oauth/OAuthFlow.java b/src/com/hypixel/hytale/server/core/auth/oauth/OAuthFlow.java index d9b7738..aadc431 100644 --- a/src/com/hypixel/hytale/server/core/auth/oauth/OAuthFlow.java +++ b/src/com/hypixel/hytale/server/core/auth/oauth/OAuthFlow.java @@ -8,9 +8,6 @@ abstract class OAuthFlow { private OAuthResult result = OAuthResult.UNKNOWN; private String errorMessage = null; - OAuthFlow() { - } - final void onSuccess(OAuthClient.TokenResponse tokenResponse) { if (!this.future.isDone()) { this.tokenResponse = tokenResponse; diff --git a/src/com/hypixel/hytale/server/core/auth/oauth/OAuthResult.java b/src/com/hypixel/hytale/server/core/auth/oauth/OAuthResult.java index c1f26da..98bf2ea 100644 --- a/src/com/hypixel/hytale/server/core/auth/oauth/OAuthResult.java +++ b/src/com/hypixel/hytale/server/core/auth/oauth/OAuthResult.java @@ -4,7 +4,4 @@ public enum OAuthResult { UNKNOWN, SUCCESS, FAILED; - - private OAuthResult() { - } } diff --git a/src/com/hypixel/hytale/server/core/blocktype/BlockTypeModule.java b/src/com/hypixel/hytale/server/core/blocktype/BlockTypeModule.java index 9c133ab..914477e 100644 --- a/src/com/hypixel/hytale/server/core/blocktype/BlockTypeModule.java +++ b/src/com/hypixel/hytale/server/core/blocktype/BlockTypeModule.java @@ -379,9 +379,6 @@ public class BlockTypeModule extends JavaPlugin { private static class FixFillerBlocksSystem extends RefSystem implements DisableProcessingAssert { private static final ComponentType COMPONENT_TYPE = WorldChunk.getComponentType(); - private FixFillerBlocksSystem() { - } - @Override public Query getQuery() { return COMPONENT_TYPE; @@ -472,9 +469,6 @@ public class BlockTypeModule extends JavaPlugin { RootDependency.first() ); - private MigrateLegacySections() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { ChunkColumn column = holder.getComponent(ChunkColumn.getComponentType()); diff --git a/src/com/hypixel/hytale/server/core/blocktype/component/BlockPhysics.java b/src/com/hypixel/hytale/server/core/blocktype/component/BlockPhysics.java index ce0e3d5..1520f72 100644 --- a/src/com/hypixel/hytale/server/core/blocktype/component/BlockPhysics.java +++ b/src/com/hypixel/hytale/server/core/blocktype/component/BlockPhysics.java @@ -40,9 +40,6 @@ public class BlockPhysics implements Component { private byte[] supportData = null; private int nonZeroCount = 0; - public BlockPhysics() { - } - public static ComponentType getComponentType() { return BlockTypeModule.get().getBlockPhysicsComponentType(); } diff --git a/src/com/hypixel/hytale/server/core/client/ClientFeatureHandler.java b/src/com/hypixel/hytale/server/core/client/ClientFeatureHandler.java index a43f801..08526d5 100644 --- a/src/com/hypixel/hytale/server/core/client/ClientFeatureHandler.java +++ b/src/com/hypixel/hytale/server/core/client/ClientFeatureHandler.java @@ -6,9 +6,6 @@ import com.hypixel.hytale.server.core.universe.world.World; import javax.annotation.Nonnull; public class ClientFeatureHandler { - public ClientFeatureHandler() { - } - public static void register(@Nonnull ClientFeature feature) { for (World world : Universe.get().getWorlds().values()) { world.registerFeature(feature, true); diff --git a/src/com/hypixel/hytale/server/core/codec/BoolDoublePairCodec.java b/src/com/hypixel/hytale/server/core/codec/BoolDoublePairCodec.java index fd70e04..ff8dc9a 100644 --- a/src/com/hypixel/hytale/server/core/codec/BoolDoublePairCodec.java +++ b/src/com/hypixel/hytale/server/core/codec/BoolDoublePairCodec.java @@ -15,9 +15,6 @@ import org.bson.BsonValue; public class BoolDoublePairCodec implements Codec { private static final Pattern PATTERN = Pattern.compile("~?[0-9]*"); - public BoolDoublePairCodec() { - } - @Nonnull public BoolDoublePair decode(BsonValue bsonValue, ExtraInfo extraInfo) { if (bsonValue instanceof BsonString) { diff --git a/src/com/hypixel/hytale/server/core/codec/LayerEntryCodec.java b/src/com/hypixel/hytale/server/core/codec/LayerEntryCodec.java index 3683532..84ebcab 100644 --- a/src/com/hypixel/hytale/server/core/codec/LayerEntryCodec.java +++ b/src/com/hypixel/hytale/server/core/codec/LayerEntryCodec.java @@ -18,10 +18,13 @@ public class LayerEntryCodec { new KeyedCodec<>("UseToolArg", Codec.BOOLEAN), (entry, useToolArg) -> entry.useToolArg = useToolArg != null && useToolArg, entry -> entry.useToolArg ) .add() + .append(new KeyedCodec<>("Skip", Codec.BOOLEAN), (entry, skip) -> entry.skip = skip != null && skip, entry -> entry.skip) + .add() .build(); private Integer depth; private String material; private boolean useToolArg = false; + private boolean skip = false; public LayerEntryCodec() { } @@ -45,4 +48,8 @@ public class LayerEntryCodec { public boolean isUseToolArg() { return this.useToolArg; } + + public boolean isSkip() { + return this.skip; + } } diff --git a/src/com/hypixel/hytale/server/core/codec/PairCodec.java b/src/com/hypixel/hytale/server/core/codec/PairCodec.java index cd5d809..edcc70d 100644 --- a/src/com/hypixel/hytale/server/core/codec/PairCodec.java +++ b/src/com/hypixel/hytale/server/core/codec/PairCodec.java @@ -8,9 +8,6 @@ import it.unimi.dsi.fastutil.Pair; import javax.annotation.Nonnull; public class PairCodec { - public PairCodec() { - } - public static class IntegerPair { public static final BuilderCodec CODEC = BuilderCodec.builder(PairCodec.IntegerPair.class, PairCodec.IntegerPair::new) .append(new KeyedCodec<>("Left", Codec.INTEGER), (pair, left) -> pair.left = left, pair -> pair.left) diff --git a/src/com/hypixel/hytale/server/core/codec/ProtocolCodecs.java b/src/com/hypixel/hytale/server/core/codec/ProtocolCodecs.java index e5eeafb..b9d92dd 100644 --- a/src/com/hypixel/hytale/server/core/codec/ProtocolCodecs.java +++ b/src/com/hypixel/hytale/server/core/codec/ProtocolCodecs.java @@ -278,7 +278,4 @@ public final class ProtocolCodecs { .addValidator(Validators.arraySizeRange(2, 16)) .add() .build(); - - public ProtocolCodecs() { - } } diff --git a/src/com/hypixel/hytale/server/core/codec/ShapeCodecs.java b/src/com/hypixel/hytale/server/core/codec/ShapeCodecs.java index 7b94f82..2153f86 100644 --- a/src/com/hypixel/hytale/server/core/codec/ShapeCodecs.java +++ b/src/com/hypixel/hytale/server/core/codec/ShapeCodecs.java @@ -34,9 +34,6 @@ public class ShapeCodecs { .addField(new KeyedCodec<>("Shape", SHAPE), (shape, childShape) -> shape.shape = (S)childShape, shape -> shape.shape) .build(); - public ShapeCodecs() { - } - static { SHAPE.register("Box", Box.class, BOX); SHAPE.register("Ellipsoid", Ellipsoid.class, ELLIPSOID); diff --git a/src/com/hypixel/hytale/server/core/codec/protocol/ColorAlphaCodec.java b/src/com/hypixel/hytale/server/core/codec/protocol/ColorAlphaCodec.java index bc38dc6..6d9cba2 100644 --- a/src/com/hypixel/hytale/server/core/codec/protocol/ColorAlphaCodec.java +++ b/src/com/hypixel/hytale/server/core/codec/protocol/ColorAlphaCodec.java @@ -15,9 +15,6 @@ import org.bson.BsonString; import org.bson.BsonValue; public class ColorAlphaCodec implements Codec { - public ColorAlphaCodec() { - } - @Nonnull public BsonValue encode(ColorAlpha colorAlpha, ExtraInfo extraInfo) { return new BsonString(ColorParseUtil.colorToHexAlphaString(colorAlpha)); diff --git a/src/com/hypixel/hytale/server/core/codec/protocol/ColorCodec.java b/src/com/hypixel/hytale/server/core/codec/protocol/ColorCodec.java index 33000b7..262bf8f 100644 --- a/src/com/hypixel/hytale/server/core/codec/protocol/ColorCodec.java +++ b/src/com/hypixel/hytale/server/core/codec/protocol/ColorCodec.java @@ -15,9 +15,6 @@ import org.bson.BsonString; import org.bson.BsonValue; public class ColorCodec implements Codec { - public ColorCodec() { - } - @Nonnull public BsonValue encode(Color color, ExtraInfo extraInfo) { return new BsonString(ColorParseUtil.colorToHexString(color)); diff --git a/src/com/hypixel/hytale/server/core/command/commands/debug/AssetTagsCommand.java b/src/com/hypixel/hytale/server/core/command/commands/debug/AssetTagsCommand.java index 6c02155..b13ee3b 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/debug/AssetTagsCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/debug/AssetTagsCommand.java @@ -17,8 +17,6 @@ import java.util.stream.Collectors; import javax.annotation.Nonnull; public class AssetTagsCommand extends CommandBase { - @Nonnull - private static final Message MESSAGE_COMMANDS_ASSETS_TAGS_TAG_NOT_FOUND = Message.translation("server.commands.assets.tags.tagNotFound"); @Nonnull private final RequiredArg classArg = this.withRequiredArg("class", "server.commands.assets.tags.class.desc", ArgTypes.STRING); @Nonnull @@ -34,7 +32,7 @@ public class AssetTagsCommand extends CommandBase { String tag = this.tagArg.get(context); int tagIndex = AssetRegistry.getTagIndex(tag); if (tagIndex == Integer.MIN_VALUE) { - context.sendMessage(MESSAGE_COMMANDS_ASSETS_TAGS_TAG_NOT_FOUND.param("tag", tag)); + context.sendMessage(Message.translation("server.commands.assets.tags.tagNotFound").param("tag", tag)); } else { for (Entry, AssetStore> entry : AssetRegistry.getStoreMap().entrySet()) { String simpleName = entry.getKey().getSimpleName(); diff --git a/src/com/hypixel/hytale/server/core/command/commands/debug/DebugPlayerPositionCommand.java b/src/com/hypixel/hytale/server/core/command/commands/debug/DebugPlayerPositionCommand.java index dd970c0..9e4b4b0 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/debug/DebugPlayerPositionCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/debug/DebugPlayerPositionCommand.java @@ -16,7 +16,7 @@ import com.hypixel.hytale.server.core.modules.entity.teleport.Teleport; import com.hypixel.hytale.server.core.universe.PlayerRef; import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; +import javax.annotation.Nonnull; public class DebugPlayerPositionCommand extends AbstractPlayerCommand { public DebugPlayerPositionCommand() { @@ -25,14 +25,18 @@ public class DebugPlayerPositionCommand extends AbstractPlayerCommand { @Override protected void execute( - @NonNullDecl CommandContext context, - @NonNullDecl Store store, - @NonNullDecl Ref ref, - @NonNullDecl PlayerRef playerRef, - @NonNullDecl World world + @Nonnull CommandContext context, @Nonnull Store store, @Nonnull Ref ref, @Nonnull PlayerRef playerRef, @Nonnull World world ) { - Transform transform = store.getComponent(ref, TransformComponent.getComponentType()).getTransform(); - Vector3f headRotation = store.getComponent(ref, HeadRotation.getComponentType()).getRotation(); + TransformComponent transformComponent = store.getComponent(ref, TransformComponent.getComponentType()); + + assert transformComponent != null; + + Transform transform = transformComponent.getTransform(); + HeadRotation headRotationComponent = store.getComponent(ref, HeadRotation.getComponentType()); + + assert headRotationComponent != null; + + Vector3f headRotation = headRotationComponent.getRotation(); Teleport teleport = store.getComponent(ref, Teleport.getComponentType()); PendingTeleport pendingTeleport = store.getComponent(ref, PendingTeleport.getComponentType()); String teleportFmt = teleport == null ? "none" : fmtPos(teleport.getPosition()); @@ -49,16 +53,16 @@ public class DebugPlayerPositionCommand extends AbstractPlayerCommand { playerRef.sendMessage(Message.translation("server.commands.debugplayerposition.notify").color("#23DDE1")); } - private static String fmtPos(Vector3d vector) { + private static String fmtPos(@Nonnull Vector3d vector) { String fmt = "%.1f"; return String.format("%.1f", vector.getX()) + ", " + String.format("%.1f", vector.getY()) + ", " + String.format("%.1f", vector.getZ()); } - private static String fmtRot(Vector3f vector) { + private static String fmtRot(@Nonnull Vector3f vector) { return "Pitch=" + fmtDegrees(vector.getPitch()) + ", Yaw=" + fmtDegrees(vector.getYaw()) + ", Roll=" + fmtDegrees(vector.getRoll()); } private static String fmtDegrees(float radians) { - return String.format("%.1f", Math.toDegrees(radians)) + "\u00b0"; + return String.format("%.1f", Math.toDegrees(radians)) + "°"; } } diff --git a/src/com/hypixel/hytale/server/core/command/commands/debug/VersionCommand.java b/src/com/hypixel/hytale/server/core/command/commands/debug/VersionCommand.java index 5694b45..6303af5 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/debug/VersionCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/debug/VersionCommand.java @@ -7,9 +7,6 @@ import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase; import javax.annotation.Nonnull; public class VersionCommand extends CommandBase { - private static final Message MESSAGE_RESPONSE = Message.translation("server.commands.version.response"); - private static final Message MESSAGE_RESPONSE_WITH_ENV = Message.translation("server.commands.version.response.withEnvironment"); - public VersionCommand() { super("version", "Displays version information about the currently running server"); } @@ -19,9 +16,14 @@ public class VersionCommand extends CommandBase { String version = ManifestUtil.getImplementationVersion(); String patchline = ManifestUtil.getPatchline(); if ("release".equals(patchline)) { - context.sendMessage(MESSAGE_RESPONSE.param("version", version).param("patchline", patchline)); + context.sendMessage(Message.translation("server.commands.version.response").param("version", version).param("patchline", patchline)); } else { - context.sendMessage(MESSAGE_RESPONSE_WITH_ENV.param("version", version).param("patchline", patchline).param("environment", "release")); + context.sendMessage( + Message.translation("server.commands.version.response.withEnvironment") + .param("version", version) + .param("patchline", patchline) + .param("environment", "release") + ); } } } diff --git a/src/com/hypixel/hytale/server/core/command/commands/debug/server/ServerStatsCpuCommand.java b/src/com/hypixel/hytale/server/core/command/commands/debug/server/ServerStatsCpuCommand.java index 9296eb8..acac3a3 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/debug/server/ServerStatsCpuCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/debug/server/ServerStatsCpuCommand.java @@ -11,12 +11,8 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Nonnull; public class ServerStatsCpuCommand extends CommandBase { - @Nonnull - private static final Message MESSAGE_COMMANDS_SERVER_STATS_CPU_FULL_USAGE_INFO = Message.translation("server.commands.server.stats.cpu.fullUsageInfo"); @Nonnull private static final Message MESSAGE_COMMANDS_SERVER_STATS_FULL_INFO_UNAVAILABLE = Message.translation("server.commands.server.stats.fullInfoUnavailable"); - @Nonnull - private static final Message MESSAGE_COMMANDS_SERVER_STATS_CPU_USAGE_INFO = Message.translation("server.commands.server.stats.cpu.usageInfo"); public ServerStatsCpuCommand() { super("cpu", "server.commands.server.stats.cpu.desc"); @@ -28,7 +24,8 @@ public class ServerStatsCpuCommand extends CommandBase { OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean(); if (operatingSystemMXBean instanceof com.sun.management.OperatingSystemMXBean sunOSBean) { context.sendMessage( - MESSAGE_COMMANDS_SERVER_STATS_CPU_FULL_USAGE_INFO.param("systemLoad", sunOSBean.getSystemCpuLoad()) + Message.translation("server.commands.server.stats.cpu.fullUsageInfo") + .param("systemLoad", sunOSBean.getSystemCpuLoad()) .param("processLoad", sunOSBean.getProcessCpuLoad()) ); } else { @@ -36,7 +33,8 @@ public class ServerStatsCpuCommand extends CommandBase { } context.sendMessage( - MESSAGE_COMMANDS_SERVER_STATS_CPU_USAGE_INFO.param("loadAverage", operatingSystemMXBean.getSystemLoadAverage()) + Message.translation("server.commands.server.stats.cpu.usageInfo") + .param("loadAverage", operatingSystemMXBean.getSystemLoadAverage()) .param("processUptime", FormatUtil.timeUnitToString(runtimeMXBean.getUptime(), TimeUnit.MILLISECONDS)) ); } diff --git a/src/com/hypixel/hytale/server/core/command/commands/debug/server/ServerStatsGcCommand.java b/src/com/hypixel/hytale/server/core/command/commands/debug/server/ServerStatsGcCommand.java index c531302..60d169e 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/debug/server/ServerStatsGcCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/debug/server/ServerStatsGcCommand.java @@ -9,9 +9,6 @@ import java.util.Arrays; import javax.annotation.Nonnull; public class ServerStatsGcCommand extends CommandBase { - @Nonnull - private static final Message MESSAGE_COMMANDS_SERVER_STATS_GC_USAGE_INFO = Message.translation("server.commands.server.stats.gc.usageInfo"); - public ServerStatsGcCommand() { super("gc", "server.commands.server.stats.gc.desc"); } @@ -20,7 +17,8 @@ public class ServerStatsGcCommand extends CommandBase { protected void executeSync(@Nonnull CommandContext context) { for (GarbageCollectorMXBean garbageCollectorMXBean : ManagementFactory.getGarbageCollectorMXBeans()) { context.sendMessage( - MESSAGE_COMMANDS_SERVER_STATS_GC_USAGE_INFO.param("name", garbageCollectorMXBean.getName()) + Message.translation("server.commands.server.stats.gc.usageInfo") + .param("name", garbageCollectorMXBean.getName()) .param("poolNames", Arrays.toString((Object[])garbageCollectorMXBean.getMemoryPoolNames())) .param("collectionCount", garbageCollectorMXBean.getCollectionCount()) .param("collectionTime", garbageCollectorMXBean.getCollectionTime()) diff --git a/src/com/hypixel/hytale/server/core/command/commands/debug/server/ServerStatsMemoryCommand.java b/src/com/hypixel/hytale/server/core/command/commands/debug/server/ServerStatsMemoryCommand.java index db39587..8e60ee6 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/debug/server/ServerStatsMemoryCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/debug/server/ServerStatsMemoryCommand.java @@ -11,12 +11,8 @@ import java.lang.management.MemoryUsage; import javax.annotation.Nonnull; public class ServerStatsMemoryCommand extends CommandBase { - @Nonnull - private static final Message MESSAGE_COMMANDS_SERVER_STATS_MEMORY_FULL_USAGE_INFO = Message.translation("server.commands.server.stats.memory.fullUsageInfo"); @Nonnull private static final Message MESSAGE_COMMANDS_SERVER_STATS_FULL_INFO_UNAVAILABLE = Message.translation("server.commands.server.stats.fullInfoUnavailable"); - @Nonnull - private static final Message MESSAGE_COMMANDS_SERVER_STATS_MEMORY_USAGE_INFO = Message.translation("server.commands.server.stats.memory.usageInfo"); public ServerStatsMemoryCommand() { super("memory", "server.commands.server.stats.memory.desc"); @@ -27,7 +23,8 @@ public class ServerStatsMemoryCommand extends CommandBase { protected void executeSync(@Nonnull CommandContext context) { if (ManagementFactory.getOperatingSystemMXBean() instanceof OperatingSystemMXBean sunOSBean) { context.sendMessage( - MESSAGE_COMMANDS_SERVER_STATS_MEMORY_FULL_USAGE_INFO.param("totalPhysicalMemory", FormatUtil.bytesToString(sunOSBean.getTotalPhysicalMemorySize())) + Message.translation("server.commands.server.stats.memory.fullUsageInfo") + .param("totalPhysicalMemory", FormatUtil.bytesToString(sunOSBean.getTotalPhysicalMemorySize())) .param("freePhysicalMemory", FormatUtil.bytesToString(sunOSBean.getFreePhysicalMemorySize())) .param("totalSwapMemory", FormatUtil.bytesToString(sunOSBean.getTotalSwapSpaceSize())) .param("freeSwapMemory", FormatUtil.bytesToString(sunOSBean.getFreeSwapSpaceSize())) @@ -38,7 +35,8 @@ public class ServerStatsMemoryCommand extends CommandBase { MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); context.sendMessage( - MESSAGE_COMMANDS_SERVER_STATS_MEMORY_USAGE_INFO.param("heapMemoryUsage", formatMemoryUsage(memoryMXBean.getHeapMemoryUsage())) + Message.translation("server.commands.server.stats.memory.usageInfo") + .param("heapMemoryUsage", formatMemoryUsage(memoryMXBean.getHeapMemoryUsage())) .param("nonHeapMemoryUsage", formatMemoryUsage(memoryMXBean.getNonHeapMemoryUsage())) .param("objectsPendingFinalizationCount", memoryMXBean.getObjectPendingFinalizationCount()) ); diff --git a/src/com/hypixel/hytale/server/core/command/commands/debug/stresstest/Bot.java b/src/com/hypixel/hytale/server/core/command/commands/debug/stresstest/Bot.java index 5394531..6420282 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/debug/stresstest/Bot.java +++ b/src/com/hypixel/hytale/server/core/command/commands/debug/stresstest/Bot.java @@ -170,9 +170,7 @@ public class Bot extends SimpleChannelInboundHandler { @Override public void channelActive(@Nonnull ChannelHandlerContext ctx) { UUID uuid = UUID.nameUUIDFromBytes(("BOT|" + this.name).getBytes(StandardCharsets.UTF_8)); - ctx.writeAndFlush( - new Connect("6708f121966c1c443f4b0eb525b2f81d0a8dc61f5003a692a8fa157e5e02cea9", ClientType.Game, "en", null, uuid, this.name, null, null) - ); + ctx.writeAndFlush(new Connect(1789265863, 2, "bot", ClientType.Game, uuid, this.name, null, "en", null, null)); this.logger.at(Level.INFO).log("Connected!"); } diff --git a/src/com/hypixel/hytale/server/core/command/commands/debug/stresstest/StressTestStartCommand.java b/src/com/hypixel/hytale/server/core/command/commands/debug/stresstest/StressTestStartCommand.java index 0ed78e5..3ce6666 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/debug/stresstest/StressTestStartCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/debug/stresstest/StressTestStartCommand.java @@ -344,17 +344,11 @@ public class StressTestStartCommand extends AbstractAsyncWorldCommand { INTERVAL, FINISH, NEVER; - - private DumpType() { - } } static enum StressTestState { NOT_RUNNING, RUNNING, STOPPING; - - private StressTestState() { - } } } diff --git a/src/com/hypixel/hytale/server/core/command/commands/player/PlayerRespawnCommand.java b/src/com/hypixel/hytale/server/core/command/commands/player/PlayerRespawnCommand.java index 703e476..576668d 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/player/PlayerRespawnCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/player/PlayerRespawnCommand.java @@ -28,7 +28,7 @@ public class PlayerRespawnCommand extends AbstractPlayerCommand { protected void execute( @Nonnull CommandContext context, @Nonnull Store store, @Nonnull Ref ref, @Nonnull PlayerRef playerRef, @Nonnull World world ) { - store.tryRemoveComponent(ref, DeathComponent.getComponentType()); + DeathComponent.respawn(store, ref); context.sendMessage(MESSAGE_COMMANDS_PLAYER_RESPAWN_SUCCESS_SELF); } @@ -54,7 +54,7 @@ public class PlayerRespawnCommand extends AbstractPlayerCommand { if (playerComponent == null) { context.sendMessage(MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD); } else { - store.tryRemoveComponent(ref, DeathComponent.getComponentType()); + DeathComponent.respawn(store, ref); context.sendMessage(Message.translation("server.commands.player.respawn.success.other").param("username", playerRef.getUsername())); } }); diff --git a/src/com/hypixel/hytale/server/core/command/commands/player/ReferCommand.java b/src/com/hypixel/hytale/server/core/command/commands/player/ReferCommand.java index e0705af..f1df02d 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/player/ReferCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/player/ReferCommand.java @@ -45,10 +45,8 @@ public class ReferCommand extends AbstractTargetPlayerCommand { } if (port > 0 && port <= 65535) { - byte[] testData = "Test referral".getBytes(); - try { - playerRef.referToServer(host, port, testData); + playerRef.referToServer(host, port); if (isTargetingOther) { context.sendMessage( Message.translation("server.commands.refer.success.other").param("username", playerRef.getUsername()).param("host", host).param("port", port) @@ -56,8 +54,8 @@ public class ReferCommand extends AbstractTargetPlayerCommand { } else { context.sendMessage(Message.translation("server.commands.refer.success.self").param("host", host).param("port", port)); } - } catch (Exception var12) { - context.sendMessage(Message.translation("server.commands.refer.failed").param("error", var12.getMessage())); + } catch (Exception var11) { + context.sendMessage(Message.translation("server.commands.refer.failed").param("error", var11.getMessage())); } } else { context.sendMessage(Message.translation("server.commands.refer.invalidPort")); diff --git a/src/com/hypixel/hytale/server/core/command/commands/player/camera/CameraDemo.java b/src/com/hypixel/hytale/server/core/command/commands/player/camera/CameraDemo.java index eebdc16..fe98bd0 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/player/camera/CameraDemo.java +++ b/src/com/hypixel/hytale/server/core/command/commands/player/camera/CameraDemo.java @@ -38,9 +38,6 @@ public class CameraDemo { private final ServerCameraSettings cameraSettings = createServerCameraSettings(); private boolean isActive; - public CameraDemo() { - } - public void activate() { if (!this.isActive) { this.eventRegistry.enable(); diff --git a/src/com/hypixel/hytale/server/core/command/commands/player/effect/PlayerEffectApplyCommand.java b/src/com/hypixel/hytale/server/core/command/commands/player/effect/PlayerEffectApplyCommand.java index 1a5c665..055d53f 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/player/effect/PlayerEffectApplyCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/player/effect/PlayerEffectApplyCommand.java @@ -22,7 +22,6 @@ import javax.annotation.Nonnull; public class PlayerEffectApplyCommand extends AbstractPlayerCommand { private static final float DEFAULT_DURATION = 100.0F; - private static final Message MESSAGE_EFFECT_APPLIED_SELF = Message.translation("server.commands.player.effect.apply.success.self"); @Nonnull private final RequiredArg effectArg = this.withRequiredArg("effect", "server.commands.player.effect.apply.effect.desc", ArgTypes.EFFECT_ASSET); @Nonnull @@ -48,12 +47,11 @@ public class PlayerEffectApplyCommand extends AbstractPlayerCommand { EntityEffect effect = this.effectArg.get(context); Float duration = this.durationArg.get(context); effectControllerComponent.addEffect(ref, effect, duration, OverlapBehavior.OVERWRITE, store); - context.sendMessage(MESSAGE_EFFECT_APPLIED_SELF.param("effect", effect.getId()).param("duration", duration)); + context.sendMessage(Message.translation("server.commands.player.effect.apply.success.self").param("effect", effect.getId()).param("duration", duration)); } private static class PlayerEffectApplyOtherCommand extends CommandBase { private static final Message MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD = Message.translation("server.commands.errors.playerNotInWorld"); - private static final Message MESSAGE_EFFECT_APPLIED_OTHER = Message.translation("server.commands.player.effect.apply.success.other"); @Nonnull private final RequiredArg playerArg = this.withRequiredArg("player", "server.commands.argtype.player.desc", ArgTypes.PLAYER_REF); @Nonnull @@ -96,7 +94,8 @@ public class PlayerEffectApplyCommand extends AbstractPlayerCommand { Float duration = this.durationArg.get(context); effectControllerComponent.addEffect(ref, effect, duration, OverlapBehavior.OVERWRITE, store); context.sendMessage( - MESSAGE_EFFECT_APPLIED_OTHER.param("username", playerRefComponent.getUsername()) + Message.translation("server.commands.player.effect.apply.success.other") + .param("username", playerRefComponent.getUsername()) .param("effect", effect.getId()) .param("duration", duration) ); diff --git a/src/com/hypixel/hytale/server/core/command/commands/player/effect/PlayerEffectClearCommand.java b/src/com/hypixel/hytale/server/core/command/commands/player/effect/PlayerEffectClearCommand.java index b64ff00..c03e956 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/player/effect/PlayerEffectClearCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/player/effect/PlayerEffectClearCommand.java @@ -39,7 +39,6 @@ public class PlayerEffectClearCommand extends AbstractPlayerCommand { private static class PlayerEffectClearOtherCommand extends CommandBase { private static final Message MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD = Message.translation("server.commands.errors.playerNotInWorld"); - private static final Message MESSAGE_EFFECTS_CLEARED_OTHER = Message.translation("server.commands.player.effect.clear.success.other"); @Nonnull private final RequiredArg playerArg = this.withRequiredArg("player", "server.commands.argtype.player.desc", ArgTypes.PLAYER_REF); @@ -55,23 +54,27 @@ public class PlayerEffectClearCommand extends AbstractPlayerCommand { if (ref != null && ref.isValid()) { Store store = ref.getStore(); World world = store.getExternalData().getWorld(); - world.execute(() -> { - Player playerComponent = store.getComponent(ref, Player.getComponentType()); - if (playerComponent == null) { - context.sendMessage(MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD); - } else { - PlayerRef playerRefComponent = store.getComponent(ref, PlayerRef.getComponentType()); + world.execute( + () -> { + Player playerComponent = store.getComponent(ref, Player.getComponentType()); + if (playerComponent == null) { + context.sendMessage(MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD); + } else { + PlayerRef playerRefComponent = store.getComponent(ref, PlayerRef.getComponentType()); - assert playerRefComponent != null; + assert playerRefComponent != null; - EffectControllerComponent effectControllerComponent = store.getComponent(ref, EffectControllerComponent.getComponentType()); + EffectControllerComponent effectControllerComponent = store.getComponent(ref, EffectControllerComponent.getComponentType()); - assert effectControllerComponent != null; + assert effectControllerComponent != null; - effectControllerComponent.clearEffects(ref, store); - context.sendMessage(MESSAGE_EFFECTS_CLEARED_OTHER.param("username", playerRefComponent.getUsername())); + effectControllerComponent.clearEffects(ref, store); + context.sendMessage( + Message.translation("server.commands.player.effect.clear.success.other").param("username", playerRefComponent.getUsername()) + ); + } } - }); + ); } else { context.sendMessage(MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD); } diff --git a/src/com/hypixel/hytale/server/core/command/commands/player/inventory/GiveCommand.java b/src/com/hypixel/hytale/server/core/command/commands/player/inventory/GiveCommand.java index e7c758c..b0eee4e 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/player/inventory/GiveCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/player/inventory/GiveCommand.java @@ -22,17 +22,13 @@ import javax.annotation.Nonnull; import org.bson.BsonDocument; public class GiveCommand extends AbstractPlayerCommand { - @Nonnull - private static final Message MESSAGE_COMMANDS_GIVE_RECEIVED = Message.translation("server.commands.give.received"); - @Nonnull - private static final Message MESSAGE_COMMANDS_GIVE_INSUFFICIENT_INV_SPACE = Message.translation("server.commands.give.insufficientInvSpace"); - @Nonnull - private static final Message MESSAGE_COMMANDS_GIVE_INVALID_METADATA = Message.translation("server.commands.give.invalidMetadata"); @Nonnull private final RequiredArg itemArg = this.withRequiredArg("item", "server.commands.give.item.desc", ArgTypes.ITEM_ASSET); @Nonnull private final DefaultArg quantityArg = this.withDefaultArg("quantity", "server.commands.give.quantity.desc", ArgTypes.INTEGER, 1, "1"); @Nonnull + private final OptionalArg durabilityArg = this.withOptionalArg("durability", "server.commands.give.durability.desc", ArgTypes.DOUBLE); + @Nonnull private final OptionalArg metadataArg = this.withOptionalArg("metadata", "server.commands.give.metadata.desc", ArgTypes.STRING); public GiveCommand() { @@ -52,25 +48,31 @@ public class GiveCommand extends AbstractPlayerCommand { Item item = this.itemArg.get(context); Integer quantity = this.quantityArg.get(context); + double durability = Double.MAX_VALUE; + if (this.durabilityArg.provided(context)) { + durability = this.durabilityArg.get(context); + } + BsonDocument metadata = null; if (this.metadataArg.provided(context)) { String metadataStr = this.metadataArg.get(context); try { metadata = BsonDocument.parse(metadataStr); - } catch (Exception var13) { - context.sendMessage(MESSAGE_COMMANDS_GIVE_INVALID_METADATA.param("error", var13.getMessage())); + } catch (Exception var16) { + context.sendMessage(Message.translation("server.commands.give.invalidMetadata").param("error", var16.getMessage())); return; } } - ItemStackTransaction transaction = playerComponent.getInventory().getCombinedHotbarFirst().addItemStack(new ItemStack(item.getId(), quantity, metadata)); + ItemStack stack = new ItemStack(item.getId(), quantity, metadata).withDurability(durability); + ItemStackTransaction transaction = playerComponent.getInventory().getCombinedHotbarFirst().addItemStack(stack); ItemStack remainder = transaction.getRemainder(); Message itemNameMessage = Message.translation(item.getTranslationKey()); if (remainder != null && !remainder.isEmpty()) { - context.sendMessage(MESSAGE_COMMANDS_GIVE_INSUFFICIENT_INV_SPACE.param("quantity", quantity).param("item", itemNameMessage)); + context.sendMessage(Message.translation("server.commands.give.insufficientInvSpace").param("quantity", quantity).param("item", itemNameMessage)); } else { - context.sendMessage(MESSAGE_COMMANDS_GIVE_RECEIVED.param("quantity", quantity).param("item", itemNameMessage)); + context.sendMessage(Message.translation("server.commands.give.received").param("quantity", quantity).param("item", itemNameMessage)); } } @@ -78,18 +80,14 @@ public class GiveCommand extends AbstractPlayerCommand { @Nonnull private static final Message MESSAGE_COMMANDS_ERRORS_PLAYER_NOT_IN_WORLD = Message.translation("server.commands.errors.playerNotInWorld"); @Nonnull - private static final Message MESSAGE_COMMANDS_GIVE_GAVE = Message.translation("server.commands.give.gave"); - @Nonnull - private static final Message MESSAGE_COMMANDS_GIVE_INSUFFICIENT_INV_SPACE = Message.translation("server.commands.give.insufficientInvSpace"); - @Nonnull - private static final Message MESSAGE_COMMANDS_GIVE_INVALID_METADATA = Message.translation("server.commands.give.invalidMetadata"); - @Nonnull private final RequiredArg playerArg = this.withRequiredArg("player", "server.commands.argtype.player.desc", ArgTypes.PLAYER_REF); @Nonnull private final RequiredArg itemArg = this.withRequiredArg("item", "server.commands.give.item.desc", ArgTypes.ITEM_ASSET); @Nonnull private final DefaultArg quantityArg = this.withDefaultArg("quantity", "server.commands.give.quantity.desc", ArgTypes.INTEGER, 1, "1"); @Nonnull + private final OptionalArg durabilityArg = this.withOptionalArg("durability", "server.commands.give.durability.desc", ArgTypes.DOUBLE); + @Nonnull private final OptionalArg metadataArg = this.withOptionalArg("metadata", "server.commands.give.metadata.desc", ArgTypes.STRING); GiveOtherCommand() { @@ -116,28 +114,35 @@ public class GiveCommand extends AbstractPlayerCommand { Item item = this.itemArg.get(context); Integer quantity = this.quantityArg.get(context); + double durability = Double.MAX_VALUE; + if (this.durabilityArg.provided(context)) { + durability = this.durabilityArg.get(context); + } + BsonDocument metadata = null; if (this.metadataArg.provided(context)) { String metadataStr = this.metadataArg.get(context); try { metadata = BsonDocument.parse(metadataStr); - } catch (Exception var13) { - context.sendMessage(MESSAGE_COMMANDS_GIVE_INVALID_METADATA.param("error", var13.getMessage())); + } catch (Exception var16) { + context.sendMessage(Message.translation("server.commands.give.invalidMetadata").param("error", var16.getMessage())); return; } } - ItemStackTransaction transaction = playerComponent.getInventory() - .getCombinedHotbarFirst() - .addItemStack(new ItemStack(item.getId(), quantity, metadata)); + ItemStack stack = new ItemStack(item.getId(), quantity, metadata).withDurability(durability); + ItemStackTransaction transaction = playerComponent.getInventory().getCombinedHotbarFirst().addItemStack(stack); ItemStack remainder = transaction.getRemainder(); Message itemNameMessage = Message.translation(item.getTranslationKey()); if (remainder != null && !remainder.isEmpty()) { - context.sendMessage(MESSAGE_COMMANDS_GIVE_INSUFFICIENT_INV_SPACE.param("quantity", quantity).param("item", itemNameMessage)); + context.sendMessage( + Message.translation("server.commands.give.insufficientInvSpace").param("quantity", quantity).param("item", itemNameMessage) + ); } else { context.sendMessage( - MESSAGE_COMMANDS_GIVE_GAVE.param("targetUsername", targetPlayerRef.getUsername()) + Message.translation("server.commands.give.gave") + .param("targetUsername", targetPlayerRef.getUsername()) .param("quantity", quantity) .param("item", itemNameMessage) ); diff --git a/src/com/hypixel/hytale/server/core/command/commands/player/inventory/InventoryBackpackCommand.java b/src/com/hypixel/hytale/server/core/command/commands/player/inventory/InventoryBackpackCommand.java index 4f0d093..cad8c46 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/player/inventory/InventoryBackpackCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/player/inventory/InventoryBackpackCommand.java @@ -18,10 +18,6 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList; import javax.annotation.Nonnull; public class InventoryBackpackCommand extends AbstractPlayerCommand { - @Nonnull - private static final Message MESSAGE_COMMANDS_INVENTORY_BACKPACK_SIZE = Message.translation("server.commands.inventory.backpack.size"); - @Nonnull - private static final Message MESSAGE_COMMANDS_INVENTORY_BACKPACK_RESIZED = Message.translation("server.commands.inventory.backpack.resized"); @Nonnull private final OptionalArg sizeArg = this.withOptionalArg("size", "server.commands.inventorybackpack.size.desc", ArgTypes.INTEGER); @@ -39,7 +35,7 @@ public class InventoryBackpackCommand extends AbstractPlayerCommand { Inventory inventory = playerComponent.getInventory(); if (!this.sizeArg.provided(context)) { - context.sendMessage(MESSAGE_COMMANDS_INVENTORY_BACKPACK_SIZE.param("capacity", inventory.getBackpack().getCapacity())); + context.sendMessage(Message.translation("server.commands.inventory.backpack.size").param("capacity", inventory.getBackpack().getCapacity())); } else { short capacity = this.sizeArg.get(context).shortValue(); ObjectArrayList remainder = new ObjectArrayList<>(); @@ -50,7 +46,9 @@ public class InventoryBackpackCommand extends AbstractPlayerCommand { } context.sendMessage( - MESSAGE_COMMANDS_INVENTORY_BACKPACK_RESIZED.param("capacity", inventory.getBackpack().getCapacity()).param("dropped", remainder.size()) + Message.translation("server.commands.inventory.backpack.resized") + .param("capacity", inventory.getBackpack().getCapacity()) + .param("dropped", remainder.size()) ); } } diff --git a/src/com/hypixel/hytale/server/core/command/commands/server/KickCommand.java b/src/com/hypixel/hytale/server/core/command/commands/server/KickCommand.java index 3ec8406..3715da6 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/server/KickCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/server/KickCommand.java @@ -9,8 +9,6 @@ import com.hypixel.hytale.server.core.universe.PlayerRef; import javax.annotation.Nonnull; public class KickCommand extends CommandBase { - @Nonnull - private static final Message MESSAGE_COMMANDS_KICK_SUCCESS = Message.translation("server.commands.kick.success"); @Nonnull private final RequiredArg playerArg = this.withRequiredArg("player", "server.commands.kick.desc", ArgTypes.PLAYER_REF); @@ -22,6 +20,6 @@ public class KickCommand extends CommandBase { protected void executeSync(@Nonnull CommandContext context) { PlayerRef playerToKick = this.playerArg.get(context); playerToKick.getPacketHandler().disconnect("You were kicked."); - context.sendMessage(MESSAGE_COMMANDS_KICK_SUCCESS.param("username", playerToKick.getUsername())); + context.sendMessage(Message.translation("server.commands.kick.success").param("username", playerToKick.getUsername())); } } diff --git a/src/com/hypixel/hytale/server/core/command/commands/server/WhoCommand.java b/src/com/hypixel/hytale/server/core/command/commands/server/WhoCommand.java index f92e8cb..fe86717 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/server/WhoCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/server/WhoCommand.java @@ -22,9 +22,6 @@ import java.util.concurrent.CompletableFuture; import javax.annotation.Nonnull; public class WhoCommand extends AbstractAsyncCommand { - @Nonnull - private static final Message MESSAGE_COMMANDS_WHO_PLAYER_WITH_DISPLAY_NAME = Message.translation("server.commands.who.playerWithDisplayName"); - public WhoCommand() { super("who", "server.commands.who.desc"); this.setPermissionGroup(GameMode.Adventure); @@ -57,7 +54,9 @@ public class WhoCommand extends AbstractAsyncCommand { Message displayName = displayNameComponent.getDisplayName(); if (displayName != null) { playerMessages.add( - MESSAGE_COMMANDS_WHO_PLAYER_WITH_DISPLAY_NAME.param("displayName", displayName).param("username", playerRef.getUsername()) + Message.translation("server.commands.who.playerWithDisplayName") + .param("displayName", displayName) + .param("username", playerRef.getUsername()) ); } else { playerMessages.add(Message.raw(playerRef.getUsername())); diff --git a/src/com/hypixel/hytale/server/core/command/commands/server/auth/AuthLoginBrowserCommand.java b/src/com/hypixel/hytale/server/core/command/commands/server/auth/AuthLoginBrowserCommand.java index eaf790d..7e25c78 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/server/auth/AuthLoginBrowserCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/server/auth/AuthLoginBrowserCommand.java @@ -30,10 +30,6 @@ public class AuthLoginBrowserCommand extends CommandBase { private static final Message MESSAGE_FAILED = Message.translation("server.commands.auth.login.browser.failed").color(Color.RED); @Nonnull private static final Message MESSAGE_PENDING = Message.translation("server.commands.auth.login.pending").color(Color.YELLOW); - @Nonnull - private static final Message MESSAGE_PERSISTENCE_MEMORY = Message.translation("server.commands.auth.login.persistence.memory").color(Color.ORANGE); - @Nonnull - private static final Message MESSAGE_PERSISTENCE_SAVED = Message.translation("server.commands.auth.login.persistence.saved").color(Color.GREEN); public AuthLoginBrowserCommand() { super("browser", "server.commands.auth.login.browser.desc"); @@ -72,17 +68,14 @@ public class AuthLoginBrowserCommand extends CommandBase { AuthCredentialStoreProvider provider = HytaleServer.get().getConfig().getAuthCredentialStoreProvider(); if (provider instanceof MemoryAuthCredentialStoreProvider) { String availableTypes = String.join(", ", AuthCredentialStoreProvider.CODEC.getRegisteredIds()); - context.sendMessage(MESSAGE_PERSISTENCE_MEMORY.param("types", availableTypes)); + context.sendMessage(Message.translation("server.commands.auth.login.persistence.memory").color(Color.ORANGE).param("types", availableTypes)); } else { String typeName = AuthCredentialStoreProvider.CODEC.getIdFor((Class)provider.getClass()); - context.sendMessage(MESSAGE_PERSISTENCE_SAVED.param("type", typeName)); + context.sendMessage(Message.translation("server.commands.auth.login.persistence.saved").color(Color.GREEN).param("type", typeName)); } } private static class AuthFlow extends OAuthBrowserFlow { - private AuthFlow() { - } - @Override public void onFlowInfo(String authUrl) { AbstractCommand.LOGGER.at(Level.INFO).log("Starting OAuth browser flow..."); diff --git a/src/com/hypixel/hytale/server/core/command/commands/server/auth/AuthLoginDeviceCommand.java b/src/com/hypixel/hytale/server/core/command/commands/server/auth/AuthLoginDeviceCommand.java index 8b194b5..8dfcde1 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/server/auth/AuthLoginDeviceCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/server/auth/AuthLoginDeviceCommand.java @@ -59,9 +59,6 @@ public class AuthLoginDeviceCommand extends CommandBase { } private static class AuthFlow extends OAuthDeviceFlow { - private AuthFlow() { - } - @Override public void onFlowInfo(String userCode, String verificationUri, String verificationUriComplete, int expiresIn) { AbstractCommand.LOGGER.at(Level.INFO).log("==================================================================="); diff --git a/src/com/hypixel/hytale/server/core/command/commands/server/auth/AuthLogoutCommand.java b/src/com/hypixel/hytale/server/core/command/commands/server/auth/AuthLogoutCommand.java index 81fc6b7..1315ce6 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/server/auth/AuthLogoutCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/server/auth/AuthLogoutCommand.java @@ -12,8 +12,6 @@ public class AuthLogoutCommand extends CommandBase { private static final Message MESSAGE_SINGLEPLAYER = Message.translation("server.commands.auth.logout.singleplayer").color(Color.RED); @Nonnull private static final Message MESSAGE_NOT_AUTHENTICATED = Message.translation("server.commands.auth.logout.notAuthenticated").color(Color.YELLOW); - @Nonnull - private static final Message MESSAGE_SUCCESS = Message.translation("server.commands.auth.logout.success").color(Color.GREEN); public AuthLogoutCommand() { super("logout", "server.commands.auth.logout.desc"); @@ -29,7 +27,7 @@ public class AuthLogoutCommand extends CommandBase { } else { ServerAuthManager.AuthMode previousMode = authManager.getAuthMode(); authManager.logout(); - context.sendMessage(MESSAGE_SUCCESS.param("previousMode", previousMode.name())); + context.sendMessage(Message.translation("server.commands.auth.logout.success").color(Color.GREEN).param("previousMode", previousMode.name())); } } } diff --git a/src/com/hypixel/hytale/server/core/command/commands/server/auth/AuthPersistenceCommand.java b/src/com/hypixel/hytale/server/core/command/commands/server/auth/AuthPersistenceCommand.java index 1aaabf4..ae26393 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/server/auth/AuthPersistenceCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/server/auth/AuthPersistenceCommand.java @@ -15,14 +15,6 @@ import javax.annotation.Nonnull; public class AuthPersistenceCommand extends CommandBase { @Nonnull private static final Message MESSAGE_SINGLEPLAYER = Message.translation("server.commands.auth.persistence.singleplayer").color(Color.RED); - @Nonnull - private static final Message MESSAGE_CURRENT = Message.translation("server.commands.auth.persistence.current").color(Color.YELLOW); - @Nonnull - private static final Message MESSAGE_AVAILABLE = Message.translation("server.commands.auth.persistence.available").color(Color.GRAY); - @Nonnull - private static final Message MESSAGE_CHANGED = Message.translation("server.commands.auth.persistence.changed").color(Color.GREEN); - @Nonnull - private static final Message MESSAGE_UNKNOWN_TYPE = Message.translation("server.commands.auth.persistence.unknownType").color(Color.RED); public AuthPersistenceCommand() { super("persistence", "server.commands.auth.persistence.desc"); @@ -36,9 +28,9 @@ public class AuthPersistenceCommand extends CommandBase { } else { AuthCredentialStoreProvider provider = HytaleServer.get().getConfig().getAuthCredentialStoreProvider(); String typeName = AuthCredentialStoreProvider.CODEC.getIdFor((Class)provider.getClass()); - context.sendMessage(MESSAGE_CURRENT.param("type", typeName)); + context.sendMessage(Message.translation("server.commands.auth.persistence.current").color(Color.YELLOW).param("type", typeName)); String availableTypes = String.join(", ", AuthCredentialStoreProvider.CODEC.getRegisteredIds()); - context.sendMessage(MESSAGE_AVAILABLE.param("types", availableTypes)); + context.sendMessage(Message.translation("server.commands.auth.persistence.available").color(Color.GRAY).param("types", availableTypes)); } } @@ -59,12 +51,12 @@ public class AuthPersistenceCommand extends CommandBase { String typeName = this.typeArg.get(context); BuilderCodec codec = AuthCredentialStoreProvider.CODEC.getCodecFor(typeName); if (codec == null) { - context.sendMessage(AuthPersistenceCommand.MESSAGE_UNKNOWN_TYPE.param("type", typeName)); + context.sendMessage(Message.translation("server.commands.auth.persistence.unknownType").color(Color.RED).param("type", typeName)); } else { AuthCredentialStoreProvider newProvider = codec.getDefaultValue(); HytaleServer.get().getConfig().setAuthCredentialStoreProvider(newProvider); authManager.swapCredentialStoreProvider(newProvider); - context.sendMessage(AuthPersistenceCommand.MESSAGE_CHANGED.param("type", typeName)); + context.sendMessage(Message.translation("server.commands.auth.persistence.changed").color(Color.GREEN).param("type", typeName)); } } } diff --git a/src/com/hypixel/hytale/server/core/command/commands/server/auth/AuthStatusCommand.java b/src/com/hypixel/hytale/server/core/command/commands/server/auth/AuthStatusCommand.java index c3a08c0..73217f4 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/server/auth/AuthStatusCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/server/auth/AuthStatusCommand.java @@ -11,8 +11,6 @@ import java.time.Instant; import javax.annotation.Nonnull; public class AuthStatusCommand extends CommandBase { - @Nonnull - private static final Message MESSAGE_STATUS_HEADER = Message.translation("server.commands.auth.status.format"); @Nonnull private static final Message MESSAGE_STATUS_CONNECTION_MODE_AUTHENTICATED = Message.translation("server.commands.auth.status.connectionMode.authenticated") .color(Color.GREEN); @@ -98,7 +96,8 @@ public class AuthStatusCommand extends CommandBase { } context.sendMessage( - MESSAGE_STATUS_HEADER.param("connectionMode", connectionModeMessage) + Message.translation("server.commands.auth.status.format") + .param("connectionMode", connectionModeMessage) .param("tokenMode", modeMessage) .param("profile", profileInfo) .param("sessionToken", sessionTokenStatus) diff --git a/src/com/hypixel/hytale/server/core/command/commands/utility/StashCommand.java b/src/com/hypixel/hytale/server/core/command/commands/utility/StashCommand.java index 0f91d5b..6a0ebcd 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/utility/StashCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/utility/StashCommand.java @@ -25,8 +25,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class StashCommand extends AbstractPlayerCommand { - @Nonnull - private static final Message MESSAGE_COMMANDS_ERRORS_CHUNK_NOT_LOADED = Message.translation("server.commands.errors.chunkNotLoaded"); @Nonnull private static final Message MESSAGE_COMMANDS_STASH_DROP_LIST_SET = Message.translation("server.commands.stash.droplistSet"); @Nonnull @@ -102,7 +100,9 @@ public class StashCommand extends AbstractPlayerCommand { } else { int chunkX = ChunkUtil.chunkCoordinate(block.x); int chunkZ = ChunkUtil.chunkCoordinate(block.z); - context.sendMessage(MESSAGE_COMMANDS_ERRORS_CHUNK_NOT_LOADED.param("chunkX", chunkX).param("chunkZ", chunkZ).param("world", world.getName())); + context.sendMessage( + Message.translation("server.commands.errors.chunkNotLoaded").param("chunkX", chunkX).param("chunkZ", chunkZ).param("world", world.getName()) + ); return null; } } diff --git a/src/com/hypixel/hytale/server/core/command/commands/utility/git/UpdateCommand.java b/src/com/hypixel/hytale/server/core/command/commands/utility/git/GitCommand.java similarity index 65% rename from src/com/hypixel/hytale/server/core/command/commands/utility/git/UpdateCommand.java rename to src/com/hypixel/hytale/server/core/command/commands/utility/git/GitCommand.java index 2f4583a..2a65a8f 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/utility/git/UpdateCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/utility/git/GitCommand.java @@ -2,9 +2,9 @@ package com.hypixel.hytale.server.core.command.commands.utility.git; import com.hypixel.hytale.server.core.command.system.basecommands.AbstractCommandCollection; -public class UpdateCommand extends AbstractCommandCollection { - public UpdateCommand() { - super("update", "server.commands.update.desc"); +public class GitCommand extends AbstractCommandCollection { + public GitCommand() { + super("git", "server.commands.git.desc"); this.addSubCommand(new UpdateAssetsCommand()); this.addSubCommand(new UpdatePrefabsCommand()); } diff --git a/src/com/hypixel/hytale/server/core/command/commands/utility/git/UpdateAssetsCommand.java b/src/com/hypixel/hytale/server/core/command/commands/utility/git/UpdateAssetsCommand.java index 8f4fb09..0e8d647 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/utility/git/UpdateAssetsCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/utility/git/UpdateAssetsCommand.java @@ -17,7 +17,7 @@ import javax.annotation.Nonnull; public class UpdateAssetsCommand extends AbstractCommandCollection { public UpdateAssetsCommand() { - super("assets", "server.commands.update.assets.desc"); + super("assets", "server.commands.git.assets.desc"); this.addSubCommand(new UpdateAssetsCommand.UpdateAssetsStatusCommand()); this.addSubCommand(new UpdateAssetsCommand.UpdateAssetsResetCommand()); this.addSubCommand(new UpdateAssetsCommand.UpdateAssetsPullCommand()); @@ -53,7 +53,7 @@ public class UpdateAssetsCommand extends AbstractCommandCollection { String commandDisplay = String.join(" ", processCommand); try { - context.sendMessage(Message.translation("server.commands.update.running").param("cmd", commandDisplay)); + context.sendMessage(Message.translation("server.commands.git.running").param("cmd", commandDisplay)); Process process = new ProcessBuilder(processCommand).directory(gitPath.toFile()).start(); try { @@ -62,21 +62,21 @@ public class UpdateAssetsCommand extends AbstractCommandCollection { String line; while ((line = reader.readLine()) != null) { - context.sendMessage(Message.translation("server.commands.update.runningStdOut").param("cmd", commandDisplay).param("line", line)); + context.sendMessage(Message.translation("server.commands.git.runningStdOut").param("cmd", commandDisplay).param("line", line)); } reader = new BufferedReader(new InputStreamReader(process.getErrorStream(), StandardCharsets.UTF_8)); while ((line = reader.readLine()) != null) { - context.sendMessage(Message.translation("server.commands.update.runningStdErr").param("cmd", commandDisplay).param("line", line)); + context.sendMessage(Message.translation("server.commands.git.runningStdErr").param("cmd", commandDisplay).param("line", line)); } - context.sendMessage(Message.translation("server.commands.update.done").param("cmd", commandDisplay)); + context.sendMessage(Message.translation("server.commands.git.done").param("cmd", commandDisplay)); } catch (InterruptedException var9) { Thread.currentThread().interrupt(); } } catch (IOException var10) { - context.sendMessage(Message.translation("server.commands.update.failed").param("cmd", commandDisplay).param("msg", var10.getMessage())); + context.sendMessage(Message.translation("server.commands.git.failed").param("cmd", commandDisplay).param("msg", var10.getMessage())); } } }); @@ -85,7 +85,7 @@ public class UpdateAssetsCommand extends AbstractCommandCollection { private static class UpdateAssetsPullCommand extends UpdateAssetsCommand.UpdateAssetsGitCommand { public UpdateAssetsPullCommand() { - super("pull", "server.commands.update.assets.pull.desc"); + super("pull", "server.commands.git.assets.pull.desc"); } @Nonnull @@ -103,7 +103,7 @@ public class UpdateAssetsCommand extends AbstractCommandCollection { private static class UpdateAssetsResetCommand extends UpdateAssetsCommand.UpdateAssetsGitCommand { public UpdateAssetsResetCommand() { - super("reset", "server.commands.update.assets.reset.desc"); + super("reset", "server.commands.git.assets.reset.desc"); } @Nonnull @@ -115,7 +115,7 @@ public class UpdateAssetsCommand extends AbstractCommandCollection { private static class UpdateAssetsStatusCommand extends UpdateAssetsCommand.UpdateAssetsGitCommand { public UpdateAssetsStatusCommand() { - super("status", "server.commands.update.assets.status.desc"); + super("status", "server.commands.git.assets.status.desc"); } @Nonnull diff --git a/src/com/hypixel/hytale/server/core/command/commands/utility/git/UpdatePrefabsCommand.java b/src/com/hypixel/hytale/server/core/command/commands/utility/git/UpdatePrefabsCommand.java index fc6e62a..972f7a4 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/utility/git/UpdatePrefabsCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/utility/git/UpdatePrefabsCommand.java @@ -17,7 +17,7 @@ import javax.annotation.Nonnull; public class UpdatePrefabsCommand extends AbstractCommandCollection { public UpdatePrefabsCommand() { - super("prefabs", "server.commands.update.prefabs.desc"); + super("prefabs", "server.commands.git.prefabs.desc"); this.addSubCommand(new UpdatePrefabsCommand.UpdatePrefabsStatusCommand()); this.addSubCommand(new UpdatePrefabsCommand.UpdatePrefabsCommitCommand()); this.addSubCommand(new UpdatePrefabsCommand.UpdatePrefabsPullCommand()); @@ -27,7 +27,7 @@ public class UpdatePrefabsCommand extends AbstractCommandCollection { private static class UpdatePrefabsAllCommand extends UpdatePrefabsCommand.UpdatePrefabsGitCommand { public UpdatePrefabsAllCommand() { - super("all", "server.commands.update.prefabs.all.desc"); + super("all", "server.commands.git.prefabs.all.desc"); } @Nonnull @@ -39,7 +39,7 @@ public class UpdatePrefabsCommand extends AbstractCommandCollection { {"git", "submodule", "foreach", "git", "pull"}, {"git", "submodule", "foreach", "git", "push"}, {"git", "add", "--all", "."}, - {"git", "commit", "-am", "\"Update prefabs by " + senderDisplayName + "\""}, + {"git", "commit", "-am", "Update prefabs by " + senderDisplayName}, {"git", "pull"}, {"git", "push"} }; @@ -48,7 +48,7 @@ public class UpdatePrefabsCommand extends AbstractCommandCollection { private static class UpdatePrefabsCommitCommand extends UpdatePrefabsCommand.UpdatePrefabsGitCommand { public UpdatePrefabsCommitCommand() { - super("commit", "server.commands.update.prefabs.commit.desc"); + super("commit", "server.commands.git.prefabs.commit.desc"); } @Nonnull @@ -56,7 +56,7 @@ public class UpdatePrefabsCommand extends AbstractCommandCollection { protected String[][] getCommands(@Nonnull String senderDisplayName) { return new String[][]{ {"git", "add", "--all", "."}, - {"git", "commit", "-am", "\"Update prefabs by " + senderDisplayName + "\""}, + {"git", "commit", "-am", "Update prefabs by " + senderDisplayName}, {"git", "submodule", "foreach", "git", "add", "--all", "."}, {"git", "submodule", "foreach", "git", "commit", "-am", "\"Update prefabs by " + senderDisplayName + "\""} }; @@ -90,13 +90,17 @@ public class UpdatePrefabsCommand extends AbstractCommandCollection { if (gitPath == null) { context.sendMessage(Message.translation("server.general.pathNotGitRepo").param("path", prefabsPath.toString())); } else { - String senderDisplayName = context.sender().getDisplayName(); + String senderDisplayName = context.sender().getDisplayName().replaceAll("[^a-zA-Z0-9 ._-]", ""); + if (senderDisplayName.isEmpty()) { + senderDisplayName = "Unknown"; + } + String[][] cmds = this.getCommands(senderDisplayName); for (String[] processCommand : cmds) { try { String commandDisplay = String.join(" ", processCommand); - context.sendMessage(Message.translation("server.commands.update.runningCmd").param("cmd", commandDisplay)); + context.sendMessage(Message.translation("server.commands.git.runningCmd").param("cmd", commandDisplay)); Process process = new ProcessBuilder(processCommand).directory(gitPath.toFile()).start(); try { @@ -105,23 +109,23 @@ public class UpdatePrefabsCommand extends AbstractCommandCollection { String line; while ((line = reader.readLine()) != null) { - context.sendMessage(Message.translation("server.commands.update.runningStdOut").param("cmd", commandDisplay).param("line", line)); + context.sendMessage(Message.translation("server.commands.git.runningStdOut").param("cmd", commandDisplay).param("line", line)); } reader = new BufferedReader(new InputStreamReader(process.getErrorStream(), StandardCharsets.UTF_8)); while ((line = reader.readLine()) != null) { - context.sendMessage(Message.translation("server.commands.update.runningStdErr").param("cmd", commandDisplay).param("line", line)); + context.sendMessage(Message.translation("server.commands.git.runningStdErr").param("cmd", commandDisplay).param("line", line)); } - context.sendMessage(Message.translation("server.commands.update.done").param("cmd", commandDisplay)); - } catch (InterruptedException var14) { + context.sendMessage(Message.translation("server.commands.git.done").param("cmd", commandDisplay)); + } catch (InterruptedException var15) { Thread.currentThread().interrupt(); break; } - } catch (IOException var15) { + } catch (IOException var16) { context.sendMessage( - Message.translation("server.commands.update.failed").param("cmd", String.join(" ", processCommand)).param("msg", var15.getMessage()) + Message.translation("server.commands.git.failed").param("cmd", String.join(" ", processCommand)).param("msg", var16.getMessage()) ); break; } @@ -134,7 +138,7 @@ public class UpdatePrefabsCommand extends AbstractCommandCollection { private static class UpdatePrefabsPullCommand extends UpdatePrefabsCommand.UpdatePrefabsGitCommand { public UpdatePrefabsPullCommand() { - super("pull", "server.commands.update.prefabs.pull.desc"); + super("pull", "server.commands.git.prefabs.pull.desc"); } @Nonnull @@ -146,7 +150,7 @@ public class UpdatePrefabsCommand extends AbstractCommandCollection { private static class UpdatePrefabsPushCommand extends UpdatePrefabsCommand.UpdatePrefabsGitCommand { public UpdatePrefabsPushCommand() { - super("push", "server.commands.update.prefabs.push.desc"); + super("push", "server.commands.git.prefabs.push.desc"); } @Nonnull @@ -158,7 +162,7 @@ public class UpdatePrefabsCommand extends AbstractCommandCollection { private static class UpdatePrefabsStatusCommand extends UpdatePrefabsCommand.UpdatePrefabsGitCommand { public UpdatePrefabsStatusCommand() { - super("status", "server.commands.update.prefabs.status.desc"); + super("status", "server.commands.git.prefabs.status.desc"); } @Nonnull diff --git a/src/com/hypixel/hytale/server/core/command/commands/utility/lighting/LightingCalculationCommand.java b/src/com/hypixel/hytale/server/core/command/commands/utility/lighting/LightingCalculationCommand.java index 017d692..7d8c5b7 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/utility/lighting/LightingCalculationCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/utility/lighting/LightingCalculationCommand.java @@ -67,8 +67,5 @@ public class LightingCalculationCommand extends AbstractWorldCommand { private static enum LightCalculationType { FLOOD, FULLBRIGHT; - - private LightCalculationType() { - } } } diff --git a/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkFixHeightMapCommand.java b/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkFixHeightMapCommand.java index ea6f40a..6299bc7 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkFixHeightMapCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkFixHeightMapCommand.java @@ -22,8 +22,6 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Nonnull; public class ChunkFixHeightMapCommand extends AbstractWorldCommand { - @Nonnull - private static final Message MESSAGE_COMMANDS_ERRORS_CHUNK_NOT_LOADED = Message.translation("server.commands.errors.chunkNotLoaded"); @Nonnull private static final Message MESSAGE_COMMANDS_CHUNK_FIXHEIGHTMAP_STARTED = Message.translation("server.commands.chunk.fixHeightMap.started"); @Nonnull @@ -33,16 +31,6 @@ public class ChunkFixHeightMapCommand extends AbstractWorldCommand { "server.commands.chunk.fixHeightMap.invalidatingLighting" ); @Nonnull - private static final Message MESSAGE_COMMANDS_CHUNK_FIXHEIGHTMAP_WAITING_FOR_LIGHTING = Message.translation( - "server.commands.chunk.fixHeightMap.waitingForLighting" - ); - @Nonnull - private static final Message MESSAGE_COMMANDS_CHUNK_FIXHEIGHTMAP_LIGHTING_FINISHED = Message.translation( - "server.commands.chunk.fixHeightMap.lightingFinished" - ); - @Nonnull - private static final Message MESSAGE_COMMANDS_CHUNK_FIXHEIGHTMAP_LIGHTING_ERROR = Message.translation("server.commands.chunk.fixHeightMap.lightingError"); - @Nonnull private final RequiredArg chunkPosArg = this.withRequiredArg( "x z", "server.commands.chunk.fixheight.position.desc", ArgTypes.RELATIVE_CHUNK_POSITION ); @@ -84,23 +72,25 @@ public class ChunkFixHeightMapCommand extends AbstractWorldCommand { chunkLighting.invalidateLightInChunk(worldChunkComponent); context.sendMessage(MESSAGE_COMMANDS_CHUNK_FIXHEIGHTMAP_DONE); - context.sendMessage(MESSAGE_COMMANDS_CHUNK_FIXHEIGHTMAP_WAITING_FOR_LIGHTING.param("x", chunkX).param("z", chunkZ)); + context.sendMessage(Message.translation("server.commands.chunk.fixHeightMap.waitingForLighting").param("x", chunkX).param("z", chunkZ)); int[] count = new int[]{0}; ScheduledFuture[] scheduledFuture = new ScheduledFuture[1]; scheduledFuture[0] = HytaleServer.SCHEDULED_EXECUTOR.scheduleWithFixedDelay(() -> { if (chunkLighting.isQueued(chunkX, chunkZ)) { if (count[0]++ > 60) { scheduledFuture[0].cancel(false); - context.sendMessage(MESSAGE_COMMANDS_CHUNK_FIXHEIGHTMAP_LIGHTING_ERROR.param("x", chunkX).param("z", chunkZ)); + context.sendMessage(Message.translation("server.commands.chunk.fixHeightMap.lightingError").param("x", chunkX).param("z", chunkZ)); } } else { world.getNotificationHandler().updateChunk(chunkIndex); - context.sendMessage(MESSAGE_COMMANDS_CHUNK_FIXHEIGHTMAP_LIGHTING_FINISHED.param("x", chunkX).param("z", chunkZ)); + context.sendMessage(Message.translation("server.commands.chunk.fixHeightMap.lightingFinished").param("x", chunkX).param("z", chunkZ)); scheduledFuture[0].cancel(false); } }, 1L, 1L, TimeUnit.SECONDS); } else { - context.sendMessage(MESSAGE_COMMANDS_ERRORS_CHUNK_NOT_LOADED.param("chunkX", chunkX).param("chunkZ", chunkZ).param("world", world.getName())); + context.sendMessage( + Message.translation("server.commands.errors.chunkNotLoaded").param("chunkX", chunkX).param("chunkZ", chunkZ).param("world", world.getName()) + ); } } } diff --git a/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkForceTickCommand.java b/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkForceTickCommand.java index 74a0d0e..f8da9f9 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkForceTickCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkForceTickCommand.java @@ -17,12 +17,6 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class ChunkForceTickCommand extends AbstractWorldCommand { - @Nonnull - private static final Message MESSAGE_COMMANDS_ERRORS_CHUNK_NOT_LOADED = Message.translation("server.commands.errors.chunkNotLoaded"); - @Nonnull - private static final Message MESSAGE_COMMANDS_FORCECHUNKTICK_CHUNK_LOAD_USAGE = Message.translation("server.commands.forcechunktick.chunkLoadUsage"); - @Nonnull - private static final Message MESSAGE_COMMANDS_FORCECHUNKTICK_BLOCKS_IN_CHUNK_TICK = Message.translation("server.commands.forcechunktick.blocksInChunkTick"); @Nonnull private final RequiredArg chunkPosArg = this.withRequiredArg( "x z", "server.commands.chunk.forcetick.position.desc", ArgTypes.RELATIVE_CHUNK_POSITION @@ -53,10 +47,15 @@ public class ChunkForceTickCommand extends AbstractWorldCommand { } } - context.sendMessage(MESSAGE_COMMANDS_FORCECHUNKTICK_BLOCKS_IN_CHUNK_TICK.param("chunkX", position.x).param("chunkZ", position.y)); + context.sendMessage(Message.translation("server.commands.forcechunktick.blocksInChunkTick").param("chunkX", position.x).param("chunkZ", position.y)); } else { - context.sendMessage(MESSAGE_COMMANDS_ERRORS_CHUNK_NOT_LOADED.param("chunkX", position.x).param("chunkZ", position.y).param("world", world.getName())); - context.sendMessage(MESSAGE_COMMANDS_FORCECHUNKTICK_CHUNK_LOAD_USAGE.param("chunkX", position.x).param("chunkZ", position.y)); + context.sendMessage( + Message.translation("server.commands.errors.chunkNotLoaded") + .param("chunkX", position.x) + .param("chunkZ", position.y) + .param("world", world.getName()) + ); + context.sendMessage(Message.translation("server.commands.forcechunktick.chunkLoadUsage").param("chunkX", position.x).param("chunkZ", position.y)); } } } diff --git a/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkInfoCommand.java b/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkInfoCommand.java index 469211f..1af1b9e 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkInfoCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkInfoCommand.java @@ -22,10 +22,6 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class ChunkInfoCommand extends AbstractWorldCommand { - @Nonnull - private static final Message MESSAGE_GENERAL_CHUNK_NOT_LOADED = Message.translation("server.general.chunkNotLoaded"); - @Nonnull - private static final Message MESSAGE_COMMANDS_CHUNKINFO_LOAD_USAGE = Message.translation("server.commands.chunkinfo.load.usage"); @Nonnull private final RequiredArg chunkPosArg = this.withRequiredArg( "x z", "server.commands.chunk.info.position.desc", ArgTypes.RELATIVE_CHUNK_POSITION @@ -94,8 +90,8 @@ public class ChunkInfoCommand extends AbstractWorldCommand { context.sendMessage(msg); } else { - context.sendMessage(MESSAGE_GENERAL_CHUNK_NOT_LOADED.param("chunkX", position.x).param("chunkZ", position.y)); - context.sendMessage(MESSAGE_COMMANDS_CHUNKINFO_LOAD_USAGE.param("chunkX", position.x).param("chunkZ", position.y)); + context.sendMessage(Message.translation("server.general.chunkNotLoaded").param("chunkX", position.x).param("chunkZ", position.y)); + context.sendMessage(Message.translation("server.commands.chunkinfo.load.usage").param("chunkX", position.x).param("chunkZ", position.y)); } } } diff --git a/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkLightingCommand.java b/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkLightingCommand.java index 4945bc9..2637848 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkLightingCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkLightingCommand.java @@ -21,10 +21,6 @@ import java.util.logging.Level; import javax.annotation.Nonnull; public class ChunkLightingCommand extends AbstractWorldCommand { - @Nonnull - private static final Message MESSAGE_COMMANDS_ERRORS_CHUNK_NOT_LOADED = Message.translation("server.commands.errors.chunkNotLoaded"); - @Nonnull - private static final Message MESSAGE_COMMANDS_CHUNKINFO_LOAD_USAGE = Message.translation("server.commands.chunkinfo.load.usage"); @Nonnull private static final Message MESSAGE_COMMANDS_CHUNKINFO_SERIALIZED = Message.translation("server.commands.chunkinfo.serialized"); @Nonnull @@ -61,8 +57,13 @@ public class ChunkLightingCommand extends AbstractWorldCommand { context.sendMessage(MESSAGE_COMMANDS_CHUNKINFO_SERIALIZED_FAILED); } } else { - context.sendMessage(MESSAGE_COMMANDS_ERRORS_CHUNK_NOT_LOADED.param("chunkX", chunkPos.x).param("chunkZ", chunkPos.y).param("world", world.getName())); - context.sendMessage(MESSAGE_COMMANDS_CHUNKINFO_LOAD_USAGE.param("chunkX", chunkPos.x).param("chunkZ", chunkPos.y)); + context.sendMessage( + Message.translation("server.commands.errors.chunkNotLoaded") + .param("chunkX", chunkPos.x) + .param("chunkZ", chunkPos.y) + .param("world", world.getName()) + ); + context.sendMessage(Message.translation("server.commands.chunkinfo.load.usage").param("chunkX", chunkPos.x).param("chunkZ", chunkPos.y)); } } } diff --git a/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkLoadCommand.java b/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkLoadCommand.java index 6c24077..f95375c 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkLoadCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkLoadCommand.java @@ -17,12 +17,6 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class ChunkLoadCommand extends AbstractWorldCommand { - @Nonnull - private static final Message MESSAGE_COMMANDS_CHUNK_LOAD_ALREADY_LOADED = Message.translation("server.commands.chunk.load.alreadyLoaded"); - @Nonnull - private static final Message MESSAGE_COMMANDS_CHUNK_LOAD_LOADING = Message.translation("server.commands.chunk.load.loading"); - @Nonnull - private static final Message MESSAGE_COMMANDS_CHUNK_LOAD_LOADED = Message.translation("server.commands.chunk.load.loaded"); @Nonnull private final RequiredArg chunkPosArg = this.withRequiredArg( "x z", "server.commands.chunk.load.position.desc", ArgTypes.RELATIVE_CHUNK_POSITION @@ -43,17 +37,35 @@ public class ChunkLoadCommand extends AbstractWorldCommand { Ref chunkRef = chunkStore.getChunkReference(chunkIndex); if (chunkRef != null && chunkRef.isValid()) { context.sendMessage( - MESSAGE_COMMANDS_CHUNK_LOAD_ALREADY_LOADED.param("chunkX", position.x).param("chunkZ", position.y).param("worldName", world.getName()) + Message.translation("server.commands.chunk.load.alreadyLoaded") + .param("chunkX", position.x) + .param("chunkZ", position.y) + .param("worldName", world.getName()) ); } else { - context.sendMessage(MESSAGE_COMMANDS_CHUNK_LOAD_LOADING.param("chunkX", position.x).param("chunkZ", position.y).param("worldName", world.getName())); - world.getChunkAsync(position.x, position.y).thenAccept(worldChunk -> world.execute(() -> { - if (this.markDirtyArg.provided(context)) { - worldChunk.markNeedsSaving(); - } + context.sendMessage( + Message.translation("server.commands.chunk.load.loading") + .param("chunkX", position.x) + .param("chunkZ", position.y) + .param("worldName", world.getName()) + ); + world.getChunkAsync(position.x, position.y) + .thenAccept( + worldChunk -> world.execute( + () -> { + if (this.markDirtyArg.provided(context)) { + worldChunk.markNeedsSaving(); + } - context.sendMessage(MESSAGE_COMMANDS_CHUNK_LOAD_LOADED.param("chunkX", position.x).param("chunkZ", position.y).param("worldName", world.getName())); - })); + context.sendMessage( + Message.translation("server.commands.chunk.load.loaded") + .param("chunkX", position.x) + .param("chunkZ", position.y) + .param("worldName", world.getName()) + ); + } + ) + ); } } } diff --git a/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkMarkSaveCommand.java b/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkMarkSaveCommand.java index e19529b..7572f40 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkMarkSaveCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkMarkSaveCommand.java @@ -17,14 +17,6 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class ChunkMarkSaveCommand extends AbstractWorldCommand { - @Nonnull - private static final Message MESSAGE_COMMANDS_CHUNK_MARKSAVE_MARKING_ALREADY_LOADED = Message.translation( - "server.commands.chunk.marksave.markingAlreadyLoaded" - ); - @Nonnull - private static final Message MESSAGE_COMMANDS_CHUNK_LOAD_LOADING = Message.translation("server.commands.chunk.load.loading"); - @Nonnull - private static final Message MESSAGE_COMMANDS_CHUNK_MARKSAVE_LOADED = Message.translation("server.commands.chunk.marksave.loaded"); @Nonnull private final RequiredArg chunkPosArg = this.withRequiredArg( "x z", "server.commands.chunk.marksave.position.desc", ArgTypes.RELATIVE_CHUNK_POSITION @@ -49,14 +41,32 @@ public class ChunkMarkSaveCommand extends AbstractWorldCommand { worldChunkComponent.markNeedsSaving(); context.sendMessage( - MESSAGE_COMMANDS_CHUNK_MARKSAVE_MARKING_ALREADY_LOADED.param("x", position.x).param("z", position.y).param("worldName", world.getName()) + Message.translation("server.commands.chunk.marksave.markingAlreadyLoaded") + .param("x", position.x) + .param("z", position.y) + .param("worldName", world.getName()) ); } else { - context.sendMessage(MESSAGE_COMMANDS_CHUNK_LOAD_LOADING.param("chunkX", position.x).param("chunkZ", position.y).param("worldName", world.getName())); - world.getChunkAsync(position.x, position.y).thenAccept(worldChunk -> world.execute(() -> { - worldChunk.markNeedsSaving(); - context.sendMessage(MESSAGE_COMMANDS_CHUNK_MARKSAVE_LOADED.param("x", position.x).param("z", position.y).param("worldName", world.getName())); - })); + context.sendMessage( + Message.translation("server.commands.chunk.load.loading") + .param("chunkX", position.x) + .param("chunkZ", position.y) + .param("worldName", world.getName()) + ); + world.getChunkAsync(position.x, position.y) + .thenAccept( + worldChunk -> world.execute( + () -> { + worldChunk.markNeedsSaving(); + context.sendMessage( + Message.translation("server.commands.chunk.marksave.loaded") + .param("x", position.x) + .param("z", position.y) + .param("worldName", world.getName()) + ); + } + ) + ); } } } diff --git a/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkMaxSendRateCommand.java b/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkMaxSendRateCommand.java index 3d2bef7..b120299 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkMaxSendRateCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkMaxSendRateCommand.java @@ -15,12 +15,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class ChunkMaxSendRateCommand extends AbstractTargetPlayerCommand { - @Nonnull - private static final Message MESSAGE_COMMANDS_CHUNK_MAXSENDRATE_SEC_SET = Message.translation("server.commands.chunk.maxsendrate.sec.set"); - @Nonnull - private static final Message MESSAGE_COMMANDS_CHUNK_MAXSENDRATE_TICK_SET = Message.translation("server.commands.chunk.maxsendrate.tick.set"); - @Nonnull - private static final Message MESSAGE_COMMANDS_CHUNK_MAXSENDRATE_SUMMARY = Message.translation("server.commands.chunk.maxsendrate.summary"); @Nonnull private final OptionalArg secArg = this.withOptionalArg("sec", "server.commands.chunk.maxsendrate.sec.desc", ArgTypes.INTEGER); @Nonnull @@ -46,17 +40,18 @@ public class ChunkMaxSendRateCommand extends AbstractTargetPlayerCommand { if (this.secArg.provided(context)) { int sec = this.secArg.get(context); chunkTracker.setMaxChunksPerSecond(sec); - context.sendMessage(MESSAGE_COMMANDS_CHUNK_MAXSENDRATE_SEC_SET.param("value", sec)); + context.sendMessage(Message.translation("server.commands.chunk.maxsendrate.sec.set").param("value", sec)); } if (this.tickArg.provided(context)) { int tick = this.tickArg.get(context); chunkTracker.setMaxChunksPerTick(tick); - context.sendMessage(MESSAGE_COMMANDS_CHUNK_MAXSENDRATE_TICK_SET.param("value", tick)); + context.sendMessage(Message.translation("server.commands.chunk.maxsendrate.tick.set").param("value", tick)); } context.sendMessage( - MESSAGE_COMMANDS_CHUNK_MAXSENDRATE_SUMMARY.param("perSecond", chunkTracker.getMaxChunksPerSecond()) + Message.translation("server.commands.chunk.maxsendrate.summary") + .param("perSecond", chunkTracker.getMaxChunksPerSecond()) .param("perTick", chunkTracker.getMaxChunksPerTick()) ); } diff --git a/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkRegenerateCommand.java b/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkRegenerateCommand.java index 059e1b8..031f423 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkRegenerateCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkRegenerateCommand.java @@ -15,8 +15,6 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class ChunkRegenerateCommand extends AbstractWorldCommand { - @Nonnull - private static final Message MESSAGE_COMMANDS_CHUNK_REGENERATE_SUCCESS = Message.translation("server.commands.chunk.regenerate.success"); @Nonnull private final RequiredArg chunkPosArg = this.withRequiredArg( "x z", "server.commands.chunk.regenerate.position.desc", ArgTypes.RELATIVE_CHUNK_POSITION @@ -35,7 +33,8 @@ public class ChunkRegenerateCommand extends AbstractWorldCommand { .thenAccept( chunkRef -> world.execute( () -> context.sendMessage( - MESSAGE_COMMANDS_CHUNK_REGENERATE_SUCCESS.param("chunkX", chunkPosition.x) + Message.translation("server.commands.chunk.regenerate.success") + .param("chunkX", chunkPosition.x) .param("chunkZ", chunkPosition.y) .param("worldName", world.getName()) ) diff --git a/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkTintCommand.java b/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkTintCommand.java index cd90081..2cfbab4 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkTintCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkTintCommand.java @@ -43,12 +43,6 @@ public class ChunkTintCommand extends AbstractPlayerCommand { private static final int BLUR_RADIUS = 5; private static final double BLUR_SIGMA = 1.5; @Nonnull - private static final Message MESSAGE_GENERAL_CHUNK_NOT_LOADED = Message.translation("server.general.chunkNotLoaded"); - @Nonnull - private static final Message MESSAGE_COMMANDS_CHUNK_TINT_SUCCESS = Message.translation("server.commands.chunk.tint.success"); - @Nonnull - private static final Message MESSAGE_COMMANDS_CHUNK_TINT_SUCCESS_BLUR = Message.translation("server.commands.chunk.tint.success.blur"); - @Nonnull private final RequiredArg colorArg = this.withRequiredArg("color", "server.commands.chunk.tint.color.desc", ArgTypes.COLOR); @Nonnull private final DefaultArg radiusArg = this.withDefaultArg( @@ -136,17 +130,18 @@ public class ChunkTintCommand extends AbstractPlayerCommand { updateChunks.forEach(chunkIndexx -> world.getNotificationHandler().updateChunk(chunkIndexx)); if (this.blurArg.provided(context)) { context.sendMessage( - MESSAGE_COMMANDS_CHUNK_TINT_SUCCESS_BLUR.param("chunkX", chunkX) + Message.translation("server.commands.chunk.tint.success.blur") + .param("chunkX", chunkX) .param("chunkZ", chunkZ) .param("chunksAffected", updateChunks.size()) .param("radius", radius) .param("sigma", sigma) ); } else { - context.sendMessage(MESSAGE_COMMANDS_CHUNK_TINT_SUCCESS.param("chunkX", chunkX).param("chunkZ", chunkZ)); + context.sendMessage(Message.translation("server.commands.chunk.tint.success").param("chunkX", chunkX).param("chunkZ", chunkZ)); } } else { - context.sendMessage(MESSAGE_GENERAL_CHUNK_NOT_LOADED.param("chunkX", chunkX).param("chunkZ", chunkZ)); + context.sendMessage(Message.translation("server.general.chunkNotLoaded").param("chunkX", chunkX).param("chunkZ", chunkZ)); } } @@ -274,9 +269,6 @@ public class ChunkTintCommand extends AbstractPlayerCommand { public static enum TintChunkPageAction { Submit, ColorChanged; - - private TintChunkPageAction() { - } } public static class TintChunkPageEventData { @@ -308,9 +300,6 @@ public class ChunkTintCommand extends AbstractPlayerCommand { private boolean isBlurEnabled; private ChunkTintCommand.TintChunkPage.TintChunkPageAction action; - public TintChunkPageEventData() { - } - public String getColor() { return this.color; } diff --git a/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkTrackerCommand.java b/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkTrackerCommand.java index 2e1363b..a6aae26 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkTrackerCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkTrackerCommand.java @@ -15,9 +15,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class ChunkTrackerCommand extends AbstractTargetPlayerCommand { - @Nonnull - private static final Message MESSAGE_COMMANDS_CHUNK_TRACKER_SUMMARY = Message.translation("server.commands.chunkTracker.summary"); - public ChunkTrackerCommand() { super("tracker", "server.commands.chunk.tracker.desc"); } @@ -42,7 +39,8 @@ public class ChunkTrackerCommand extends AbstractTargetPlayerCommand { ChunkStore chunkStore = world.getChunkStore(); String loadedWorldChunks = Integer.toString(chunkStore.getLoadedChunksCount()); context.sendMessage( - MESSAGE_COMMANDS_CHUNK_TRACKER_SUMMARY.param("maxChunksPerSecond", chunkTrackerComponent.getMaxChunksPerSecond()) + Message.translation("server.commands.chunkTracker.summary") + .param("maxChunksPerSecond", chunkTrackerComponent.getMaxChunksPerSecond()) .param("maxChunksPerTick", chunkTrackerComponent.getMaxChunksPerTick()) .param("minChunkLoadedRadius", chunkTrackerComponent.getMinLoadedChunksRadius()) .param("maxHotChunkLoadedRadius", chunkTrackerComponent.getMaxHotLoadedChunksRadius()) diff --git a/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkUnloadCommand.java b/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkUnloadCommand.java index 3c0a0dd..482c963 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkUnloadCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/world/chunk/ChunkUnloadCommand.java @@ -17,10 +17,6 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class ChunkUnloadCommand extends AbstractWorldCommand { - @Nonnull - private static final Message MESSAGE_COMMANDS_CHUNK_UNLOAD_ALREADY_UNLOADED = Message.translation("server.commands.chunk.unload.alreadyUnloaded"); - @Nonnull - private static final Message MESSAGE_COMMANDS_CHUNK_UNLOAD_SUCCESS = Message.translation("server.commands.chunk.unload.success"); @Nonnull private final RequiredArg chunkPosArg = this.withRequiredArg( "x z", "server.commands.chunk.unload.position.desc", ArgTypes.RELATIVE_CHUNK_POSITION @@ -39,12 +35,20 @@ public class ChunkUnloadCommand extends AbstractWorldCommand { Ref chunkRef = chunkComponentStore.getChunkReference(indexChunk); if (chunkRef == null) { context.sendMessage( - MESSAGE_COMMANDS_CHUNK_UNLOAD_ALREADY_UNLOADED.param("chunkX", position.x).param("chunkZ", position.y).param("worldName", world.getName()) + Message.translation("server.commands.chunk.unload.alreadyUnloaded") + .param("chunkX", position.x) + .param("chunkZ", position.y) + .param("worldName", world.getName()) ); } else { chunkComponentStore.remove(chunkRef, RemoveReason.UNLOAD); world.getNotificationHandler().updateChunk(indexChunk); - context.sendMessage(MESSAGE_COMMANDS_CHUNK_UNLOAD_SUCCESS.param("chunkX", position.x).param("chunkZ", position.y).param("worldName", world.getName())); + context.sendMessage( + Message.translation("server.commands.chunk.unload.success") + .param("chunkX", position.x) + .param("chunkZ", position.y) + .param("worldName", world.getName()) + ); } } } diff --git a/src/com/hypixel/hytale/server/core/command/commands/world/worldgen/WorldGenBenchmarkCommand.java b/src/com/hypixel/hytale/server/core/command/commands/world/worldgen/WorldGenBenchmarkCommand.java index 51c0546..1cfd06f 100644 --- a/src/com/hypixel/hytale/server/core/command/commands/world/worldgen/WorldGenBenchmarkCommand.java +++ b/src/com/hypixel/hytale/server/core/command/commands/world/worldgen/WorldGenBenchmarkCommand.java @@ -20,6 +20,7 @@ import java.io.FileWriter; import java.util.HashSet; import java.util.Set; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.logging.Level; import javax.annotation.Nonnull; @@ -27,11 +28,7 @@ import javax.annotation.Nonnull; public class WorldGenBenchmarkCommand extends CommandBase { private static final AtomicBoolean IS_RUNNING = new AtomicBoolean(false); public static final Message MESSAGE_COMMANDS_WORLD_GEN_BENCHMARK_SAVING = Message.translation("server.commands.worldgenbenchmark.saving"); - public static final Message MESSAGE_COMMANDS_WORLD_GEN_BENCHMARK_DONE = Message.translation("server.commands.worldgenbenchmark.done"); public static final Message MESSAGE_COMMANDS_WORLD_GEN_BENCHMARK_SAVE_FAILED = Message.translation("server.commands.worldgenbenchmark.saveFailed"); - public static final Message MESSAGE_COMMANDS_WORLD_GEN_BENCHMARK_SAVE_DONE = Message.translation("server.commands.worldgenbenchmark.saveDone"); - public static final Message MESSAGE_COMMANDS_WORLD_GEN_BENCHMARK_PROGRESS = Message.translation("server.commands.worldgenbenchmark.progress"); - public static final Message MESSAGE_COMMANDS_WORLD_GEN_BENCHMARK_STARTED = Message.translation("server.commands.worldgenbenchmark.started"); public static final Message MESSAGE_COMMANDS_WORLD_GEN_BENCHMARK_ABORT = Message.translation("server.commands.worldgenbenchmark.abort"); public static final Message MESSAGE_COMMANDS_WORLD_GEN_BENCHMARK_BENCHMARK_NOT_SUPPORTED = Message.translation( "server.commands.worldgenbenchmark.benchmarkNotSupported" @@ -98,58 +95,67 @@ public class WorldGenBenchmarkCommand extends CommandBase { context.sendMessage(MESSAGE_COMMANDS_WORLD_GEN_BENCHMARK_ABORT); } else { context.sendMessage( - MESSAGE_COMMANDS_WORLD_GEN_BENCHMARK_STARTED.param("seed", seed).param("worldName", worldName).param("size", generatingChunks.size()) + Message.translation("server.commands.worldgenbenchmark.started") + .param("seed", seed) + .param("worldName", worldName) + .param("size", generatingChunks.size()) ); benchmarkableWorldGen.getBenchmark().start(); int chunkCount = generatingChunks.size(); long startTime = System.nanoTime(); new Thread( () -> { - Set> currentChunks = new HashSet<>(); - long nextBroadcast = System.nanoTime(); + try { + Set> currentChunks = new HashSet<>(); + long nextBroadcast = System.nanoTime(); - do { - long thisTime = System.nanoTime(); - if (thisTime >= nextBroadcast) { - world.execute( - () -> world.sendMessage( - MESSAGE_COMMANDS_WORLD_GEN_BENCHMARK_PROGRESS.param( - "percent", Math.round((1.0 - (double)generatingChunks.size() / chunkCount) * 1000.0) / 10.0 + do { + long thisTime = System.nanoTime(); + if (thisTime >= nextBroadcast) { + world.execute( + () -> world.sendMessage( + Message.translation("server.commands.worldgenbenchmark.progress") + .param("percent", Math.round((1.0 - (double)generatingChunks.size() / chunkCount) * 1000.0) / 10.0) ) - ) + ); + nextBroadcast = thisTime + 5000000000L; + } + + currentChunks.removeIf(CompletableFuture::isDone); + + for (int i = currentChunks.size(); i < 20 && !generatingChunks.isEmpty(); i++) { + long index = generatingChunks.removeLong(generatingChunks.size() - 1); + CompletableFuture future = worldGen.generate( + seed, index, ChunkUtil.xOfChunkIndex(index), ChunkUtil.zOfChunkIndex(index), idx -> true + ); + currentChunks.add(future); + } + } while (!currentChunks.isEmpty()); + + String duration = FormatUtil.nanosToString(System.nanoTime() - startTime); + world.execute(() -> world.sendMessage(Message.translation("server.commands.worldgenbenchmark.done").param("duration", duration))); + world.execute(() -> world.sendMessage(MESSAGE_COMMANDS_WORLD_GEN_BENCHMARK_SAVING)); + String fileName = "quant." + System.currentTimeMillis() + "." + (maxX - minX) + "x" + (maxZ - minZ) + "." + worldName + ".txt"; + File folder = new File("quantification"); + File file = new File("quantification" + File.separator + fileName); + folder.mkdirs(); + + try (FileWriter fw = new FileWriter(file)) { + fw.write(benchmarkableWorldGen.getBenchmark().buildReport().join()); + world.execute( + () -> world.sendMessage(Message.translation("server.commands.worldgenbenchmark.saveDone").param("fileName", fileName)) ); - nextBroadcast = thisTime + 5000000000L; + } catch (Exception var31) { + HytaleLogger.getLogger().at(Level.SEVERE).withCause(var31).log("Failed to save worldgen benchmark report!"); + world.execute(() -> world.sendMessage(MESSAGE_COMMANDS_WORLD_GEN_BENCHMARK_SAVE_FAILED)); } - currentChunks.removeIf(CompletableFuture::isDone); - - for (int i = currentChunks.size(); i < 20 && !generatingChunks.isEmpty(); i++) { - long index = generatingChunks.removeLong(generatingChunks.size() - 1); - CompletableFuture future = worldGen.generate( - seed, index, ChunkUtil.xOfChunkIndex(index), ChunkUtil.zOfChunkIndex(index), idx -> true - ); - currentChunks.add(future); - } - } while (!currentChunks.isEmpty()); - - String duration = FormatUtil.nanosToString(System.nanoTime() - startTime); - world.execute(() -> world.sendMessage(MESSAGE_COMMANDS_WORLD_GEN_BENCHMARK_DONE.param("duration", duration))); - world.execute(() -> world.sendMessage(MESSAGE_COMMANDS_WORLD_GEN_BENCHMARK_SAVING)); - String fileName = "quant." + System.currentTimeMillis() + "." + (maxX - minX) + "x" + (maxZ - minZ) + "." + worldName + ".txt"; - File folder = new File("quantification"); - File file = new File("quantification" + File.separator + fileName); - folder.mkdirs(); - - try (FileWriter fw = new FileWriter(file)) { - fw.write(benchmarkableWorldGen.getBenchmark().buildReport().join()); - world.execute(() -> world.sendMessage(MESSAGE_COMMANDS_WORLD_GEN_BENCHMARK_SAVE_DONE.param("fileName", fileName))); - } catch (Exception var25) { - HytaleLogger.getLogger().at(Level.SEVERE).withCause(var25).log("Failed to save worldgen benchmark report!"); - world.execute(() -> world.sendMessage(MESSAGE_COMMANDS_WORLD_GEN_BENCHMARK_SAVE_FAILED)); + benchmarkableWorldGen.getBenchmark().stop(); + } catch (RejectedExecutionException var32) { + HytaleLogger.getLogger().at(Level.SEVERE).log("Cancelled worldgen benchmark due to generator shutdown"); + } finally { + IS_RUNNING.set(false); } - - benchmarkableWorldGen.getBenchmark().stop(); - IS_RUNNING.set(false); }, "WorldGenBenchmarkCommand" ) diff --git a/src/com/hypixel/hytale/server/core/command/system/AbbreviationMap.java b/src/com/hypixel/hytale/server/core/command/system/AbbreviationMap.java index 595dae9..ebc96f6 100644 --- a/src/com/hypixel/hytale/server/core/command/system/AbbreviationMap.java +++ b/src/com/hypixel/hytale/server/core/command/system/AbbreviationMap.java @@ -26,9 +26,6 @@ public class AbbreviationMap { public static class AbbreviationMapBuilder { private final Map keys = new Object2ObjectOpenHashMap<>(); - public AbbreviationMapBuilder() { - } - @Nonnull public AbbreviationMap.AbbreviationMapBuilder put(@Nonnull String key, @Nonnull Value value) { if (this.keys.putIfAbsent(key.toLowerCase(), value) != null) { diff --git a/src/com/hypixel/hytale/server/core/command/system/CommandManager.java b/src/com/hypixel/hytale/server/core/command/system/CommandManager.java index 0274736..de8e480 100644 --- a/src/com/hypixel/hytale/server/core/command/system/CommandManager.java +++ b/src/com/hypixel/hytale/server/core/command/system/CommandManager.java @@ -49,7 +49,7 @@ import com.hypixel.hytale.server.core.command.commands.utility.EventTitleCommand import com.hypixel.hytale.server.core.command.commands.utility.NotifyCommand; import com.hypixel.hytale.server.core.command.commands.utility.StashCommand; import com.hypixel.hytale.server.core.command.commands.utility.ValidateCPBCommand; -import com.hypixel.hytale.server.core.command.commands.utility.git.UpdateCommand; +import com.hypixel.hytale.server.core.command.commands.utility.git.GitCommand; import com.hypixel.hytale.server.core.command.commands.utility.help.HelpCommand; import com.hypixel.hytale.server.core.command.commands.utility.lighting.LightingCommand; import com.hypixel.hytale.server.core.command.commands.utility.metacommands.CommandsCommand; @@ -159,7 +159,7 @@ public class CommandManager implements CommandOwner { this.registerSystemCommand(new SleepCommand()); this.registerSystemCommand(new NetworkCommand()); this.registerSystemCommand(new CommandsCommand()); - this.registerSystemCommand(new UpdateCommand()); + this.registerSystemCommand(new GitCommand()); } public Map> createVirtualPermissionGroups() { diff --git a/src/com/hypixel/hytale/server/core/command/system/CommandUtil.java b/src/com/hypixel/hytale/server/core/command/system/CommandUtil.java index b475e13..0b98491 100644 --- a/src/com/hypixel/hytale/server/core/command/system/CommandUtil.java +++ b/src/com/hypixel/hytale/server/core/command/system/CommandUtil.java @@ -11,9 +11,6 @@ public class CommandUtil { public static final String PLAYER_OPTION = "player"; public static int RECOMMEND_COUNT = 5; - public CommandUtil() { - } - @Nonnull public static String stripCommandName(@Nonnull String rawCommand) { int indexOf = rawCommand.indexOf(32); diff --git a/src/com/hypixel/hytale/server/core/command/system/ParserContext.java b/src/com/hypixel/hytale/server/core/command/system/ParserContext.java index 33f4037..c09de2c 100644 --- a/src/com/hypixel/hytale/server/core/command/system/ParserContext.java +++ b/src/com/hypixel/hytale/server/core/command/system/ParserContext.java @@ -237,9 +237,6 @@ public class ParserContext { private int numTokensSinceLastSeparator = 0; private int numberOfListItems = 0; - public PreOptionalListContext() { - } - @Nullable public ParserContext.PreOptionalListContext addToken(@Nonnull String token, @Nonnull ParseResult parseResult) { if (token.equals(Tokenizer.MULTI_ARG_SEPARATOR)) { diff --git a/src/com/hypixel/hytale/server/core/command/system/Tokenizer.java b/src/com/hypixel/hytale/server/core/command/system/Tokenizer.java index 292cf39..87da286 100644 --- a/src/com/hypixel/hytale/server/core/command/system/Tokenizer.java +++ b/src/com/hypixel/hytale/server/core/command/system/Tokenizer.java @@ -16,9 +16,6 @@ public class Tokenizer { public static final String MULTI_ARG_END = String.valueOf(']'); private static final Message MESSAGE_COMMANDS_PARSING_ERROR_UNBALANCED_QUOTES = Message.translation("server.commands.parsing.error.unbalancedQuotes"); - public Tokenizer() { - } - @Nullable public static List parseArguments(@Nonnull String input, @Nonnull ParseResult parseResult) { List parsedTokens = new ObjectArrayList<>(); diff --git a/src/com/hypixel/hytale/server/core/command/system/arguments/types/ArgTypes.java b/src/com/hypixel/hytale/server/core/command/system/arguments/types/ArgTypes.java index 067886e..31ad56e 100644 --- a/src/com/hypixel/hytale/server/core/command/system/arguments/types/ArgTypes.java +++ b/src/com/hypixel/hytale/server/core/command/system/arguments/types/ArgTypes.java @@ -16,6 +16,8 @@ import com.hypixel.hytale.server.core.asset.type.model.config.ModelAsset; import com.hypixel.hytale.server.core.asset.type.particle.config.ParticleSystem; import com.hypixel.hytale.server.core.asset.type.soundevent.config.SoundEvent; import com.hypixel.hytale.server.core.asset.type.weather.config.Weather; +import com.hypixel.hytale.server.core.auth.ProfileServiceClient; +import com.hypixel.hytale.server.core.auth.ServerAuthManager; import com.hypixel.hytale.server.core.command.system.CommandContext; import com.hypixel.hytale.server.core.command.system.CommandSender; import com.hypixel.hytale.server.core.command.system.ParseResult; @@ -38,6 +40,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.UUID; +import java.util.concurrent.CompletableFuture; import java.util.function.BiFunction; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -154,6 +157,82 @@ public final class ArgTypes { } } }; + public static final SingleArgumentType> GAME_PROFILE_LOOKUP_ASYNC = new SingleArgumentType>( + "server.commands.parsing.argtype.playerUuidLookup.name", + "server.commands.parsing.argtype.playerUuidLookup.usage", + java.util.UUID.randomUUID().toString(), + "john_doe", + "user123" + ) { + @Nullable + public CompletableFuture parse(@Nonnull String input, @Nonnull ParseResult parseResult) { + for (World world : Universe.get().getWorlds().values()) { + Collection playerRefs = world.getPlayerRefs(); + PlayerRef playerRef = NameMatching.DEFAULT.find(playerRefs, input, PlayerRef::getUsername); + if (playerRef != null) { + return CompletableFuture.completedFuture(new ProfileServiceClient.PublicGameProfile(playerRef.getUuid(), playerRef.getUsername())); + } + } + + UUID inputAsUuid = null; + + try { + inputAsUuid = java.util.UUID.fromString(input); + } catch (IllegalArgumentException var8) { + } + + ServerAuthManager authManager = ServerAuthManager.getInstance(); + String sessionToken = authManager.getSessionToken(); + if (sessionToken == null) { + return CompletableFuture.failedFuture(new IllegalStateException("No session token available for profile lookup")); + } else { + ProfileServiceClient profileClient = authManager.getProfileServiceClient(); + CompletableFuture future; + if (inputAsUuid != null) { + future = profileClient.getProfileByUuidAsync(inputAsUuid, sessionToken); + } else { + future = profileClient.getProfileByUsernameAsync(input, sessionToken); + } + + return future.thenApply(profile -> { + if (profile != null && profile.getUuid() != null) { + return (ProfileServiceClient.PublicGameProfile)profile; + } else { + throw new IllegalArgumentException("Player not found: " + input); + } + }); + } + } + }; + public static final SingleArgumentType GAME_PROFILE_LOOKUP = new SingleArgumentType( + "server.commands.parsing.argtype.playerUuidLookup.name", + "server.commands.parsing.argtype.playerUuidLookup.usage", + java.util.UUID.randomUUID().toString(), + "john_doe", + "user123" + ) { + @Nullable + public ProfileServiceClient.PublicGameProfile parse(@Nonnull String input, @Nonnull ParseResult parseResult) { + try { + return ArgTypes.GAME_PROFILE_LOOKUP_ASYNC.parse(input, parseResult).join(); + } catch (Exception var5) { + Throwable cause = (Throwable)(var5.getCause() != null ? var5.getCause() : var5); + if (cause instanceof IllegalStateException) { + parseResult.fail(Message.translation("server.commands.parsing.argtype.playerUuidLookup.noAuth").param("input", input)); + } else if (cause instanceof IllegalArgumentException) { + parseResult.fail(Message.translation("server.commands.parsing.argtype.playerUuidLookup.notFound").param("input", input)); + } else { + parseResult.fail( + Message.translation("server.commands.parsing.argtype.playerUuidLookup.lookupError") + .param("input", input) + .param("error", cause.getMessage() != null ? cause.getMessage() : cause.getClass().getSimpleName()) + ); + } + + return null; + } + } + }; public static final SingleArgumentType RELATIVE_DOUBLE_COORD = new SingleArgumentType( "server.commands.parsing.argtype.doubleCoordinate.name", "server.commands.parsing.argtype.doubleCoordinate.usage", "5.0", "~-2.3", "0.0" ) { @@ -599,7 +678,24 @@ public final class ArgTypes { parseResult.fail(Message.raw("Block entry cannot be empty")); return null; } else { - return input; + String blockName = input; + int percentIndex = input.indexOf(37); + if (percentIndex != -1) { + blockName = input.substring(percentIndex + 1); + } + + int pipeIndex = blockName.indexOf(124); + if (pipeIndex != -1) { + blockName = blockName.substring(0, pipeIndex); + } + + int blockId = BlockType.getAssetMap().getIndex(blockName); + if (blockId == Integer.MIN_VALUE) { + parseResult.fail(Message.translation("server.builderTools.invalidBlockType").param("name", "").param("key", blockName)); + return null; + } else { + return input; + } } } }; @@ -686,9 +782,6 @@ public final class ArgTypes { }; public static final SingleArgumentType GAME_MODE = new GameModeArgumentType(); - public ArgTypes() { - } - @Nonnull public static > SingleArgumentType forEnum(String name, @Nonnull Class enumType) { return new EnumArgumentType<>(name, enumType); diff --git a/src/com/hypixel/hytale/server/core/command/system/arguments/types/MultiArgumentContext.java b/src/com/hypixel/hytale/server/core/command/system/arguments/types/MultiArgumentContext.java index 8d451f4..f0196cd 100644 --- a/src/com/hypixel/hytale/server/core/command/system/arguments/types/MultiArgumentContext.java +++ b/src/com/hypixel/hytale/server/core/command/system/arguments/types/MultiArgumentContext.java @@ -10,9 +10,6 @@ public class MultiArgumentContext { @Nonnull private final Map, Object> parsedArguments = new Object2ObjectOpenHashMap<>(); - public MultiArgumentContext() { - } - public void registerArgumentValues(@Nonnull ArgumentType argumentType, @Nonnull String[] values, @Nonnull ParseResult parseResult) { this.parsedArguments.put(argumentType, argumentType.parse(values, parseResult)); } diff --git a/src/com/hypixel/hytale/server/core/command/system/arguments/types/RelativeDirection.java b/src/com/hypixel/hytale/server/core/command/system/arguments/types/RelativeDirection.java index 73533b2..059e65e 100644 --- a/src/com/hypixel/hytale/server/core/command/system/arguments/types/RelativeDirection.java +++ b/src/com/hypixel/hytale/server/core/command/system/arguments/types/RelativeDirection.java @@ -45,9 +45,6 @@ public enum RelativeDirection { } }; - private RelativeDirection() { - } - @Nonnull public static Vector3i toDirectionVector(@Nullable RelativeDirection direction, @Nonnull HeadRotation headRotation) { if (direction == null) { diff --git a/src/com/hypixel/hytale/server/core/command/system/exceptions/CommandException.java b/src/com/hypixel/hytale/server/core/command/system/exceptions/CommandException.java index 5d3f381..fbc9d27 100644 --- a/src/com/hypixel/hytale/server/core/command/system/exceptions/CommandException.java +++ b/src/com/hypixel/hytale/server/core/command/system/exceptions/CommandException.java @@ -4,8 +4,5 @@ import com.hypixel.hytale.server.core.command.system.CommandSender; import javax.annotation.Nonnull; public abstract class CommandException extends RuntimeException { - public CommandException() { - } - public abstract void sendTranslatedMessage(@Nonnull CommandSender var1); } diff --git a/src/com/hypixel/hytale/server/core/command/system/pages/CommandListPage.java b/src/com/hypixel/hytale/server/core/command/system/pages/CommandListPage.java index 5119699..c070f48 100644 --- a/src/com/hypixel/hytale/server/core/command/system/pages/CommandListPage.java +++ b/src/com/hypixel/hytale/server/core/command/system/pages/CommandListPage.java @@ -716,9 +716,6 @@ public class CommandListPage extends InteractiveCustomUIPage> INTEGER_STRING_PAIR_COMPARATOR = Comparator.comparingInt(IntObjectPair::leftInt); private final List suggestions = new ObjectArrayList<>(); - public SuggestionResult() { - } - @Nonnull public SuggestionResult suggest(@Nonnull String suggestion) { this.suggestions.add(suggestion); diff --git a/src/com/hypixel/hytale/server/core/cosmetics/BodyType.java b/src/com/hypixel/hytale/server/core/cosmetics/BodyType.java index 23cce87..ebd0424 100644 --- a/src/com/hypixel/hytale/server/core/cosmetics/BodyType.java +++ b/src/com/hypixel/hytale/server/core/cosmetics/BodyType.java @@ -3,7 +3,4 @@ package com.hypixel.hytale.server.core.cosmetics; public enum BodyType { Masculine, Feminine; - - private BodyType() { - } } diff --git a/src/com/hypixel/hytale/server/core/cosmetics/CosmeticType.java b/src/com/hypixel/hytale/server/core/cosmetics/CosmeticType.java index fff9f19..6e992d8 100644 --- a/src/com/hypixel/hytale/server/core/cosmetics/CosmeticType.java +++ b/src/com/hypixel/hytale/server/core/cosmetics/CosmeticType.java @@ -25,7 +25,4 @@ public enum CosmeticType { GLOVES, CAPES, SKIN_FEATURES; - - private CosmeticType() { - } } diff --git a/src/com/hypixel/hytale/server/core/cosmetics/CosmeticsModule.java b/src/com/hypixel/hytale/server/core/cosmetics/CosmeticsModule.java index abd0538..269699f 100644 --- a/src/com/hypixel/hytale/server/core/cosmetics/CosmeticsModule.java +++ b/src/com/hypixel/hytale/server/core/cosmetics/CosmeticsModule.java @@ -79,47 +79,47 @@ public class CosmeticsModule extends JavaPlugin { public void validateSkin(@Nonnull com.hypixel.hytale.protocol.PlayerSkin skin) throws CosmeticsModule.InvalidSkinException { if (skin == null) { - throw new CosmeticsModule.InvalidSkinException("Skin can't be null!"); + throw new CosmeticsModule.InvalidSkinException("skin", null); } else if (skin.face == null || !this.registry.getFaces().containsKey(skin.face)) { - throw new CosmeticsModule.InvalidSkinException("Invalid face attachment!"); + throw new CosmeticsModule.InvalidSkinException("face", skin.face); } else if (skin.ears == null || !this.registry.getEars().containsKey(skin.ears)) { - throw new CosmeticsModule.InvalidSkinException("Invalid ears attachment!"); + throw new CosmeticsModule.InvalidSkinException("ears", skin.ears); } else if (skin.mouth == null || !this.registry.getMouths().containsKey(skin.mouth)) { - throw new CosmeticsModule.InvalidSkinException("Invalid mouth attachment!"); + throw new CosmeticsModule.InvalidSkinException("mouth", skin.mouth); } else if (!this.isValidAttachment(this.registry.getBodyCharacteristics(), skin.bodyCharacteristic, true)) { - throw new CosmeticsModule.InvalidSkinException("Invalid body characteristic!"); + throw new CosmeticsModule.InvalidSkinException("body", skin.bodyCharacteristic); } else if (!this.isValidAttachment(this.registry.getUnderwear(), skin.underwear, true)) { - throw new CosmeticsModule.InvalidSkinException("Invalid underwear attachment!"); + throw new CosmeticsModule.InvalidSkinException("underwear", skin.underwear); } else if (!this.isValidAttachment(this.registry.getEyes(), skin.eyes, true)) { - throw new CosmeticsModule.InvalidSkinException("Invalid eye attachment!"); + throw new CosmeticsModule.InvalidSkinException("eyes", skin.eyes); } else if (!this.isValidAttachment(this.registry.getSkinFeatures(), skin.skinFeature)) { - throw new CosmeticsModule.InvalidSkinException("Invalid skin feature attachment!"); + throw new CosmeticsModule.InvalidSkinException("skin feature", skin.skinFeature); } else if (!this.isValidAttachment(this.registry.getEyebrows(), skin.eyebrows)) { - throw new CosmeticsModule.InvalidSkinException("Invalid eye brows attachment!"); + throw new CosmeticsModule.InvalidSkinException("eyebrows", skin.eyebrows); } else if (!this.isValidAttachment(this.registry.getPants(), skin.pants)) { - throw new CosmeticsModule.InvalidSkinException("Invalid pants attachment!"); + throw new CosmeticsModule.InvalidSkinException("pants", skin.pants); } else if (!this.isValidAttachment(this.registry.getOverpants(), skin.overpants)) { - throw new CosmeticsModule.InvalidSkinException("Invalid overpants attachment!"); + throw new CosmeticsModule.InvalidSkinException("overpants", skin.overpants); } else if (!this.isValidAttachment(this.registry.getShoes(), skin.shoes)) { - throw new CosmeticsModule.InvalidSkinException("Invalid shoes attachment!"); + throw new CosmeticsModule.InvalidSkinException("shoes", skin.shoes); } else if (!this.isValidAttachment(this.registry.getUndertops(), skin.undertop)) { - throw new CosmeticsModule.InvalidSkinException("Invalid under top attachment!"); + throw new CosmeticsModule.InvalidSkinException("undertop", skin.undertop); } else if (!this.isValidAttachment(this.registry.getOvertops(), skin.overtop)) { - throw new CosmeticsModule.InvalidSkinException("Invalid over top attachment!"); + throw new CosmeticsModule.InvalidSkinException("overtop", skin.overtop); } else if (!this.isValidAttachment(this.registry.getGloves(), skin.gloves)) { - throw new CosmeticsModule.InvalidSkinException("Invalid gloves attachment!"); + throw new CosmeticsModule.InvalidSkinException("gloves", skin.gloves); } else if (!this.isValidAttachment(this.registry.getHeadAccessories(), skin.headAccessory)) { - throw new CosmeticsModule.InvalidSkinException("Invalid head accessory attachment!"); + throw new CosmeticsModule.InvalidSkinException("head accessory", skin.headAccessory); } else if (!this.isValidAttachment(this.registry.getFaceAccessories(), skin.faceAccessory)) { - throw new CosmeticsModule.InvalidSkinException("Invalid face accessory attachment!"); + throw new CosmeticsModule.InvalidSkinException("face accessory", skin.faceAccessory); } else if (!this.isValidAttachment(this.registry.getEarAccessories(), skin.earAccessory)) { - throw new CosmeticsModule.InvalidSkinException("Invalid ear accessory attachment!"); + throw new CosmeticsModule.InvalidSkinException("ear accessory", skin.earAccessory); } else if (!this.isValidHaircutAttachment(skin.haircut, skin.headAccessory)) { - throw new CosmeticsModule.InvalidSkinException("Invalid haircut attachment!"); + throw new CosmeticsModule.InvalidSkinException("haircut", skin.haircut); } else if (!this.isValidAttachment(this.registry.getFacialHairs(), skin.facialHair)) { - throw new CosmeticsModule.InvalidSkinException("Invalid facial accessory attachment!"); + throw new CosmeticsModule.InvalidSkinException("facial hair", skin.facialHair); } else if (!this.isValidAttachment(this.registry.getCapes(), skin.cape)) { - throw new CosmeticsModule.InvalidSkinException("Invalid capes attachment!"); + throw new CosmeticsModule.InvalidSkinException("cape", skin.cape); } } @@ -297,8 +297,26 @@ public class CosmeticsModule extends JavaPlugin { } public static class InvalidSkinException extends Exception { - public InvalidSkinException(String message) { - super(message); + private final String partType; + private final String partId; + + public InvalidSkinException(String partType, @Nullable String partId) { + super(formatMessage(partType, partId)); + this.partType = partType; + this.partId = partId; + } + + private static String formatMessage(String partType, @Nullable String partId) { + return partId == null ? "Missing required " + partType : "Unknown " + partType + ": " + partId; + } + + public String getPartType() { + return this.partType; + } + + @Nullable + public String getPartId() { + return this.partId; } } } diff --git a/src/com/hypixel/hytale/server/core/cosmetics/PlayerSkinPart.java b/src/com/hypixel/hytale/server/core/cosmetics/PlayerSkinPart.java index 44cb5e7..a79d22c 100644 --- a/src/com/hypixel/hytale/server/core/cosmetics/PlayerSkinPart.java +++ b/src/com/hypixel/hytale/server/core/cosmetics/PlayerSkinPart.java @@ -164,18 +164,12 @@ public class PlayerSkinPart { Short, Medium, Long; - - private HaircutType() { - } } public static enum HeadAccessoryType { Simple, HalfCovering, FullyCovering; - - private HeadAccessoryType() { - } } public static class Variant { diff --git a/src/com/hypixel/hytale/server/core/cosmetics/PlayerSkinPartType.java b/src/com/hypixel/hytale/server/core/cosmetics/PlayerSkinPartType.java index 01478f7..70cbe43 100644 --- a/src/com/hypixel/hytale/server/core/cosmetics/PlayerSkinPartType.java +++ b/src/com/hypixel/hytale/server/core/cosmetics/PlayerSkinPartType.java @@ -17,7 +17,4 @@ public enum PlayerSkinPartType { EarAccessory, SkinFeature, Gloves; - - private PlayerSkinPartType() { - } } diff --git a/src/com/hypixel/hytale/server/core/entity/AnimationUtils.java b/src/com/hypixel/hytale/server/core/entity/AnimationUtils.java index a808bf9..d7b7422 100644 --- a/src/com/hypixel/hytale/server/core/entity/AnimationUtils.java +++ b/src/com/hypixel/hytale/server/core/entity/AnimationUtils.java @@ -16,9 +16,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class AnimationUtils { - public AnimationUtils() { - } - public static void playAnimation( @Nonnull Ref ref, @Nonnull AnimationSlot animationSlot, diff --git a/src/com/hypixel/hytale/server/core/entity/Entity.java b/src/com/hypixel/hytale/server/core/entity/Entity.java index 0b37d87..0f50a61 100644 --- a/src/com/hypixel/hytale/server/core/entity/Entity.java +++ b/src/com/hypixel/hytale/server/core/entity/Entity.java @@ -333,9 +333,6 @@ public abstract class Entity implements Component { @Nonnull public static final String FLY_SUFFIX = "Fly"; - public DefaultAnimations() { - } - @Nonnull public static String[] getHurtAnimationIds(@Nonnull MovementStates movementStates, @Nonnull DamageCause damageCause) { String animationId = damageCause.getAnimationId(); diff --git a/src/com/hypixel/hytale/server/core/entity/EntityUtils.java b/src/com/hypixel/hytale/server/core/entity/EntityUtils.java index 0684db7..c4bf32f 100644 --- a/src/com/hypixel/hytale/server/core/entity/EntityUtils.java +++ b/src/com/hypixel/hytale/server/core/entity/EntityUtils.java @@ -15,9 +15,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class EntityUtils { - public EntityUtils() { - } - @Nonnull public static Holder toHolder(int index, @Nonnull ArchetypeChunk archetypeChunk) { Holder holder = EntityStore.REGISTRY.newHolder(); diff --git a/src/com/hypixel/hytale/server/core/entity/ExplosionConfig.java b/src/com/hypixel/hytale/server/core/entity/ExplosionConfig.java index 656d4f7..4ba2a51 100644 --- a/src/com/hypixel/hytale/server/core/entity/ExplosionConfig.java +++ b/src/com/hypixel/hytale/server/core/entity/ExplosionConfig.java @@ -104,7 +104,4 @@ public class ExplosionConfig { protected Knockback knockback; @Nullable protected ItemTool itemTool; - - public ExplosionConfig() { - } } diff --git a/src/com/hypixel/hytale/server/core/entity/ExplosionUtils.java b/src/com/hypixel/hytale/server/core/entity/ExplosionUtils.java index d516b4a..4e17f56 100644 --- a/src/com/hypixel/hytale/server/core/entity/ExplosionUtils.java +++ b/src/com/hypixel/hytale/server/core/entity/ExplosionUtils.java @@ -48,9 +48,6 @@ public class ExplosionUtils { private static final int DEBUG_BLOCK_RADIUS_TIME = 5; private static final int DEBUG_ENTITY_RADIUS_TIME = 5; - public ExplosionUtils() { - } - public static void performExplosion( @Nonnull Damage.Source damageSource, @Nonnull Vector3d position, diff --git a/src/com/hypixel/hytale/server/core/entity/Frozen.java b/src/com/hypixel/hytale/server/core/entity/Frozen.java index 8cc56c7..8a056f6 100644 --- a/src/com/hypixel/hytale/server/core/entity/Frozen.java +++ b/src/com/hypixel/hytale/server/core/entity/Frozen.java @@ -5,8 +5,10 @@ import com.hypixel.hytale.component.Component; import com.hypixel.hytale.component.ComponentType; import com.hypixel.hytale.server.core.modules.entity.EntityModule; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; +import javax.annotation.Nonnull; public class Frozen implements Component { + @Nonnull public static final BuilderCodec CODEC = BuilderCodec.builder(Frozen.class, Frozen::get).build(); private static final Frozen INSTANCE = new Frozen(); diff --git a/src/com/hypixel/hytale/server/core/entity/InteractionChain.java b/src/com/hypixel/hytale/server/core/entity/InteractionChain.java index 415017c..e935e6d 100644 --- a/src/com/hypixel/hytale/server/core/entity/InteractionChain.java +++ b/src/com/hypixel/hytale/server/core/entity/InteractionChain.java @@ -470,7 +470,7 @@ public class InteractionChain implements ChainSyncStorage { public void removeInteractionEntry(@Nonnull InteractionManager interactionManager, int index) { int oIndex = index - this.operationIndexOffset; if (oIndex != 0) { - throw new IllegalArgumentException("Trying to remove out of order"); + this.flagDesync(); } else { InteractionEntry entry = this.interactions.remove(oIndex); this.operationIndexOffset++; @@ -488,15 +488,14 @@ public class InteractionChain implements ChainSyncStorage { @Override public void putInteractionSyncData(int index, InteractionSyncData data) { index -= this.tempSyncDataOffset; - if (index < 0) { - LOGGER.at(Level.SEVERE) - .log("Attempted to store sync data at %d. Offset: %d, Size: %d", index + this.tempSyncDataOffset, this.tempSyncDataOffset, this.tempSyncData.size()); - } else if (index < this.tempSyncData.size()) { - this.tempSyncData.set(index, data); - } else if (index == this.tempSyncData.size()) { - this.tempSyncData.add(data); - } else { - LOGGER.at(Level.WARNING).log("Temp sync data sent out of order: " + index + " " + this.tempSyncData.size()); + if (index >= 0) { + if (index < this.tempSyncData.size()) { + this.tempSyncData.set(index, data); + } else if (index == this.tempSyncData.size()) { + this.tempSyncData.add(data); + } else { + LOGGER.at(Level.WARNING).log("Temp sync data sent out of order: " + index + " " + this.tempSyncData.size()); + } } } @@ -738,9 +737,6 @@ public class InteractionChain implements ChainSyncStorage { ForkedChainId baseForkedChainId; InteractionChainData chainData; - TempChain() { - } - @Nonnull public InteractionChain.TempChain getOrCreateTempForkedChain(@Nonnull ForkedChainId chainId) { return this.tempForkedChainData.computeIfAbsent(InteractionChain.forkedIdToIndex(chainId), i -> new InteractionChain.TempChain()); diff --git a/src/com/hypixel/hytale/server/core/entity/InteractionContext.java b/src/com/hypixel/hytale/server/core/entity/InteractionContext.java index bb3ac30..abd826e 100644 --- a/src/com/hypixel/hytale/server/core/entity/InteractionContext.java +++ b/src/com/hypixel/hytale/server/core/entity/InteractionContext.java @@ -533,6 +533,14 @@ public class InteractionContext { } } else if (prioPrimary < prioSecondary) { selectedInventory = -5; + } else { + if (type == InteractionType.Primary && !primary.getItem().getInteractions().containsKey(InteractionType.Primary)) { + selectedInventory = -5; + } + + if (type == InteractionType.Secondary && !primary.getItem().getInteractions().containsKey(InteractionType.Secondary)) { + selectedInventory = -5; + } } } diff --git a/src/com/hypixel/hytale/server/core/entity/InteractionEntry.java b/src/com/hypixel/hytale/server/core/entity/InteractionEntry.java index 4a8ad7e..e7c952b 100644 --- a/src/com/hypixel/hytale/server/core/entity/InteractionEntry.java +++ b/src/com/hypixel/hytale/server/core/entity/InteractionEntry.java @@ -124,7 +124,7 @@ public class InteractionEntry { public boolean setClientState(@Nullable InteractionSyncData clientState) { if (clientState != null && (clientState.operationCounter != this.serverState.operationCounter || clientState.rootInteraction != this.serverState.rootInteraction)) { - HytaleLogger.Api ctx = LOGGER.at(Level.WARNING); + HytaleLogger.Api ctx = LOGGER.at(Level.FINE); if (ctx.isEnabled()) { RootInteraction root = RootInteraction.getAssetMap().getAsset(this.serverState.rootInteraction); Operation op = root.getOperation(this.serverState.operationCounter); diff --git a/src/com/hypixel/hytale/server/core/entity/InteractionManager.java b/src/com/hypixel/hytale/server/core/entity/InteractionManager.java index 18f8d8f..5974f02 100644 --- a/src/com/hypixel/hytale/server/core/entity/InteractionManager.java +++ b/src/com/hypixel/hytale/server/core/entity/InteractionManager.java @@ -8,7 +8,9 @@ import com.hypixel.hytale.component.ComponentAccessor; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.function.function.TriFunction; import com.hypixel.hytale.logger.HytaleLogger; +import com.hypixel.hytale.math.util.ChunkUtil; import com.hypixel.hytale.math.vector.Vector4d; +import com.hypixel.hytale.metrics.metric.HistoricMetric; import com.hypixel.hytale.protocol.BlockPosition; import com.hypixel.hytale.protocol.ForkedChainId; import com.hypixel.hytale.protocol.GameMode; @@ -23,6 +25,7 @@ import com.hypixel.hytale.protocol.WaitForDataFrom; import com.hypixel.hytale.protocol.packets.interaction.CancelInteractionChain; import com.hypixel.hytale.protocol.packets.interaction.SyncInteractionChain; import com.hypixel.hytale.protocol.packets.inventory.SetActiveSlot; +import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType; import com.hypixel.hytale.server.core.entity.entities.Player; import com.hypixel.hytale.server.core.inventory.Inventory; import com.hypixel.hytale.server.core.inventory.ItemStack; @@ -38,8 +41,14 @@ import com.hypixel.hytale.server.core.modules.interaction.interaction.operation. import com.hypixel.hytale.server.core.modules.time.TimeResource; import com.hypixel.hytale.server.core.universe.PlayerRef; import com.hypixel.hytale.server.core.universe.world.World; +import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import com.hypixel.hytale.server.core.util.UUIDUtil; +import io.sentry.Sentry; +import io.sentry.SentryEvent; +import io.sentry.SentryLevel; +import io.sentry.protocol.Message; +import io.sentry.protocol.SentryId; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMaps; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; @@ -47,6 +56,7 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectList; import java.util.Arrays; import java.util.Deque; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -84,6 +94,7 @@ public class InteractionManager implements Component { private final boolean[] globalTimeShiftDirty = new boolean[InteractionType.VALUES.length]; private boolean timeShiftsDirty; private final ObjectList syncPackets = new ObjectArrayList<>(); + private long currentTime = 1L; @Nonnull private final ObjectList chainStartQueue = new ObjectArrayList<>(); @Nonnull @@ -137,6 +148,7 @@ public class InteractionManager implements Component { } public void tick(@Nonnull Ref ref, @Nonnull CommandBuffer commandBuffer, float dt) { + this.currentTime = this.currentTime + commandBuffer.getExternalData().getWorld().getTickStepNanos(); this.commandBuffer = commandBuffer; this.clearAllGlobalTimeShift(dt); this.cooldownHandler.tick(dt); @@ -238,10 +250,10 @@ public class InteractionManager implements Component { if (!this.waitingForClient(ref)) { long queuedTime; if (this.packetQueueTime == 0L) { - this.packetQueueTime = System.nanoTime(); + this.packetQueueTime = this.currentTime; queuedTime = 0L; } else { - queuedTime = System.nanoTime() - this.packetQueueTime; + queuedTime = this.currentTime - this.packetQueueTime; } HytaleLogger.Api context = LOGGER.at(Level.FINE); @@ -339,10 +351,10 @@ public class InteractionManager implements Component { if (chain.requiresClient() && chain.getClientState() == InteractionState.NotFinished) { if (!this.waitingForClient(ref)) { if (chain.getWaitingForClientFinished() == 0L) { - chain.setWaitingForClientFinished(System.nanoTime()); + chain.setWaitingForClientFinished(this.currentTime); } - long waitMillis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - chain.getWaitingForClientFinished()); + long waitMillis = TimeUnit.NANOSECONDS.toMillis(this.currentTime - chain.getWaitingForClientFinished()); HytaleLogger.Api context = LOGGER.at(Level.FINE); if (context.isEnabled()) { context.log("Server finished chain but client hasn't! %d, %s, %s", chain.getChainId(), chain, waitMillis); @@ -400,10 +412,10 @@ public class InteractionManager implements Component { } } else if (chain.getClientState() != InteractionState.NotFinished && !this.waitingForClient(ref)) { if (chain.getWaitingForServerFinished() == 0L) { - chain.setWaitingForServerFinished(System.nanoTime()); + chain.setWaitingForServerFinished(this.currentTime); } - long waitMillisx = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - chain.getWaitingForServerFinished()); + long waitMillisx = TimeUnit.NANOSECONDS.toMillis(this.currentTime - chain.getWaitingForServerFinished()); HytaleLogger.Api contextxx = LOGGER.at(Level.FINE); if (contextxx.isEnabled()) { contextxx.log("Client finished chain but server hasn't! %d, %s, %s", chain.getChainId(), chain, waitMillisx); @@ -441,7 +453,7 @@ public class InteractionManager implements Component { try { context.initEntry(chain, entry, this.entity); TimeResource timeResource = this.commandBuffer.getResource(TimeResource.getResourceType()); - operation.handle(ref, false, entry.getTimeInSeconds(System.nanoTime()) * timeResource.getTimeDilationModifier(), chain.getType(), context); + operation.handle(ref, false, entry.getTimeInSeconds(this.currentTime) * timeResource.getTimeDilationModifier(), chain.getType(), context); } finally { context.deinitEntry(chain, entry, this.entity); } @@ -477,7 +489,7 @@ public class InteractionManager implements Component { while (true) { Operation simOp = !this.hasRemoteClient ? root.getOperation(chain.getSimulatedOperationCounter()) : null; WaitForDataFrom simWaitFrom = simOp != null ? simOp.getWaitForDataFrom() : null; - long tickTime = System.nanoTime(); + long tickTime = this.currentTime; if (!this.hasRemoteClient && simWaitFrom != WaitForDataFrom.Server) { this.simulationTick(ref, chain, tickTime); } @@ -618,10 +630,10 @@ public class InteractionManager implements Component { return null; } else { if (entry.getWaitingForSyncData() == 0L) { - entry.setWaitingForSyncData(System.nanoTime()); + entry.setWaitingForSyncData(this.currentTime); } - long waitMillis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - entry.getWaitingForSyncData()); + long waitMillis = TimeUnit.NANOSECONDS.toMillis(this.currentTime - entry.getWaitingForSyncData()); HytaleLogger.Api contextx = LOGGER.at(Level.FINE); if (contextx.isEnabled()) { contextx.log("Wait for interaction clientData: %d, %s, %s", chain.getOperationIndex(), entry, waitMillis); @@ -629,20 +641,42 @@ public class InteractionManager implements Component { long threshold = this.getOperationTimeoutThreshold(); if (tickTimeDilation == 1.0F && waitMillis > threshold) { - throw new RuntimeException( - "Client took too long to send clientData! Millis: " - + waitMillis - + ", Threshold: " - + threshold - + ",\nChain: " - + chain - + ",\nEntry: " - + chain.getOperationIndex() - + ", " - + entry - + ",\nWaiting for data from: " - + operation.getWaitForDataFrom() - ); + SentryEvent event = new SentryEvent(); + event.setLevel(SentryLevel.ERROR); + Message message = new Message(); + message.setMessage("Client failed to send client data, ending early to prevent desync"); + HashMap unknown = new HashMap<>(); + unknown.put("Threshold", threshold); + unknown.put("Wait Millis", waitMillis); + unknown.put("Current Root", chain.getRootInteraction() != null ? chain.getRootInteraction().getId() : ""); + Operation innerOp = operation.getInnerOperation(); + unknown.put("Current Op", innerOp.getClass().getName()); + if (innerOp instanceof Interaction interaction) { + unknown.put("Current Interaction", interaction.getId()); + } + + unknown.put("Current Index", chain.getOperationIndex()); + unknown.put("Current Op Counter", chain.getOperationCounter()); + HistoricMetric metric = ref.getStore().getExternalData().getWorld().getBufferedTickLengthMetricSet(); + long[] periods = metric.getPeriodsNanos(); + + for (int i = 0; i < periods.length; i++) { + String length = FormatUtil.timeUnitToString(periods[i], TimeUnit.NANOSECONDS, true); + double average = metric.getAverage(i); + long min = metric.calculateMin(i); + long max = metric.calculateMax(i); + String value = FormatUtil.simpleTimeUnitFormat(min, average, max, TimeUnit.NANOSECONDS, TimeUnit.MILLISECONDS, 3); + unknown.put(String.format("World Perf %s", length), value); + } + + event.setExtras(unknown); + event.setMessage(message); + SentryId eventId = Sentry.captureEvent(event); + LOGGER.atWarning().log("Client failed to send client data, ending early to prevent desync. %s", eventId); + chain.setServerState(InteractionState.Failed); + chain.setClientState(InteractionState.Failed); + this.sendCancelPacket(chain); + return null; } else { if (entry.consumeSendInitial() || wasWrong) { returnData = entry.getServerState(); @@ -666,10 +700,10 @@ public class InteractionManager implements Component { } } else if (entry.getClientState() != null && entry.getClientState().state != InteractionState.NotFinished && !this.waitingForClient(ref)) { if (entry.getWaitingForServerFinished() == 0L) { - entry.setWaitingForServerFinished(System.nanoTime()); + entry.setWaitingForServerFinished(this.currentTime); } - long waitMillis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - entry.getWaitingForServerFinished()); + long waitMillis = TimeUnit.NANOSECONDS.toMillis(this.currentTime - entry.getWaitingForServerFinished()); HytaleLogger.Api context = LOGGER.at(Level.FINE); if (context.isEnabled()) { context.log("Client finished interaction but server hasn't! %s, %d, %s, %s", entry.getClientState().state, entry.getIndex(), entry, waitMillis); @@ -770,7 +804,7 @@ public class InteractionManager implements Component { Ref proxyTarget = world.getEntityStore().getRefFromUUID(proxyId); if (proxyTarget == null) { if (this.packetQueueTime != 0L - && System.nanoTime() - this.packetQueueTime > TimeUnit.MILLISECONDS.toNanos(this.getOperationTimeoutThreshold()) / 2L) { + && this.currentTime - this.packetQueueTime > TimeUnit.MILLISECONDS.toNanos(this.getOperationTimeoutThreshold()) / 2L) { HytaleLogger.Api ctx = LOGGER.at(Level.FINE); if (ctx.isEnabled()) { ctx.log("Proxy entity never spawned"); @@ -876,6 +910,28 @@ public class InteractionManager implements Component { BlockPosition targetBlock = world.getBaseBlock(packet.data.blockPosition); context.getMetaStore().putMetaObject(Interaction.TARGET_BLOCK, targetBlock); context.getMetaStore().putMetaObject(Interaction.TARGET_BLOCK_RAW, packet.data.blockPosition); + if (!packet.data.blockPosition.equals(targetBlock)) { + WorldChunk otherChunk = world.getChunkIfInMemory( + ChunkUtil.indexChunkFromBlock(packet.data.blockPosition.x, packet.data.blockPosition.z) + ); + if (otherChunk == null) { + HytaleLogger.Api ctxxx = LOGGER.at(Level.FINE); + if (ctxxx.isEnabled()) { + ctxxx.log("Unloaded chunk interacted with: %d, %s", index, type); + } + + this.sendCancelPacket(index, packet.forkedId); + return true; + } + + int blockId = world.getBlock(targetBlock.x, targetBlock.y, targetBlock.z); + int otherBlockId = world.getBlock(packet.data.blockPosition.x, packet.data.blockPosition.y, packet.data.blockPosition.z); + if (blockId != otherBlockId) { + otherChunk.setBlock( + packet.data.blockPosition.x, packet.data.blockPosition.y, packet.data.blockPosition.z, 0, BlockType.EMPTY, 0, 0, 1052 + ); + } + } } if (packet.data.entityId >= 0) { @@ -951,7 +1007,7 @@ public class InteractionManager implements Component { "%d, %d: Time (Sync) - Server: %s vs Client: %s", packet.chainId, index, - interaction.getTimeInSeconds(System.nanoTime()) * tickTimeDilation, + interaction.getTimeInSeconds(this.currentTime) * tickTimeDilation, interaction.getClientState().progress ); } @@ -1178,12 +1234,35 @@ public class InteractionManager implements Component { Player playerComponent = this.commandBuffer.getComponent(ref, Player.getComponentType()); GameMode gameMode = playerComponent != null ? playerComponent.getGameMode() : GameMode.Adventure; RootInteractionSettings settings = root.getSettings().get(gameMode); - if (settings != null && settings.allowSkipChainOnClick && remote) { - this.cooldownHandler.resetCooldown(cooldownId, cooldownTime, cooldownChargeTimes, interruptRecharge); - return false; - } else { - return this.cooldownHandler.isOnCooldown(root, cooldownId, cooldownTime, cooldownChargeTimes, interruptRecharge); + if (settings != null) { + cooldown = settings.cooldown; + if (cooldown != null) { + cooldownTime = cooldown.cooldown; + if (cooldown.chargeTimes != null && cooldown.chargeTimes.length > 0) { + cooldownChargeTimes = cooldown.chargeTimes; + } + + if (cooldown.cooldownId != null) { + cooldownId = cooldown.cooldownId; + } + + if (cooldown.interruptRecharge) { + interruptRecharge = true; + } + + if (cooldown.clickBypass && remote) { + this.cooldownHandler.resetCooldown(cooldownId, cooldownTime, cooldownChargeTimes, interruptRecharge); + return false; + } + } + + if (settings.allowSkipChainOnClick && remote) { + this.cooldownHandler.resetCooldown(cooldownId, cooldownTime, cooldownChargeTimes, interruptRecharge); + return false; + } } + + return this.cooldownHandler.isOnCooldown(root, cooldownId, cooldownTime, cooldownChargeTimes, interruptRecharge); } public void tryRunHeldInteraction(@Nonnull Ref ref, @Nonnull CommandBuffer commandBuffer, @Nonnull InteractionType type) { diff --git a/src/com/hypixel/hytale/server/core/entity/ItemUtils.java b/src/com/hypixel/hytale/server/core/entity/ItemUtils.java index 27930ea..bec7db1 100644 --- a/src/com/hypixel/hytale/server/core/entity/ItemUtils.java +++ b/src/com/hypixel/hytale/server/core/entity/ItemUtils.java @@ -28,9 +28,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class ItemUtils { - public ItemUtils() { - } - public static void interactivelyPickupItem( @Nonnull Ref ref, @Nonnull ItemStack itemStack, @Nullable Vector3d origin, @Nonnull ComponentAccessor componentAccessor ) { diff --git a/src/com/hypixel/hytale/server/core/entity/StatModifiersManager.java b/src/com/hypixel/hytale/server/core/entity/StatModifiersManager.java index 3b64f1b..e1de46b 100644 --- a/src/com/hypixel/hytale/server/core/entity/StatModifiersManager.java +++ b/src/com/hypixel/hytale/server/core/entity/StatModifiersManager.java @@ -34,9 +34,6 @@ public class StatModifiersManager { @Nonnull private final IntSet statsToClear = new IntOpenHashSet(); - public StatModifiersManager() { - } - public void setRecalculate(boolean value) { this.recalculate.set(value); } @@ -63,16 +60,16 @@ public class StatModifiersManager { World world = componentAccessor.getExternalData().getWorld(); if (EntityUtils.getEntity(ref, componentAccessor) instanceof LivingEntity livingEntity) { - Inventory inventory = livingEntity.getInventory(); + Inventory var12 = livingEntity.getInventory(); Int2ObjectOpenHashMap effectModifiers = calculateEffectStatModifiers(ref, componentAccessor); applyEffectModifiers(statMap, effectModifiers); BrokenPenalties brokenPenalties = world.getGameplayConfig().getItemDurabilityConfig().getBrokenPenalties(); - Int2ObjectMap statModifiers = computeStatModifiers(brokenPenalties, inventory); + Int2ObjectMap statModifiers = computeStatModifiers(brokenPenalties, var12); applyStatModifiers(statMap, statModifiers); - ItemStack itemInHand = inventory.getItemInHand(); + ItemStack itemInHand = var12.getItemInHand(); addItemStatModifiers(itemInHand, statMap, "*Weapon_", v -> v.getWeapon() != null ? v.getWeapon().getStatModifiers() : null); if (itemInHand == null || itemInHand.getItem().getUtility().isCompatible()) { - addItemStatModifiers(inventory.getUtilityItem(), statMap, "*Utility_", v -> v.getUtility().getStatModifiers()); + addItemStatModifiers(var12.getUtilityItem(), statMap, "*Utility_", v -> v.getUtility().getStatModifiers()); } } } diff --git a/src/com/hypixel/hytale/server/core/entity/damage/DamageDataComponent.java b/src/com/hypixel/hytale/server/core/entity/damage/DamageDataComponent.java index dc03abe..c5d58af 100644 --- a/src/com/hypixel/hytale/server/core/entity/damage/DamageDataComponent.java +++ b/src/com/hypixel/hytale/server/core/entity/damage/DamageDataComponent.java @@ -19,9 +19,6 @@ public class DamageDataComponent implements Component { @Nullable private Instant lastChargeTime; - public DamageDataComponent() { - } - @Nonnull public static ComponentType getComponentType() { return EntityModule.get().getDamageDataComponentType(); diff --git a/src/com/hypixel/hytale/server/core/entity/entities/Player.java b/src/com/hypixel/hytale/server/core/entity/entities/Player.java index d50550b..5a53419 100644 --- a/src/com/hypixel/hytale/server/core/entity/entities/Player.java +++ b/src/com/hypixel/hytale/server/core/entity/entities/Player.java @@ -10,6 +10,7 @@ import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.Store; import com.hypixel.hytale.event.IEventDispatcher; import com.hypixel.hytale.math.shape.Box; +import com.hypixel.hytale.math.util.ChunkUtil; import com.hypixel.hytale.math.vector.Transform; import com.hypixel.hytale.math.vector.Vector3d; import com.hypixel.hytale.math.vector.Vector3f; @@ -72,10 +73,13 @@ import com.hypixel.hytale.server.core.universe.Universe; import com.hypixel.hytale.server.core.universe.world.SoundUtil; import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.WorldMapTracker; +import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk; +import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import com.hypixel.hytale.server.core.util.NotificationUtil; import com.hypixel.hytale.server.core.util.TempAssetIdUtil; -import it.unimi.dsi.fastutil.Pair; +import it.unimi.dsi.fastutil.longs.LongIterator; +import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import java.util.Arrays; import java.util.List; import java.util.UUID; @@ -159,9 +163,6 @@ public class Player extends LivingEntity implements CommandSender, PermissionHol return EntityModule.get().getPlayerComponentType(); } - public Player() { - } - public void copyFrom(@Nonnull Player oldPlayerComponent) { this.init(this.legacyUuid, this.playerRef); this.worldMapTracker.copyFrom(oldPlayerComponent.worldMapTracker); @@ -249,7 +250,7 @@ public class Player extends LivingEntity implements CommandSender, PermissionHol Vector3d position = transformComponent.getPosition(); this.addLocationChange(ref, locX - position.getX(), locY - position.getY(), locZ - position.getZ(), componentAccessor); super.moveTo(ref, locX, locY, locZ, componentAccessor); - this.windowManager.validateWindows(); + this.windowManager.validateWindows(ref, componentAccessor); } @Nonnull @@ -367,7 +368,6 @@ public class Player extends LivingEntity implements CommandSender, PermissionHol PlayerRef playerRef = this.playerRef; LegacyEntityTrackerSystems.clear(this, holder); this.worldMapTracker.clear(); - this.windowManager.closeAllWindows(); this.hudManager.resetUserInterface(this.playerRef); this.hudManager.resetHud(this.playerRef); CameraManager cameraManagerComponent = playerRef.getComponent(CameraManager.getComponentType()); @@ -521,7 +521,7 @@ public class Player extends LivingEntity implements CommandSender, PermissionHol } @Nonnull - public static Transform getRespawnPosition( + public static CompletableFuture getRespawnPosition( @Nonnull Ref ref, @Nonnull String worldName, @Nonnull ComponentAccessor componentAccessor ) { Player playerComponent = componentAccessor.getComponent(ref, getComponentType()); @@ -545,34 +545,96 @@ public class Player extends LivingEntity implements CommandSender, PermissionHol return Double.compare(distA, distB); }).toList(); BoundingBox playerBoundingBoxComponent = componentAccessor.getComponent(ref, BoundingBox.getComponentType()); - if (playerBoundingBoxComponent == null) { - return new Transform(sortedRespawnPoints.getFirst().getRespawnPosition()); - } else { - for (PlayerRespawnPointData respawnPoint : sortedRespawnPoints) { - Pair respawnPointResult = ensureNoCollisionAtRespawnPosition(respawnPoint, playerBoundingBoxComponent.getBoundingBox(), world); - if (respawnPointResult.left()) { - return new Transform(respawnPointResult.right(), Vector3f.ZERO); - } - - playerComponent.sendMessage(Message.translation("server.general.respawnPointObstructed").param("respawnPointName", respawnPoint.getName())); - } - - playerComponent.sendMessage(Message.translation("server.general.allRespawnPointsObstructed")); - Transform worldSpawnPoint = world.getWorldConfig().getSpawnProvider().getSpawnPoint(ref, componentAccessor); - worldSpawnPoint.setRotation(Vector3f.ZERO); - return worldSpawnPoint; - } + return playerBoundingBoxComponent == null + ? CompletableFuture.completedFuture(new Transform(sortedRespawnPoints.getFirst().getRespawnPosition())) + : tryUseSpawnPoint(world, sortedRespawnPoints, 0, ref, playerComponent, playerBoundingBoxComponent.getBoundingBox()); } else { Transform worldSpawnPoint = world.getWorldConfig().getSpawnProvider().getSpawnPoint(ref, componentAccessor); worldSpawnPoint.setRotation(Vector3f.ZERO); - return worldSpawnPoint; + return CompletableFuture.completedFuture(worldSpawnPoint); } } - private static Pair ensureNoCollisionAtRespawnPosition(PlayerRespawnPointData playerRespawnPointData, Box playerHitbox, World world) { + @Nonnull + private static CompletableFuture tryUseSpawnPoint( + World world, List sortedRespawnPoints, int index, Ref ref, Player playerComponent, Box boundingBox + ) { + if (sortedRespawnPoints != null && index < sortedRespawnPoints.size()) { + PlayerRespawnPointData respawnPoint = sortedRespawnPoints.get(index); + LongOpenHashSet requiredChunks = new LongOpenHashSet(); + if (respawnPoint.getRespawnPosition() != null) { + boundingBox.forEachBlock(respawnPoint.getRespawnPosition(), 2.0, requiredChunks, (x, y, z, chunks) -> { + chunks.add(ChunkUtil.indexChunkFromBlock(x, z)); + return true; + }); + } + + if (respawnPoint.getBlockPosition() != null) { + boundingBox.forEachBlock(respawnPoint.getBlockPosition().toVector3d(), 2.0, requiredChunks, (x, y, z, chunks) -> { + chunks.add(ChunkUtil.indexChunkFromBlock(x, z)); + return true; + }); + } + + CompletableFuture[] chunkFutures = new CompletableFuture[requiredChunks.size()]; + int i = 0; + LongIterator iterator = requiredChunks.iterator(); + + while (iterator.hasNext()) { + long chunkIndex = iterator.nextLong(); + chunkFutures[i++] = world.getChunkStore().getChunkReferenceAsync(chunkIndex).thenApplyAsync(v -> { + if (v != null && v.isValid()) { + WorldChunk wc = v.getStore().getComponent((Ref)v, WorldChunk.getComponentType()); + + assert wc != null; + + wc.addKeepLoaded(); + return wc; + } else { + return null; + } + }, world); + } + + return CompletableFuture.allOf(chunkFutures) + .thenApplyAsync(v -> { + Vector3d pos = ensureNoCollisionAtRespawnPosition(respawnPoint, boundingBox, world); + if (pos != null) { + return new Transform(pos, Vector3f.ZERO); + } else { + playerComponent.sendMessage(Message.translation("server.general.respawnPointObstructed").param("respawnPointName", respawnPoint.getName())); + return null; + } + }, world) + .whenComplete((unused, throwable) -> { + for (CompletableFuture future : chunkFutures) { + future.thenAccept(WorldChunk::removeKeepLoaded); + } + }) + .thenCompose( + v -> v != null + ? CompletableFuture.completedFuture(v) + : tryUseSpawnPoint(world, sortedRespawnPoints, index + 1, ref, playerComponent, boundingBox) + ); + } else { + playerComponent.sendMessage(Message.translation("server.general.allRespawnPointsObstructed")); + return CompletableFuture.supplyAsync(() -> { + if (!ref.isValid()) { + return new Transform(); + } else { + Transform worldSpawnPoint = world.getWorldConfig().getSpawnProvider().getSpawnPoint(ref, ref.getStore()); + worldSpawnPoint.setRotation(Vector3f.ZERO); + return worldSpawnPoint; + } + }, world); + } + } + + @Nullable + private static Vector3d ensureNoCollisionAtRespawnPosition(PlayerRespawnPointData playerRespawnPointData, Box playerHitbox, World world) { Vector3d respawnPosition = new Vector3d(playerRespawnPointData.getRespawnPosition()); if (CollisionModule.get().validatePosition(world, playerHitbox, respawnPosition, new CollisionResult()) != -1) { - return Pair.of(Boolean.TRUE, respawnPosition); + return respawnPosition; } else { respawnPosition.x = playerRespawnPointData.getBlockPosition().x + 0.5F; respawnPosition.y = playerRespawnPointData.getBlockPosition().y; @@ -582,29 +644,29 @@ public class Player extends LivingEntity implements CommandSender, PermissionHol for (int offset = -distance; offset <= distance; offset++) { Vector3d newPosition = new Vector3d(respawnPosition.x + offset, respawnPosition.y, respawnPosition.z - distance); if (CollisionModule.get().validatePosition(world, playerHitbox, newPosition, new CollisionResult()) != -1) { - return Pair.of(Boolean.TRUE, newPosition); + return newPosition; } newPosition = new Vector3d(respawnPosition.x + offset, respawnPosition.y, respawnPosition.z + distance); if (CollisionModule.get().validatePosition(world, playerHitbox, newPosition, new CollisionResult()) != -1) { - return Pair.of(Boolean.TRUE, newPosition); + return newPosition; } } for (int offset = -distance + 1; offset < distance; offset++) { Vector3d newPositionx = new Vector3d(respawnPosition.x - distance, respawnPosition.y, respawnPosition.z + offset); if (CollisionModule.get().validatePosition(world, playerHitbox, newPositionx, new CollisionResult()) != -1) { - return Pair.of(Boolean.TRUE, newPositionx); + return newPositionx; } newPositionx = new Vector3d(respawnPosition.x + distance, respawnPosition.y, respawnPosition.z + offset); if (CollisionModule.get().validatePosition(world, playerHitbox, newPositionx, new CollisionResult()) != -1) { - return Pair.of(Boolean.TRUE, newPositionx); + return newPositionx; } } } - return Pair.of(Boolean.FALSE, respawnPosition); + return null; } } diff --git a/src/com/hypixel/hytale/server/core/entity/entities/player/HiddenPlayersManager.java b/src/com/hypixel/hytale/server/core/entity/entities/player/HiddenPlayersManager.java index f1d3383..695fcbe 100644 --- a/src/com/hypixel/hytale/server/core/entity/entities/player/HiddenPlayersManager.java +++ b/src/com/hypixel/hytale/server/core/entity/entities/player/HiddenPlayersManager.java @@ -9,9 +9,6 @@ public class HiddenPlayersManager { @Nonnull private final Set hiddenPlayers = ConcurrentHashMap.newKeySet(); - public HiddenPlayersManager() { - } - public void hidePlayer(@Nonnull UUID uuid) { this.hiddenPlayers.add(uuid); } diff --git a/src/com/hypixel/hytale/server/core/entity/entities/player/HotbarManager.java b/src/com/hypixel/hytale/server/core/entity/entities/player/HotbarManager.java index e34788a..2976ea9 100644 --- a/src/com/hypixel/hytale/server/core/entity/entities/player/HotbarManager.java +++ b/src/com/hypixel/hytale/server/core/entity/entities/player/HotbarManager.java @@ -38,9 +38,6 @@ public class HotbarManager { private int currentHotbar = 0; private boolean currentlyLoadingHotbar; - public HotbarManager() { - } - public void saveHotbar(@Nonnull Ref playerRef, short hotbarIndex, @Nonnull ComponentAccessor componentAccessor) { PlayerRef playerRefComponent = componentAccessor.getComponent(playerRef, PlayerRef.getComponentType()); diff --git a/src/com/hypixel/hytale/server/core/entity/entities/player/data/PlayerConfigData.java b/src/com/hypixel/hytale/server/core/entity/entities/player/data/PlayerConfigData.java index 6221039..d790a20 100644 --- a/src/com/hypixel/hytale/server/core/entity/entities/player/data/PlayerConfigData.java +++ b/src/com/hypixel/hytale/server/core/entity/entities/player/data/PlayerConfigData.java @@ -124,9 +124,6 @@ public final class PlayerConfigData { public final Vector3d lastSavedPosition = new Vector3d(); public final Vector3f lastSavedRotation = new Vector3f(); - public PlayerConfigData() { - } - public int getBlockIdVersion() { return this.blockIdVersion; } diff --git a/src/com/hypixel/hytale/server/core/entity/entities/player/data/UniqueItemUsagesComponent.java b/src/com/hypixel/hytale/server/core/entity/entities/player/data/UniqueItemUsagesComponent.java index e798d29..b5219ea 100644 --- a/src/com/hypixel/hytale/server/core/entity/entities/player/data/UniqueItemUsagesComponent.java +++ b/src/com/hypixel/hytale/server/core/entity/entities/player/data/UniqueItemUsagesComponent.java @@ -11,9 +11,11 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import java.util.Collections; import java.util.HashSet; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; public class UniqueItemUsagesComponent implements Component { + @Nonnull public static final BuilderCodec CODEC = BuilderCodec.builder(UniqueItemUsagesComponent.class, UniqueItemUsagesComponent::new) .append(new KeyedCodec<>("UniqueItemUsed", new ArrayCodec<>(Codec.STRING, String[]::new)), (playerMemories, usages) -> { if (usages != null) { @@ -24,14 +26,11 @@ public class UniqueItemUsagesComponent implements Component { .build(); private final Set usedUniqueItems = new HashSet<>(); - public UniqueItemUsagesComponent() { - } - public static ComponentType getComponentType() { return EntityModule.get().getUniqueItemUsagesComponentType(); } - @NullableDecl + @Nullable @Override public Component clone() { UniqueItemUsagesComponent component = new UniqueItemUsagesComponent(); diff --git a/src/com/hypixel/hytale/server/core/entity/entities/player/pages/PageManager.java b/src/com/hypixel/hytale/server/core/entity/entities/player/pages/PageManager.java index f2ef04d..26889d1 100644 --- a/src/com/hypixel/hytale/server/core/entity/entities/player/pages/PageManager.java +++ b/src/com/hypixel/hytale/server/core/entity/entities/player/pages/PageManager.java @@ -27,9 +27,6 @@ public class PageManager { @Nonnull private final AtomicInteger customPageRequiredAcknowledgments = new AtomicInteger(); - public PageManager() { - } - public void init(@Nonnull PlayerRef playerRef, @Nonnull WindowManager windowManager) { this.windowManager = windowManager; this.playerRef = playerRef; @@ -76,7 +73,7 @@ public class PageManager { if (this.windowManager == null) { return false; } else { - List windowPackets = this.windowManager.openWindows(windows); + List windowPackets = this.windowManager.openWindows(ref, store, windows); if (windowPackets == null) { return false; } else { @@ -97,7 +94,7 @@ public class PageManager { if (this.windowManager == null) { return false; } else { - List windowPackets = this.windowManager.openWindows(windows); + List windowPackets = this.windowManager.openWindows(ref, store, windows); if (windowPackets == null) { return false; } else { diff --git a/src/com/hypixel/hytale/server/core/entity/entities/player/pages/RespawnPage.java b/src/com/hypixel/hytale/server/core/entity/entities/player/pages/RespawnPage.java index a757e44..12c5e4a 100644 --- a/src/com/hypixel/hytale/server/core/entity/entities/player/pages/RespawnPage.java +++ b/src/com/hypixel/hytale/server/core/entity/entities/player/pages/RespawnPage.java @@ -3,6 +3,7 @@ package com.hypixel.hytale.server.core.entity.entities.player.pages; import com.hypixel.hytale.codec.Codec; import com.hypixel.hytale.codec.KeyedCodec; import com.hypixel.hytale.codec.builder.BuilderCodec; +import com.hypixel.hytale.common.util.CompletableFutureUtil; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.Store; import com.hypixel.hytale.protocol.packets.interface_.CustomPageLifetime; @@ -22,6 +23,7 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.HashMap; +import java.util.concurrent.CompletableFuture; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -123,11 +125,27 @@ public class RespawnPage extends InteractiveCustomUIPage ref, @Nonnull Store store, @Nonnull RespawnPage.RespawnPageEventData data) { if ("Respawn".equals(data.action)) { - Player playerComponent = store.getComponent(ref, Player.getComponentType()); + PlayerRef playerRef = store.getComponent(ref, PlayerRef.getComponentType()); - assert playerComponent != null; + assert playerRef != null; - playerComponent.getPageManager().setPage(ref, store, Page.None); + UICommandBuilder commandBuilder = new UICommandBuilder(); + commandBuilder.set("#RespawnButton.Disabled", true); + this.sendUpdate(commandBuilder); + CompletableFutureUtil._catch(DeathComponent.respawn(store, ref).thenCompose(v -> { + Ref currentRef = playerRef.getReference(); + return currentRef != null && currentRef.isValid() ? CompletableFuture.runAsync(() -> { + if (currentRef.isValid()) { + Player playerComponent = currentRef.getStore().getComponent(currentRef, Player.getComponentType()); + + assert playerComponent != null; + + if (playerComponent.getPageManager().getCustomPage() == this) { + playerComponent.getPageManager().setPage(currentRef, currentRef.getStore(), Page.None); + } + } + }, currentRef.getStore().getExternalData().getWorld()) : CompletableFuture.completedFuture(null); + })); } } @@ -140,13 +158,7 @@ public class RespawnPage extends InteractiveCustomUIPage("Action", Codec.STRING), (entry, s) -> entry.action = s, entry -> entry.action) .build(); private String action; - - public RespawnPageEventData() { - } } } diff --git a/src/com/hypixel/hytale/server/core/entity/entities/player/pages/audio/PlaySoundPage.java b/src/com/hypixel/hytale/server/core/entity/entities/player/pages/audio/PlaySoundPage.java index a23c60b..afd4881 100644 --- a/src/com/hypixel/hytale/server/core/entity/entities/player/pages/audio/PlaySoundPage.java +++ b/src/com/hypixel/hytale/server/core/entity/entities/player/pages/audio/PlaySoundPage.java @@ -179,8 +179,5 @@ public class PlaySoundPage extends InteractiveCustomUIPage ref = playerRef.getReference(); - if (ref == null) { - return false; - } else { - Store store = ref.getStore(); - World world = store.getExternalData().getWorld(); - TransformComponent transformComponent = store.getComponent(ref, TransformComponent.getComponentType()); - if (transformComponent.getPosition().distanceSquaredTo(this.x, this.y, this.z) > this.maxDistanceSqr) { + public boolean validate(@Nonnull Ref ref, @Nonnull ComponentAccessor store) { + World world = store.getExternalData().getWorld(); + TransformComponent transformComponent = store.getComponent(ref, TransformComponent.getComponentType()); + if (transformComponent != null && !(transformComponent.getPosition().distanceSquaredTo(this.x, this.y, this.z) > this.maxDistanceSqr)) { + ChunkStore chunkStore = world.getChunkStore(); + long chunkIndex = ChunkUtil.indexChunkFromBlock(this.x, this.z); + Ref chunkRef = chunkStore.getChunkReference(chunkIndex); + if (chunkRef != null && chunkRef.isValid()) { + Store chunkComponentStore = chunkStore.getStore(); + WorldChunk worldChunkComponent = chunkComponentStore.getComponent(chunkRef, WorldChunk.getComponentType()); + if (worldChunkComponent == null) { return false; } else { - WorldChunk worldChunk = world.getChunkIfInMemory(ChunkUtil.indexChunkFromBlock(this.x, this.z)); - if (worldChunk == null) { + BlockType currentBlockType = worldChunkComponent.getBlockType(this.x, this.y, this.z); + if (currentBlockType == null) { return false; } else { - BlockType currentBlockType = worldChunk.getBlockType(this.x, this.y, this.z); - if (currentBlockType == null) { - return false; - } else { - Item currentItem = currentBlockType.getItem(); - return currentItem == null ? false : currentItem.equals(this.blockType.getItem()); - } + Item currentItem = currentBlockType.getItem(); + return currentItem == null ? false : currentItem.equals(this.blockType.getItem()); } } + } else { + return false; } + } else { + return false; } } } diff --git a/src/com/hypixel/hytale/server/core/entity/entities/player/windows/ContainerBlockWindow.java b/src/com/hypixel/hytale/server/core/entity/entities/player/windows/ContainerBlockWindow.java index 2711d63..1ca3dc8 100644 --- a/src/com/hypixel/hytale/server/core/entity/entities/player/windows/ContainerBlockWindow.java +++ b/src/com/hypixel/hytale/server/core/entity/entities/player/windows/ContainerBlockWindow.java @@ -1,6 +1,7 @@ package com.hypixel.hytale.server.core.entity.entities.player.windows; import com.google.gson.JsonObject; +import com.hypixel.hytale.component.ComponentAccessor; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.Store; import com.hypixel.hytale.protocol.packets.window.SortItemsAction; @@ -35,12 +36,12 @@ public class ContainerBlockWindow extends BlockWindow implements ItemContainerWi } @Override - public boolean onOpen0() { + public boolean onOpen0(@Nonnull Ref ref, @Nonnull Store store) { return true; } @Override - public void onClose0() { + public void onClose0(@Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor) { } @Nonnull diff --git a/src/com/hypixel/hytale/server/core/entity/entities/player/windows/ContainerWindow.java b/src/com/hypixel/hytale/server/core/entity/entities/player/windows/ContainerWindow.java index f2ba8f1..4dd6bb3 100644 --- a/src/com/hypixel/hytale/server/core/entity/entities/player/windows/ContainerWindow.java +++ b/src/com/hypixel/hytale/server/core/entity/entities/player/windows/ContainerWindow.java @@ -1,8 +1,12 @@ package com.hypixel.hytale.server.core.entity.entities.player.windows; import com.google.gson.JsonObject; +import com.hypixel.hytale.component.ComponentAccessor; +import com.hypixel.hytale.component.Ref; +import com.hypixel.hytale.component.Store; import com.hypixel.hytale.protocol.packets.window.WindowType; import com.hypixel.hytale.server.core.inventory.container.ItemContainer; +import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class ContainerWindow extends Window implements ItemContainerWindow { @@ -24,12 +28,12 @@ public class ContainerWindow extends Window implements ItemContainerWindow { } @Override - public boolean onOpen0() { + public boolean onOpen0(@Nonnull Ref ref, @Nonnull Store store) { return true; } @Override - public void onClose0() { + public void onClose0(@Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor) { } @Nonnull diff --git a/src/com/hypixel/hytale/server/core/entity/entities/player/windows/ItemStackContainerWindow.java b/src/com/hypixel/hytale/server/core/entity/entities/player/windows/ItemStackContainerWindow.java index 2470889..1f51d6d 100644 --- a/src/com/hypixel/hytale/server/core/entity/entities/player/windows/ItemStackContainerWindow.java +++ b/src/com/hypixel/hytale/server/core/entity/entities/player/windows/ItemStackContainerWindow.java @@ -1,10 +1,14 @@ package com.hypixel.hytale.server.core.entity.entities.player.windows; import com.google.gson.JsonObject; +import com.hypixel.hytale.component.ComponentAccessor; +import com.hypixel.hytale.component.Ref; +import com.hypixel.hytale.component.Store; import com.hypixel.hytale.event.EventRegistration; import com.hypixel.hytale.protocol.packets.window.WindowType; import com.hypixel.hytale.server.core.inventory.container.ItemContainer; import com.hypixel.hytale.server.core.inventory.container.ItemStackItemContainer; +import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -28,17 +32,17 @@ public class ItemStackContainerWindow extends Window implements ItemContainerWin } @Override - public boolean onOpen0() { + public boolean onOpen0(@Nonnull Ref ref, @Nonnull Store store) { this.eventRegistration = this.itemStackItemContainer.getParentContainer().registerChangeEvent(event -> { if (!this.itemStackItemContainer.isItemStackValid()) { - this.close(); + this.close(ref, store); } }); return true; } @Override - public void onClose0() { + public void onClose0(@Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor) { this.eventRegistration.unregister(); this.eventRegistration = null; } diff --git a/src/com/hypixel/hytale/server/core/entity/entities/player/windows/MaterialExtraResourcesSection.java b/src/com/hypixel/hytale/server/core/entity/entities/player/windows/MaterialExtraResourcesSection.java index 24274ef..6951d14 100644 --- a/src/com/hypixel/hytale/server/core/entity/entities/player/windows/MaterialExtraResourcesSection.java +++ b/src/com/hypixel/hytale/server/core/entity/entities/player/windows/MaterialExtraResourcesSection.java @@ -9,9 +9,6 @@ public class MaterialExtraResourcesSection { private ItemContainer itemContainer; private ItemQuantity[] extraMaterials; - public MaterialExtraResourcesSection() { - } - public void setExtraMaterials(ItemQuantity[] extraMaterials) { this.extraMaterials = extraMaterials; } diff --git a/src/com/hypixel/hytale/server/core/entity/entities/player/windows/ValidatedWindow.java b/src/com/hypixel/hytale/server/core/entity/entities/player/windows/ValidatedWindow.java index 6885964..64af4b8 100644 --- a/src/com/hypixel/hytale/server/core/entity/entities/player/windows/ValidatedWindow.java +++ b/src/com/hypixel/hytale/server/core/entity/entities/player/windows/ValidatedWindow.java @@ -1,5 +1,10 @@ package com.hypixel.hytale.server.core.entity.entities.player.windows; +import com.hypixel.hytale.component.ComponentAccessor; +import com.hypixel.hytale.component.Ref; +import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; +import javax.annotation.Nonnull; + public interface ValidatedWindow { - boolean validate(); + boolean validate(@Nonnull Ref var1, @Nonnull ComponentAccessor var2); } diff --git a/src/com/hypixel/hytale/server/core/entity/entities/player/windows/Window.java b/src/com/hypixel/hytale/server/core/entity/entities/player/windows/Window.java index f3d10e0..c9fe8ba 100644 --- a/src/com/hypixel/hytale/server/core/entity/entities/player/windows/Window.java +++ b/src/com/hypixel/hytale/server/core/entity/entities/player/windows/Window.java @@ -1,6 +1,7 @@ package com.hypixel.hytale.server.core.entity.entities.player.windows; import com.google.gson.JsonObject; +import com.hypixel.hytale.component.ComponentAccessor; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.Store; import com.hypixel.hytale.event.EventPriority; @@ -51,22 +52,22 @@ public abstract class Window { @Nonnull public abstract JsonObject getData(); - protected abstract boolean onOpen0(); - - protected abstract void onClose0(); - - protected boolean onOpen() { - return this.onOpen0(); + protected boolean onOpen(@Nonnull Ref ref, @Nonnull Store store) { + return this.onOpen0(ref, store); } - protected void onClose() { + protected abstract boolean onOpen0(@Nonnull Ref var1, @Nonnull Store var2); + + protected void onClose(@Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor) { try { - this.onClose0(); + this.onClose0(ref, componentAccessor); } finally { this.closeEventRegistry.dispatchFor(null).dispatch(new Window.WindowCloseEvent()); } } + protected abstract void onClose0(@Nonnull Ref var1, @Nonnull ComponentAccessor var2); + public void handleAction(@Nonnull Ref ref, @Nonnull Store store, @Nonnull WindowAction action) { } @@ -88,10 +89,10 @@ public abstract class Window { return this.playerRef; } - public void close() { + public void close(@Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor) { assert this.manager != null; - this.manager.closeWindow(this.id); + this.manager.closeWindow(ref, this.id, componentAccessor); } protected void invalidate() { @@ -153,7 +154,5 @@ public abstract class Window { } public static class WindowCloseEvent implements IEvent { - public WindowCloseEvent() { - } } } diff --git a/src/com/hypixel/hytale/server/core/entity/entities/player/windows/WindowManager.java b/src/com/hypixel/hytale/server/core/entity/entities/player/windows/WindowManager.java index 27e526d..00d5f40 100644 --- a/src/com/hypixel/hytale/server/core/entity/entities/player/windows/WindowManager.java +++ b/src/com/hypixel/hytale/server/core/entity/entities/player/windows/WindowManager.java @@ -1,6 +1,9 @@ package com.hypixel.hytale.server.core.entity.entities.player.windows; import com.hypixel.fastutil.ints.Int2ObjectConcurrentHashMap; +import com.hypixel.hytale.component.ComponentAccessor; +import com.hypixel.hytale.component.Ref; +import com.hypixel.hytale.component.Store; import com.hypixel.hytale.event.EventPriority; import com.hypixel.hytale.event.EventRegistration; import com.hypixel.hytale.logger.HytaleLogger; @@ -11,6 +14,7 @@ import com.hypixel.hytale.protocol.packets.window.OpenWindow; import com.hypixel.hytale.protocol.packets.window.UpdateWindow; import com.hypixel.hytale.server.core.inventory.container.ItemContainer; import com.hypixel.hytale.server.core.universe.PlayerRef; +import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectList; import java.util.Iterator; @@ -29,18 +33,15 @@ public class WindowManager { @Nonnull private final Int2ObjectConcurrentHashMap windows = new Int2ObjectConcurrentHashMap<>(); @Nonnull - private final Int2ObjectConcurrentHashMap windowChangeEvents = new Int2ObjectConcurrentHashMap<>(); + private final Int2ObjectConcurrentHashMap> windowChangeEvents = new Int2ObjectConcurrentHashMap<>(); private PlayerRef playerRef; - public WindowManager() { - } - public void init(@Nonnull PlayerRef playerRef) { this.playerRef = playerRef; } @Nullable - public UpdateWindow clientOpenWindow(@Nonnull Window window) { + public UpdateWindow clientOpenWindow(@Nonnull Ref ref, @Nonnull Window window, @Nonnull Store store) { if (!Window.CLIENT_REQUESTABLE_WINDOW_TYPES.containsKey(window.getType())) { throw new IllegalArgumentException("Client opened window must be registered in Window.CLIENT_REQUESTABLE_WINDOW_TYPES but got: " + window.getType()); } else { @@ -51,26 +52,26 @@ public class WindowManager { this.windowChangeEvents.remove(oldWindow.getId()).unregister(); } - oldWindow.onClose(); + oldWindow.onClose(ref, store); LOGGER.at(Level.FINE).log("%s close window %s with id %s", this.playerRef.getUuid(), oldWindow.getType(), 0); } this.setWindow0(0, window); - if (!window.onOpen()) { - this.closeWindow(0); + if (!window.onOpen(ref, store)) { + this.closeWindow(ref, 0, store); window.setId(-1); return null; } else if (!window.consumeIsDirty()) { return null; } else { InventorySection section = null; - if (window instanceof ItemContainerWindow) { - section = ((ItemContainerWindow)window).getItemContainer().toPacket(); + if (window instanceof ItemContainerWindow itemContainerWindow) { + section = itemContainerWindow.getItemContainer().toPacket(); } ExtraResources extraResources = null; - if (window instanceof MaterialContainerWindow) { - extraResources = ((MaterialContainerWindow)window).getExtraResourcesSection().toPacket(); + if (window instanceof MaterialContainerWindow materialContainerWindow) { + extraResources = materialContainerWindow.getExtraResourcesSection().toPacket(); } return new UpdateWindow(0, window.getData().toString(), section, extraResources); @@ -79,27 +80,27 @@ public class WindowManager { } @Nullable - public OpenWindow openWindow(@Nonnull Window window) { + public OpenWindow openWindow(@Nonnull Ref ref, @Nonnull Window window, @Nonnull Store store) { int id = this.windowId.getAndUpdate(operand -> { operand++; return operand > 0 ? operand : 1; }); this.setWindow(id, window); - if (!window.onOpen()) { - this.closeWindow(id); + if (!window.onOpen(ref, store)) { + this.closeWindow(ref, id, store); window.setId(-1); return null; } else { window.consumeIsDirty(); LOGGER.at(Level.FINE).log("%s opened window %s with id %s and data %s", this.playerRef.getUuid(), window.getType(), id, window.getData()); InventorySection section = null; - if (window instanceof ItemContainerWindow) { - section = ((ItemContainerWindow)window).getItemContainer().toPacket(); + if (window instanceof ItemContainerWindow itemContainerWindow) { + section = itemContainerWindow.getItemContainer().toPacket(); } ExtraResources extraResources = null; - if (window instanceof MaterialContainerWindow) { - extraResources = ((MaterialContainerWindow)window).getExtraResourcesSection().toPacket(); + if (window instanceof MaterialContainerWindow materialContainerWindow) { + extraResources = materialContainerWindow.getExtraResourcesSection().toPacket(); } return new OpenWindow(id, window.getType(), window.getData().toString(), section, extraResources); @@ -107,14 +108,14 @@ public class WindowManager { } @Nullable - public List openWindows(@Nonnull Window... windows) { + public List openWindows(@Nonnull Ref ref, @Nonnull Store store, @Nonnull Window... windows) { ObjectList packets = new ObjectArrayList<>(); for (Window window : windows) { - OpenWindow packet = this.openWindow(window); + OpenWindow packet = this.openWindow(ref, window, store); if (packet == null) { for (OpenWindow addedPacket : packets) { - this.closeWindow(addedPacket.id); + this.closeWindow(ref, addedPacket.id, store); } return null; @@ -142,8 +143,8 @@ public class WindowManager { } else { window.setId(id); window.init(this.playerRef, this); - if (window instanceof ItemContainerWindow) { - ItemContainer itemContainer = ((ItemContainerWindow)window).getItemContainer(); + if (window instanceof ItemContainerWindow itemContainerWindow) { + ItemContainer itemContainer = itemContainerWindow.getItemContainer(); this.windowChangeEvents.put(id, itemContainer.registerChangeEvent(EventPriority.LAST, e -> this.markWindowChanged(id))); } } @@ -180,11 +181,15 @@ public class WindowManager { } @Nonnull - public Window closeWindow(int id) { + public Window closeWindow(@Nonnull Ref ref, int id, @Nonnull ComponentAccessor componentAccessor) { if (id == -1) { throw new IllegalArgumentException("Window id -1 is invalid!"); } else { - this.playerRef.getPacketHandler().writeNoCache(new CloseWindow(id)); + PlayerRef playerRefComponent = componentAccessor.getComponent(ref, PlayerRef.getComponentType()); + + assert playerRefComponent != null; + + playerRefComponent.getPacketHandler().writeNoCache(new CloseWindow(id)); Window window = this.windows.remove(id); if (window instanceof ItemContainerWindow) { this.windowChangeEvents.remove(window.getId()).unregister(); @@ -193,16 +198,16 @@ public class WindowManager { if (window == null) { throw new IllegalStateException("Window id " + id + " is invalid!"); } else { - window.onClose(); + window.onClose(ref, componentAccessor); LOGGER.at(Level.FINE).log("%s close window %s with id %s", this.playerRef.getUuid(), window.getType(), id); return window; } } } - public void closeAllWindows() { + public void closeAllWindows(@Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor) { for (Window window : this.windows.values()) { - window.close(); + window.close(ref, componentAccessor); } } @@ -221,20 +226,25 @@ public class WindowManager { }, this); } - public void validateWindows() { + public void validateWindows(@Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor) { for (Window value : this.windows.values()) { - if (value instanceof ValidatedWindow && !((ValidatedWindow)value).validate()) { - value.close(); + if (value instanceof ValidatedWindow validatedWindow && !validatedWindow.validate(ref, componentAccessor)) { + value.close(ref, componentAccessor); } } } public static void closeAndRemoveAll(@Nonnull Map windows) { - Iterator iterator = windows.values().iterator(); - - while (iterator.hasNext()) { - iterator.next().close(); - iterator.remove(); + for (Iterator iterator = windows.values().iterator(); iterator.hasNext(); iterator.remove()) { + W window = (W)iterator.next(); + PlayerRef playerRef = window.getPlayerRef(); + if (playerRef != null) { + Ref ref = playerRef.getReference(); + if (ref != null && ref.isValid()) { + Store store = ref.getStore(); + window.close(ref, store); + } + } } } diff --git a/src/com/hypixel/hytale/server/core/entity/group/EntityGroup.java b/src/com/hypixel/hytale/server/core/entity/group/EntityGroup.java index 3ed8b13..56b6ca2 100644 --- a/src/com/hypixel/hytale/server/core/entity/group/EntityGroup.java +++ b/src/com/hypixel/hytale/server/core/entity/group/EntityGroup.java @@ -26,9 +26,6 @@ public class EntityGroup implements Component { private Ref leaderRef; private boolean dissolved; - public EntityGroup() { - } - public static ComponentType getComponentType() { return EntityModule.get().getEntityGroupComponentType(); } diff --git a/src/com/hypixel/hytale/server/core/entity/knockback/KnockbackComponent.java b/src/com/hypixel/hytale/server/core/entity/knockback/KnockbackComponent.java index 349a364..c0f34cf 100644 --- a/src/com/hypixel/hytale/server/core/entity/knockback/KnockbackComponent.java +++ b/src/com/hypixel/hytale/server/core/entity/knockback/KnockbackComponent.java @@ -23,9 +23,6 @@ public class KnockbackComponent implements Component { private float duration; private float timer; - public KnockbackComponent() { - } - public static ComponentType getComponentType() { return EntityModule.get().getKnockbackComponentType(); } diff --git a/src/com/hypixel/hytale/server/core/entity/knockback/KnockbackSystems.java b/src/com/hypixel/hytale/server/core/entity/knockback/KnockbackSystems.java index 1c07043..fda3f6d 100644 --- a/src/com/hypixel/hytale/server/core/entity/knockback/KnockbackSystems.java +++ b/src/com/hypixel/hytale/server/core/entity/knockback/KnockbackSystems.java @@ -19,18 +19,12 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class KnockbackSystems { - public KnockbackSystems() { - } - public static class ApplyKnockback extends EntityTickingSystem implements IVelocityModifyingSystem { @Nonnull private static final Query QUERY = Query.and( AllLegacyLivingEntityTypesQuery.INSTANCE, KnockbackComponent.getComponentType(), Velocity.getComponentType(), Query.not(Player.getComponentType()) ); - public ApplyKnockback() { - } - @Nonnull @Override public Query getQuery() { @@ -71,9 +65,6 @@ public class KnockbackSystems { @Nonnull private static final Query QUERY = Query.and(KnockbackComponent.getComponentType(), Player.getComponentType(), Velocity.getComponentType()); - public ApplyPlayerKnockback() { - } - @Nonnull @Override public Query getQuery() { diff --git a/src/com/hypixel/hytale/server/core/entity/movement/MovementStatesSystems.java b/src/com/hypixel/hytale/server/core/entity/movement/MovementStatesSystems.java index 540276e..3538bda 100644 --- a/src/com/hypixel/hytale/server/core/entity/movement/MovementStatesSystems.java +++ b/src/com/hypixel/hytale/server/core/entity/movement/MovementStatesSystems.java @@ -29,9 +29,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class MovementStatesSystems { - public MovementStatesSystems() { - } - public static class AddSystem extends HolderSystem { @Nonnull private final ComponentType movementStatesComponentComponentType; diff --git a/src/com/hypixel/hytale/server/core/entity/nameplate/NameplateSystems.java b/src/com/hypixel/hytale/server/core/entity/nameplate/NameplateSystems.java index 5f8dd85..6431035 100644 --- a/src/com/hypixel/hytale/server/core/entity/nameplate/NameplateSystems.java +++ b/src/com/hypixel/hytale/server/core/entity/nameplate/NameplateSystems.java @@ -18,9 +18,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class NameplateSystems { - public NameplateSystems() { - } - public static class EntityTrackerRemove extends RefChangeSystem { @Nonnull private final ComponentType componentType; diff --git a/src/com/hypixel/hytale/server/core/entity/reference/InvalidatablePersistentRef.java b/src/com/hypixel/hytale/server/core/entity/reference/InvalidatablePersistentRef.java index 6368b3a..1c562d7 100644 --- a/src/com/hypixel/hytale/server/core/entity/reference/InvalidatablePersistentRef.java +++ b/src/com/hypixel/hytale/server/core/entity/reference/InvalidatablePersistentRef.java @@ -17,9 +17,6 @@ public class InvalidatablePersistentRef extends PersistentRef { .build(); protected int refCount; - public InvalidatablePersistentRef() { - } - @Override public void setEntity(@Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor) { super.setEntity(ref, componentAccessor); diff --git a/src/com/hypixel/hytale/server/core/entity/reference/PersistentRef.java b/src/com/hypixel/hytale/server/core/entity/reference/PersistentRef.java index 8b78e29..2254625 100644 --- a/src/com/hypixel/hytale/server/core/entity/reference/PersistentRef.java +++ b/src/com/hypixel/hytale/server/core/entity/reference/PersistentRef.java @@ -21,9 +21,6 @@ public class PersistentRef { @Nullable protected Ref reference; - public PersistentRef() { - } - @Nullable public UUID getUuid() { return this.uuid; diff --git a/src/com/hypixel/hytale/server/core/entity/reference/PersistentRefCount.java b/src/com/hypixel/hytale/server/core/entity/reference/PersistentRefCount.java index a1fa6f7..a5ac59a 100644 --- a/src/com/hypixel/hytale/server/core/entity/reference/PersistentRefCount.java +++ b/src/com/hypixel/hytale/server/core/entity/reference/PersistentRefCount.java @@ -16,9 +16,6 @@ public class PersistentRefCount implements Component { .build(); private int refCount; - public PersistentRefCount() { - } - public static ComponentType getComponentType() { return EntityModule.get().getPersistentRefCountComponentType(); } diff --git a/src/com/hypixel/hytale/server/core/event/events/BootEvent.java b/src/com/hypixel/hytale/server/core/event/events/BootEvent.java index 675eed3..79f85b3 100644 --- a/src/com/hypixel/hytale/server/core/event/events/BootEvent.java +++ b/src/com/hypixel/hytale/server/core/event/events/BootEvent.java @@ -4,9 +4,6 @@ import com.hypixel.hytale.event.IEvent; import javax.annotation.Nonnull; public class BootEvent implements IEvent { - public BootEvent() { - } - @Nonnull @Override public String toString() { diff --git a/src/com/hypixel/hytale/server/core/event/events/ShutdownEvent.java b/src/com/hypixel/hytale/server/core/event/events/ShutdownEvent.java index 5e934e6..83dc962 100644 --- a/src/com/hypixel/hytale/server/core/event/events/ShutdownEvent.java +++ b/src/com/hypixel/hytale/server/core/event/events/ShutdownEvent.java @@ -8,9 +8,6 @@ public class ShutdownEvent implements IEvent { public static final short UNBIND_LISTENERS = -40; public static final short SHUTDOWN_WORLDS = -32; - public ShutdownEvent() { - } - @Nonnull @Override public String toString() { diff --git a/src/com/hypixel/hytale/server/core/event/events/ecs/DropItemEvent.java b/src/com/hypixel/hytale/server/core/event/events/ecs/DropItemEvent.java index 8b9ffca..c787f4f 100644 --- a/src/com/hypixel/hytale/server/core/event/events/ecs/DropItemEvent.java +++ b/src/com/hypixel/hytale/server/core/event/events/ecs/DropItemEvent.java @@ -5,9 +5,6 @@ import com.hypixel.hytale.server.core.inventory.ItemStack; import javax.annotation.Nonnull; public class DropItemEvent extends CancellableEcsEvent { - public DropItemEvent() { - } - public static final class Drop extends DropItemEvent { @Nonnull private ItemStack itemStack; diff --git a/src/com/hypixel/hytale/server/core/inventory/Inventory.java b/src/com/hypixel/hytale/server/core/inventory/Inventory.java index 730d337..a6e8529 100644 --- a/src/com/hypixel/hytale/server/core/inventory/Inventory.java +++ b/src/com/hypixel/hytale/server/core/inventory/Inventory.java @@ -396,11 +396,7 @@ public class Inventory implements NetworkSerializable { if (targetContainer != null) { switch (moveType) { case EquipOrMergeStack: - ItemStack itemStack = targetContainer.getItemStack((short)fromSlotId); - Item item = itemStack.getItem(); - ItemArmor itemArmor = item.getArmor(); - if (itemArmor != null && fromSectionId != -3) { - targetContainer.moveItemStackFromSlotToSlot((short)fromSlotId, quantity, this.armor, (short)itemArmor.getArmorSlot().ordinal()); + if (this.tryEquipArmorPart(fromSectionId, (short)fromSlotId, quantity, targetContainer, true)) { return; } @@ -433,6 +429,10 @@ public class Inventory implements NetworkSerializable { } } + if (this.tryEquipArmorPart(fromSectionId, (short)fromSlotId, quantity, targetContainer, false)) { + return; + } + switch (fromSectionId) { case -2: targetContainer.moveItemStackFromSlot((short)fromSlotId, quantity, this.hotbar); @@ -454,10 +454,22 @@ public class Inventory implements NetworkSerializable { } } + private boolean tryEquipArmorPart(int fromSectionId, short fromSlotId, int quantity, ItemContainer targetContainer, boolean forceEquip) { + ItemStack itemStack = targetContainer.getItemStack(fromSlotId); + Item item = itemStack.getItem(); + ItemArmor itemArmor = item.getArmor(); + if (itemArmor == null || fromSectionId == -3 || !forceEquip && this.armor.getItemStack((short)itemArmor.getArmorSlot().ordinal()) != null) { + return false; + } else { + targetContainer.moveItemStackFromSlotToSlot(fromSlotId, quantity, this.armor, (short)itemArmor.getArmorSlot().ordinal()); + return true; + } + } + @Nullable public ListTransaction> takeAll(int inventorySectionId) { ItemContainer sectionById = this.getSectionById(inventorySectionId); - return sectionById != null ? sectionById.moveAllItemStacksTo(this.combinedArmorHotbarStorage) : null; + return sectionById != null ? sectionById.moveAllItemStacksTo(this.combinedHotbarFirst) : null; } @Nullable @@ -912,8 +924,5 @@ public class Inventory implements NetworkSerializable { public static enum ItemPickupType { PASSIVE, INTERACTION; - - private ItemPickupType() { - } } } diff --git a/src/com/hypixel/hytale/server/core/inventory/ItemStack.java b/src/com/hypixel/hytale/server/core/inventory/ItemStack.java index 8394574..e7fa4e9 100644 --- a/src/com/hypixel/hytale/server/core/inventory/ItemStack.java +++ b/src/com/hypixel/hytale/server/core/inventory/ItemStack.java @@ -387,8 +387,5 @@ public class ItemStack implements NetworkSerializable { public static class Metadata { public static final String BLOCK_STATE = "BlockState"; - - public Metadata() { - } } } diff --git a/src/com/hypixel/hytale/server/core/inventory/container/InternalContainerUtilItemStack.java b/src/com/hypixel/hytale/server/core/inventory/container/InternalContainerUtilItemStack.java index cde4060..3480d1f 100644 --- a/src/com/hypixel/hytale/server/core/inventory/container/InternalContainerUtilItemStack.java +++ b/src/com/hypixel/hytale/server/core/inventory/container/InternalContainerUtilItemStack.java @@ -16,9 +16,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class InternalContainerUtilItemStack { - public InternalContainerUtilItemStack() { - } - protected static int testAddToExistingSlot( @Nonnull ItemContainer abstractItemContainer, short slot, ItemStack itemStack, int itemMaxStack, int testQuantityRemaining, boolean filter ) { diff --git a/src/com/hypixel/hytale/server/core/inventory/container/InternalContainerUtilMaterial.java b/src/com/hypixel/hytale/server/core/inventory/container/InternalContainerUtilMaterial.java index 35e1bf4..0d632bb 100644 --- a/src/com/hypixel/hytale/server/core/inventory/container/InternalContainerUtilMaterial.java +++ b/src/com/hypixel/hytale/server/core/inventory/container/InternalContainerUtilMaterial.java @@ -18,9 +18,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class InternalContainerUtilMaterial { - public InternalContainerUtilMaterial() { - } - @Nonnull protected static MaterialSlotTransaction internal_removeMaterialFromSlot( @Nonnull ItemContainer itemContainer, short slot, @Nonnull MaterialQuantity material, boolean allOrNothing, boolean filter diff --git a/src/com/hypixel/hytale/server/core/inventory/container/InternalContainerUtilResource.java b/src/com/hypixel/hytale/server/core/inventory/container/InternalContainerUtilResource.java index fd69ceb..b79e82f 100644 --- a/src/com/hypixel/hytale/server/core/inventory/container/InternalContainerUtilResource.java +++ b/src/com/hypixel/hytale/server/core/inventory/container/InternalContainerUtilResource.java @@ -17,9 +17,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class InternalContainerUtilResource { - public InternalContainerUtilResource() { - } - protected static ResourceSlotTransaction internal_removeResourceFromSlot( @Nonnull ItemContainer itemContainer, short slot, @Nonnull ResourceQuantity resource, boolean allOrNothing, boolean filter ) { diff --git a/src/com/hypixel/hytale/server/core/inventory/container/InternalContainerUtilTag.java b/src/com/hypixel/hytale/server/core/inventory/container/InternalContainerUtilTag.java index 12cf63c..82f91b3 100644 --- a/src/com/hypixel/hytale/server/core/inventory/container/InternalContainerUtilTag.java +++ b/src/com/hypixel/hytale/server/core/inventory/container/InternalContainerUtilTag.java @@ -12,9 +12,6 @@ import java.util.List; import javax.annotation.Nonnull; public class InternalContainerUtilTag { - public InternalContainerUtilTag() { - } - protected static TagSlotTransaction internal_removeTagFromSlot( @Nonnull ItemContainer itemContainer, short slot, int tagIndex, int quantity, boolean allOrNothing, boolean filter ) { diff --git a/src/com/hypixel/hytale/server/core/inventory/container/ItemContainer.java b/src/com/hypixel/hytale/server/core/inventory/container/ItemContainer.java index 4bbc6ff..e21c0bf 100644 --- a/src/com/hypixel/hytale/server/core/inventory/container/ItemContainer.java +++ b/src/com/hypixel/hytale/server/core/inventory/container/ItemContainer.java @@ -62,9 +62,6 @@ public abstract class ItemContainer { LOGGER, ItemContainer.ItemContainerChangeEvent.class ); - public ItemContainer() { - } - public abstract short getCapacity(); public abstract void setGlobalFilter(FilterType var1); diff --git a/src/com/hypixel/hytale/server/core/inventory/container/ItemContainerUtil.java b/src/com/hypixel/hytale/server/core/inventory/container/ItemContainerUtil.java index e84d74f..025518d 100644 --- a/src/com/hypixel/hytale/server/core/inventory/container/ItemContainerUtil.java +++ b/src/com/hypixel/hytale/server/core/inventory/container/ItemContainerUtil.java @@ -7,9 +7,6 @@ import com.hypixel.hytale.server.core.inventory.container.filter.NoDuplicateFilt import com.hypixel.hytale.server.core.inventory.container.filter.SlotFilter; public class ItemContainerUtil { - public ItemContainerUtil() { - } - public static T trySetArmorFilters(T container) { if (container instanceof SimpleItemContainer itemContainer) { ItemArmorSlot[] itemArmorSlots = ItemArmorSlot.VALUES; diff --git a/src/com/hypixel/hytale/server/core/inventory/container/SortType.java b/src/com/hypixel/hytale/server/core/inventory/container/SortType.java index 5c5b38f..8f0d000 100644 --- a/src/com/hypixel/hytale/server/core/inventory/container/SortType.java +++ b/src/com/hypixel/hytale/server/core/inventory/container/SortType.java @@ -74,9 +74,6 @@ public enum SortType { } static class Dummy { - Dummy() { - } - static enum ItemType { WEAPON, ARMOR, @@ -84,9 +81,6 @@ public enum SortType { ITEM, SPECIAL; - private ItemType() { - } - @Nonnull private static SortType.Dummy.ItemType getType(@Nonnull Item item) { if (item.getWeapon() != null) { diff --git a/src/com/hypixel/hytale/server/core/inventory/container/filter/FilterActionType.java b/src/com/hypixel/hytale/server/core/inventory/container/filter/FilterActionType.java index f9c0270..a703bfc 100644 --- a/src/com/hypixel/hytale/server/core/inventory/container/filter/FilterActionType.java +++ b/src/com/hypixel/hytale/server/core/inventory/container/filter/FilterActionType.java @@ -4,7 +4,4 @@ public enum FilterActionType { ADD, REMOVE, DROP; - - private FilterActionType() { - } } diff --git a/src/com/hypixel/hytale/server/core/inventory/transaction/MoveType.java b/src/com/hypixel/hytale/server/core/inventory/transaction/MoveType.java index 2532107..22887f7 100644 --- a/src/com/hypixel/hytale/server/core/inventory/transaction/MoveType.java +++ b/src/com/hypixel/hytale/server/core/inventory/transaction/MoveType.java @@ -3,7 +3,4 @@ package com.hypixel.hytale.server.core.inventory.transaction; public enum MoveType { MOVE_TO_SELF, MOVE_FROM_SELF; - - private MoveType() { - } } diff --git a/src/com/hypixel/hytale/server/core/io/PacketHandler.java b/src/com/hypixel/hytale/server/core/io/PacketHandler.java index 83dcda7..69da3f8 100644 --- a/src/com/hypixel/hytale/server/core/io/PacketHandler.java +++ b/src/com/hypixel/hytale/server/core/io/PacketHandler.java @@ -18,7 +18,6 @@ import com.hypixel.hytale.protocol.packets.connection.DisconnectType; import com.hypixel.hytale.protocol.packets.connection.Ping; import com.hypixel.hytale.protocol.packets.connection.Pong; import com.hypixel.hytale.protocol.packets.connection.PongType; -import com.hypixel.hytale.server.core.HytaleServer; import com.hypixel.hytale.server.core.auth.PlayerAuthentication; import com.hypixel.hytale.server.core.io.adapter.PacketAdapters; import com.hypixel.hytale.server.core.io.handlers.login.AuthenticationPacketHandler; @@ -43,7 +42,6 @@ import java.net.SocketAddress; import java.security.SecureRandom; import java.time.Duration; import java.time.Instant; -import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; @@ -276,45 +274,61 @@ public abstract class PacketHandler implements IPacketReceiver { this.pingInfo[packet.type.ordinal()].handlePacket(packet); } - protected void setTimeout(@Nonnull String stageId, @Nonnull BooleanSupplier meets, long def, @Nonnull TimeUnit timeUnit) { + protected void initStage(@Nonnull String stage, @Nonnull Duration timeout, @Nonnull BooleanSupplier condition) { + NettyUtil.TimeoutContext.init(this.channel, stage, this.getIdentifier()); + this.setStageTimeout(stage, timeout, condition); + } + + protected void enterStage(@Nonnull String stage, @Nonnull Duration timeout, @Nonnull BooleanSupplier condition) { + NettyUtil.TimeoutContext.update(this.channel, stage, this.getIdentifier()); + this.updatePacketTimeout(timeout); + this.setStageTimeout(stage, timeout, condition); + } + + protected void enterStage(@Nonnull String stage, @Nonnull Duration timeout) { + NettyUtil.TimeoutContext.update(this.channel, stage, this.getIdentifier()); + this.updatePacketTimeout(timeout); + } + + protected void continueStage(@Nonnull String stage, @Nonnull Duration timeout, @Nonnull BooleanSupplier condition) { + NettyUtil.TimeoutContext.update(this.channel, stage); + this.updatePacketTimeout(timeout); + this.setStageTimeout(stage, timeout, condition); + } + + private void setStageTimeout(@Nonnull String stageId, @Nonnull Duration timeout, @Nonnull BooleanSupplier meets) { if (this.timeoutTask != null) { this.timeoutTask.cancel(false); } if (this instanceof AuthenticationPacketHandler || !(this instanceof PasswordPacketHandler) || this.auth != null) { - logConnectionTimings(this.channel, "setTimeout-" + stageId, Level.FINEST); - Map timeouts = HytaleServer.get().getConfig().getConnectionTimeouts().getJoinTimeouts(); - long timeout; - if (timeouts.containsKey(stageId)) { - timeout = timeouts.get(stageId).toMillis(); - } else { - timeout = TimeUnit.MILLISECONDS.convert(def, timeUnit); - } - + logConnectionTimings(this.channel, "Entering stage '" + stageId + "'", Level.FINEST); + long timeoutMillis = timeout.toMillis(); this.timeoutTask = this.channel .eventLoop() .schedule( () -> { if (this.channel.isOpen()) { if (!meets.getAsBoolean()) { - this.disconnect("Either you took too long to login or we took too long to process your request! Retry again in a moment."); + NettyUtil.TimeoutContext context = this.channel.attr(NettyUtil.TimeoutContext.KEY).get(); + String duration = context != null ? FormatUtil.nanosToString(System.nanoTime() - context.connectionStartNs()) : "unknown"; HytaleLogger.getLogger() .at(Level.WARNING) - .log( - "Took longer than %s for %s to log in at stage %s! Aborting!", - FormatUtil.timeUnitToString(timeout, TimeUnit.MILLISECONDS), - this.getIdentifier(), - stageId - ); + .log("Stage timeout for %s at stage '%s' after %s connected", this.getIdentifier(), stageId, duration); + this.disconnect("Either you took too long to login or we took too long to process your request! Retry again in a moment."); } } }, - timeout, + timeoutMillis, TimeUnit.MILLISECONDS ); } } + private void updatePacketTimeout(@Nonnull Duration timeout) { + this.channel.attr(ProtocolUtil.PACKET_TIMEOUT_KEY).set(timeout); + } + protected void clearTimeout() { if (this.timeoutTask != null) { this.timeoutTask.cancel(false); diff --git a/src/com/hypixel/hytale/server/core/io/ProtocolVersion.java b/src/com/hypixel/hytale/server/core/io/ProtocolVersion.java index 60a9e27..2572e59 100644 --- a/src/com/hypixel/hytale/server/core/io/ProtocolVersion.java +++ b/src/com/hypixel/hytale/server/core/io/ProtocolVersion.java @@ -4,14 +4,14 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class ProtocolVersion { - private final String hash; + private final int crc; - public ProtocolVersion(String hash) { - this.hash = hash; + public ProtocolVersion(int crc) { + this.crc = crc; } - public String getHash() { - return this.hash; + public int getCrc() { + return this.crc; } @Override @@ -20,7 +20,7 @@ public class ProtocolVersion { return true; } else if (o != null && this.getClass() == o.getClass()) { ProtocolVersion that = (ProtocolVersion)o; - return this.hash != null ? this.hash.equals(that.hash) : that.hash == null; + return this.crc == that.crc; } else { return false; } @@ -28,12 +28,12 @@ public class ProtocolVersion { @Override public int hashCode() { - return 31 * (this.hash != null ? this.hash.hashCode() : 0); + return 31 * this.crc; } @Nonnull @Override public String toString() { - return "ProtocolVersion{hash='" + this.hash + "'}"; + return "ProtocolVersion{crc=" + this.crc + "}"; } } diff --git a/src/com/hypixel/hytale/server/core/io/adapter/PacketAdapters.java b/src/com/hypixel/hytale/server/core/io/adapter/PacketAdapters.java index ac88971..c22e7cd 100644 --- a/src/com/hypixel/hytale/server/core/io/adapter/PacketAdapters.java +++ b/src/com/hypixel/hytale/server/core/io/adapter/PacketAdapters.java @@ -13,9 +13,6 @@ public class PacketAdapters { private static final List inboundHandlers = new CopyOnWriteArrayList<>(); private static final List outboundHandlers = new CopyOnWriteArrayList<>(); - public PacketAdapters() { - } - @Nonnull public static PacketFilter registerInbound(@Nonnull PacketWatcher watcher) { PacketFilter out = (packetListener, packet) -> { diff --git a/src/com/hypixel/hytale/server/core/io/handlers/InitialPacketHandler.java b/src/com/hypixel/hytale/server/core/io/handlers/InitialPacketHandler.java index 8164ed4..deab77a 100644 --- a/src/com/hypixel/hytale/server/core/io/handlers/InitialPacketHandler.java +++ b/src/com/hypixel/hytale/server/core/io/handlers/InitialPacketHandler.java @@ -1,5 +1,6 @@ package com.hypixel.hytale.server.core.io.handlers; +import com.hypixel.hytale.common.util.java.ManifestUtil; import com.hypixel.hytale.logger.HytaleLogger; import com.hypixel.hytale.protocol.Packet; import com.hypixel.hytale.protocol.io.netty.ProtocolUtil; @@ -9,6 +10,7 @@ import com.hypixel.hytale.protocol.packets.connection.Connect; import com.hypixel.hytale.protocol.packets.connection.Disconnect; import com.hypixel.hytale.server.core.Constants; import com.hypixel.hytale.server.core.HytaleServer; +import com.hypixel.hytale.server.core.HytaleServerConfig; import com.hypixel.hytale.server.core.Options; import com.hypixel.hytale.server.core.io.PacketHandler; import com.hypixel.hytale.server.core.io.ProtocolVersion; @@ -20,9 +22,7 @@ import com.hypixel.hytale.server.core.plugin.PluginManager; import io.netty.channel.Channel; import io.netty.handler.codec.quic.QuicStreamChannel; import java.security.SecureRandom; -import java.time.Duration; import java.util.UUID; -import java.util.concurrent.TimeUnit; import java.util.logging.Level; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -45,8 +45,8 @@ public class InitialPacketHandler extends PacketHandler { @Override public void registered0(PacketHandler oldHandler) { - Duration initialTimeout = HytaleServer.get().getConfig().getConnectionTimeouts().getInitialTimeout(); - this.setTimeout("initial", () -> !this.registered, initialTimeout.toMillis(), TimeUnit.MILLISECONDS); + HytaleServerConfig.TimeoutProfile timeouts = HytaleServer.get().getConfig().getConnectionTimeouts(); + this.initStage("initial", timeouts.getInitial(), () -> !this.registered); PacketHandler.logConnectionTimings(this.channel, "Registered", Level.FINE); } @@ -75,139 +75,157 @@ public class InitialPacketHandler extends PacketHandler { this.receivedConnect = true; this.clearTimeout(); PacketHandler.logConnectionTimings(this.channel, "Connect", Level.FINE); - String clientProtocolHash = packet.protocolHash; - if (clientProtocolHash.length() > 64) { - this.disconnect("Invalid Protocol Hash! " + clientProtocolHash.length()); - } else { - String expectedHash = "6708f121966c1c443f4b0eb525b2f81d0a8dc61f5003a692a8fa157e5e02cea9"; - if (!clientProtocolHash.equals(expectedHash)) { - this.disconnect("Incompatible protocol!\nServer: " + expectedHash + "\nClient: " + clientProtocolHash); - } else if (HytaleServer.get().isShuttingDown()) { - this.disconnect("Server is shutting down!"); - } else if (!HytaleServer.get().isBooted()) { - this.disconnect("Server is booting up! Please try again in a moment. [" + PluginManager.get().getState() + "]"); + if (packet.protocolCrc != 1789265863) { + int clientBuild = packet.protocolBuildNumber; + int serverBuild = 2; + int errorCode; + if (clientBuild < serverBuild) { + errorCode = 5; } else { - ProtocolVersion protocolVersion = new ProtocolVersion(clientProtocolHash); - String language = packet.language; - if (language == null) { - language = "en-US"; - } + errorCode = 6; + } - boolean isTcpConnection = !(this.channel instanceof QuicStreamChannel); - if (isTcpConnection) { + String serverVersion = ManifestUtil.getImplementationVersion(); + ProtocolUtil.closeApplicationConnection(this.channel, errorCode, serverVersion != null ? serverVersion : "unknown"); + } else if (HytaleServer.get().isShuttingDown()) { + this.disconnect("Server is shutting down!"); + } else if (!HytaleServer.get().isBooted()) { + this.disconnect("Server is booting up! Please try again in a moment. [" + PluginManager.get().getState() + "]"); + } else { + ProtocolVersion protocolVersion = new ProtocolVersion(packet.protocolCrc); + String language = packet.language; + if (language == null) { + language = "en-US"; + } + + boolean isTcpConnection = !(this.channel instanceof QuicStreamChannel); + if (isTcpConnection) { + HytaleLogger.getLogger().at(Level.INFO).log("TCP connection from %s - only insecure auth supported", NettyUtil.formatRemoteAddress(this.channel)); + } + + if (packet.uuid == null) { + this.disconnect("Missing UUID"); + } else if (packet.username != null && !packet.username.isEmpty()) { + if (packet.referralData != null && packet.referralData.length > 4096) { HytaleLogger.getLogger() - .at(Level.INFO) - .log("TCP connection from %s - only insecure auth supported", NettyUtil.formatRemoteAddress(this.channel)); - } + .at(Level.WARNING) + .log("Rejecting connection from %s - referral data too large: %d bytes (max: %d)", packet.username, packet.referralData.length, 4096); + this.disconnect("Referral data exceeds maximum size of 4096 bytes"); + } else { + if (packet.referralData != null) { + if (packet.referralSource == null) { + HytaleLogger.getLogger() + .at(Level.WARNING) + .log("Rejecting connection from %s - referral data provided without source address", packet.username); + this.disconnect("Referral connections must include source server address"); + return; + } + + if (packet.referralSource.host == null || packet.referralSource.host.isEmpty()) { + HytaleLogger.getLogger().at(Level.WARNING).log("Rejecting connection from %s - referral source has empty host", packet.username); + this.disconnect("Referral source address is invalid"); + return; + } + } + + boolean hasIdentityToken = packet.identityToken != null && !packet.identityToken.isEmpty(); + boolean isEditorClient = packet.clientType == ClientType.Editor; + Options.AuthMode authMode = Options.getOptionSet().valueOf(Options.AUTH_MODE); + if (hasIdentityToken && authMode == Options.AuthMode.AUTHENTICATED) { + if (isTcpConnection) { + HytaleLogger.getLogger() + .at(Level.WARNING) + .log("Rejecting authenticated connection from %s - TCP only supports insecure auth", NettyUtil.formatRemoteAddress(this.channel)); + this.disconnect("TCP connections only support insecure authentication. Use QUIC for authenticated connections."); + return; + } + + AuthenticationPacketHandler.AuthHandlerSupplier supplier = isEditorClient ? EDITOR_PACKET_HANDLER_SUPPLIER : SetupPacketHandler::new; + if (isEditorClient && supplier == null) { + this.disconnect("Editor isn't supported on this server!"); + return; + } - if (packet.uuid == null) { - this.disconnect("Missing UUID"); - } else if (packet.username != null && !packet.username.isEmpty()) { - if (packet.referralData != null && packet.referralData.length > 4096) { HytaleLogger.getLogger() - .at(Level.WARNING) - .log("Rejecting connection from %s - referral data too large: %d bytes (max: %d)", packet.username, packet.referralData.length, 4096); - this.disconnect("Referral data exceeds maximum size of 4096 bytes"); + .at(Level.INFO) + .log("Starting authenticated flow for %s (%s) from %s", packet.username, packet.uuid, NettyUtil.formatRemoteAddress(this.channel)); + NettyUtil.setChannelHandler( + this.channel, + new AuthenticationPacketHandler( + this.channel, + protocolVersion, + language, + supplier, + packet.clientType, + packet.identityToken, + packet.uuid, + packet.username, + packet.referralData, + packet.referralSource + ) + ); } else { - boolean hasIdentityToken = packet.identityToken != null && !packet.identityToken.isEmpty(); - boolean isEditorClient = packet.clientType == ClientType.Editor; - Options.AuthMode authMode = Options.getOptionSet().valueOf(Options.AUTH_MODE); - if (hasIdentityToken && authMode == Options.AuthMode.AUTHENTICATED) { - if (isTcpConnection) { + if (authMode == Options.AuthMode.AUTHENTICATED) { + HytaleLogger.getLogger() + .at(Level.WARNING) + .log( + "Rejecting development connection from %s - server requires authentication (auth-mode=%s)", + NettyUtil.formatRemoteAddress(this.channel), + authMode + ); + this.disconnect("This server requires authentication!"); + return; + } + + if (authMode == Options.AuthMode.OFFLINE) { + if (!Constants.SINGLEPLAYER) { HytaleLogger.getLogger() .at(Level.WARNING) - .log("Rejecting authenticated connection from %s - TCP only supports insecure auth", NettyUtil.formatRemoteAddress(this.channel)); - this.disconnect("TCP connections only support insecure authentication. Use QUIC for authenticated connections."); + .log("Rejecting connection from %s - offline mode is only valid in singleplayer", NettyUtil.formatRemoteAddress(this.channel)); + this.disconnect("Offline mode is only available in singleplayer."); return; } - AuthenticationPacketHandler.AuthHandlerSupplier supplier = isEditorClient ? EDITOR_PACKET_HANDLER_SUPPLIER : SetupPacketHandler::new; - if (isEditorClient && supplier == null) { - this.disconnect("Editor isn't supported on this server!"); - return; - } - - HytaleLogger.getLogger() - .at(Level.INFO) - .log("Starting authenticated flow for %s (%s) from %s", packet.username, packet.uuid, NettyUtil.formatRemoteAddress(this.channel)); - NettyUtil.setChannelHandler( - this.channel, - new AuthenticationPacketHandler( - this.channel, - protocolVersion, - language, - supplier, - packet.clientType, - packet.identityToken, - packet.uuid, - packet.username, - packet.referralData, - packet.referralSource - ) - ); - } else { - if (authMode == Options.AuthMode.AUTHENTICATED) { + if (!SingleplayerModule.isOwner(null, packet.uuid)) { HytaleLogger.getLogger() .at(Level.WARNING) .log( - "Rejecting development connection from %s - server requires authentication (auth-mode=%s)", - NettyUtil.formatRemoteAddress(this.channel), - authMode + "Rejecting connection from %s (%s) - offline mode only allows the world owner (%s)", + packet.username, + packet.uuid, + SingleplayerModule.getUuid() ); - this.disconnect("This server requires authentication!"); + this.disconnect("This world is in offline mode and only the owner can connect."); return; } - - if (authMode == Options.AuthMode.OFFLINE) { - if (!Constants.SINGLEPLAYER) { - HytaleLogger.getLogger() - .at(Level.WARNING) - .log("Rejecting connection from %s - offline mode is only valid in singleplayer", NettyUtil.formatRemoteAddress(this.channel)); - this.disconnect("Offline mode is only available in singleplayer."); - return; - } - - if (!SingleplayerModule.isOwner(null, packet.uuid)) { - HytaleLogger.getLogger() - .at(Level.WARNING) - .log( - "Rejecting connection from %s (%s) - offline mode only allows the world owner (%s)", - packet.username, - packet.uuid, - SingleplayerModule.getUuid() - ); - this.disconnect("This world is in offline mode and only the owner can connect."); - return; - } - } - - HytaleLogger.getLogger() - .at(Level.INFO) - .log("Starting development flow for %s (%s) from %s", packet.username, packet.uuid, NettyUtil.formatRemoteAddress(this.channel)); - byte[] passwordChallenge = this.generatePasswordChallengeIfNeeded(packet.uuid); - this.write(new ConnectAccept(passwordChallenge)); - PasswordPacketHandler.SetupHandlerSupplier setupSupplier = isEditorClient && EDITOR_PACKET_HANDLER_SUPPLIER != null - ? (ch, pv, lang, auth) -> EDITOR_PACKET_HANDLER_SUPPLIER.create(ch, pv, lang, auth) - : SetupPacketHandler::new; - NettyUtil.setChannelHandler( - this.channel, - new PasswordPacketHandler( - this.channel, - protocolVersion, - language, - packet.uuid, - packet.username, - packet.referralData, - packet.referralSource, - passwordChallenge, - setupSupplier - ) - ); } + + HytaleLogger.getLogger() + .at(Level.INFO) + .log("Starting development flow for %s (%s) from %s", packet.username, packet.uuid, NettyUtil.formatRemoteAddress(this.channel)); + byte[] passwordChallenge = this.generatePasswordChallengeIfNeeded(packet.uuid); + this.write(new ConnectAccept(passwordChallenge)); + PasswordPacketHandler.SetupHandlerSupplier setupSupplier = isEditorClient && EDITOR_PACKET_HANDLER_SUPPLIER != null + ? (ch, pv, lang, auth) -> EDITOR_PACKET_HANDLER_SUPPLIER.create(ch, pv, lang, auth) + : SetupPacketHandler::new; + NettyUtil.setChannelHandler( + this.channel, + new PasswordPacketHandler( + this.channel, + protocolVersion, + language, + packet.uuid, + packet.username, + packet.referralData, + packet.referralSource, + passwordChallenge, + setupSupplier + ) + ); } - } else { - this.disconnect("Missing username"); } + } else { + this.disconnect("Missing username"); } } } diff --git a/src/com/hypixel/hytale/server/core/io/handlers/SetupPacketHandler.java b/src/com/hypixel/hytale/server/core/io/handlers/SetupPacketHandler.java index c302d56..88b0fc4 100644 --- a/src/com/hypixel/hytale/server/core/io/handlers/SetupPacketHandler.java +++ b/src/com/hypixel/hytale/server/core/io/handlers/SetupPacketHandler.java @@ -45,7 +45,6 @@ import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; import java.util.UUID; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.TimeUnit; import java.util.logging.Level; import javax.annotation.Nonnull; @@ -77,17 +76,6 @@ public class SetupPacketHandler extends GenericConnectionPacketHandler { this.referralData = referralData; this.referralSource = referralSource; this.auth = null; - if (referralData != null && referralData.length > 0) { - HytaleLogger.getLogger() - .at(Level.INFO) - .log( - "Player %s connecting with %d bytes of referral data from %s:%d (unauthenticated - plugins must validate!)", - username, - referralData.length, - referralSource != null ? referralSource.host : "unknown", - referralSource != null ? referralSource.port : 0 - ); - } } public SetupPacketHandler(@Nonnull Channel channel, @Nonnull ProtocolVersion protocolVersion, String language, @Nonnull PlayerAuthentication auth) { @@ -97,17 +85,6 @@ public class SetupPacketHandler extends GenericConnectionPacketHandler { this.auth = auth; this.referralData = auth.getReferralData(); this.referralSource = auth.getReferralSource(); - if (this.referralData != null && this.referralData.length > 0) { - HytaleLogger.getLogger() - .at(Level.INFO) - .log( - "Player %s connecting with %d bytes of referral data from %s:%d (authenticated)", - this.username, - this.referralData.length, - this.referralSource != null ? this.referralSource.host : "unknown", - this.referralSource != null ? this.referralSource.port : 0 - ); - } } @Nonnull @@ -126,7 +103,20 @@ public class SetupPacketHandler extends GenericConnectionPacketHandler { @Override public void registered0(@Nonnull PacketHandler oldHandler) { - this.setTimeout("send-world-settings", () -> this.assets != null, 1L, TimeUnit.SECONDS); + HytaleServerConfig.TimeoutProfile timeouts = HytaleServer.get().getConfig().getConnectionTimeouts(); + this.enterStage("setup:world-settings", timeouts.getSetupWorldSettings(), () -> this.assets != null); + if (this.referralSource != null) { + HytaleLogger.getLogger() + .at(Level.INFO) + .log( + "Player %s referred from %s:%d with %d bytes of data", + this.username, + this.referralSource.host, + this.referralSource.port, + this.referralData != null ? this.referralData.length : 0 + ); + } + PlayerSetupConnectEvent event = HytaleServer.get() .getEventBus() .dispatchFor(PlayerSetupConnectEvent.class) @@ -138,15 +128,6 @@ public class SetupPacketHandler extends GenericConnectionPacketHandler { if (clientReferral != null) { this.writeNoCache(clientReferral); } else { - HytaleServerConfig serverConfig = HytaleServer.get().getConfig(); - boolean enableCompression; - if (!serverConfig.isLocalCompressionEnabled()) { - enableCompression = !oldHandler.isLocalConnection(); - } else { - enableCompression = true; - } - - oldHandler.setCompressionEnabled(enableCompression); PlayerRef otherPlayer = Universe.get().getPlayer(this.uuid); if (otherPlayer != null) { HytaleLogger.getLogger().at(Level.INFO).log("Found match of player %s on %s", this.uuid, otherPlayer.getUsername()); @@ -180,8 +161,9 @@ public class SetupPacketHandler extends GenericConnectionPacketHandler { this.assets = new PlayerCommonAssets(requiredAssets); worldSettings.requiredAssets = requiredAssets; this.write(worldSettings); + HytaleServerConfig serverConfig = HytaleServer.get().getConfig(); this.write(new ServerInfo(HytaleServer.get().getServerName(), serverConfig.getMotd(), serverConfig.getMaxPlayers())); - this.setTimeout("receive-assets-request", () -> this.receivedRequest, 120L, TimeUnit.SECONDS); + this.continueStage("setup:assets-request", timeouts.getSetupAssetsRequest(), () -> this.receivedRequest); } } } @@ -274,7 +256,8 @@ public class SetupPacketHandler extends GenericConnectionPacketHandler { } }) ); - this.setTimeout("send-assets", () -> future.isDone() || !future.cancel(true), 120L, TimeUnit.SECONDS); + HytaleServerConfig.TimeoutProfile timeouts = HytaleServer.get().getConfig().getConnectionTimeouts(); + this.continueStage("setup:send-assets", timeouts.getSetupSendAssets(), () -> future.isDone() || !future.cancel(true)); } } @@ -291,8 +274,10 @@ public class SetupPacketHandler extends GenericConnectionPacketHandler { if (packet.skin != null) { try { CosmeticsModule.get().validateSkin(packet.skin); - } catch (CosmeticsModule.InvalidSkinException var3) { - this.disconnect("Invalid skin! " + var3.getMessage()); + } catch (CosmeticsModule.InvalidSkinException var4) { + String msg = "Your skin contains parts that aren't available on this server.\nThis usually happens when assets are out of sync.\n\n" + + var4.getMessage(); + this.disconnect(msg); return; } } @@ -315,7 +300,8 @@ public class SetupPacketHandler extends GenericConnectionPacketHandler { } }) ); - this.setTimeout("add-to-universe", () -> future.isDone() || !future.cancel(true), 60L, TimeUnit.SECONDS); + HytaleServerConfig.TimeoutProfile timeouts = HytaleServer.get().getConfig().getConnectionTimeouts(); + this.continueStage("setup:add-to-universe", timeouts.getSetupAddToUniverse(), () -> future.isDone() || !future.cancel(true)); } } } diff --git a/src/com/hypixel/hytale/server/core/io/handlers/game/GamePacketHandler.java b/src/com/hypixel/hytale/server/core/io/handlers/game/GamePacketHandler.java index 92dd403..7a39930 100644 --- a/src/com/hypixel/hytale/server/core/io/handlers/game/GamePacketHandler.java +++ b/src/com/hypixel/hytale/server/core/io/handlers/game/GamePacketHandler.java @@ -6,6 +6,7 @@ import com.hypixel.hytale.component.Store; import com.hypixel.hytale.logger.HytaleLogger; import com.hypixel.hytale.math.util.ChunkUtil; import com.hypixel.hytale.math.util.MathUtil; +import com.hypixel.hytale.math.vector.Transform; import com.hypixel.hytale.math.vector.Vector3d; import com.hypixel.hytale.math.vector.Vector3f; import com.hypixel.hytale.math.vector.Vector3i; @@ -68,6 +69,7 @@ import com.hypixel.hytale.server.core.entity.movement.MovementStatesComponent; import com.hypixel.hytale.server.core.event.events.player.PlayerChatEvent; import com.hypixel.hytale.server.core.inventory.Inventory; import com.hypixel.hytale.server.core.inventory.ItemStack; +import com.hypixel.hytale.server.core.io.PacketHandler; import com.hypixel.hytale.server.core.io.ProtocolVersion; import com.hypixel.hytale.server.core.io.ServerManager; import com.hypixel.hytale.server.core.io.handlers.GenericPacketHandler; @@ -82,6 +84,7 @@ import com.hypixel.hytale.server.core.modules.entity.player.PlayerSettings; import com.hypixel.hytale.server.core.modules.entity.teleport.PendingTeleport; import com.hypixel.hytale.server.core.modules.entity.teleport.Teleport; import com.hypixel.hytale.server.core.modules.entity.tracker.EntityTrackerSystems; +import com.hypixel.hytale.server.core.modules.i18n.I18nModule; import com.hypixel.hytale.server.core.modules.interaction.BlockPlaceUtils; import com.hypixel.hytale.server.core.modules.interaction.InteractionModule; import com.hypixel.hytale.server.core.modules.singleplayer.SingleplayerModule; @@ -153,6 +156,12 @@ public class GamePacketHandler extends GenericPacketHandler implements IPacketHa + "}"; } + @Override + protected void registered0(PacketHandler oldHandler) { + HytaleServerConfig.TimeoutProfile timeouts = HytaleServer.get().getConfig().getConnectionTimeouts(); + this.enterStage("play", timeouts.getPlay()); + } + protected void registerHandlers() { this.registerHandler(1, p -> this.handle((Disconnect)p)); this.registerHandler(3, p -> this.handlePong((Pong)p)); @@ -426,6 +435,7 @@ public class GamePacketHandler extends GenericPacketHandler implements IPacketHa Ref ref = this.playerRef.getReference(); if (ref != null && ref.isValid()) { this.playerRef.setLanguage(packet.language); + I18nModule.get().sendTranslations(this, packet.language); } } @@ -443,7 +453,7 @@ public class GamePacketHandler extends GenericPacketHandler implements IPacketHa assert playerComponent != null; - UpdateWindow updateWindowPacket = playerComponent.getWindowManager().clientOpenWindow(supplier.get()); + UpdateWindow updateWindowPacket = playerComponent.getWindowManager().clientOpenWindow(ref, supplier.get(), store); if (updateWindowPacket != null) { this.writeNoCache(updateWindowPacket); } @@ -464,8 +474,8 @@ public class GamePacketHandler extends GenericPacketHandler implements IPacketHa Window window = playerComponent.getWindowManager().getWindow(packet.id); if (window != null) { - if (window instanceof ValidatedWindow && !((ValidatedWindow)window).validate()) { - window.close(); + if (window instanceof ValidatedWindow validatedWindow && !validatedWindow.validate(ref, store)) { + window.close(ref, store); } else { window.handleAction(this.playerRef.getReference(), store, packet.action); } @@ -492,9 +502,14 @@ public class GamePacketHandler extends GenericPacketHandler implements IPacketHa packet.usableItemsItemsPreferredPickupLocation, packet.solidBlockItemsPreferredPickupLocation, packet.miscItemsPreferredPickupLocation, - new PlayerCreativeSettings(packet.allowNPCDetection, packet.respondToHit) + new PlayerCreativeSettings(packet.allowNPCDetection, packet.respondToHit), + packet.hideHelmet, + packet.hideCuirass, + packet.hideGauntlets, + packet.hidePants ) ); + store.getComponent(ref, Player.getComponentType()).invalidateEquipmentNetwork(); } ); } @@ -598,7 +613,7 @@ public class GamePacketHandler extends GenericPacketHandler implements IPacketHa assert playerComponent != null; - playerComponent.getWindowManager().closeWindow(packet.id); + playerComponent.getWindowManager().closeWindow(ref, packet.id, store); }); } } @@ -721,27 +736,23 @@ public class GamePacketHandler extends GenericPacketHandler implements IPacketHa if (ref != null && ref.isValid()) { Store store = ref.getStore(); World world = store.getExternalData().getWorld(); - world.execute( - () -> { - Player playerComponent = store.getComponent(ref, Player.getComponentType()); + world.execute(() -> { + Player playerComponent = store.getComponent(ref, Player.getComponentType()); - assert playerComponent != null; + assert playerComponent != null; - WorldMapTracker worldMapTracker = playerComponent.getWorldMapTracker(); - if (!worldMapTracker.isAllowTeleportToMarkers()) { - this.disconnect("You are not allowed to use TeleportToWorldMapMarker!"); - } else { - MapMarker marker = worldMapTracker.getSentMarkers().get(packet.id); - if (marker != null) { - world.getEntityStore() - .getStore() - .addComponent( - this.playerRef.getReference(), Teleport.getComponentType(), new Teleport(null, PositionUtil.toTransform(marker.transform)) - ); - } + WorldMapTracker worldMapTracker = playerComponent.getWorldMapTracker(); + if (!worldMapTracker.isAllowTeleportToMarkers()) { + this.disconnect("You are not allowed to use TeleportToWorldMapMarker!"); + } else { + MapMarker marker = worldMapTracker.getSentMarkers().get(packet.id); + if (marker != null) { + Transform transform = PositionUtil.toTransform(marker.transform); + Teleport teleportComponent = Teleport.createForPlayer(transform); + world.getEntityStore().getStore().addComponent(this.playerRef.getReference(), Teleport.getComponentType(), teleportComponent); } } - ); + }); } } @@ -750,31 +761,26 @@ public class GamePacketHandler extends GenericPacketHandler implements IPacketHa if (ref != null && ref.isValid()) { Store store = ref.getStore(); World world = store.getExternalData().getWorld(); - world.execute( - () -> { - Player playerComponent = store.getComponent(ref, Player.getComponentType()); + world.execute(() -> { + Player playerComponent = store.getComponent(ref, Player.getComponentType()); - assert playerComponent != null; + assert playerComponent != null; - WorldMapTracker worldMapTracker = playerComponent.getWorldMapTracker(); - if (!worldMapTracker.isAllowTeleportToCoordinates()) { - this.disconnect("You are not allowed to use TeleportToWorldMapMarker!"); - } else { - world.getChunkStore() - .getChunkReferenceAsync(ChunkUtil.indexChunkFromBlock(packet.x, packet.y)) - .thenAcceptAsync( - chunkRef -> { - BlockChunk blockChunk = world.getChunkStore().getStore().getComponent((Ref)chunkRef, BlockChunk.getComponentType()); - Vector3d position = new Vector3d(packet.x, blockChunk.getHeight(packet.x, packet.y) + 2, packet.y); - world.getEntityStore() - .getStore() - .addComponent(this.playerRef.getReference(), Teleport.getComponentType(), new Teleport(null, position, Vector3f.NaN)); - }, - world - ); - } + WorldMapTracker worldMapTracker = playerComponent.getWorldMapTracker(); + if (!worldMapTracker.isAllowTeleportToCoordinates()) { + this.disconnect("You are not allowed to use TeleportToWorldMapMarker!"); + } else { + world.getChunkStore().getChunkReferenceAsync(ChunkUtil.indexChunkFromBlock(packet.x, packet.y)).thenAcceptAsync(chunkRef -> { + BlockChunk blockChunkComponent = world.getChunkStore().getStore().getComponent((Ref)chunkRef, BlockChunk.getComponentType()); + + assert blockChunkComponent != null; + + Vector3d position = new Vector3d(packet.x, blockChunkComponent.getHeight(packet.x, packet.y) + 2, packet.y); + Teleport teleportComponent = Teleport.createForPlayer(null, position, new Vector3f(0.0F, 0.0F, 0.0F)); + world.getEntityStore().getStore().addComponent(this.playerRef.getReference(), Teleport.getComponentType(), teleportComponent); + }, world); } - ); + }); } } diff --git a/src/com/hypixel/hytale/server/core/io/handlers/login/HandshakeHandler.java b/src/com/hypixel/hytale/server/core/io/handlers/login/HandshakeHandler.java index 3ee44cc..aaa1368 100644 --- a/src/com/hypixel/hytale/server/core/io/handlers/login/HandshakeHandler.java +++ b/src/com/hypixel/hytale/server/core/io/handlers/login/HandshakeHandler.java @@ -11,6 +11,7 @@ import com.hypixel.hytale.protocol.packets.connection.ClientType; import com.hypixel.hytale.protocol.packets.connection.Disconnect; import com.hypixel.hytale.server.core.Constants; import com.hypixel.hytale.server.core.HytaleServer; +import com.hypixel.hytale.server.core.HytaleServerConfig; import com.hypixel.hytale.server.core.auth.AuthConfig; import com.hypixel.hytale.server.core.auth.JWTValidator; import com.hypixel.hytale.server.core.auth.PlayerAuthentication; @@ -23,12 +24,9 @@ import com.hypixel.hytale.server.core.io.netty.NettyUtil; import com.hypixel.hytale.server.core.io.transport.QUICTransport; import com.hypixel.hytale.server.core.modules.singleplayer.SingleplayerModule; import io.netty.channel.Channel; -import io.netty.handler.timeout.ReadTimeoutHandler; import java.security.SecureRandom; import java.security.cert.X509Certificate; -import java.time.Duration; import java.util.UUID; -import java.util.concurrent.TimeUnit; import java.util.logging.Level; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -40,9 +38,6 @@ public abstract class HandshakeHandler extends GenericConnectionPacketHandler { private volatile HandshakeHandler.AuthState authState = HandshakeHandler.AuthState.REQUESTING_AUTH_GRANT; private volatile boolean authTokenPacketReceived = false; private volatile String authenticatedUsername; - private static final int AUTH_GRANT_TIMEOUT_SECONDS = 30; - private static final int AUTH_TOKEN_TIMEOUT_SECONDS = 30; - private static final int SERVER_TOKEN_EXCHANGE_TIMEOUT_SECONDS = 15; private final ClientType clientType; private final String identityToken; private final UUID playerUuid; @@ -110,8 +105,8 @@ public abstract class HandshakeHandler extends GenericConnectionPacketHandler { @Override public void registered0(PacketHandler oldHandler) { - Duration authTimeout = HytaleServer.get().getConfig().getConnectionTimeouts().getAuthTimeout(); - this.channel.pipeline().replace("timeOut", "timeOut", new ReadTimeoutHandler(authTimeout.toMillis(), TimeUnit.MILLISECONDS)); + HytaleServerConfig.TimeoutProfile timeouts = HytaleServer.get().getConfig().getConnectionTimeouts(); + this.enterStage("auth", timeouts.getAuth()); JWTValidator.IdentityTokenClaims identityClaims = getJwtValidator().validateIdentityToken(this.identityToken); if (identityClaims == null) { LOGGER.at(Level.WARNING).log("Identity token validation failed for %s from %s", this.username, NettyUtil.formatRemoteAddress(this.channel)); @@ -140,7 +135,7 @@ public abstract class HandshakeHandler extends GenericConnectionPacketHandler { identityClaims.scope, NettyUtil.formatRemoteAddress(this.channel) ); - this.setTimeout("auth-grant-timeout", () -> this.authState != HandshakeHandler.AuthState.REQUESTING_AUTH_GRANT, 30L, TimeUnit.SECONDS); + this.continueStage("auth:grant", timeouts.getAuthGrant(), () -> this.authState != HandshakeHandler.AuthState.REQUESTING_AUTH_GRANT); this.requestAuthGrant(); } } else { @@ -187,11 +182,9 @@ public abstract class HandshakeHandler extends GenericConnectionPacketHandler { ); this.write(new AuthGrant(authGrant, serverIdentityToken)); this.authState = HandshakeHandler.AuthState.AWAITING_AUTH_TOKEN; - this.setTimeout( - "auth-token-timeout", - () -> this.authState != HandshakeHandler.AuthState.AWAITING_AUTH_TOKEN, - 30L, - TimeUnit.SECONDS + HytaleServerConfig.TimeoutProfile timeouts = HytaleServer.get().getConfig().getConnectionTimeouts(); + this.continueStage( + "auth:token", timeouts.getAuthToken(), () -> this.authState != HandshakeHandler.AuthState.AWAITING_AUTH_TOKEN ); } } @@ -274,8 +267,9 @@ public abstract class HandshakeHandler extends GenericConnectionPacketHandler { this.authenticatedUsername = tokenUsername; if (serverAuthGrant != null && !serverAuthGrant.isEmpty()) { this.authState = HandshakeHandler.AuthState.EXCHANGING_SERVER_TOKEN; - this.setTimeout( - "server-token-exchange-timeout", () -> this.authState != HandshakeHandler.AuthState.EXCHANGING_SERVER_TOKEN, 15L, TimeUnit.SECONDS + HytaleServerConfig.TimeoutProfile timeouts = HytaleServer.get().getConfig().getConnectionTimeouts(); + this.continueStage( + "auth:server-exchange", timeouts.getAuthServerExchange(), () -> this.authState != HandshakeHandler.AuthState.EXCHANGING_SERVER_TOKEN ); this.exchangeServerAuthGrant(serverAuthGrant); } else { @@ -350,8 +344,7 @@ public abstract class HandshakeHandler extends GenericConnectionPacketHandler { LOGGER.at(Level.WARNING).withCause(ex).log("Error exchanging server auth grant"); this.channel.eventLoop().execute(() -> { if (this.authState == HandshakeHandler.AuthState.EXCHANGING_SERVER_TOKEN) { - byte[] passwordChallenge = this.generatePasswordChallengeIfNeeded(); - this.completeAuthentication(passwordChallenge); + this.disconnect("Server authentication failed - please try again later"); } }); return null; @@ -403,8 +396,5 @@ public abstract class HandshakeHandler extends GenericConnectionPacketHandler { PROCESSING_AUTH_TOKEN, EXCHANGING_SERVER_TOKEN, AUTHENTICATED; - - private AuthState() { - } } } diff --git a/src/com/hypixel/hytale/server/core/io/handlers/login/PasswordPacketHandler.java b/src/com/hypixel/hytale/server/core/io/handlers/login/PasswordPacketHandler.java index 89ff40c..f1c25f1 100644 --- a/src/com/hypixel/hytale/server/core/io/handlers/login/PasswordPacketHandler.java +++ b/src/com/hypixel/hytale/server/core/io/handlers/login/PasswordPacketHandler.java @@ -9,27 +9,24 @@ import com.hypixel.hytale.protocol.packets.auth.PasswordRejected; import com.hypixel.hytale.protocol.packets.auth.PasswordResponse; import com.hypixel.hytale.protocol.packets.connection.Disconnect; import com.hypixel.hytale.server.core.HytaleServer; +import com.hypixel.hytale.server.core.HytaleServerConfig; import com.hypixel.hytale.server.core.auth.PlayerAuthentication; import com.hypixel.hytale.server.core.io.PacketHandler; import com.hypixel.hytale.server.core.io.ProtocolVersion; import com.hypixel.hytale.server.core.io.handlers.GenericConnectionPacketHandler; import com.hypixel.hytale.server.core.io.netty.NettyUtil; import io.netty.channel.Channel; -import io.netty.handler.timeout.ReadTimeoutHandler; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; -import java.time.Duration; import java.util.UUID; -import java.util.concurrent.TimeUnit; import java.util.logging.Level; import javax.annotation.Nonnull; import javax.annotation.Nullable; public class PasswordPacketHandler extends GenericConnectionPacketHandler { private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); - private static final int PASSWORD_TIMEOUT_SECONDS = 30; private static final int MAX_PASSWORD_ATTEMPTS = 3; private static final int CHALLENGE_LENGTH = 32; private final UUID playerUuid; @@ -68,11 +65,10 @@ public class PasswordPacketHandler extends GenericConnectionPacketHandler { @Override public void registered0(PacketHandler oldHandler) { - Duration playTimeout = HytaleServer.get().getConfig().getConnectionTimeouts().getPlayTimeout(); - this.channel.pipeline().replace("timeOut", "timeOut", new ReadTimeoutHandler(playTimeout.toMillis(), TimeUnit.MILLISECONDS)); + HytaleServerConfig.TimeoutProfile timeouts = HytaleServer.get().getConfig().getConnectionTimeouts(); if (this.passwordChallenge != null && this.passwordChallenge.length != 0) { LOGGER.at(Level.FINE).log("Waiting for password response from %s", this.username); - this.setTimeout("password-timeout", () -> !this.registered, 30L, TimeUnit.SECONDS); + this.enterStage("password", timeouts.getPassword(), () -> !this.registered); } else { LOGGER.at(Level.FINE).log("No password required for %s, proceeding to setup", this.username); this.proceedToSetup(); @@ -132,7 +128,8 @@ public class PasswordPacketHandler extends GenericConnectionPacketHandler { } else { this.passwordChallenge = generateChallenge(); this.write(new PasswordRejected(this.passwordChallenge, this.attemptsRemaining)); - this.setTimeout("password-timeout", () -> !this.registered, 30L, TimeUnit.SECONDS); + HytaleServerConfig.TimeoutProfile timeouts = HytaleServer.get().getConfig().getConnectionTimeouts(); + this.continueStage("password", timeouts.getPassword(), () -> !this.registered); } } else { LOGGER.at(Level.INFO).log("Password accepted for %s (%s)", this.username, this.playerUuid); diff --git a/src/com/hypixel/hytale/server/core/io/netty/HytaleChannelInitializer.java b/src/com/hypixel/hytale/server/core/io/netty/HytaleChannelInitializer.java index c6d2758..e07cd72 100644 --- a/src/com/hypixel/hytale/server/core/io/netty/HytaleChannelInitializer.java +++ b/src/com/hypixel/hytale/server/core/io/netty/HytaleChannelInitializer.java @@ -1,5 +1,6 @@ package com.hypixel.hytale.server.core.io.netty; +import com.hypixel.hytale.common.util.FormatUtil; import com.hypixel.hytale.logger.HytaleLogger; import com.hypixel.hytale.protocol.io.PacketStatsRecorder; import com.hypixel.hytale.protocol.io.netty.PacketDecoder; @@ -20,7 +21,6 @@ import io.netty.channel.ChannelInitializer; import io.netty.handler.codec.quic.QuicChannel; import io.netty.handler.codec.quic.QuicStreamChannel; import io.netty.handler.timeout.ReadTimeoutException; -import io.netty.handler.timeout.ReadTimeoutHandler; import io.netty.handler.timeout.TimeoutException; import io.netty.handler.timeout.WriteTimeoutException; import java.io.IOException; @@ -33,14 +33,23 @@ import java.util.logging.Level; import javax.annotation.Nonnull; public class HytaleChannelInitializer extends ChannelInitializer { - public HytaleChannelInitializer() { - } - @Override protected void initChannel(Channel channel) { if (channel instanceof QuicStreamChannel quicStreamChannel) { HytaleLogger.getLogger().at(Level.INFO).log("Received stream %s to %s", NettyUtil.formatRemoteAddress(channel), NettyUtil.formatLocalAddress(channel)); QuicChannel parentChannel = quicStreamChannel.parent(); + Integer rejectErrorCode = parentChannel.attr(QUICTransport.ALPN_REJECT_ERROR_CODE_ATTR).get(); + if (rejectErrorCode != null) { + HytaleLogger.getLogger().at(Level.INFO).log("Rejecting stream from %s: client outdated (ALPN mismatch)", NettyUtil.formatRemoteAddress(channel)); + channel.config().setAutoRead(false); + channel.pipeline().addLast("packetEncoder", new PacketEncoder()); + channel.writeAndFlush(new Disconnect("Your game client needs to be updated.", DisconnectType.Disconnect)) + .addListener( + future -> channel.eventLoop().schedule(() -> ProtocolUtil.closeApplicationConnection(channel, rejectErrorCode), 100L, TimeUnit.MILLISECONDS) + ); + return; + } + X509Certificate clientCert = parentChannel.attr(QUICTransport.CLIENT_CERTIFICATE_ATTR).get(); if (clientCert != null) { channel.attr(QUICTransport.CLIENT_CERTIFICATE_ATTR).set(clientCert); @@ -54,8 +63,8 @@ public class HytaleChannelInitializer extends ChannelInitializer { PacketStatsRecorderImpl statsRecorder = new PacketStatsRecorderImpl(); channel.attr(PacketStatsRecorder.CHANNEL_KEY).set(statsRecorder); - Duration initialTimeout = HytaleServer.get().getConfig().getConnectionTimeouts().getInitialTimeout(); - channel.pipeline().addLast("timeOut", new ReadTimeoutHandler(initialTimeout.toMillis(), TimeUnit.MILLISECONDS)); + Duration initialTimeout = HytaleServer.get().getConfig().getConnectionTimeouts().getInitial(); + channel.attr(ProtocolUtil.PACKET_TIMEOUT_KEY).set(initialTimeout); channel.pipeline().addLast("packetDecoder", new PacketDecoder()); HytaleServerConfig.RateLimitConfig rateLimitConfig = HytaleServer.get().getConfig().getRateLimitConfig(); if (rateLimitConfig.isEnabled()) { @@ -91,11 +100,9 @@ public class HytaleChannelInitializer extends ChannelInitializer { } private static class ExceptionHandler extends ChannelInboundHandlerAdapter { + private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); private final AtomicBoolean handled = new AtomicBoolean(); - private ExceptionHandler() { - } - @Override public void exceptionCaught(@Nonnull ChannelHandlerContext ctx, Throwable cause) { if (!(cause instanceof ClosedChannelException)) { @@ -109,8 +116,8 @@ public class HytaleChannelInitializer extends ChannelInitializer { if (this.handled.getAndSet(true)) { if (cause instanceof IOException && cause.getMessage() != null) { - String var8 = cause.getMessage(); - switch (var8) { + String var5 = cause.getMessage(); + switch (var5) { case "Broken pipe": case "Connection reset by peer": case "An existing connection was forcibly closed by the remote host": @@ -118,31 +125,44 @@ public class HytaleChannelInitializer extends ChannelInitializer { } } - HytaleLogger.getLogger().at(Level.WARNING).withCause(cause).log("Already handled exception in ExceptionHandler but got another!"); + LOGGER.at(Level.WARNING).withCause(cause).log("Already handled exception in ExceptionHandler but got another!"); } else if (cause instanceof TimeoutException) { - boolean readTimeout = cause instanceof ReadTimeoutException; - boolean writeTimeout = cause instanceof WriteTimeoutException; - String msg = readTimeout ? "Read timeout for %s" : (writeTimeout ? "Write timeout for %s" : "Connection timeout for %s"); - HytaleLogger.getLogger().at(Level.INFO).log(msg, identifier); - NettyUtil.CONNECTION_EXCEPTION_LOGGER.at(Level.FINE).withCause(cause).log(msg, identifier); - if (ctx.channel().isWritable()) { - ctx.channel() - .writeAndFlush( - new Disconnect(readTimeout ? "Read timeout" : (writeTimeout ? "Write timeout" : "Connection timeout"), DisconnectType.Crash) - ) - .addListener(ProtocolUtil.CLOSE_ON_COMPLETE); - } else { - ProtocolUtil.closeApplicationConnection(ctx.channel()); - } + this.handleTimeout(ctx, cause, identifier); } else { - HytaleLogger.getLogger().at(Level.SEVERE).withCause(cause).log("Got exception from netty pipeline in ExceptionHandler: %s", cause.getMessage()); - if (ctx.channel().isWritable()) { - ctx.channel().writeAndFlush(new Disconnect("Internal server error!", DisconnectType.Crash)).addListener(ProtocolUtil.CLOSE_ON_COMPLETE); - } else { - ProtocolUtil.closeApplicationConnection(ctx.channel()); - } + LOGGER.at(Level.SEVERE).withCause(cause).log("Got exception from netty pipeline in ExceptionHandler: %s", cause.getMessage()); + this.gracefulDisconnect(ctx, identifier, "Internal server error!"); } } } + + private void handleTimeout(@Nonnull ChannelHandlerContext ctx, Throwable cause, String identifier) { + boolean readTimeout = cause instanceof ReadTimeoutException; + boolean writeTimeout = cause instanceof WriteTimeoutException; + String timeoutType = readTimeout ? "Read" : (writeTimeout ? "Write" : "Connection"); + NettyUtil.TimeoutContext context = ctx.channel().attr(NettyUtil.TimeoutContext.KEY).get(); + String stage = context != null ? context.stage() : "unknown"; + String duration = context != null ? FormatUtil.nanosToString(System.nanoTime() - context.connectionStartNs()) : "unknown"; + LOGGER.at(Level.INFO).log("%s timeout for %s at stage '%s' after %s connected", timeoutType, identifier, stage, duration); + NettyUtil.CONNECTION_EXCEPTION_LOGGER + .at(Level.FINE) + .withCause(cause) + .log("%s timeout for %s at stage '%s' after %s connected", timeoutType, identifier, stage, duration); + this.gracefulDisconnect(ctx, identifier, timeoutType + " timeout"); + } + + private void gracefulDisconnect(@Nonnull ChannelHandlerContext ctx, String identifier, String reason) { + Channel channel = ctx.channel(); + if (channel.isWritable()) { + channel.writeAndFlush(new Disconnect(reason, DisconnectType.Disconnect)).addListener(future -> ProtocolUtil.closeApplicationConnection(channel, 4)); + channel.eventLoop().schedule(() -> { + if (channel.isOpen()) { + LOGGER.at(Level.FINE).log("Force closing %s after graceful disconnect attempt", identifier); + ProtocolUtil.closeApplicationConnection(channel, 4); + } + }, 1L, TimeUnit.SECONDS); + } else { + ProtocolUtil.closeApplicationConnection(channel, 4); + } + } } } diff --git a/src/com/hypixel/hytale/server/core/io/netty/NettyUtil.java b/src/com/hypixel/hytale/server/core/io/netty/NettyUtil.java index e6392ff..8e52622 100644 --- a/src/com/hypixel/hytale/server/core/io/netty/NettyUtil.java +++ b/src/com/hypixel/hytale/server/core/io/netty/NettyUtil.java @@ -29,6 +29,7 @@ import io.netty.handler.codec.quic.QuicChannel; import io.netty.handler.codec.quic.QuicStreamChannel; import io.netty.handler.logging.LogLevel; import io.netty.handler.logging.LoggingHandler; +import io.netty.util.AttributeKey; import io.netty.util.internal.ObjectUtil; import io.netty.util.internal.StringUtil; import io.netty.util.internal.SystemPropertyUtil; @@ -51,12 +52,8 @@ public class NettyUtil { public static final String LOGGER_KEY = "logger"; public static final LoggingHandler LOGGER = new LoggingHandler("PacketLogging", LogLevel.INFO); public static final String HANDLER = "handler"; - public static final String TIMEOUT_HANDLER = "timeOut"; public static final String RATE_LIMIT = "rateLimit"; - public NettyUtil() { - } - public static void init() { } @@ -243,4 +240,32 @@ public class NettyUtil { + ")"; } } + + public record TimeoutContext(@Nonnull String stage, long connectionStartNs, @Nonnull String playerIdentifier) { + public static final AttributeKey KEY = AttributeKey.newInstance("TIMEOUT_CONTEXT"); + + public static void init(@Nonnull Channel channel, @Nonnull String stage, @Nonnull String identifier) { + channel.attr(KEY).set(new NettyUtil.TimeoutContext(stage, System.nanoTime(), identifier)); + } + + public static void update(@Nonnull Channel channel, @Nonnull String stage, @Nonnull String identifier) { + NettyUtil.TimeoutContext existing = get(channel); + channel.attr(KEY).set(new NettyUtil.TimeoutContext(stage, existing.connectionStartNs, identifier)); + } + + public static void update(@Nonnull Channel channel, @Nonnull String stage) { + NettyUtil.TimeoutContext existing = get(channel); + channel.attr(KEY).set(new NettyUtil.TimeoutContext(stage, existing.connectionStartNs, existing.playerIdentifier)); + } + + @Nonnull + public static NettyUtil.TimeoutContext get(@Nonnull Channel channel) { + NettyUtil.TimeoutContext context = channel.attr(KEY).get(); + if (context == null) { + throw new IllegalStateException("TimeoutContext not initialized - this indicates a bug in the connection flow"); + } else { + return context; + } + } + } } diff --git a/src/com/hypixel/hytale/server/core/io/netty/PacketArrayEncoder.java b/src/com/hypixel/hytale/server/core/io/netty/PacketArrayEncoder.java index b7aa3ef..9652531 100644 --- a/src/com/hypixel/hytale/server/core/io/netty/PacketArrayEncoder.java +++ b/src/com/hypixel/hytale/server/core/io/netty/PacketArrayEncoder.java @@ -9,9 +9,6 @@ import javax.annotation.Nonnull; @Sharable public class PacketArrayEncoder extends MessageToMessageEncoder { - public PacketArrayEncoder() { - } - protected void encode(ChannelHandlerContext ctx, @Nonnull Packet[] packets, @Nonnull List out) { for (Packet packet : packets) { if (packet != null) { diff --git a/src/com/hypixel/hytale/server/core/io/transport/QUICTransport.java b/src/com/hypixel/hytale/server/core/io/transport/QUICTransport.java index 5495079..aa9c8a5 100644 --- a/src/com/hypixel/hytale/server/core/io/transport/QUICTransport.java +++ b/src/com/hypixel/hytale/server/core/io/transport/QUICTransport.java @@ -22,6 +22,7 @@ import io.netty.channel.socket.SocketProtocolFamily; import io.netty.channel.socket.nio.NioChannelOption; import io.netty.handler.codec.quic.InsecureQuicTokenHandler; import io.netty.handler.codec.quic.QuicChannel; +import io.netty.handler.codec.quic.QuicCongestionControlAlgorithm; import io.netty.handler.codec.quic.QuicServerCodecBuilder; import io.netty.handler.codec.quic.QuicSslContext; import io.netty.handler.codec.quic.QuicSslContextBuilder; @@ -46,6 +47,7 @@ import jdk.net.ExtendedSocketOptions; public class QUICTransport implements Transport { private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); public static final AttributeKey CLIENT_CERTIFICATE_ATTR = AttributeKey.valueOf("CLIENT_CERTIFICATE"); + public static final AttributeKey ALPN_REJECT_ERROR_CODE_ATTR = AttributeKey.valueOf("ALPN_REJECT_ERROR_CODE"); @Nonnull private final EventLoopGroup workerGroup = NettyUtil.getEventLoopGroup("ServerWorkerGroup"); private final Bootstrap bootstrapIpv4; @@ -63,7 +65,7 @@ public class QUICTransport implements Transport { ServerAuthManager.getInstance().setServerCertificate(ssc.cert()); LOGGER.at(Level.INFO).log("Server certificate registered for mutual auth, fingerprint: %s", CertificateUtil.computeCertificateFingerprint(ssc.cert())); QuicSslContext sslContext = QuicSslContextBuilder.forServer(ssc.key(), null, ssc.cert()) - .applicationProtocols("hytale/1") + .applicationProtocols("hytale/2", "hytale/1") .earlyData(false) .clientAuth(ClientAuth.REQUIRE) .trustManager(InsecureTrustManagerFactory.INSTANCE) @@ -133,7 +135,7 @@ public class QUICTransport implements Transport { @Override public void channelActive(@Nonnull ChannelHandlerContext ctx) throws Exception { - Duration playTimeout = HytaleServer.get().getConfig().getConnectionTimeouts().getPlayTimeout(); + Duration playTimeout = HytaleServer.get().getConfig().getConnectionTimeouts().getPlay(); ChannelHandler quicHandler = new QuicServerCodecBuilder() .sslContext(this.sslContext) .tokenHandler(InsecureQuicTokenHandler.INSTANCE) @@ -145,6 +147,8 @@ public class QUICTransport implements Transport { .initialMaxStreamDataBidirectionalLocal(131072L) .initialMaxStreamDataBidirectionalRemote(131072L) .initialMaxStreamsBidirectional(1L) + .discoverPmtu(true) + .congestionControlAlgorithm(QuicCongestionControlAlgorithm.BBR) .handler( new ChannelInboundHandlerAdapter() { @Override @@ -158,6 +162,15 @@ public class QUICTransport implements Transport { QUICTransport.LOGGER .at(Level.INFO) .log("Received connection from %s to %s", NettyUtil.formatRemoteAddress(channel), NettyUtil.formatLocalAddress(channel)); + String negotiatedAlpn = channel.sslEngine().getApplicationProtocol(); + int negotiatedVersion = this.parseProtocolVersion(negotiatedAlpn); + if (negotiatedVersion < 2) { + QUICTransport.LOGGER + .at(Level.INFO) + .log("Marking connection from %s for rejection: ALPN %s < required %d", NettyUtil.formatRemoteAddress(channel), negotiatedAlpn, 2); + channel.attr(QUICTransport.ALPN_REJECT_ERROR_CODE_ATTR).set(5); + } + X509Certificate clientCert = QuicChannelInboundHandlerAdapter.this.extractClientCertificate(channel); if (clientCert == null) { QUICTransport.LOGGER @@ -170,6 +183,18 @@ public class QUICTransport implements Transport { } } + private int parseProtocolVersion(String alpn) { + if (alpn != null && alpn.startsWith("hytale/")) { + try { + return Integer.parseInt(alpn.substring(7)); + } catch (NumberFormatException var3) { + return 0; + } + } else { + return 0; + } + } + @Override public void channelInactive(@Nonnull ChannelHandlerContext ctx) { ((QuicChannel)ctx.channel()).collectStats().addListener(f -> { diff --git a/src/com/hypixel/hytale/server/core/io/transport/TransportType.java b/src/com/hypixel/hytale/server/core/io/transport/TransportType.java index 9fbbd85..65561b3 100644 --- a/src/com/hypixel/hytale/server/core/io/transport/TransportType.java +++ b/src/com/hypixel/hytale/server/core/io/transport/TransportType.java @@ -3,7 +3,4 @@ package com.hypixel.hytale.server.core.io.transport; public enum TransportType { TCP, QUIC; - - private TransportType() { - } } diff --git a/src/com/hypixel/hytale/server/core/meta/MetaRegistry.java b/src/com/hypixel/hytale/server/core/meta/MetaRegistry.java index b62f657..eb6ea77 100644 --- a/src/com/hypixel/hytale/server/core/meta/MetaRegistry.java +++ b/src/com/hypixel/hytale/server/core/meta/MetaRegistry.java @@ -15,9 +15,6 @@ public class MetaRegistry implements IMetaRegistry { private final List suppliers = new ObjectArrayList<>(); private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - public MetaRegistry() { - } - @Override public MetaKey registerMetaObject(Function function, boolean persistent, String keyName, @Nonnull Codec codec) { this.lock.writeLock().lock(); diff --git a/src/com/hypixel/hytale/server/core/modules/LegacyModule.java b/src/com/hypixel/hytale/server/core/modules/LegacyModule.java index e7c2333..6c2f5f9 100644 --- a/src/com/hypixel/hytale/server/core/modules/LegacyModule.java +++ b/src/com/hypixel/hytale/server/core/modules/LegacyModule.java @@ -231,9 +231,6 @@ public class LegacyModule extends JavaPlugin { new SystemDependency<>(Order.AFTER, ChunkSystems.OnNewChunk.class), RootDependency.first() ); - public MigrateLegacySections() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { ChunkColumn column = holder.getComponent(ChunkColumn.getComponentType()); diff --git a/src/com/hypixel/hytale/server/core/modules/accesscontrol/commands/BanCommand.java b/src/com/hypixel/hytale/server/core/modules/accesscontrol/commands/BanCommand.java index 464871d..336111e 100644 --- a/src/com/hypixel/hytale/server/core/modules/accesscontrol/commands/BanCommand.java +++ b/src/com/hypixel/hytale/server/core/modules/accesscontrol/commands/BanCommand.java @@ -1,8 +1,9 @@ package com.hypixel.hytale.server.core.modules.accesscontrol.commands; import com.hypixel.hytale.server.core.Message; +import com.hypixel.hytale.server.core.auth.ProfileServiceClient; import com.hypixel.hytale.server.core.command.system.CommandContext; -import com.hypixel.hytale.server.core.command.system.arguments.system.OptionalArg; +import com.hypixel.hytale.server.core.command.system.CommandUtil; import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg; import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes; import com.hypixel.hytale.server.core.command.system.basecommands.AbstractAsyncCommand; @@ -10,9 +11,9 @@ import com.hypixel.hytale.server.core.modules.accesscontrol.ban.InfiniteBan; import com.hypixel.hytale.server.core.modules.accesscontrol.provider.HytaleBanProvider; import com.hypixel.hytale.server.core.universe.PlayerRef; import com.hypixel.hytale.server.core.universe.Universe; -import com.hypixel.hytale.server.core.util.AuthUtil; import java.time.Instant; import java.util.Optional; +import java.util.UUID; import java.util.concurrent.CompletableFuture; import javax.annotation.Nonnull; @@ -20,9 +21,9 @@ public class BanCommand extends AbstractAsyncCommand { @Nonnull private final HytaleBanProvider banProvider; @Nonnull - private final RequiredArg usernameArg = this.withRequiredArg("username", "server.commands.ban.username.desc", ArgTypes.STRING); - @Nonnull - private final OptionalArg reasonArg = this.withOptionalArg("reason", "server.commands.ban.reason.desc", ArgTypes.STRING); + private final RequiredArg playerArg = this.withRequiredArg( + "player", "server.commands.ban.player.desc", ArgTypes.GAME_PROFILE_LOOKUP + ); public BanCommand(@Nonnull HytaleBanProvider banProvider) { super("ban", "server.commands.ban.desc"); @@ -33,34 +34,38 @@ public class BanCommand extends AbstractAsyncCommand { @Nonnull @Override protected CompletableFuture executeAsync(@Nonnull CommandContext context) { - String username = this.usernameArg.get(context); - String rawInput = context.getInputString(); - int usernameIndex = rawInput.indexOf(username); - String reason; - if (usernameIndex != -1 && usernameIndex + username.length() < rawInput.length()) { - String afterUsername = rawInput.substring(usernameIndex + username.length()).trim(); - reason = afterUsername.isEmpty() ? "No reason." : afterUsername; + ProfileServiceClient.PublicGameProfile profile = this.playerArg.get(context); + if (profile == null) { + return CompletableFuture.completedFuture(null); } else { - reason = "No reason."; - } + UUID uuid = profile.getUuid(); + String rawArgs = CommandUtil.stripCommandName(context.getInputString()); + int firstSpaceIndex = rawArgs.indexOf(32); + String reason; + if (firstSpaceIndex != -1) { + String afterPlayer = rawArgs.substring(firstSpaceIndex + 1).trim(); + reason = afterPlayer.isEmpty() ? "No reason." : afterPlayer; + } else { + reason = "No reason."; + } - return AuthUtil.lookupUuid(username).thenCompose(uuid -> { + Message displayMessage = Message.raw(profile.getUsername()).bold(true); + PlayerRef playerRef = Universe.get().getPlayer(uuid); if (this.banProvider.hasBan(uuid)) { - context.sendMessage(Message.translation("server.modules.ban.alreadyBanned").param("name", username)); + context.sendMessage(Message.translation("server.modules.ban.alreadyBanned").param("name", displayMessage)); return CompletableFuture.completedFuture(null); } else { InfiniteBan ban = new InfiniteBan(uuid, context.sender().getUuid(), Instant.now(), reason); this.banProvider.modify(banMap -> { banMap.put(uuid, ban); - return true; + return Boolean.TRUE; }); - PlayerRef player = Universe.get().getPlayer(uuid); - if (player != null) { + if (playerRef != null) { CompletableFuture> disconnectReason = ban.getDisconnectReason(uuid); return disconnectReason.whenComplete((string, disconnectEx) -> { Optional optional = (Optional)string; if (disconnectEx != null) { - context.sendMessage(Message.translation("server.modules.ban.failedDisconnectReason").param("name", username)); + context.sendMessage(Message.translation("server.modules.ban.failedDisconnectReason").param("name", displayMessage)); disconnectEx.printStackTrace(); } @@ -68,14 +73,14 @@ public class BanCommand extends AbstractAsyncCommand { optional = Optional.of("Failed to get disconnect reason."); } - player.getPacketHandler().disconnect(optional.get()); - context.sendMessage(Message.translation("server.modules.ban.bannedWithReason").param("name", username).param("reason", reason)); + playerRef.getPacketHandler().disconnect(optional.get()); + context.sendMessage(Message.translation("server.modules.ban.bannedWithReason").param("name", displayMessage).param("reason", reason)); }).thenApply(v -> null); } else { - context.sendMessage(Message.translation("server.modules.ban.bannedWithReason").param("name", username).param("reason", reason)); + context.sendMessage(Message.translation("server.modules.ban.bannedWithReason").param("name", displayMessage).param("reason", reason)); return CompletableFuture.completedFuture(null); } } - }); + } } } diff --git a/src/com/hypixel/hytale/server/core/modules/accesscontrol/commands/UnbanCommand.java b/src/com/hypixel/hytale/server/core/modules/accesscontrol/commands/UnbanCommand.java index 15ded9b..fe647ac 100644 --- a/src/com/hypixel/hytale/server/core/modules/accesscontrol/commands/UnbanCommand.java +++ b/src/com/hypixel/hytale/server/core/modules/accesscontrol/commands/UnbanCommand.java @@ -1,12 +1,13 @@ package com.hypixel.hytale.server.core.modules.accesscontrol.commands; import com.hypixel.hytale.server.core.Message; +import com.hypixel.hytale.server.core.auth.ProfileServiceClient; import com.hypixel.hytale.server.core.command.system.CommandContext; import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg; import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes; import com.hypixel.hytale.server.core.command.system.basecommands.AbstractAsyncCommand; import com.hypixel.hytale.server.core.modules.accesscontrol.provider.HytaleBanProvider; -import com.hypixel.hytale.server.core.util.AuthUtil; +import java.util.UUID; import java.util.concurrent.CompletableFuture; import javax.annotation.Nonnull; @@ -14,7 +15,9 @@ public class UnbanCommand extends AbstractAsyncCommand { @Nonnull private final HytaleBanProvider banProvider; @Nonnull - private final RequiredArg usernameArg = this.withRequiredArg("username", "server.commands.unban.username.desc", ArgTypes.STRING); + private final RequiredArg playerArg = this.withRequiredArg( + "player", "server.commands.unban.player.desc", ArgTypes.GAME_PROFILE_LOOKUP + ); public UnbanCommand(@Nonnull HytaleBanProvider banProvider) { super("unban", "server.commands.unban.desc"); @@ -25,18 +28,20 @@ public class UnbanCommand extends AbstractAsyncCommand { @Nonnull @Override protected CompletableFuture executeAsync(@Nonnull CommandContext context) { - String username = this.usernameArg.get(context); - return AuthUtil.lookupUuid(username).thenAccept(uuid -> { + ProfileServiceClient.PublicGameProfile profile = this.playerArg.get(context); + if (profile == null) { + return CompletableFuture.completedFuture(null); + } else { + UUID uuid = profile.getUuid(); + Message displayMessage = Message.raw(profile.getUsername()).bold(true); if (!this.banProvider.hasBan(uuid)) { - context.sendMessage(Message.translation("server.modules.unban.playerNotBanned").param("name", username)); + context.sendMessage(Message.translation("server.modules.unban.playerNotBanned").param("name", displayMessage)); } else { this.banProvider.modify(map -> map.remove(uuid) != null); - context.sendMessage(Message.translation("server.modules.unban.success").param("name", username)); + context.sendMessage(Message.translation("server.modules.unban.success").param("name", displayMessage)); } - }).exceptionally(ex -> { - context.sendMessage(Message.translation("server.modules.ban.lookupFailed").param("name", username)); - ex.printStackTrace(); - return null; - }); + + return CompletableFuture.completedFuture(null); + } } } diff --git a/src/com/hypixel/hytale/server/core/modules/accesscontrol/commands/WhitelistAddCommand.java b/src/com/hypixel/hytale/server/core/modules/accesscontrol/commands/WhitelistAddCommand.java index 42ebbff..12d4b1f 100644 --- a/src/com/hypixel/hytale/server/core/modules/accesscontrol/commands/WhitelistAddCommand.java +++ b/src/com/hypixel/hytale/server/core/modules/accesscontrol/commands/WhitelistAddCommand.java @@ -1,12 +1,13 @@ package com.hypixel.hytale.server.core.modules.accesscontrol.commands; import com.hypixel.hytale.server.core.Message; +import com.hypixel.hytale.server.core.auth.ProfileServiceClient; import com.hypixel.hytale.server.core.command.system.CommandContext; import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg; import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes; import com.hypixel.hytale.server.core.command.system.basecommands.AbstractAsyncCommand; import com.hypixel.hytale.server.core.modules.accesscontrol.provider.HytaleWhitelistProvider; -import com.hypixel.hytale.server.core.util.AuthUtil; +import java.util.UUID; import java.util.concurrent.CompletableFuture; import javax.annotation.Nonnull; @@ -14,7 +15,9 @@ public class WhitelistAddCommand extends AbstractAsyncCommand { @Nonnull private final HytaleWhitelistProvider whitelistProvider; @Nonnull - private final RequiredArg usernameArg = this.withRequiredArg("username", "server.commands.whitelist.add.username.desc", ArgTypes.STRING); + private final RequiredArg playerArg = this.withRequiredArg( + "player", "server.commands.whitelist.add.player.desc", ArgTypes.GAME_PROFILE_LOOKUP + ); public WhitelistAddCommand(@Nonnull HytaleWhitelistProvider whitelistProvider) { super("add", "server.commands.whitelist.add.desc"); @@ -24,17 +27,19 @@ public class WhitelistAddCommand extends AbstractAsyncCommand { @Nonnull @Override protected CompletableFuture executeAsync(@Nonnull CommandContext context) { - String username = this.usernameArg.get(context); - return AuthUtil.lookupUuid(username).thenAccept(uuid -> { + ProfileServiceClient.PublicGameProfile profile = this.playerArg.get(context); + if (profile == null) { + return CompletableFuture.completedFuture(null); + } else { + UUID uuid = profile.getUuid(); + Message displayMessage = Message.raw(profile.getUsername()).bold(true); if (this.whitelistProvider.modify(list -> list.add(uuid))) { - context.sendMessage(Message.translation("server.modules.whitelist.addSuccess").param("name", username)); + context.sendMessage(Message.translation("server.modules.whitelist.addSuccess").param("name", displayMessage)); } else { - context.sendMessage(Message.translation("server.modules.whitelist.alreadyWhitelisted").param("name", username)); + context.sendMessage(Message.translation("server.modules.whitelist.alreadyWhitelisted").param("name", displayMessage)); } - }).exceptionally(ex -> { - context.sendMessage(Message.translation("server.modules.ban.lookupFailed").param("name", username)); - ex.printStackTrace(); - return null; - }); + + return CompletableFuture.completedFuture(null); + } } } diff --git a/src/com/hypixel/hytale/server/core/modules/accesscontrol/commands/WhitelistRemoveCommand.java b/src/com/hypixel/hytale/server/core/modules/accesscontrol/commands/WhitelistRemoveCommand.java index d82caba..6a09692 100644 --- a/src/com/hypixel/hytale/server/core/modules/accesscontrol/commands/WhitelistRemoveCommand.java +++ b/src/com/hypixel/hytale/server/core/modules/accesscontrol/commands/WhitelistRemoveCommand.java @@ -1,12 +1,13 @@ package com.hypixel.hytale.server.core.modules.accesscontrol.commands; import com.hypixel.hytale.server.core.Message; +import com.hypixel.hytale.server.core.auth.ProfileServiceClient; import com.hypixel.hytale.server.core.command.system.CommandContext; import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg; import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes; import com.hypixel.hytale.server.core.command.system.basecommands.AbstractAsyncCommand; import com.hypixel.hytale.server.core.modules.accesscontrol.provider.HytaleWhitelistProvider; -import com.hypixel.hytale.server.core.util.AuthUtil; +import java.util.UUID; import java.util.concurrent.CompletableFuture; import javax.annotation.Nonnull; @@ -14,7 +15,9 @@ public class WhitelistRemoveCommand extends AbstractAsyncCommand { @Nonnull private final HytaleWhitelistProvider whitelistProvider; @Nonnull - private final RequiredArg usernameArg = this.withRequiredArg("username", "server.commands.whitelist.remove.username.desc", ArgTypes.STRING); + private final RequiredArg playerArg = this.withRequiredArg( + "player", "server.commands.whitelist.remove.player.desc", ArgTypes.GAME_PROFILE_LOOKUP + ); public WhitelistRemoveCommand(@Nonnull HytaleWhitelistProvider whitelistProvider) { super("remove", "server.commands.whitelist.remove.desc"); @@ -24,17 +27,19 @@ public class WhitelistRemoveCommand extends AbstractAsyncCommand { @Nonnull @Override protected CompletableFuture executeAsync(@Nonnull CommandContext context) { - String username = this.usernameArg.get(context); - return AuthUtil.lookupUuid(username).thenAccept(uuid -> { + ProfileServiceClient.PublicGameProfile profile = this.playerArg.get(context); + if (profile == null) { + return CompletableFuture.completedFuture(null); + } else { + UUID uuid = profile.getUuid(); + Message displayMessage = Message.raw(profile.getUsername()).bold(true); if (this.whitelistProvider.modify(list -> list.remove(uuid))) { - context.sendMessage(Message.translation("server.modules.whitelist.removalSuccess").param("uuid", uuid.toString())); + context.sendMessage(Message.translation("server.modules.whitelist.removalSuccess").param("uuid", displayMessage)); } else { - context.sendMessage(Message.translation("server.modules.whitelist.uuidNotWhitelisted").param("uuid", uuid.toString())); + context.sendMessage(Message.translation("server.modules.whitelist.uuidNotWhitelisted").param("uuid", displayMessage)); } - }).exceptionally(ex -> { - context.sendMessage(Message.translation("server.modules.ban.lookupFailed").param("name", username)); - ex.printStackTrace(); - return null; - }); + + return CompletableFuture.completedFuture(null); + } } } diff --git a/src/com/hypixel/hytale/server/core/modules/accesscontrol/commands/WhitelistStatusCommand.java b/src/com/hypixel/hytale/server/core/modules/accesscontrol/commands/WhitelistStatusCommand.java index a7ff067..2080f1b 100644 --- a/src/com/hypixel/hytale/server/core/modules/accesscontrol/commands/WhitelistStatusCommand.java +++ b/src/com/hypixel/hytale/server/core/modules/accesscontrol/commands/WhitelistStatusCommand.java @@ -8,8 +8,6 @@ import com.hypixel.hytale.server.core.util.message.MessageFormat; import javax.annotation.Nonnull; public class WhitelistStatusCommand extends CommandBase { - @Nonnull - private static final Message MESSAGE_MODULES_WHITELIST_STATUS = Message.translation("server.modules.whitelist.status"); @Nonnull private final HytaleWhitelistProvider whitelistProvider; @@ -20,6 +18,6 @@ public class WhitelistStatusCommand extends CommandBase { @Override protected void executeSync(@Nonnull CommandContext context) { - context.sendMessage(MESSAGE_MODULES_WHITELIST_STATUS.param("status", MessageFormat.enabled(this.whitelistProvider.isEnabled()))); + context.sendMessage(Message.translation("server.modules.whitelist.status").param("status", MessageFormat.enabled(this.whitelistProvider.isEnabled()))); } } diff --git a/src/com/hypixel/hytale/server/core/modules/accesscontrol/provider/ClientDelegatingProvider.java b/src/com/hypixel/hytale/server/core/modules/accesscontrol/provider/ClientDelegatingProvider.java index 15bab13..c09822a 100644 --- a/src/com/hypixel/hytale/server/core/modules/accesscontrol/provider/ClientDelegatingProvider.java +++ b/src/com/hypixel/hytale/server/core/modules/accesscontrol/provider/ClientDelegatingProvider.java @@ -6,9 +6,6 @@ import java.util.concurrent.CompletableFuture; import javax.annotation.Nonnull; public class ClientDelegatingProvider implements AccessProvider { - public ClientDelegatingProvider() { - } - @Nonnull @Override public CompletableFuture> getDisconnectReason(UUID uuid) { diff --git a/src/com/hypixel/hytale/server/core/modules/accesscontrol/provider/HytaleWhitelistProvider.java b/src/com/hypixel/hytale/server/core/modules/accesscontrol/provider/HytaleWhitelistProvider.java index d45c7b3..9a44e8c 100644 --- a/src/com/hypixel/hytale/server/core/modules/accesscontrol/provider/HytaleWhitelistProvider.java +++ b/src/com/hypixel/hytale/server/core/modules/accesscontrol/provider/HytaleWhitelistProvider.java @@ -22,7 +22,11 @@ import java.util.function.Function; import javax.annotation.Nonnull; public class HytaleWhitelistProvider extends BlockingDiskFile implements AccessProvider { + @Nonnull + private static final String WHITELIST_FILE_PATH = "whitelist.json"; + @Nonnull private final ReadWriteLock lock = new ReentrantReadWriteLock(); + @Nonnull private final Set whitelist = new HashSet<>(); private boolean isEnabled; diff --git a/src/com/hypixel/hytale/server/core/modules/block/BlockModule.java b/src/com/hypixel/hytale/server/core/modules/block/BlockModule.java index f711d8e..100bede 100644 --- a/src/com/hypixel/hytale/server/core/modules/block/BlockModule.java +++ b/src/com/hypixel/hytale/server/core/modules/block/BlockModule.java @@ -353,9 +353,6 @@ public class BlockModule extends JavaPlugin { @Deprecated(forRemoval = true) public static class MigrateLaunchPad extends BlockModule.MigrationSystem { - public MigrateLaunchPad() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { UnknownComponents unknown = holder.getComponent(ChunkStore.REGISTRY.getUnknownComponentType()); @@ -380,7 +377,5 @@ public class BlockModule extends JavaPlugin { } public abstract static class MigrationSystem extends HolderSystem { - public MigrationSystem() { - } } } diff --git a/src/com/hypixel/hytale/server/core/modules/blockhealth/BlockHealthChunk.java b/src/com/hypixel/hytale/server/core/modules/blockhealth/BlockHealthChunk.java index 44e9b5b..2bd3b3e 100644 --- a/src/com/hypixel/hytale/server/core/modules/blockhealth/BlockHealthChunk.java +++ b/src/com/hypixel/hytale/server/core/modules/blockhealth/BlockHealthChunk.java @@ -37,9 +37,6 @@ public class BlockHealthChunk implements Component { private final Map blockFragilityMap = new Object2ObjectOpenHashMap<>(0); private Instant lastRepairGameTime; - public BlockHealthChunk() { - } - public Instant getLastRepairGameTime() { return this.lastRepairGameTime; } diff --git a/src/com/hypixel/hytale/server/core/modules/collision/BasicCollisionData.java b/src/com/hypixel/hytale/server/core/modules/collision/BasicCollisionData.java index e86ba66..20dab91 100644 --- a/src/com/hypixel/hytale/server/core/modules/collision/BasicCollisionData.java +++ b/src/com/hypixel/hytale/server/core/modules/collision/BasicCollisionData.java @@ -9,9 +9,6 @@ public class BasicCollisionData { public final Vector3d collisionPoint = new Vector3d(); public double collisionStart; - public BasicCollisionData() { - } - public void setStart(@Nonnull Vector3d point, double start) { this.collisionPoint.assign(point); this.collisionStart = start; diff --git a/src/com/hypixel/hytale/server/core/modules/collision/BlockCollisionData.java b/src/com/hypixel/hytale/server/core/modules/collision/BlockCollisionData.java index 22420e6..0ca2658 100644 --- a/src/com/hypixel/hytale/server/core/modules/collision/BlockCollisionData.java +++ b/src/com/hypixel/hytale/server/core/modules/collision/BlockCollisionData.java @@ -24,9 +24,6 @@ public class BlockCollisionData extends BoxCollisionData { public boolean touching; public boolean overlapping; - public BlockCollisionData() { - } - public void setBlockData(@Nonnull CollisionConfig collisionConfig) { this.x = collisionConfig.blockX; this.y = collisionConfig.blockY; diff --git a/src/com/hypixel/hytale/server/core/modules/collision/BlockCollisionProvider.java b/src/com/hypixel/hytale/server/core/modules/collision/BlockCollisionProvider.java index c9a2685..eb7f032 100644 --- a/src/com/hypixel/hytale/server/core/modules/collision/BlockCollisionProvider.java +++ b/src/com/hypixel/hytale/server/core/modules/collision/BlockCollisionProvider.java @@ -31,9 +31,6 @@ public class BlockCollisionProvider implements BoxBlockIterator.BoxIterationCons protected double relativeStopDistance; protected IBlockCollisionConsumer.Result collisionState; - public BlockCollisionProvider() { - } - public void setRequestedCollisionMaterials(int requestedCollisionMaterials) { this.requestedCollisionMaterials = requestedCollisionMaterials; } diff --git a/src/com/hypixel/hytale/server/core/modules/collision/BlockContactData.java b/src/com/hypixel/hytale/server/core/modules/collision/BlockContactData.java index 702b27b..0ddd1d8 100644 --- a/src/com/hypixel/hytale/server/core/modules/collision/BlockContactData.java +++ b/src/com/hypixel/hytale/server/core/modules/collision/BlockContactData.java @@ -13,9 +13,6 @@ public class BlockContactData { protected boolean isSubmergeFluid; protected boolean overlapping; - public BlockContactData() { - } - public void clear() { } diff --git a/src/com/hypixel/hytale/server/core/modules/collision/BlockData.java b/src/com/hypixel/hytale/server/core/modules/collision/BlockData.java index a527e23..445def1 100644 --- a/src/com/hypixel/hytale/server/core/modules/collision/BlockData.java +++ b/src/com/hypixel/hytale/server/core/modules/collision/BlockData.java @@ -25,9 +25,6 @@ public class BlockData { @Nullable protected BlockBoundingBoxes blockBoundingBoxes; - public BlockData() { - } - public void assign(@Nonnull BlockData other) { this.blockId = other.blockId; this.blockType = other.blockType; diff --git a/src/com/hypixel/hytale/server/core/modules/collision/BlockDataProvider.java b/src/com/hypixel/hytale/server/core/modules/collision/BlockDataProvider.java index 109d460..4f0a8b0 100644 --- a/src/com/hypixel/hytale/server/core/modules/collision/BlockDataProvider.java +++ b/src/com/hypixel/hytale/server/core/modules/collision/BlockDataProvider.java @@ -30,9 +30,6 @@ public class BlockDataProvider extends BlockData { @Nullable protected Ref chunkSectionRef; - public BlockDataProvider() { - } - public void initialize(World world) { this.world = world; this.blockId = Integer.MIN_VALUE; diff --git a/src/com/hypixel/hytale/server/core/modules/collision/BoxCollisionData.java b/src/com/hypixel/hytale/server/core/modules/collision/BoxCollisionData.java index ebd4db6..e0b058b 100644 --- a/src/com/hypixel/hytale/server/core/modules/collision/BoxCollisionData.java +++ b/src/com/hypixel/hytale/server/core/modules/collision/BoxCollisionData.java @@ -7,9 +7,6 @@ public class BoxCollisionData extends BasicCollisionData { public double collisionEnd; public final Vector3d collisionNormal = new Vector3d(); - public BoxCollisionData() { - } - public void setEnd(double collisionEnd, @Nonnull Vector3d collisionNormal) { this.collisionEnd = collisionEnd; this.collisionNormal.assign(collisionNormal); diff --git a/src/com/hypixel/hytale/server/core/modules/collision/CharacterCollisionData.java b/src/com/hypixel/hytale/server/core/modules/collision/CharacterCollisionData.java index e06a5cc..53f30bc 100644 --- a/src/com/hypixel/hytale/server/core/modules/collision/CharacterCollisionData.java +++ b/src/com/hypixel/hytale/server/core/modules/collision/CharacterCollisionData.java @@ -9,9 +9,6 @@ public class CharacterCollisionData extends BasicCollisionData { public Ref entityReference; public boolean isPlayer; - public CharacterCollisionData() { - } - public void assign(@Nonnull Vector3d collisionPoint, double collisionVectorScale, Ref entityReference, boolean isPlayer) { this.collisionPoint.assign(collisionPoint); this.collisionStart = collisionVectorScale; diff --git a/src/com/hypixel/hytale/server/core/modules/collision/CollisionConfig.java b/src/com/hypixel/hytale/server/core/modules/collision/CollisionConfig.java index 06fd4b0..591ef59 100644 --- a/src/com/hypixel/hytale/server/core/modules/collision/CollisionConfig.java +++ b/src/com/hypixel/hytale/server/core/modules/collision/CollisionConfig.java @@ -71,9 +71,6 @@ public class CollisionConfig { @Nullable public Object extraData2; - public CollisionConfig() { - } - public int getDetailCount() { return this.boundingBoxes.getDetailBoxes().length; } diff --git a/src/com/hypixel/hytale/server/core/modules/collision/CollisionMaterial.java b/src/com/hypixel/hytale/server/core/modules/collision/CollisionMaterial.java index 2d30c48..8229eb2 100644 --- a/src/com/hypixel/hytale/server/core/modules/collision/CollisionMaterial.java +++ b/src/com/hypixel/hytale/server/core/modules/collision/CollisionMaterial.java @@ -8,7 +8,4 @@ public class CollisionMaterial { public static final int MATERIAL_SET_ANY = 15; public static final int MATERIAL_DAMAGE = 16; public static final int MATERIAL_SET_NONE = 0; - - public CollisionMaterial() { - } } diff --git a/src/com/hypixel/hytale/server/core/modules/collision/CollisionModuleConfig.java b/src/com/hypixel/hytale/server/core/modules/collision/CollisionModuleConfig.java index 7d92651..934c1d6 100644 --- a/src/com/hypixel/hytale/server/core/modules/collision/CollisionModuleConfig.java +++ b/src/com/hypixel/hytale/server/core/modules/collision/CollisionModuleConfig.java @@ -19,9 +19,6 @@ public class CollisionModuleConfig { @Nullable private Double minimumThickness = null; - public CollisionModuleConfig() { - } - public double getExtentMax() { return this.extentMax; } diff --git a/src/com/hypixel/hytale/server/core/modules/collision/CollisionResult.java b/src/com/hypixel/hytale/server/core/modules/collision/CollisionResult.java index f709ba4..a7ee127 100644 --- a/src/com/hypixel/hytale/server/core/modules/collision/CollisionResult.java +++ b/src/com/hypixel/hytale/server/core/modules/collision/CollisionResult.java @@ -267,14 +267,13 @@ public class CollisionResult implements BoxBlockIterator.BoxIterationConsumer { int x = triggerCollision.x; int y = triggerCollision.y; int z = triggerCollision.z; - String blockTypeId = blockType.getId(); if (filler != 0) { x -= FillerBlockUtil.unpackX(filler); y -= FillerBlockUtil.unpackY(filler); z -= FillerBlockUtil.unpackZ(filler); } - long index = BlockUtil.pack(x, y, z); + long index = BlockUtil.packUnchecked(x, y, z); if (this.newTriggers.add(index)) { BlockPosition pos = new BlockPosition(x, y, z); if (!this.lastTriggers.remove(index) && interactionsEnter != null) { diff --git a/src/com/hypixel/hytale/server/core/modules/collision/EntityContactData.java b/src/com/hypixel/hytale/server/core/modules/collision/EntityContactData.java index 4a321b7..28240e1 100644 --- a/src/com/hypixel/hytale/server/core/modules/collision/EntityContactData.java +++ b/src/com/hypixel/hytale/server/core/modules/collision/EntityContactData.java @@ -14,9 +14,6 @@ public class EntityContactData { protected Ref entityReference; protected String collisionDetailName; - public EntityContactData() { - } - @Nonnull public Vector3d getCollisionPoint() { return this.collisionPoint; diff --git a/src/com/hypixel/hytale/server/core/modules/collision/IBlockCollisionConsumer.java b/src/com/hypixel/hytale/server/core/modules/collision/IBlockCollisionConsumer.java index e5d0a59..a8bab5d 100644 --- a/src/com/hypixel/hytale/server/core/modules/collision/IBlockCollisionConsumer.java +++ b/src/com/hypixel/hytale/server/core/modules/collision/IBlockCollisionConsumer.java @@ -18,8 +18,5 @@ public interface IBlockCollisionConsumer { CONTINUE, STOP, STOP_NOW; - - private Result() { - } } } diff --git a/src/com/hypixel/hytale/server/core/modules/collision/MovingBoxBoxCollisionEvaluator.java b/src/com/hypixel/hytale/server/core/modules/collision/MovingBoxBoxCollisionEvaluator.java index 93613cc..12ce64b 100644 --- a/src/com/hypixel/hytale/server/core/modules/collision/MovingBoxBoxCollisionEvaluator.java +++ b/src/com/hypixel/hytale/server/core/modules/collision/MovingBoxBoxCollisionEvaluator.java @@ -187,9 +187,6 @@ public class MovingBoxBoxCollisionEvaluator extends BlockContactData implements public int kind; public boolean touching; - private Collision1D() { - } - boolean isColliding(double min, double max) { this.min = min; this.max = max; diff --git a/src/com/hypixel/hytale/server/core/modules/collision/WorldUtil.java b/src/com/hypixel/hytale/server/core/modules/collision/WorldUtil.java index 6322bd3..13817cc 100644 --- a/src/com/hypixel/hytale/server/core/modules/collision/WorldUtil.java +++ b/src/com/hypixel/hytale/server/core/modules/collision/WorldUtil.java @@ -18,9 +18,6 @@ import com.hypixel.hytale.server.core.util.FillerBlockUtil; import javax.annotation.Nonnull; public final class WorldUtil { - public WorldUtil() { - } - public static boolean isFluidOnlyBlock(@Nonnull BlockType blockType, int fluidId) { return blockType.getMaterial() == BlockMaterial.Empty && fluidId != 0; } @@ -227,7 +224,7 @@ public final class WorldUtil { while (y >= yBottom) { int blockId = chunkSection.get(x, y--, z); int fluidId = fluidSectionComponent != null ? fluidSectionComponent.getFluidId(x, y, z) : 0; - if (blockId != 0 || fluidId == 0) { + if (blockId != 0 || fluidId != 0) { BlockType blockType = assetMap.getAsset(blockId); if (blockType != null && !blockType.isUnknown()) { int filler = chunkSection.getFiller(x, y, z); diff --git a/src/com/hypixel/hytale/server/core/modules/debug/DebugUtils.java b/src/com/hypixel/hytale/server/core/modules/debug/DebugUtils.java index 0f51a0b..7a30ca6 100644 --- a/src/com/hypixel/hytale/server/core/modules/debug/DebugUtils.java +++ b/src/com/hypixel/hytale/server/core/modules/debug/DebugUtils.java @@ -18,9 +18,6 @@ import javax.annotation.Nullable; public class DebugUtils { public static boolean DISPLAY_FORCES = false; - public DebugUtils() { - } - public static void add(@Nonnull World world, @Nonnull DebugShape shape, @Nonnull Matrix4d matrix, @Nonnull Vector3f color, float time, boolean fade) { DisplayDebug packet = new DisplayDebug(shape, matrix.asFloatData(), new com.hypixel.hytale.protocol.Vector3f(color.x, color.y, color.z), time, fade, null); diff --git a/src/com/hypixel/hytale/server/core/modules/entity/AllLegacyEntityTypesQuery.java b/src/com/hypixel/hytale/server/core/modules/entity/AllLegacyEntityTypesQuery.java index 3797b79..884d3df 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/AllLegacyEntityTypesQuery.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/AllLegacyEntityTypesQuery.java @@ -10,11 +10,9 @@ import javax.annotation.Nonnull; @Deprecated public class AllLegacyEntityTypesQuery implements Query { + @Nonnull public static final AllLegacyEntityTypesQuery INSTANCE = new AllLegacyEntityTypesQuery(); - public AllLegacyEntityTypesQuery() { - } - @Override public boolean test(@Nonnull Archetype archetype) { return EntityUtils.hasEntity(archetype); @@ -26,7 +24,7 @@ public class AllLegacyEntityTypesQuery implements Query { } @Override - public void validateRegistry(ComponentRegistry registry) { + public void validateRegistry(@Nonnull ComponentRegistry registry) { } @Override diff --git a/src/com/hypixel/hytale/server/core/modules/entity/AllLegacyLivingEntityTypesQuery.java b/src/com/hypixel/hytale/server/core/modules/entity/AllLegacyLivingEntityTypesQuery.java index 5613608..ac92b5c 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/AllLegacyLivingEntityTypesQuery.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/AllLegacyLivingEntityTypesQuery.java @@ -13,9 +13,6 @@ public class AllLegacyLivingEntityTypesQuery implements Query { @Nonnull public static final AllLegacyLivingEntityTypesQuery INSTANCE = new AllLegacyLivingEntityTypesQuery(); - public AllLegacyLivingEntityTypesQuery() { - } - @Override public boolean test(@Nonnull Archetype archetype) { return EntityUtils.hasLivingEntity(archetype); @@ -27,7 +24,7 @@ public class AllLegacyLivingEntityTypesQuery implements Query { } @Override - public void validateRegistry(ComponentRegistry registry) { + public void validateRegistry(@Nonnull ComponentRegistry registry) { } @Override diff --git a/src/com/hypixel/hytale/server/core/modules/entity/BlockEntitySystems.java b/src/com/hypixel/hytale/server/core/modules/entity/BlockEntitySystems.java index d714837..3412ca9 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/BlockEntitySystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/BlockEntitySystems.java @@ -36,9 +36,6 @@ import javax.annotation.Nullable; public class BlockEntitySystems { private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); - public BlockEntitySystems() { - } - public static class BlockEntitySetupSystem extends HolderSystem { private final ComponentType blockEntityComponentType; diff --git a/src/com/hypixel/hytale/server/core/modules/entity/EntityModule.java b/src/com/hypixel/hytale/server/core/modules/entity/EntityModule.java index d184616..152f2af 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/EntityModule.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/EntityModule.java @@ -145,6 +145,7 @@ import com.hypixel.hytale.server.core.modules.entity.system.UpdateEntitySeedSyst import com.hypixel.hytale.server.core.modules.entity.system.UpdateLocationSystems; import com.hypixel.hytale.server.core.modules.entity.teleport.PendingTeleport; import com.hypixel.hytale.server.core.modules.entity.teleport.Teleport; +import com.hypixel.hytale.server.core.modules.entity.teleport.TeleportRecord; import com.hypixel.hytale.server.core.modules.entity.teleport.TeleportSystems; import com.hypixel.hytale.server.core.modules.entity.tracker.EntityTrackerSystems; import com.hypixel.hytale.server.core.modules.entity.tracker.LegacyEntityTrackerSystems; @@ -242,6 +243,7 @@ public class EntityModule extends JavaPlugin { private ComponentType repulsionComponentType; private ComponentType teleportComponentType; private ComponentType pendingTeleportComponentType; + private ComponentType teleportRecordComponentType; private ComponentType applyRandomSkinPersistedComponent; private SystemGroup preClearMarkersGroup; private ComponentType playerInputComponentType; @@ -362,6 +364,7 @@ public class EntityModule extends JavaPlugin { throw new UnsupportedOperationException("Teleport must be created directly"); }); this.pendingTeleportComponentType = entityStoreRegistry.registerComponent(PendingTeleport.class, PendingTeleport::new); + this.teleportRecordComponentType = entityStoreRegistry.registerComponent(TeleportRecord.class, TeleportRecord::new); this.playerComponentType = entityStoreRegistry.registerComponent(Player.class, "Player", Player.CODEC); this.frozenComponentType = entityStoreRegistry.registerComponent(Frozen.class, "Frozen", Frozen.CODEC); entityStoreRegistry.registerSystem(new PlayerCollisionResultAddSystem(this.playerComponentType, this.collisionResultComponentType)); @@ -384,6 +387,7 @@ public class EntityModule extends JavaPlugin { throw new UnsupportedOperationException(); }); this.movementManagerComponentType = entityStoreRegistry.registerComponent(MovementManager.class, MovementManager::new); + this.displayNameComponentType = entityStoreRegistry.registerComponent(DisplayNameComponent.class, "DisplayName", DisplayNameComponent.CODEC); entityStoreRegistry.registerSystem(new PlayerSystems.PlayerSpawnedSystem()); entityStoreRegistry.registerSystem(new PlayerSystems.PlayerAddedSystem(this.movementManagerComponentType)); entityStoreRegistry.registerSystem(new PlayerSystems.EnsurePlayerInput()); @@ -403,7 +407,6 @@ public class EntityModule extends JavaPlugin { this.playerSkinComponentType = entityStoreRegistry.registerComponent(PlayerSkinComponent.class, () -> { throw new UnsupportedOperationException("Not implemented"); }); - this.displayNameComponentType = entityStoreRegistry.registerComponent(DisplayNameComponent.class, "DisplayName", DisplayNameComponent.CODEC); this.fromPrefabComponentType = entityStoreRegistry.registerComponent(FromPrefab.class, "FromPrefab", FromPrefab.CODEC); entityStoreRegistry.registerSystem(new EntitySystems.ClearFromPrefabMarker(this.fromPrefabComponentType, this.preClearMarkersGroup)); this.hiddenFromAdventurePlayerComponentType = entityStoreRegistry.registerComponent( @@ -434,8 +437,8 @@ public class EntityModule extends JavaPlugin { this.itemPhysicsComponentType = entityStoreRegistry.registerComponent(ItemPhysicsComponent.class, ItemPhysicsComponent::new); entityStoreRegistry.registerSystem(new ItemSystems.EnsureRequiredComponents()); entityStoreRegistry.registerSystem(new ItemSystems.TrackerSystem(this.visibleComponentType)); - this.prefabCopyableComponentType = entityStoreRegistry.registerComponent(PrefabCopyableComponent.class, PrefabCopyableComponent::get); - this.pickupItemComponentType = entityStoreRegistry.registerComponent(PickupItemComponent.class, "PickupItem", PickupItemComponent.CODEC); + this.prefabCopyableComponentType = entityStoreRegistry.registerComponent(PrefabCopyableComponent.class, "PrefabCopyable", PrefabCopyableComponent.CODEC); + this.pickupItemComponentType = entityStoreRegistry.registerComponent(PickupItemComponent.class, PickupItemComponent::new); entityStoreRegistry.registerSystem(new DespawnSystem(this.despawnComponentComponentType)); this.itemSpatialResourceType = entityStoreRegistry.registerSpatialResource(() -> new KDTree<>(Ref::isValid)); entityStoreRegistry.registerSystem(new ItemSpatialSystem(this.itemSpatialResourceType)); @@ -812,6 +815,10 @@ public class EntityModule extends JavaPlugin { return this.pendingTeleportComponentType; } + public ComponentType getTeleportRecordComponentType() { + return this.teleportRecordComponentType; + } + public ComponentType getModelComponentType() { return this.modelComponentType; } @@ -1214,9 +1221,6 @@ public class EntityModule extends JavaPlugin { } public static class LegacyTransformSystem extends EntityModule.MigrationSystem { - public LegacyTransformSystem() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { TransformComponent transformComponent = holder.getComponent(TransformComponent.getComponentType()); @@ -1247,9 +1251,6 @@ public class EntityModule extends JavaPlugin { new SystemDependency<>(Order.BEFORE, EntityStore.UUIDSystem.class), RootDependency.first() ); - public LegacyUUIDSystem() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { UUIDComponent uuid = holder.getComponent(UUIDComponent.getComponentType()); @@ -1282,9 +1283,6 @@ public class EntityModule extends JavaPlugin { } public static class LegacyUUIDUpdateSystem extends RefChangeSystem { - public LegacyUUIDUpdateSystem() { - } - @Nonnull @Override public Query getQuery() { @@ -1321,8 +1319,6 @@ public class EntityModule extends JavaPlugin { } public abstract static class MigrationSystem extends HolderSystem { - public MigrationSystem() { - } } @Deprecated(forRemoval = true) @@ -1354,8 +1350,5 @@ public class EntityModule extends JavaPlugin { public static enum Type { PLAYERS, ALL; - - private Type() { - } } } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/LegacyProjectileSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/LegacyProjectileSystems.java index fe22a3c..39863fd 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/LegacyProjectileSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/LegacyProjectileSystems.java @@ -30,22 +30,15 @@ import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import java.util.logging.Level; import javax.annotation.Nonnull; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class LegacyProjectileSystems { @Nonnull private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); - public LegacyProjectileSystems() { - } - public static class OnAddHolderSystem extends HolderSystem { @Nonnull private static final ComponentType PROJECTILE_COMPONENT_TYPE = ProjectileComponent.getComponentType(); - public OnAddHolderSystem() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { if (!holder.getArchetype().contains(NetworkId.getComponentType())) { @@ -91,9 +84,6 @@ public class LegacyProjectileSystems { @Nonnull private static final ComponentType PROJECTILE_COMPONENT_TYPE = ProjectileComponent.getComponentType(); - public OnAddRefSystem() { - } - @Override public Query getQuery() { return PROJECTILE_COMPONENT_TYPE; @@ -101,10 +91,7 @@ public class LegacyProjectileSystems { @Override public void onEntityAdded( - @NonNullDecl Ref ref, - @NonNullDecl AddReason reason, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { ProjectileComponent projectileComponent = commandBuffer.getComponent(ref, PROJECTILE_COMPONENT_TYPE); @@ -118,10 +105,7 @@ public class LegacyProjectileSystems { @Override public void onEntityRemove( - @NonNullDecl Ref ref, - @NonNullDecl RemoveReason reason, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, @Nonnull RemoveReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { } } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/component/DisplayNameComponent.java b/src/com/hypixel/hytale/server/core/modules/entity/component/DisplayNameComponent.java index 0504da3..8830c11 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/component/DisplayNameComponent.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/component/DisplayNameComponent.java @@ -9,7 +9,6 @@ import com.hypixel.hytale.server.core.modules.entity.EntityModule; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; public class DisplayNameComponent implements Component { @Nonnull @@ -38,7 +37,7 @@ public class DisplayNameComponent implements Component { return this.displayName; } - @NullableDecl + @Nullable @Override public Component clone() { return new DisplayNameComponent(this.displayName); diff --git a/src/com/hypixel/hytale/server/core/modules/entity/component/MovementAudioComponent.java b/src/com/hypixel/hytale/server/core/modules/entity/component/MovementAudioComponent.java index 68d9878..6054af4 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/component/MovementAudioComponent.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/component/MovementAudioComponent.java @@ -18,9 +18,6 @@ public class MovementAudioComponent implements Component { return EntityModule.get().getMovementAudioComponentType(); } - public MovementAudioComponent() { - } - @Nonnull public MovementAudioComponent.ShouldHearPredicate getShouldHearPredicate(Ref ref) { this.shouldHearPredicate.owner = ref; @@ -56,9 +53,6 @@ public class MovementAudioComponent implements Component { public static class ShouldHearPredicate implements Predicate> { protected Ref owner; - public ShouldHearPredicate() { - } - public boolean test(@Nonnull Ref targetRef) { return !this.owner.equals(targetRef); } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/component/PropComponent.java b/src/com/hypixel/hytale/server/core/modules/entity/component/PropComponent.java index d01eff1..a16cd38 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/component/PropComponent.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/component/PropComponent.java @@ -11,9 +11,6 @@ public class PropComponent implements Component { public static final BuilderCodec CODEC = BuilderCodec.builder(PropComponent.class, PropComponent::new).build(); private static final PropComponent INSTANCE = new PropComponent(); - public PropComponent() { - } - public static ComponentType getComponentType() { return EntityModule.get().getPropComponentType(); } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/component/SnapshotBuffer.java b/src/com/hypixel/hytale/server/core/modules/entity/component/SnapshotBuffer.java index a629d33..7075672 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/component/SnapshotBuffer.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/component/SnapshotBuffer.java @@ -17,9 +17,6 @@ public class SnapshotBuffer implements Component { private int oldestTickIndex = Integer.MIN_VALUE; private int currentIndex = -1; - public SnapshotBuffer() { - } - public static ComponentType getComponentType() { return EntityModule.get().getSnapshotBufferComponentType(); } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/damage/DamageCalculatorSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/damage/DamageCalculatorSystems.java index 0a93e7f..aea0540 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/damage/DamageCalculatorSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/damage/DamageCalculatorSystems.java @@ -30,9 +30,6 @@ public class DamageCalculatorSystems { @Nonnull public static MetaKey DAMAGE_SEQUENCE = Damage.META_REGISTRY.registerMetaObject(); - public DamageCalculatorSystems() { - } - @Nonnull public static Damage[] queueDamageCalculator( @Nonnull World world, @@ -132,9 +129,6 @@ public class DamageCalculatorSystems { new SystemDependency(Order.BEFORE, DamageSystems.ApplyDamage.class) ); - public SequenceModifier() { - } - @Nonnull @Override public Set> getDependencies() { @@ -168,14 +162,14 @@ public class DamageCalculatorSystems { damageSequence.addSequentialHit(); DamageEntityInteraction.EntityStatOnHit[] entityStatsOnHit = damageSequence.getEntityStatOnHit(); if (entityStatsOnHit != null && damage.getSource() instanceof Damage.EntitySource entitySource) { - Ref attackerRef = entitySource.getRef(); - EntityStatMap entityStatMapComponent = commandBuffer.getComponent(attackerRef, EntityStatMap.getComponentType()); - if (entityStatMapComponent == null) { + Ref sourceRef = entitySource.getRef(); + EntityStatMap sourceEntityStatMapComponent = commandBuffer.getComponent(sourceRef, EntityStatMap.getComponentType()); + if (sourceEntityStatMapComponent == null) { return; } for (DamageEntityInteraction.EntityStatOnHit statOnHit : entityStatsOnHit) { - statOnHit.processEntityStatsOnHit(damageSequence.getSequentialHits(), entityStatMapComponent); + statOnHit.processEntityStatsOnHit(damageSequence.getSequentialHits(), sourceEntityStatMapComponent); } } } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/damage/DamageModule.java b/src/com/hypixel/hytale/server/core/modules/entity/damage/DamageModule.java index 14797cf..325bec0 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/damage/DamageModule.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/damage/DamageModule.java @@ -96,7 +96,6 @@ public class DamageModule extends JavaPlugin { entityStoreRegistry.registerSystem(new RespawnSystems.ResetPlayerRespawnSystem()); entityStoreRegistry.registerSystem(new RespawnSystems.ClearEntityEffectsRespawnSystem()); entityStoreRegistry.registerSystem(new RespawnSystems.ClearInteractionsRespawnSystem()); - entityStoreRegistry.registerSystem(new RespawnSystems.RespawnControllerRespawnSystem()); entityStoreRegistry.registerSystem(new RespawnSystems.CheckBrokenItemsRespawnSystem()); entityStoreRegistry.registerSystem(new DamageCalculatorSystems.SequenceModifier()); this.getCommandRegistry().registerCommand(new DesyncDamageCommand()); @@ -129,9 +128,6 @@ public class DamageModule extends JavaPlugin { new SystemGroupDependency<>(Order.BEFORE, DamageModule.get().getFilterDamageGroup()) ); - public OrderGatherFilter() { - } - @Nonnull @Override public Set> getDependencies() { diff --git a/src/com/hypixel/hytale/server/core/modules/entity/damage/DamageSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/damage/DamageSystems.java index 6727dfc..4333bc4 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/damage/DamageSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/damage/DamageSystems.java @@ -107,8 +107,6 @@ import java.util.function.Predicate; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.bouncycastle.util.Arrays; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; public class DamageSystems { public static final float DEFAULT_DAMAGE_DELAY = 1.0F; @@ -119,9 +117,6 @@ public class DamageSystems { Query.not(EntityModule.get().getPlayerComponentType()) ); - public DamageSystems() { - } - public static void executeDamage(@Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor, @Nonnull Damage damage) { componentAccessor.invoke(ref, damage); } @@ -146,9 +141,6 @@ public class DamageSystems { new SystemGroupDependency<>(Order.BEFORE, DamageModule.get().getInspectDamageGroup()) ); - public ApplyDamage() { - } - @Override public Query getQuery() { return QUERY; @@ -194,10 +186,9 @@ public class DamageSystems { @Nonnull private static final ComponentType TRANSFORM_COMPONENT_TYPE = TransformComponent.getComponentType(); @Nonnull - private static final Query QUERY = TRANSFORM_COMPONENT_TYPE; - - public ApplyParticles() { - } + private static final ComponentType NETWORK_ID_COMPONENT_TYPE = NetworkId.getComponentType(); + @Nonnull + private static final Query QUERY = Query.and(TRANSFORM_COMPONENT_TYPE, NETWORK_ID_COMPONENT_TYPE); @Nonnull @Override @@ -212,20 +203,15 @@ public class DamageSystems { @Nonnull CommandBuffer commandBuffer, @Nonnull Damage damage ) { - TransformComponent transformComponent = archetypeChunk.getComponent(index, TRANSFORM_COMPONENT_TYPE); - - assert transformComponent != null; - - NetworkId networkIdComponent = archetypeChunk.getComponent(index, NetworkId.getComponentType()); - - assert networkIdComponent != null; - - int targetNetworkId = networkIdComponent.getId(); Damage.Particles particles = damage.getIfPresentMetaObject(Damage.IMPACT_PARTICLES); if (particles != null) { if (damage.getSource() instanceof Damage.EntitySource sourceEntity) { Ref sourceRef = sourceEntity.getRef(); if (sourceRef.isValid()) { + TransformComponent transformComponent = archetypeChunk.getComponent(index, TRANSFORM_COMPONENT_TYPE); + + assert transformComponent != null; + Vector4d hitLocation = damage.getIfPresentMetaObject(Damage.HIT_LOCATION); Vector3d targetPosition = hitLocation == null ? transformComponent.getPosition() : new Vector3d(hitLocation.x, hitLocation.y, hitLocation.z); boolean damageCanBePredicted = damage.getMetaStore().getMetaObject(Damage.CAN_BE_PREDICTED); @@ -233,21 +219,20 @@ public class DamageSystems { WorldParticle[] worldParticles = particles.getWorldParticles(); if (!Arrays.isNullOrEmpty((Object[])worldParticles)) { TransformComponent sourceTransformComponent = commandBuffer.getComponent(sourceRef, TransformComponent.getComponentType()); + if (sourceTransformComponent != null) { + float angleBetween = TrigMathUtil.atan2( + sourceTransformComponent.getPosition().x - targetPosition.x, sourceTransformComponent.getPosition().z - targetPosition.z + ); + SpatialResource, EntityStore> playerSpatialResource = commandBuffer.getResource( + EntityModule.get().getPlayerSpatialResourceType() + ); + ObjectList> results = SpatialResource.getThreadLocalReferenceList(); + playerSpatialResource.getSpatialStructure().collect(targetPosition, particlesViewDistance, results); + Ref particleSource = damageCanBePredicted ? sourceRef : null; - assert sourceTransformComponent != null; - - float angleBetween = TrigMathUtil.atan2( - sourceTransformComponent.getPosition().x - targetPosition.x, sourceTransformComponent.getPosition().z - targetPosition.z - ); - SpatialResource, EntityStore> playerSpatialResource = commandBuffer.getResource( - EntityModule.get().getPlayerSpatialResourceType() - ); - ObjectList> results = SpatialResource.getThreadLocalReferenceList(); - playerSpatialResource.getSpatialStructure().collect(targetPosition, particlesViewDistance, results); - Ref particleSource = damageCanBePredicted ? sourceRef : null; - - for (WorldParticle particle : worldParticles) { - ParticleUtil.spawnParticleEffect(particle, targetPosition, angleBetween, 0.0F, 0.0F, particleSource, results, commandBuffer); + for (WorldParticle particle : worldParticles) { + ParticleUtil.spawnParticleEffect(particle, targetPosition, angleBetween, 0.0F, 0.0F, particleSource, results, commandBuffer); + } } } @@ -259,6 +244,11 @@ public class DamageSystems { modelParticlesProtocol[j] = modelParticles[j].toPacket(); } + NetworkId networkIdComponent = archetypeChunk.getComponent(index, NETWORK_ID_COMPONENT_TYPE); + + assert networkIdComponent != null; + + int targetNetworkId = networkIdComponent.getId(); SpawnModelParticles packet = new SpawnModelParticles(targetNetworkId, modelParticlesProtocol); SpatialResource, EntityStore> spatialResource = store.getResource(PLAYER_SPATIAL_RESOURCE_TYPE); SpatialStructure> spatialStructure = spatialResource.getSpatialStructure(); @@ -271,10 +261,9 @@ public class DamageSystems { } PlayerRef playerRefComponent = commandBuffer.getComponent(targetRef, PlayerRef.getComponentType()); - - assert playerRefComponent != null; - - playerRefComponent.getPacketHandler().write(packet); + if (playerRefComponent != null) { + playerRefComponent.getPacketHandler().write(packet); + } } } } @@ -297,9 +286,6 @@ public class DamageSystems { @Nonnull private static final Query QUERY = TRANSFORM_COMPONENT_TYPE; - public ApplySoundEffects() { - } - @Nonnull @Override public Query getQuery() { @@ -365,9 +351,6 @@ public class DamageSystems { @Nonnull private static final Query QUERY = AllLegacyLivingEntityTypesQuery.INSTANCE; - public ArmorDamageReduction() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -523,9 +506,6 @@ public class DamageSystems { public float multiplierModifier; @Nullable public DamageCause inheritedParentId; - - public ArmorResistanceModifiers() { - } } } @@ -538,9 +518,6 @@ public class DamageSystems { AllLegacyLivingEntityTypesQuery.INSTANCE, DamageDataComponent.getComponentType(), TRANSFORM_COMPONENT_TYPE ); - public ArmorKnockbackReduction() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -678,9 +655,6 @@ public class DamageSystems { @Nonnull private static final Query QUERY = AllLegacyLivingEntityTypesQuery.INSTANCE; - public DamageArmor() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -726,9 +700,6 @@ public class DamageSystems { @Nonnull private static final Query QUERY = AllLegacyLivingEntityTypesQuery.INSTANCE; - public DamageAttackerTool() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -748,15 +719,15 @@ public class DamageSystems { @Nonnull CommandBuffer commandBuffer, @Nonnull Damage damage ) { - if (damage.getCause().isDurabilityLoss() && damage.getSource() instanceof Damage.EntitySource) { - Ref attackerRef = ((Damage.EntitySource)damage.getSource()).getRef(); - if (attackerRef.isValid()) { - if (EntityUtils.getEntity(attackerRef, commandBuffer) instanceof LivingEntity attackerLivingEntity) { - Inventory attackerInventory = attackerLivingEntity.getInventory(); - byte activeHotbarSlot = attackerInventory.getActiveHotbarSlot(); + if (damage.getCause().isDurabilityLoss() && damage.getSource() instanceof Damage.EntitySource entitySource) { + Ref sourceRef = entitySource.getRef(); + if (sourceRef.isValid()) { + if (EntityUtils.getEntity(sourceRef, commandBuffer) instanceof LivingEntity sourceLivingEntity) { + Inventory sourceInventory = sourceLivingEntity.getInventory(); + byte activeHotbarSlot = sourceInventory.getActiveHotbarSlot(); if (activeHotbarSlot != -1) { - attackerLivingEntity.decreaseItemStackDurability( - attackerRef, attackerInventory.getItemInHand(), -1, attackerInventory.getActiveHotbarSlot(), commandBuffer + sourceLivingEntity.decreaseItemStackDurability( + sourceRef, sourceInventory.getItemInHand(), -1, sourceInventory.getActiveHotbarSlot(), commandBuffer ); } } @@ -769,9 +740,6 @@ public class DamageSystems { @Nonnull private static final Query QUERY = Query.and(DamageDataComponent.getComponentType(), EntityStatMap.getComponentType()); - public DamageStamina() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -834,9 +802,6 @@ public class DamageSystems { @Nonnull private final Query query = Query.and(this.visibleComponentType, this.uiComponentListComponentType); - public EntityUIEvents() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -857,19 +822,18 @@ public class DamageSystems { @Nonnull Damage damage ) { if (!(damage.getAmount() <= 0.0F)) { - if (damage.getSource() instanceof Damage.EntitySource) { - Ref attackerRef = ((Damage.EntitySource)damage.getSource()).getRef(); - if (attackerRef.isValid()) { - PlayerRef playerRef = commandBuffer.getComponent(attackerRef, PlayerRef.getComponentType()); - if (playerRef != null && playerRef.isValid()) { - EntityTrackerSystems.EntityViewer entityViewer = commandBuffer.getComponent( - attackerRef, EntityTrackerSystems.EntityViewer.getComponentType() + if (damage.getSource() instanceof Damage.EntitySource entitySource) { + Ref sourceRef = entitySource.getRef(); + if (sourceRef.isValid()) { + PlayerRef sourcePlayerRef = commandBuffer.getComponent(sourceRef, PlayerRef.getComponentType()); + if (sourcePlayerRef != null && sourcePlayerRef.isValid()) { + EntityTrackerSystems.EntityViewer sourceEntityViewerComponent = commandBuffer.getComponent( + sourceRef, EntityTrackerSystems.EntityViewer.getComponentType() ); - - assert entityViewer != null; - - Float hitAngleDeg = damage.getIfPresentMetaObject(Damage.HIT_ANGLE); - queueUpdateFor(archetypeChunk.getReferenceTo(index), damage.getAmount(), hitAngleDeg, entityViewer); + if (sourceEntityViewerComponent != null) { + Float hitAngleDeg = damage.getIfPresentMetaObject(Damage.HIT_ANGLE); + queueUpdateFor(archetypeChunk.getReferenceTo(index), damage.getAmount(), hitAngleDeg, sourceEntityViewerComponent); + } } } } @@ -894,9 +858,6 @@ public class DamageSystems { static final float CURVE_MULTIPLIER = 2.0F; public static final double MIN_DAMAGE = 10.0; - public FallDamageNPCs() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -910,7 +871,7 @@ public class DamageSystems { } @Override - public void tick(float dt, int systemIndex, @NonNullDecl Store store) { + public void tick(float dt, int systemIndex, @Nonnull Store store) { World world = store.getExternalData().getWorld(); if (world.getWorldConfig().isFallDamageEnabled()) { super.tick(dt, systemIndex, store); @@ -997,9 +958,6 @@ public class DamageSystems { @Nonnull private static final Set> DEPENDENCIES = Set.of(new SystemDependency<>(Order.BEFORE, PlayerSystems.ProcessPlayerInput.class)); - public FallDamagePlayers() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -1019,7 +977,7 @@ public class DamageSystems { } @Override - public void tick(float dt, int systemIndex, @NonNullDecl Store store) { + public void tick(float dt, int systemIndex, @Nonnull Store store) { World world = store.getExternalData().getWorld(); if (world.getWorldConfig().isFallDamageEnabled()) { super.tick(dt, systemIndex, store); @@ -1063,18 +1021,19 @@ public class DamageSystems { MovementConfig movementConfig = MovementConfig.getAssetMap().getAsset(movementConfigIndex); float minFallSpeedToEngageRoll = movementConfig.getMinFallSpeedToEngageRoll(); if (yVelocity > minFallSpeedToEngageRoll && !movementStatesEntry.movementStates().inFluid) { - EntityStatMap entityStatMapComponent = archetypeChunk.getComponent(index, EntityStatMap.getComponentType()); + double damagePercentagex = Math.pow(0.58F * (yVelocity - minFallSpeedToEngageRoll), 2.0) + 10.0; + EntityStatValue healthStatValuex = entityStatMapComponent.get(DefaultEntityStatTypes.getHealth()); - assert entityStatMapComponent != null; + assert healthStatValuex != null; - double damagePercentage = Math.pow(0.58F * (yVelocity - minFallSpeedToEngageRoll), 2.0) + 10.0; - EntityStatValue healthStatValue = entityStatMapComponent.get(DefaultEntityStatTypes.getHealth()); + double damagePercentagex = Math.pow(0.58F * (yVelocity - minFallSpeedToEngageRoll), 2.0) + 10.0; + EntityStatValue healthStatValuex = entityStatMapComponent.get(DefaultEntityStatTypes.getHealth()); - assert healthStatValue != null; + assert healthStatValuex != null; - float maxHealth = healthStatValue.getMax(); + float maxHealth = healthStatValuex.getMax(); double healthModifier = maxHealth / 100.0; - int damageInt = (int)Math.floor(healthModifier * damagePercentage); + int damageInt = (int)Math.floor(healthModifier * damagePercentagex); if (movementStatesEntry.movementStates().rolling) { if (yVelocity <= movementConfig.getMaxFallSpeedRollFullMitigation()) { damageInt = 0; @@ -1106,16 +1065,13 @@ public class DamageSystems { } public static class FilterNPCWorldConfig extends DamageEventSystem { - public FilterNPCWorldConfig() { - } - - @NullableDecl + @Nullable @Override public SystemGroup getGroup() { return DamageModule.get().getFilterDamageGroup(); } - @NullableDecl + @Nullable @Override public Query getQuery() { return DamageSystems.NPCS_QUERY; @@ -1123,10 +1079,10 @@ public class DamageSystems { public void handle( int index, - @NonNullDecl ArchetypeChunk archetypeChunk, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer, - @NonNullDecl Damage event + @Nonnull ArchetypeChunk archetypeChunk, + @Nonnull Store store, + @Nonnull CommandBuffer commandBuffer, + @Nonnull Damage event ) { World world = store.getExternalData().getWorld(); GameplayConfig gameplayConfig = world.getGameplayConfig(); @@ -1141,16 +1097,13 @@ public class DamageSystems { public static class FilterPlayerWorldConfig extends DamageEventSystem { private static final Query QUERY = Query.and(AllLegacyLivingEntityTypesQuery.INSTANCE, Player.getComponentType()); - public FilterPlayerWorldConfig() { - } - - @NullableDecl + @Nullable @Override public SystemGroup getGroup() { return DamageModule.get().getFilterDamageGroup(); } - @NullableDecl + @Nullable @Override public Query getQuery() { return QUERY; @@ -1158,10 +1111,10 @@ public class DamageSystems { public void handle( int index, - @NonNullDecl ArchetypeChunk archetypeChunk, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer, - @NonNullDecl Damage event + @Nonnull ArchetypeChunk archetypeChunk, + @Nonnull Store store, + @Nonnull CommandBuffer commandBuffer, + @Nonnull Damage event ) { World world = store.getExternalData().getWorld(); GameplayConfig gameplayConfig = world.getGameplayConfig(); @@ -1178,9 +1131,6 @@ public class DamageSystems { @Nonnull private static final Query QUERY = AllLegacyLivingEntityTypesQuery.INSTANCE; - public FilterUnkillable() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -1220,9 +1170,6 @@ public class DamageSystems { public static float PLAYER_KNOCKBACK_SCALE = 25.0F; private static final Query QUERY = Query.and(AllLegacyLivingEntityTypesQuery.INSTANCE, KnockbackComponent.getComponentType()); - public HackKnockbackValues() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -1265,9 +1212,6 @@ public class DamageSystems { @Nonnull private static final Query QUERY = Query.and(Query.not(DeathComponent.getComponentType()), MovementStatesComponent.getComponentType()); - public HitAnimation() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -1359,9 +1303,6 @@ public class DamageSystems { @Nonnull private static final Query QUERY = Player.getComponentType(); - public PlayerDamageFilterSystem() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -1405,9 +1346,6 @@ public class DamageSystems { @Nonnull private static final Query QUERY = PlayerRef.getComponentType(); - public PlayerHitIndicators() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -1430,14 +1368,14 @@ public class DamageSystems { assert playerRefComponent != null; - if (damage.getSource() instanceof Damage.EntitySource) { - Ref attackerRef = ((Damage.EntitySource)damage.getSource()).getRef(); - if (attackerRef.isValid()) { + if (damage.getSource() instanceof Damage.EntitySource entitySource) { + Ref sourceRef = entitySource.getRef(); + if (sourceRef.isValid()) { DamageCause damageCause = damage.getCause(); if (damageCause != null) { - TransformComponent attackerTransform = commandBuffer.getComponent(attackerRef, TRANSFORM_COMPONENT_TYPE); - if (attackerTransform != null) { - Vector3d position = attackerTransform.getPosition(); + TransformComponent sourceTransformComponent = commandBuffer.getComponent(sourceRef, TRANSFORM_COMPONENT_TYPE); + if (sourceTransformComponent != null) { + Vector3d position = sourceTransformComponent.getPosition(); playerRefComponent.getPacketHandler() .writeNoCache( new DamageInfo( @@ -1461,9 +1399,6 @@ public class DamageSystems { @Nonnull private static final Query QUERY = DAMAGE_DATA_COMPONENT_TYPE; - public RecordLastCombat() { - } - @Override public Query getQuery() { return QUERY; @@ -1508,9 +1443,6 @@ public class DamageSystems { private static final ReticleEvent ON_HIT = new ReticleEvent(EVENT_ON_HIT_TAG_INDEX); private static final ReticleEvent ON_KILL = new ReticleEvent(EVENT_ON_KILL_TAG_INDEX); - public ReticleEvents() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -1532,12 +1464,12 @@ public class DamageSystems { ) { boolean isDead = archetypeChunk.getArchetype().contains(DeathComponent.getComponentType()); if (!(damage.getAmount() <= 0.0F)) { - if (damage.getSource() instanceof Damage.EntitySource) { - Ref attackerRef = ((Damage.EntitySource)damage.getSource()).getRef(); - if (attackerRef.isValid()) { - PlayerRef playerRef = commandBuffer.getComponent(attackerRef, PlayerRef.getComponentType()); - if (playerRef != null && playerRef.isValid()) { - playerRef.getPacketHandler().writeNoCache(isDead ? ON_KILL : ON_HIT); + if (damage.getSource() instanceof Damage.EntitySource entitySource) { + Ref sourceRef = entitySource.getRef(); + if (sourceRef.isValid()) { + PlayerRef sourcePlayerRef = commandBuffer.getComponent(sourceRef, PlayerRef.getComponentType()); + if (sourcePlayerRef != null && sourcePlayerRef.isValid()) { + sourcePlayerRef.getPacketHandler().writeNoCache(isDead ? ON_KILL : ON_HIT); } } } @@ -1547,10 +1479,9 @@ public class DamageSystems { public static class TrackLastDamage extends DamageEventSystem { @Nonnull - private static final Query QUERY = AllLegacyLivingEntityTypesQuery.INSTANCE; - - public TrackLastDamage() { - } + private static final ComponentType DAMAGE_DATA_COMPONENT_TYPE = DamageDataComponent.getComponentType(); + @Nonnull + private static final Query QUERY = Query.and(AllLegacyLivingEntityTypesQuery.INSTANCE, DAMAGE_DATA_COMPONENT_TYPE); @Nullable @Override @@ -1572,7 +1503,7 @@ public class DamageSystems { @Nonnull Damage damage ) { TimeResource timeResource = commandBuffer.getResource(TimeResource.getResourceType()); - DamageDataComponent damageDataComponent = archetypeChunk.getComponent(index, DamageDataComponent.getComponentType()); + DamageDataComponent damageDataComponent = archetypeChunk.getComponent(index, DAMAGE_DATA_COMPONENT_TYPE); assert damageDataComponent != null; @@ -1592,9 +1523,6 @@ public class DamageSystems { TRANSFORM_COMPONENT_TYPE ); - public WieldingDamageReduction() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -1632,71 +1560,69 @@ public class DamageSystems { Vector3d targetPosition = transformComponent.getPosition(); Vector3f targetRotation = transformComponent.getRotation(); - if (damage.getSource() instanceof Damage.EntitySource source) { - Ref attackerRef = source.getRef(); - if (attackerRef.isValid()) { - TransformComponent attackerTransformComponent = commandBuffer.getComponent(attackerRef, TRANSFORM_COMPONENT_TYPE); + if (damage.getSource() instanceof Damage.EntitySource entitySource) { + Ref sourceRef = entitySource.getRef(); + if (sourceRef.isValid()) { + TransformComponent sourceTransformComponent = commandBuffer.getComponent(sourceRef, TRANSFORM_COMPONENT_TYPE); + if (sourceTransformComponent != null) { + int damageCauseIndex = damage.getDamageCauseIndex(); + float wieldingModifier = 1.0F; + float angledWieldingModifier = 1.0F; + String blockedInteractions = null; + Int2FloatMap wieldingDamageModifiers = wielding.getDamageModifiers(); + if (!wieldingDamageModifiers.isEmpty()) { + wieldingModifier = wieldingDamageModifiers.getOrDefault(damageCauseIndex, 1.0F); + DamageEffects wieldingBlockedEffects = wielding.getBlockedEffects(); + if (wieldingBlockedEffects != null) { + wieldingBlockedEffects.addToDamage(damage); + } - assert attackerTransformComponent != null; + String wieldingBlockedInteractions = wielding.getBlockedInteractions(); + if (wieldingBlockedInteractions != null) { + blockedInteractions = wieldingBlockedInteractions; + } - int damageCauseIndex = damage.getDamageCauseIndex(); - float wieldingModifier = 1.0F; - float angledWieldingModifier = 1.0F; - String blockedInteractions = null; - Int2FloatMap wieldingDamageModifiers = wielding.getDamageModifiers(); - if (!wieldingDamageModifiers.isEmpty()) { - wieldingModifier = wieldingDamageModifiers.getOrDefault(damageCauseIndex, 1.0F); - DamageEffects wieldingBlockedEffects = wielding.getBlockedEffects(); - if (wieldingBlockedEffects != null) { - wieldingBlockedEffects.addToDamage(damage); + damage.putMetaObject(Damage.BLOCKED, Boolean.TRUE); } - String wieldingBlockedInteractions = wielding.getBlockedInteractions(); - if (wieldingBlockedInteractions != null) { - blockedInteractions = wieldingBlockedInteractions; - } + if (angledWielding != null) { + Int2FloatMap angledWieldingDamageModifiers = angledWielding.getDamageModifiers(); + if (angledWieldingDamageModifiers.containsKey(damageCauseIndex)) { + Vector3d sourcePosition = sourceTransformComponent.getPosition(); + float angleBetween = TrigMathUtil.atan2(sourcePosition.x - targetPosition.x, sourcePosition.z - targetPosition.z); + angleBetween = MathUtil.wrapAngle(angleBetween + (float) Math.PI - targetRotation.getYaw()); + if (Math.abs(MathUtil.compareAngle(angleBetween, angledWielding.getAngleRad())) < angledWielding.getAngleDistanceRad()) { + angledWieldingModifier = angledWieldingDamageModifiers.getOrDefault(damageCauseIndex, 1.0F); + DamageEffects wieldingBlockedEffectsx = wielding.getBlockedEffects(); + if (wieldingBlockedEffectsx != null) { + wieldingBlockedEffectsx.addToDamage(damage); + } - damage.putMetaObject(Damage.BLOCKED, Boolean.TRUE); - } + String wieldingBlockedInteractions = wielding.getBlockedInteractions(); + if (wieldingBlockedInteractions != null) { + blockedInteractions = wieldingBlockedInteractions; + } - if (angledWielding != null) { - Int2FloatMap angledWieldingDamageModifiers = angledWielding.getDamageModifiers(); - if (angledWieldingDamageModifiers.containsKey(damageCauseIndex)) { - Vector3d attackerPosition = attackerTransformComponent.getPosition(); - float angleBetween = TrigMathUtil.atan2(attackerPosition.x - targetPosition.x, attackerPosition.z - targetPosition.z); - angleBetween = MathUtil.wrapAngle(angleBetween + (float) Math.PI - targetRotation.getYaw()); - if (Math.abs(MathUtil.compareAngle(angleBetween, angledWielding.getAngleRad())) < angledWielding.getAngleDistanceRad()) { - angledWieldingModifier = angledWieldingDamageModifiers.getOrDefault(damageCauseIndex, 1.0F); - DamageEffects wieldingBlockedEffectsx = wielding.getBlockedEffects(); - if (wieldingBlockedEffectsx != null) { - wieldingBlockedEffectsx.addToDamage(damage); + damage.putMetaObject(Damage.BLOCKED, Boolean.TRUE); } - - String wieldingBlockedInteractions = wielding.getBlockedInteractions(); - if (wieldingBlockedInteractions != null) { - blockedInteractions = wieldingBlockedInteractions; - } - - damage.putMetaObject(Damage.BLOCKED, Boolean.TRUE); } } - } - damage.setAmount(damage.getAmount() * wieldingModifier * angledWieldingModifier); - if (blockedInteractions != null) { - InteractionContext context = InteractionContext.forInteraction(interactionManager, ref, InteractionType.Wielding, commandBuffer); - DynamicMetaStore contextMetaStore = context.getMetaStore(); - contextMetaStore.putMetaObject(Interaction.TARGET_ENTITY, attackerRef); - contextMetaStore.putMetaObject(Interaction.DAMAGE, damage); - NetworkId attackerNetworkIdComponent = commandBuffer.getComponent(attackerRef, NetworkId.getComponentType()); - - assert attackerNetworkIdComponent != null; - - int networkId = attackerNetworkIdComponent.getId(); - InteractionChain chain = interactionManager.initChain( - InteractionType.Wielding, context, RootInteraction.getRootInteractionOrUnknown(blockedInteractions), networkId, null, false - ); - interactionManager.queueExecuteChain(chain); + damage.setAmount(damage.getAmount() * wieldingModifier * angledWieldingModifier); + if (blockedInteractions != null) { + NetworkId sourceNetworkIdComponent = commandBuffer.getComponent(sourceRef, NetworkId.getComponentType()); + if (sourceNetworkIdComponent != null) { + InteractionContext context = InteractionContext.forInteraction(interactionManager, ref, InteractionType.Wielding, commandBuffer); + DynamicMetaStore contextMetaStore = context.getMetaStore(); + contextMetaStore.putMetaObject(Interaction.TARGET_ENTITY, sourceRef); + contextMetaStore.putMetaObject(Interaction.DAMAGE, damage); + int networkId = sourceNetworkIdComponent.getId(); + InteractionChain chain = interactionManager.initChain( + InteractionType.Wielding, context, RootInteraction.getRootInteractionOrUnknown(blockedInteractions), networkId, null, false + ); + interactionManager.queueExecuteChain(chain); + } + } } } } @@ -1713,9 +1639,6 @@ public class DamageSystems { AllLegacyLivingEntityTypesQuery.INSTANCE, DamageDataComponent.getComponentType(), TRANSFORM_COMPONENT_TYPE ); - public WieldingKnockbackReduction() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -1730,10 +1653,10 @@ public class DamageSystems { public void handle( int index, - @NonNullDecl ArchetypeChunk archetypeChunk, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer, - @NonNullDecl Damage event + @Nonnull ArchetypeChunk archetypeChunk, + @Nonnull Store store, + @Nonnull CommandBuffer commandBuffer, + @Nonnull Damage event ) { } @@ -1758,31 +1681,30 @@ public class DamageSystems { WieldingInteraction.AngledWielding angledWielding = wielding.getAngledWielding(); KnockbackComponent knockbackComponent = damage.getIfPresentMetaObject(Damage.KNOCKBACK_COMPONENT); if (knockbackComponent != null) { - if (damage.getSource() instanceof Damage.EntitySource source) { - Ref attackerRef = source.getRef(); - if (attackerRef.isValid()) { - TransformComponent attackerTransformComponent = commandBuffer.getComponent(attackerRef, TRANSFORM_COMPONENT_TYPE); - - assert attackerTransformComponent != null; - - int damageCauseIndex = damage.getDamageCauseIndex(); - double angledWieldingModifier = 1.0; - double wieldingModifier = knockbackModifiers.getOrDefault(damageCauseIndex, 1.0); - if (angledWielding != null) { - Int2DoubleMap angledWieldingKnockbackModifiers = angledWielding.getKnockbackModifiers(); - if (angledWieldingKnockbackModifiers.containsKey(damageCauseIndex)) { - Vector3d targetPos = transformComponent.getPosition(); - Vector3d attackerPos = attackerTransformComponent.getPosition(); - float angleBetween = TrigMathUtil.atan2(attackerPos.x - targetPos.x, attackerPos.z - targetPos.z); - angleBetween = MathUtil.wrapAngle(angleBetween + (float) Math.PI - transformComponent.getRotation().getYaw()); - if (Math.abs(MathUtil.compareAngle(angleBetween, angledWielding.getAngleRad())) < angledWielding.getAngleDistanceRad()) { - angledWieldingModifier = angledWieldingKnockbackModifiers.getOrDefault(damageCauseIndex, 1.0); + if (damage.getSource() instanceof Damage.EntitySource entitySource) { + Ref sourceRef = entitySource.getRef(); + if (sourceRef.isValid()) { + TransformComponent sourceTransformComponent = commandBuffer.getComponent(sourceRef, TRANSFORM_COMPONENT_TYPE); + if (sourceTransformComponent != null) { + int damageCauseIndex = damage.getDamageCauseIndex(); + double angledWieldingModifier = 1.0; + double wieldingModifier = knockbackModifiers.getOrDefault(damageCauseIndex, 1.0); + if (angledWielding != null) { + Int2DoubleMap angledWieldingKnockbackModifiers = angledWielding.getKnockbackModifiers(); + if (angledWieldingKnockbackModifiers.containsKey(damageCauseIndex)) { + Vector3d targetPos = transformComponent.getPosition(); + Vector3d attackerPos = sourceTransformComponent.getPosition(); + float angleBetween = TrigMathUtil.atan2(attackerPos.x - targetPos.x, attackerPos.z - targetPos.z); + angleBetween = MathUtil.wrapAngle(angleBetween + (float) Math.PI - transformComponent.getRotation().getYaw()); + if (Math.abs(MathUtil.compareAngle(angleBetween, angledWielding.getAngleRad())) < angledWielding.getAngleDistanceRad()) { + angledWieldingModifier = angledWieldingKnockbackModifiers.getOrDefault(damageCauseIndex, 1.0); + } } } - } - knockbackComponent.addModifier(wieldingModifier); - knockbackComponent.addModifier(angledWieldingModifier); + knockbackComponent.addModifier(wieldingModifier); + knockbackComponent.addModifier(angledWieldingModifier); + } } } } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/damage/DeathComponent.java b/src/com/hypixel/hytale/server/core/modules/entity/damage/DeathComponent.java index 3af9abe..064a194 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/damage/DeathComponent.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/damage/DeathComponent.java @@ -8,19 +8,25 @@ import com.hypixel.hytale.codec.builder.BuilderCodec; import com.hypixel.hytale.codec.codecs.array.ArrayCodec; import com.hypixel.hytale.component.CommandBuffer; import com.hypixel.hytale.component.Component; +import com.hypixel.hytale.component.ComponentAccessor; import com.hypixel.hytale.component.ComponentType; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.Store; +import com.hypixel.hytale.logger.HytaleLogger; import com.hypixel.hytale.server.core.Message; import com.hypixel.hytale.server.core.asset.type.gameplay.DeathConfig; +import com.hypixel.hytale.server.core.asset.type.gameplay.respawn.RespawnController; import com.hypixel.hytale.server.core.entity.InteractionChain; import com.hypixel.hytale.server.core.inventory.ItemStack; +import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import java.util.List; +import java.util.concurrent.CompletableFuture; import javax.annotation.Nonnull; import javax.annotation.Nullable; public class DeathComponent implements Component { + public static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); public static final BuilderCodec CODEC = BuilderCodec.builder(DeathComponent.class, DeathComponent::new) .append(new KeyedCodec<>("DeathCause", Codec.STRING), (o, i) -> o.deathCause = i, o -> o.deathCause) .add() @@ -70,10 +76,11 @@ public class DeathComponent implements Component { private double itemsDurabilityLossPercentage; private boolean displayDataOnDeathScreen; @Nullable - private Damage deathInfo; - private DeathConfig.ItemsLossMode itemsLossMode = DeathConfig.ItemsLossMode.ALL; + private transient Damage deathInfo; + private transient DeathConfig.ItemsLossMode itemsLossMode = DeathConfig.ItemsLossMode.ALL; @Nullable - private InteractionChain interactionChain; + private transient InteractionChain interactionChain; + private transient CompletableFuture respawnFuture = null; public static ComponentType getComponentType() { return DamageModule.get().getDeathComponentType(); @@ -194,4 +201,27 @@ public class DeathComponent implements Component { store.addComponent(ref, getComponentType(), new DeathComponent(damage)); } } + + public static CompletableFuture respawn(@Nonnull ComponentAccessor componentAccessor, @Nonnull Ref ref) { + DeathComponent deathComponent = componentAccessor.getComponent(ref, getComponentType()); + if (deathComponent == null) { + return CompletableFuture.completedFuture(null); + } else if (deathComponent.respawnFuture != null) { + return deathComponent.respawnFuture; + } else { + World world = componentAccessor.getExternalData().getWorld(); + RespawnController respawnController = world.getDeathConfig().getRespawnController(); + deathComponent.respawnFuture = respawnController.respawnPlayer(world, ref, componentAccessor).whenComplete((ignore, ex) -> { + if (ex != null) { + LOGGER.atSevere().withCause(ex).log("Failed to respawn entity"); + } + + Store store = world.getEntityStore().getStore(); + if (ref.isValid()) { + store.tryRemoveComponent(ref, getComponentType()); + } + }); + return deathComponent.respawnFuture; + } + } } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/damage/DeathSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/damage/DeathSystems.java index 5d31a73..eb60322 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/damage/DeathSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/damage/DeathSystems.java @@ -74,9 +74,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class DeathSystems { - public DeathSystems() { - } - private static void playDeathAnimation( @Nonnull Ref ref, @Nonnull DeathComponent deathComponent, @@ -85,17 +82,17 @@ public class DeathSystems { @Nonnull ComponentAccessor componentAccessor ) { if (modelComponent != null) { - Model model = modelComponent.getModel(); - String[] animationIds = Entity.DefaultAnimations.getDeathAnimationIds(movementStatesComponent.getMovementStates(), deathComponent.getDeathCause()); - String selectedAnimationId = model.getFirstBoundAnimationId(animationIds); - AnimationUtils.playAnimation(ref, AnimationSlot.Status, selectedAnimationId, true, componentAccessor); + DamageCause deathCause = deathComponent.getDeathCause(); + if (deathCause != null) { + Model model = modelComponent.getModel(); + String[] animationIds = Entity.DefaultAnimations.getDeathAnimationIds(movementStatesComponent.getMovementStates(), deathCause); + String selectedAnimationId = model.getFirstBoundAnimationId(animationIds); + AnimationUtils.playAnimation(ref, AnimationSlot.Status, selectedAnimationId, true, componentAccessor); + } } } public static class ClearEntityEffects extends DeathSystems.OnDeathSystem { - public ClearEntityEffects() { - } - @Nonnull @Override public Query getQuery() { @@ -117,9 +114,6 @@ public class DeathSystems { @Nonnull private static final ComponentType ENTITY_STAT_MAP_COMPONENT_TYPE = EntityStatMap.getComponentType(); - public ClearHealth() { - } - @Nonnull @Override public Set> getDependencies() { @@ -148,9 +142,6 @@ public class DeathSystems { private static final ComponentType INTERACTION_MANAGER_COMPONENT_TYPE = InteractionModule.get() .getInteractionManagerComponent(); - public ClearInteractions() { - } - @Nonnull @Override public Set> getDependencies() { @@ -180,9 +171,6 @@ public class DeathSystems { @Nonnull private static final Query QUERY = Query.and(DeathComponent.getComponentType(), Query.not(Player.getComponentType())); - public CorpseRemoval() { - } - @Nonnull @Override public Query getQuery() { @@ -220,9 +208,6 @@ public class DeathSystems { new SystemDependency<>(Order.AFTER, DeathSystems.ClearEntityEffects.class) ); - public DeathAnimation() { - } - @Nonnull @Override public Query getQuery() { @@ -249,10 +234,9 @@ public class DeathSystems { public static class DropPlayerDeathItems extends DeathSystems.OnDeathSystem { @Nonnull - private static final Query QUERY = Archetype.of(Player.getComponentType(), TransformComponent.getComponentType()); - - public DropPlayerDeathItems() { - } + private static final Query QUERY = Archetype.of( + Player.getComponentType(), TransformComponent.getComponentType(), HeadRotation.getComponentType() + ); @Nonnull @Override @@ -340,9 +324,6 @@ public class DeathSystems { } public static class KillFeed extends DeathSystems.OnDeathSystem { - public KillFeed() { - } - @Nonnull @Override public Query getQuery() { @@ -397,9 +378,6 @@ public class DeathSystems { } public abstract static class OnDeathSystem extends RefChangeSystem { - public OnDeathSystem() { - } - @Nonnull @Override public ComponentType componentType() { @@ -422,9 +400,6 @@ public class DeathSystems { } public static class PlayerDeathMarker extends DeathSystems.OnDeathSystem { - public PlayerDeathMarker() { - } - @Nonnull @Override public Query getQuery() { @@ -459,13 +434,10 @@ public class DeathSystems { } public static class PlayerDeathScreen extends DeathSystems.OnDeathSystem { - public PlayerDeathScreen() { - } - @Nonnull @Override public Query getQuery() { - return Player.getComponentType(); + return Query.and(Player.getComponentType(), TransformComponent.getComponentType()); } public void onComponentAdded( @@ -495,13 +467,10 @@ public class DeathSystems { @Nonnull private static final Set> DEPENDENCIES = Set.of(new SystemDependency<>(Order.BEFORE, DeathSystems.DropPlayerDeathItems.class)); - public PlayerDropItemsConfig() { - } - @Nonnull @Override public Query getQuery() { - return Player.getComponentType(); + return Query.and(Player.getComponentType(), PlayerRef.getComponentType()); } @Nonnull @@ -524,9 +493,6 @@ public class DeathSystems { @Nonnull private static final Query QUERY = Archetype.of(Player.getComponentType(), Nameplate.getComponentType()); - public PlayerKilledPlayer() { - } - @Nonnull @Override public Query getQuery() { @@ -564,9 +530,6 @@ public class DeathSystems { @Nonnull private static final Set> DEPENDENCIES = Set.of(new SystemDependency<>(Order.AFTER, DeathSystems.ClearEntityEffects.class)); - public RunDeathInteractions() { - } - @Nonnull @Override public Query getQuery() { @@ -613,9 +576,6 @@ public class DeathSystems { AllLegacyLivingEntityTypesQuery.INSTANCE, DeathComponent.getComponentType(), MovementStatesComponent.getComponentType() ); - public SpawnedDeathAnimation() { - } - @Nonnull @Override public Query getQuery() { diff --git a/src/com/hypixel/hytale/server/core/modules/entity/damage/RespawnSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/damage/RespawnSystems.java index 5827f7f..c4372fb 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/damage/RespawnSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/damage/RespawnSystems.java @@ -8,25 +8,17 @@ import com.hypixel.hytale.component.Store; import com.hypixel.hytale.component.query.Query; import com.hypixel.hytale.component.system.RefChangeSystem; import com.hypixel.hytale.server.core.Message; -import com.hypixel.hytale.server.core.asset.type.gameplay.respawn.RespawnController; import com.hypixel.hytale.server.core.entity.InteractionManager; import com.hypixel.hytale.server.core.entity.effect.EffectControllerComponent; import com.hypixel.hytale.server.core.entity.entities.Player; import com.hypixel.hytale.server.core.modules.entitystats.EntityStatMap; import com.hypixel.hytale.server.core.modules.entitystats.EntityStatValue; import com.hypixel.hytale.server.core.modules.interaction.InteractionModule; -import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class RespawnSystems { - public RespawnSystems() { - } - public static class CheckBrokenItemsRespawnSystem extends RespawnSystems.OnRespawnSystem { - public CheckBrokenItemsRespawnSystem() { - } - @Nonnull @Override public Query getQuery() { @@ -47,9 +39,6 @@ public class RespawnSystems { } public static class ClearEntityEffectsRespawnSystem extends RespawnSystems.OnRespawnSystem { - public ClearEntityEffectsRespawnSystem() { - } - @Nonnull @Override public Query getQuery() { @@ -68,9 +57,6 @@ public class RespawnSystems { } public static class ClearInteractionsRespawnSystem extends RespawnSystems.OnRespawnSystem { - public ClearInteractionsRespawnSystem() { - } - @Override public Query getQuery() { return InteractionModule.get().getInteractionManagerComponent(); @@ -85,9 +71,6 @@ public class RespawnSystems { } public abstract static class OnRespawnSystem extends RefChangeSystem { - public OnRespawnSystem() { - } - @Nonnull @Override public ComponentType componentType() { @@ -110,9 +93,6 @@ public class RespawnSystems { } public static class ResetPlayerRespawnSystem extends RespawnSystems.OnRespawnSystem { - public ResetPlayerRespawnSystem() { - } - @Nonnull @Override public Query getQuery() { @@ -134,9 +114,6 @@ public class RespawnSystems { @Nonnull private static final Query QUERY = Archetype.of(Player.getComponentType(), EntityStatMap.getComponentType()); - public ResetStatsRespawnSystem() { - } - @Nonnull @Override public Query getQuery() { @@ -158,23 +135,4 @@ public class RespawnSystems { } } } - - public static class RespawnControllerRespawnSystem extends RespawnSystems.OnRespawnSystem { - public RespawnControllerRespawnSystem() { - } - - @Nonnull - @Override - public Query getQuery() { - return Player.getComponentType(); - } - - public void onComponentRemoved( - @Nonnull Ref ref, @Nonnull DeathComponent component, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer - ) { - World world = store.getExternalData().getWorld(); - RespawnController respawnController = world.getDeathConfig().getRespawnController(); - respawnController.respawnPlayer(world, ref, commandBuffer); - } - } } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/damage/event/KillFeedEvent.java b/src/com/hypixel/hytale/server/core/modules/entity/damage/event/KillFeedEvent.java index fc6ab7b..c1e23c5 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/damage/event/KillFeedEvent.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/damage/event/KillFeedEvent.java @@ -11,9 +11,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class KillFeedEvent { - public KillFeedEvent() { - } - public static final class DecedentMessage extends CancellableEcsEvent { @Nonnull private final Damage damage; diff --git a/src/com/hypixel/hytale/server/core/modules/entity/dynamiclight/DynamicLightSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/dynamiclight/DynamicLightSystems.java index 7653e07..0c1a34f 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/dynamiclight/DynamicLightSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/dynamiclight/DynamicLightSystems.java @@ -18,9 +18,6 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class DynamicLightSystems { - public DynamicLightSystems() { - } - public static class EntityTrackerRemove extends RefChangeSystem { private final ComponentType visibleComponentType; @@ -71,9 +68,6 @@ public class DynamicLightSystems { private final ComponentType persistentDynamicLightComponentType = PersistentDynamicLight.getComponentType(); private final Query query = Query.and(this.persistentDynamicLightComponentType, Query.not(this.dynamicLightComponentType)); - public Setup() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { PersistentDynamicLight persistentLight = holder.getComponent(this.persistentDynamicLightComponentType); diff --git a/src/com/hypixel/hytale/server/core/modules/entity/hitboxcollision/HitboxCollisionConfigPacketGenerator.java b/src/com/hypixel/hytale/server/core/modules/entity/hitboxcollision/HitboxCollisionConfigPacketGenerator.java index a68e872..69867a0 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/hitboxcollision/HitboxCollisionConfigPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/hitboxcollision/HitboxCollisionConfigPacketGenerator.java @@ -15,9 +15,6 @@ import javax.annotation.Nonnull; public class HitboxCollisionConfigPacketGenerator extends AssetPacketGenerator> { - public HitboxCollisionConfigPacketGenerator() { - } - @Nonnull public Packet generateInitPacket( @Nonnull IndexedLookupTableAssetMap assetMap, @Nonnull Map assets diff --git a/src/com/hypixel/hytale/server/core/modules/entity/hitboxcollision/HitboxCollisionSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/hitboxcollision/HitboxCollisionSystems.java index b322d15..9280a52 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/hitboxcollision/HitboxCollisionSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/hitboxcollision/HitboxCollisionSystems.java @@ -24,9 +24,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class HitboxCollisionSystems { - public HitboxCollisionSystems() { - } - public static class EntityTrackerRemove extends RefChangeSystem { private final ComponentType componentType; private final ComponentType visibleComponentType; diff --git a/src/com/hypixel/hytale/server/core/modules/entity/item/ItemMergeSystem.java b/src/com/hypixel/hytale/server/core/modules/entity/item/ItemMergeSystem.java index 295edf7..4831d96 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/item/ItemMergeSystem.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/item/ItemMergeSystem.java @@ -42,7 +42,12 @@ public class ItemMergeSystem extends EntityTickingSystem { this.itemComponentComponentType = itemComponentComponentType; this.itemSpatialComponent = itemSpatialComponent; this.interactableComponentType = interactableComponentType; - this.query = Query.and(itemComponentComponentType, Query.not(interactableComponentType), Query.not(PreventItemMerging.getComponentType())); + this.query = Query.and( + itemComponentComponentType, + TransformComponent.getComponentType(), + Query.not(interactableComponentType), + Query.not(PreventItemMerging.getComponentType()) + ); } @Nonnull diff --git a/src/com/hypixel/hytale/server/core/modules/entity/item/ItemPhysicsSystem.java b/src/com/hypixel/hytale/server/core/modules/entity/item/ItemPhysicsSystem.java index 9cc66b8..7e547b4 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/item/ItemPhysicsSystem.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/item/ItemPhysicsSystem.java @@ -44,7 +44,7 @@ public class ItemPhysicsSystem extends EntityTickingSystem { this.velocityComponentType = velocityComponentType; this.boundingBoxComponentType = boundingBoxComponentType; this.transformComponentType = TransformComponent.getComponentType(); - this.query = Query.and(itemPhysicsComponentType, boundingBoxComponentType, velocityComponentType); + this.query = Query.and(itemPhysicsComponentType, boundingBoxComponentType, velocityComponentType, this.transformComponentType); } @Nonnull @@ -95,9 +95,16 @@ public class ItemPhysicsSystem extends EntityTickingSystem { } BlockCollisionData blockCollisionData = collisionResult.getFirstBlockCollision(); - if (blockCollisionData != null && blockCollisionData.collisionNormal.equals(Vector3d.UP)) { - velocityComponent.setZero(); - position.assign(blockCollisionData.collisionPoint); + if (blockCollisionData != null) { + if (blockCollisionData.collisionNormal.equals(Vector3d.UP)) { + velocityComponent.setZero(); + position.assign(blockCollisionData.collisionPoint); + } else { + Vector3d velocity = velocityComponent.getVelocity(); + double dot = velocity.dot(blockCollisionData.collisionNormal); + Vector3d velocityToCancel = blockCollisionData.collisionNormal.clone().scale(dot); + velocity.subtract(velocityToCancel); + } } else { velocityComponent.assignVelocityTo(scaledVelocity).scale(dt); position.add(scaledVelocity); diff --git a/src/com/hypixel/hytale/server/core/modules/entity/item/ItemSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/item/ItemSystems.java index f3dbe61..96d48e2 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/item/ItemSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/item/ItemSystems.java @@ -28,15 +28,9 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class ItemSystems { - public ItemSystems() { - } - public static class EnsureRequiredComponents extends HolderSystem { private static final ComponentType ITEM_COMPONENT_TYPE = ItemComponent.getComponentType(); - public EnsureRequiredComponents() { - } - @Nonnull @Override public Query getQuery() { diff --git a/src/com/hypixel/hytale/server/core/modules/entity/item/PickupItemComponent.java b/src/com/hypixel/hytale/server/core/modules/entity/item/PickupItemComponent.java index 6285808..101ae6f 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/item/PickupItemComponent.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/item/PickupItemComponent.java @@ -1,6 +1,5 @@ package com.hypixel.hytale.server.core.modules.entity.item; -import com.hypixel.hytale.codec.builder.BuilderCodec; import com.hypixel.hytale.component.Component; import com.hypixel.hytale.component.ComponentType; import com.hypixel.hytale.component.Ref; @@ -8,16 +7,15 @@ import com.hypixel.hytale.math.vector.Vector3d; import com.hypixel.hytale.server.core.modules.entity.EntityModule; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; +import javax.annotation.Nullable; public class PickupItemComponent implements Component { public static final float PICKUP_TRAVEL_TIME_DEFAULT = 0.15F; - @Nonnull - public static final BuilderCodec CODEC = BuilderCodec.builder(PickupItemComponent.class, PickupItemComponent::new).build(); private Ref targetRef; private Vector3d startPosition; private float originalLifeTime; private float lifeTime = 0.15F; - private boolean finished = false; + private boolean finished; @Nonnull public static ComponentType getComponentType() { @@ -76,7 +74,7 @@ public class PickupItemComponent implements Component { return this.startPosition; } - @Nonnull + @Nullable public Ref getTargetRef() { return this.targetRef; } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/item/PickupItemSystem.java b/src/com/hypixel/hytale/server/core/modules/entity/item/PickupItemSystem.java index 33e7e46..830462d 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/item/PickupItemSystem.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/item/PickupItemSystem.java @@ -48,28 +48,27 @@ public class PickupItemSystem extends EntityTickingSystem { commandBuffer.removeEntity(archetypeChunk.getReferenceTo(index), RemoveReason.REMOVE); } else { Ref targetRef = pickupItemComponent.getTargetRef(); - if (!targetRef.isValid()) { - commandBuffer.removeEntity(archetypeChunk.getReferenceTo(index), RemoveReason.REMOVE); - } else { + if (targetRef != null && targetRef.isValid()) { TransformComponent transformComponent = archetypeChunk.getComponent(index, this.transformComponentType); assert transformComponent != null; Vector3d position = transformComponent.getPosition(); TransformComponent targetTransformComponent = commandBuffer.getComponent(targetRef, this.transformComponentType); + if (targetTransformComponent != null) { + Vector3d targetPosition = targetTransformComponent.getPosition().clone(); + ModelComponent targetModelComponent = commandBuffer.getComponent(targetRef, ModelComponent.getComponentType()); + if (targetModelComponent != null) { + float targetModelEyeHeight = targetModelComponent.getModel().getEyeHeight(targetRef, commandBuffer); + targetPosition.add(0.0, targetModelEyeHeight / 5.0F, 0.0); + } - assert targetTransformComponent != null; - - Vector3d targetPosition = targetTransformComponent.getPosition().clone(); - ModelComponent targetModelComponent = commandBuffer.getComponent(targetRef, ModelComponent.getComponentType()); - if (targetModelComponent != null) { - float targetModelEyeHeight = targetModelComponent.getModel().getEyeHeight(targetRef, commandBuffer); - targetPosition.add(0.0, targetModelEyeHeight / 5.0F, 0.0); - } - - if (updateMovement(pickupItemComponent, position, targetPosition, dt)) { - pickupItemComponent.setFinished(true); + if (updateMovement(pickupItemComponent, position, targetPosition, dt)) { + pickupItemComponent.setFinished(true); + } } + } else { + commandBuffer.removeEntity(archetypeChunk.getReferenceTo(index), RemoveReason.REMOVE); } } } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/livingentity/LivingEntityEffectClearChangesSystem.java b/src/com/hypixel/hytale/server/core/modules/entity/livingentity/LivingEntityEffectClearChangesSystem.java index 8708b0f..42cf2f8 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/livingentity/LivingEntityEffectClearChangesSystem.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/livingentity/LivingEntityEffectClearChangesSystem.java @@ -20,9 +20,6 @@ public class LivingEntityEffectClearChangesSystem extends EntityTickingSystem(Order.AFTER, EntityTrackerSystems.EffectControllerSystem.class) ); - public LivingEntityEffectClearChangesSystem() { - } - @Nonnull @Override public Query getQuery() { diff --git a/src/com/hypixel/hytale/server/core/modules/entity/livingentity/LivingEntityEffectSystem.java b/src/com/hypixel/hytale/server/core/modules/entity/livingentity/LivingEntityEffectSystem.java index 9cd202e..55e8cb2 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/livingentity/LivingEntityEffectSystem.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/livingentity/LivingEntityEffectSystem.java @@ -13,6 +13,7 @@ import com.hypixel.hytale.component.system.tick.EntityTickingSystem; import com.hypixel.hytale.math.shape.Box; import com.hypixel.hytale.math.util.ChunkUtil; import com.hypixel.hytale.math.vector.Vector3d; +import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType; import com.hypixel.hytale.server.core.asset.type.entityeffect.config.EntityEffect; import com.hypixel.hytale.server.core.entity.EntityUtils; import com.hypixel.hytale.server.core.entity.LivingEntity; @@ -33,13 +34,19 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class LivingEntityEffectSystem extends EntityTickingSystem implements DisableProcessingAssert { - public LivingEntityEffectSystem() { - } + @Nonnull + private static final Query QUERY = Query.and( + EffectControllerComponent.getComponentType(), TransformComponent.getComponentType(), BoundingBox.getComponentType() + ); + @Nonnull + private static final String EFFECT_NAME_BURN = "Burn"; + @Nonnull + private static final String BLOCK_TYPE_FLUID_WATER = "Fluid_Water"; @Nonnull @Override public Query getQuery() { - return EffectControllerComponent.getComponentType(); + return QUERY; } @Override @@ -65,43 +72,45 @@ public class LivingEntityEffectSystem extends EntityTickingSystem i Ref entityRef = archetypeChunk.getReferenceTo(index); ObjectIterator iterator = activeEffects.values().iterator(); EntityStatMap entityStatMapComponent = commandBuffer.getComponent(entityRef, EntityStatMap.getComponentType()); - boolean invalidated = false; - boolean invulnerable = false; + if (entityStatMapComponent != null) { + boolean invalidated = false; + boolean invulnerable = false; - while (iterator.hasNext()) { - ActiveEntityEffect activeEntityEffect = iterator.next(); - int entityEffectIndex = activeEntityEffect.getEntityEffectIndex(); - EntityEffect entityEffect = entityEffectAssetMap.getAsset(entityEffectIndex); - if (entityEffect == null) { - iterator.remove(); - invalidated = true; - } else if (!canApplyEffect(entityRef, entityEffect, commandBuffer)) { - iterator.remove(); - invalidated = true; - } else { - float tickDelta = Math.min(activeEntityEffect.getRemainingDuration(), dt); - activeEntityEffect.tick(commandBuffer, entityRef, entityEffect, entityStatMapComponent, tickDelta); - if (activeEffects.isEmpty()) { - return; - } - - if (!activeEntityEffect.isInfinite() && activeEntityEffect.getRemainingDuration() <= 0.0F) { + while (iterator.hasNext()) { + ActiveEntityEffect activeEntityEffect = iterator.next(); + int entityEffectIndex = activeEntityEffect.getEntityEffectIndex(); + EntityEffect entityEffect = entityEffectAssetMap.getAsset(entityEffectIndex); + if (entityEffect == null) { iterator.remove(); - effectControllerComponent.tryResetModelChange(entityRef, activeEntityEffect.getEntityEffectIndex(), commandBuffer); invalidated = true; - } + } else if (!canApplyEffect(entityRef, entityEffect, commandBuffer)) { + iterator.remove(); + invalidated = true; + } else { + float tickDelta = Math.min(activeEntityEffect.getRemainingDuration(), dt); + activeEntityEffect.tick(commandBuffer, entityRef, entityEffect, entityStatMapComponent, tickDelta); + if (activeEffects.isEmpty()) { + return; + } - if (activeEntityEffect.isInvulnerable()) { - invulnerable = true; + if (!activeEntityEffect.isInfinite() && activeEntityEffect.getRemainingDuration() <= 0.0F) { + iterator.remove(); + effectControllerComponent.tryResetModelChange(entityRef, activeEntityEffect.getEntityEffectIndex(), commandBuffer); + invalidated = true; + } + + if (activeEntityEffect.isInvulnerable()) { + invulnerable = true; + } } } - } - effectControllerComponent.setInvulnerable(invulnerable); - if (invalidated) { - effectControllerComponent.invalidateCache(); - if (EntityUtils.getEntity(index, archetypeChunk) instanceof LivingEntity livingEntity) { - livingEntity.getStatModifiersManager().setRecalculate(true); + effectControllerComponent.setInvulnerable(invulnerable); + if (invalidated) { + effectControllerComponent.invalidateCache(); + if (EntityUtils.getEntity(index, archetypeChunk) instanceof LivingEntity livingEntity) { + livingEntity.getStatModifiersManager().setRecalculate(true); + } } } } @@ -116,29 +125,34 @@ public class LivingEntityEffectSystem extends EntityTickingSystem i public static boolean canApplyEffect( @Nonnull Ref ownerRef, @Nonnull EntityEffect entityEffect, @Nonnull ComponentAccessor componentAccessor ) { - TransformComponent transformComponent = componentAccessor.getComponent(ownerRef, TransformComponent.getComponentType()); - - assert transformComponent != null; - - BoundingBox boundingBoxComponent = componentAccessor.getComponent(ownerRef, BoundingBox.getComponentType()); - - assert boundingBoxComponent != null; - - Vector3d position = transformComponent.getPosition(); - Box boundingBox = boundingBoxComponent.getBoundingBox(); - World world = componentAccessor.getExternalData().getWorld(); if ("Burn".equals(entityEffect.getId())) { + TransformComponent transformComponent = componentAccessor.getComponent(ownerRef, TransformComponent.getComponentType()); + + assert transformComponent != null; + Ref chunkRef = transformComponent.getChunkRef(); if (chunkRef != null && chunkRef.isValid()) { + World world = componentAccessor.getExternalData().getWorld(); Store chunkComponentStore = world.getChunkStore().getStore(); WorldChunk worldChunkComponent = chunkComponentStore.getComponent(chunkRef, WorldChunk.getComponentType()); assert worldChunkComponent != null; + BoundingBox boundingBoxComponent = componentAccessor.getComponent(ownerRef, BoundingBox.getComponentType()); + + assert boundingBoxComponent != null; + + Vector3d position = transformComponent.getPosition(); + Box boundingBox = boundingBoxComponent.getBoundingBox(); LocalCachedChunkAccessor chunkAccessor = LocalCachedChunkAccessor.atChunkCoords(world, worldChunkComponent.getX(), worldChunkComponent.getZ(), 1); return boundingBox.forEachBlock(position, chunkAccessor, (x, y, z, _chunkAccessor) -> { WorldChunk localChunk = _chunkAccessor.getChunkIfInMemory(ChunkUtil.indexChunkFromBlock(x, z)); - return localChunk == null ? true : !localChunk.getBlockType(x, y, z).getId().contains("Fluid_Water"); + if (localChunk == null) { + return true; + } else { + BlockType blockType = localChunk.getBlockType(x, y, z); + return blockType == null ? true : !blockType.getId().contains("Fluid_Water"); + } }); } else { return false; diff --git a/src/com/hypixel/hytale/server/core/modules/entity/player/ApplyRandomSkinPersistedComponent.java b/src/com/hypixel/hytale/server/core/modules/entity/player/ApplyRandomSkinPersistedComponent.java index 16be729..d3bdcd8 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/player/ApplyRandomSkinPersistedComponent.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/player/ApplyRandomSkinPersistedComponent.java @@ -16,9 +16,6 @@ public class ApplyRandomSkinPersistedComponent implements Component return EntityModule.get().getApplyRandomSkinPersistedComponent(); } - public ApplyRandomSkinPersistedComponent() { - } - @Nonnull @Override public Component clone() { diff --git a/src/com/hypixel/hytale/server/core/modules/entity/player/ChunkTracker.java b/src/com/hypixel/hytale/server/core/modules/entity/player/ChunkTracker.java index 31bb12d..dca842a 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/player/ChunkTracker.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/player/ChunkTracker.java @@ -8,6 +8,7 @@ import com.hypixel.hytale.component.Component; import com.hypixel.hytale.component.ComponentAccessor; import com.hypixel.hytale.component.ComponentType; import com.hypixel.hytale.component.Ref; +import com.hypixel.hytale.component.Store; import com.hypixel.hytale.logger.HytaleLogger; import com.hypixel.hytale.math.iterator.CircleSpiralIterator; import com.hypixel.hytale.math.util.ChunkUtil; @@ -18,6 +19,7 @@ import com.hypixel.hytale.protocol.Packet; import com.hypixel.hytale.protocol.packets.world.UnloadChunk; import com.hypixel.hytale.server.core.Message; import com.hypixel.hytale.server.core.entity.entities.Player; +import com.hypixel.hytale.server.core.io.PacketHandler; import com.hypixel.hytale.server.core.modules.entity.EntityModule; import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent; import com.hypixel.hytale.server.core.universe.PlayerRef; @@ -39,6 +41,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class ChunkTracker implements Component { + @Nonnull public static final MetricsRegistry METRICS_REGISTRY = new MetricsRegistry() .register("ViewRadius", tracker -> tracker.chunkViewRadius, Codec.INTEGER) .register("SentViewRadius", tracker -> tracker.sentViewRadius, Codec.INTEGER) @@ -60,10 +63,15 @@ public class ChunkTracker implements Component { @Nullable private TransformComponent transformComponent; private int chunkViewRadius; + @Nonnull private final CircleSpiralIterator spiralIterator = new CircleSpiralIterator(); + @Nonnull private final StampedLock loadedLock = new StampedLock(); + @Nonnull private final HLongSet loading = new HLongOpenHashSet(); + @Nonnull private final HLongSet loaded = new HLongOpenHashSet(); + @Nonnull private final HLongSet reload = new HLongOpenHashSet(); private int maxChunksPerSecond; private float inverseMaxChunksPerSecond; @@ -126,21 +134,15 @@ public class ChunkTracker implements Component { } } - public void tick(@Nonnull Ref playerRef, float dt, @Nonnull CommandBuffer commandBuffer) { + public void tick( + @Nonnull Player playerComponent, + @Nonnull PlayerRef playerRefComponent, + @Nonnull TransformComponent transformComponent, + float dt, + @Nonnull CommandBuffer commandBuffer + ) { if (this.readyForChunks) { - World world = commandBuffer.getExternalData().getWorld(); - TransformComponent transformComponent = this.transformComponent = commandBuffer.getComponent(playerRef, TransformComponent.getComponentType()); - - assert transformComponent != null; - - Player playerComponent = commandBuffer.getComponent(playerRef, Player.getComponentType()); - - assert playerComponent != null; - - PlayerRef playerRefComponent = commandBuffer.getComponent(playerRef, PlayerRef.getComponentType()); - - assert playerRefComponent != null; - + this.transformComponent = transformComponent; int chunkViewRadius = this.chunkViewRadius = playerComponent.getViewRadius(); Vector3d position = transformComponent.getPosition(); int chunkX = MathUtil.floor(position.getX()) >> 5; @@ -161,6 +163,7 @@ public class ChunkTracker implements Component { this.hotRadius = chunkViewRadius; } + World world = commandBuffer.getExternalData().getWorld(); ChunkStore chunkStore = world.getChunkStore(); int minLoadedRadius = Math.max(this.minLoadedChunksRadius, chunkViewRadius); int minLoadedRadiusSq = minLoadedRadius * minLoadedRadius; @@ -212,9 +215,9 @@ public class ChunkTracker implements Component { this.loadedLock.unlockWrite(stamp); } - int var29 = Math.min(this.maxHotLoadedChunksRadius, this.sentViewRadius); - if (this.hotRadius < var29) { - this.spiralIterator.init(chunkX, chunkZ, this.hotRadius, var29); + int var28 = Math.min(this.maxHotLoadedChunksRadius, this.sentViewRadius); + if (this.hotRadius < var28) { + this.spiralIterator.init(chunkX, chunkZ, this.hotRadius, var28); while (this.spiralIterator.hasNext()) { Ref chunkReference = chunkStore.getChunkReference(this.spiralIterator.next()); @@ -229,7 +232,7 @@ public class ChunkTracker implements Component { } } - this.hotRadius = var29; + this.hotRadius = var28; } if (this.sentViewRadius == chunkViewRadius) { @@ -265,31 +268,40 @@ public class ChunkTracker implements Component { } public boolean shouldBeVisible(long chunkCoordinates) { - Vector3d position = this.transformComponent.getPosition(); - int chunkX = MathUtil.floor(position.getX()) >> 5; - int chunkZ = MathUtil.floor(position.getZ()) >> 5; - int x = ChunkUtil.xOfChunkIndex(chunkCoordinates); - int z = ChunkUtil.zOfChunkIndex(chunkCoordinates); - int minLoadedRadius = Math.max(this.minLoadedChunksRadius, this.chunkViewRadius); - return shouldBeVisible(minLoadedRadius * minLoadedRadius, chunkX, chunkZ, x, z); + if (this.transformComponent == null) { + return false; + } else { + Vector3d position = this.transformComponent.getPosition(); + int chunkX = MathUtil.floor(position.getX()) >> 5; + int chunkZ = MathUtil.floor(position.getZ()) >> 5; + int x = ChunkUtil.xOfChunkIndex(chunkCoordinates); + int z = ChunkUtil.zOfChunkIndex(chunkCoordinates); + int minLoadedRadius = Math.max(this.minLoadedChunksRadius, this.chunkViewRadius); + return shouldBeVisible(minLoadedRadius * minLoadedRadius, chunkX, chunkZ, x, z); + } } + @Nonnull public ChunkTracker.ChunkVisibility getChunkVisibility(long indexChunk) { - Vector3d position = this.transformComponent.getPosition(); - int chunkX = MathUtil.floor(position.getX()) >> 5; - int chunkZ = MathUtil.floor(position.getZ()) >> 5; - int x = ChunkUtil.xOfChunkIndex(indexChunk); - int z = ChunkUtil.zOfChunkIndex(indexChunk); - int xDiff = Math.abs(x - chunkX); - int zDiff = Math.abs(z - chunkZ); - int distanceSq = xDiff * xDiff + zDiff * zDiff; - int minLoadedRadius = Math.max(this.minLoadedChunksRadius, this.chunkViewRadius); - boolean shouldBeVisible = distanceSq <= minLoadedRadius * minLoadedRadius; - if (shouldBeVisible) { - boolean isHot = distanceSq <= this.maxHotLoadedChunksRadius * this.maxHotLoadedChunksRadius; - return isHot ? ChunkTracker.ChunkVisibility.HOT : ChunkTracker.ChunkVisibility.COLD; - } else { + if (this.transformComponent == null) { return ChunkTracker.ChunkVisibility.NONE; + } else { + Vector3d position = this.transformComponent.getPosition(); + int chunkX = MathUtil.floor(position.getX()) >> 5; + int chunkZ = MathUtil.floor(position.getZ()) >> 5; + int x = ChunkUtil.xOfChunkIndex(indexChunk); + int z = ChunkUtil.zOfChunkIndex(indexChunk); + int xDiff = Math.abs(x - chunkX); + int zDiff = Math.abs(z - chunkZ); + int distanceSq = xDiff * xDiff + zDiff * zDiff; + int minLoadedRadius = Math.max(this.minLoadedChunksRadius, this.chunkViewRadius); + boolean shouldBeVisible = distanceSq <= minLoadedRadius * minLoadedRadius; + if (shouldBeVisible) { + boolean isHot = distanceSq <= this.maxHotLoadedChunksRadius * this.maxHotLoadedChunksRadius; + return isHot ? ChunkTracker.ChunkVisibility.HOT : ChunkTracker.ChunkVisibility.COLD; + } else { + return ChunkTracker.ChunkVisibility.NONE; + } } } @@ -440,9 +452,9 @@ public class ChunkTracker implements Component { public String getLoadedChunksDebug() { long stamp = this.loadedLock.readLock(); - String var4; + String var3; try { - String sb = "Chunks (#: Loaded, &: Loading, ' ': Not loaded):\n" + var3 = "Chunks (#: Loaded, &: Loading, ' ': Not loaded):\n" + this.getLoadedChunksGrid() + "\nView Radius: " + this.chunkViewRadius @@ -456,12 +468,11 @@ public class ChunkTracker implements Component { + this.loaded.size() + "\nLoading: " + this.loading.size(); - var4 = sb; } finally { this.loadedLock.unlockRead(stamp); } - return var4; + return var3; } public void setReadyForChunks(boolean readyForChunks) { @@ -491,12 +502,6 @@ public class ChunkTracker implements Component { } } - @Nonnull - @Override - public Component clone() { - return new ChunkTracker(this); - } - private static boolean shouldBeVisible(int chunkViewRadiusSquared, int chunkX, int chunkZ, int x, int z) { int xDiff = Math.abs(x - chunkX); int zDiff = Math.abs(z - chunkZ); @@ -512,20 +517,30 @@ public class ChunkTracker implements Component { if (shouldBeVisible(chunkViewRadiusSquared, x, z, chunkX, chunkZ)) { return false; } else { - ChunkStore chunkComponentStore = playerRef.getReference().getStore().getExternalData().getWorld().getChunkStore(); - Ref reference = chunkComponentStore.getChunkReference(chunkIndex); - if (reference != null) { - ObjectArrayList packets = new ObjectArrayList<>(); - chunkComponentStore.getStore().fetch(Collections.singletonList(reference), ChunkStore.UNLOAD_PACKETS_DATA_QUERY_SYSTEM_TYPE, playerRef, packets); + Ref ref = playerRef.getReference(); + if (ref != null && ref.isValid()) { + Store store = ref.getStore(); + World world = store.getExternalData().getWorld(); + PacketHandler packetHandler = playerRef.getPacketHandler(); + ChunkStore chunkComponentStore = world.getChunkStore(); + Ref chunkRef = chunkComponentStore.getChunkReference(chunkIndex); + if (chunkRef != null) { + Store chunkStore = chunkComponentStore.getStore(); + ObjectArrayList packets = new ObjectArrayList<>(); + chunkStore.fetch(Collections.singletonList(chunkRef), ChunkStore.UNLOAD_PACKETS_DATA_QUERY_SYSTEM_TYPE, playerRef, packets); - for (int i = 0; i < packets.size(); i++) { - playerRef.getPacketHandler().write(packets.get(i)); + for (int i = 0; i < packets.size(); i++) { + packetHandler.write(packets.get(i)); + } } - } - playerRef.getPacketHandler().writeNoCache(new UnloadChunk(x, z)); - loading.remove(chunkIndex); - return true; + packetHandler.writeNoCache(new UnloadChunk(x, z)); + loading.remove(chunkIndex); + return true; + } else { + loading.remove(chunkIndex); + return true; + } } } @@ -600,12 +615,12 @@ public class ChunkTracker implements Component { @Nonnull private CompletableFuture _loadChunkAsync( - long chunkIndex, @Nonnull PlayerRef playerRefComponent, @Nonnull Ref chunkRef, @Nonnull ChunkStore chunkStore + long chunkIndex, @Nonnull PlayerRef playerRefComponent, @Nonnull Ref chunkRef, @Nonnull ChunkStore chunkComponentStore ) { List packets = new ObjectArrayList<>(); - chunkStore.getStore().fetch(Collections.singletonList(chunkRef), ChunkStore.LOAD_PACKETS_DATA_QUERY_SYSTEM_TYPE, playerRefComponent, packets); + chunkComponentStore.getStore().fetch(Collections.singletonList(chunkRef), ChunkStore.LOAD_PACKETS_DATA_QUERY_SYSTEM_TYPE, playerRefComponent, packets); ObjectArrayList> futurePackets = new ObjectArrayList<>(); - chunkStore.getStore() + chunkComponentStore.getStore() .fetch(Collections.singletonList(chunkRef), ChunkStore.LOAD_FUTURE_PACKETS_DATA_QUERY_SYSTEM_TYPE, playerRefComponent, futurePackets); return CompletableFuture.allOf(futurePackets.toArray(CompletableFuture[]::new)).thenAcceptAsync(o -> { for (CompletableFuture futurePacket : futurePackets) { @@ -631,12 +646,15 @@ public class ChunkTracker implements Component { }); } + @Nonnull + @Override + public Component clone() { + return new ChunkTracker(this); + } + public static enum ChunkVisibility { NONE, HOT, COLD; - - private ChunkVisibility() { - } } } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/player/KnockbackPredictionSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/player/KnockbackPredictionSystems.java index 6e5e888..1d5abcf 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/player/KnockbackPredictionSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/player/KnockbackPredictionSystems.java @@ -52,16 +52,10 @@ public class KnockbackPredictionSystems { public static final float TIME_STEP = 0.016666668F; public static final int MAX_JUMP_COMBOS = 3; - public KnockbackPredictionSystems() { - } - public static class CaptureKnockbackInput extends EntityTickingSystem { private static final Query QUERY = Query.and(PlayerInput.getComponentType(), KnockbackSimulation.getComponentType()); private static final Set> DEPENDENCIES = Set.of(new SystemDependency<>(Order.BEFORE, PlayerSystems.ProcessPlayerInput.class)); - public CaptureKnockbackInput() { - } - @Nonnull @Override public Query getQuery() { @@ -138,9 +132,6 @@ public class KnockbackPredictionSystems { public static class ClearOnRemove extends RefSystem { private static final ComponentType KNOCKBACK_SIMULATION_COMPONENT_TYPE = KnockbackSimulation.getComponentType(); - public ClearOnRemove() { - } - @Override public Query getQuery() { return KNOCKBACK_SIMULATION_COMPONENT_TYPE; @@ -164,9 +155,6 @@ public class KnockbackPredictionSystems { private static final ComponentType TELEPORT_COMPONENT_TYPE = Teleport.getComponentType(); private static final ComponentType KNOCKBACK_SIMULATION_COMPONENT_TYPE = KnockbackSimulation.getComponentType(); - public ClearOnTeleport() { - } - @Override public Query getQuery() { return KNOCKBACK_SIMULATION_COMPONENT_TYPE; @@ -203,9 +191,6 @@ public class KnockbackPredictionSystems { X, Y, Z; - - private CollisionAxis() { - } } public static class InitKnockback extends RefChangeSystem { @@ -213,9 +198,6 @@ public class KnockbackPredictionSystems { Player.getComponentType(), TransformComponent.getComponentType(), KnockbackSimulation.getComponentType(), MovementStatesComponent.getComponentType() ); - public InitKnockback() { - } - @Nonnull @Override public Query getQuery() { @@ -284,13 +266,12 @@ public class KnockbackPredictionSystems { TransformComponent.getComponentType(), KnockbackSimulation.getComponentType(), BOUNDING_BOX_COMPONENT_TYPE, - MovementStatesComponent.getComponentType() + MovementStatesComponent.getComponentType(), + MovementManager.getComponentType(), + PlayerRef.getComponentType() ); private static final Set> DEPENDENCIES = Set.of(new SystemDependency<>(Order.AFTER, PlayerSystems.ProcessPlayerInput.class)); - public SimulateKnockback() { - } - @Nonnull @Override public Query getQuery() { diff --git a/src/com/hypixel/hytale/server/core/modules/entity/player/KnockbackSimulation.java b/src/com/hypixel/hytale/server/core/modules/entity/player/KnockbackSimulation.java index 956f90a..f0baffe 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/player/KnockbackSimulation.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/player/KnockbackSimulation.java @@ -35,9 +35,6 @@ public class KnockbackSimulation implements Component { private final Vector3d checkPosition = new Vector3d(); private final Vector3d tempPosition = new Vector3d(); - public KnockbackSimulation() { - } - public static ComponentType getComponentType() { return EntityModule.get().getKnockbackSimulationComponentType(); } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerCameraAddSystem.java b/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerCameraAddSystem.java index 0607952..d729fe2 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerCameraAddSystem.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerCameraAddSystem.java @@ -16,9 +16,6 @@ public class PlayerCameraAddSystem extends HolderSystem { private static final ComponentType CAMERA_MANAGER_COMPONENT_TYPE = CameraManager.getComponentType(); private static final Query QUERY = Query.and(PlayerRef.getComponentType(), Query.not(CAMERA_MANAGER_COMPONENT_TYPE)); - public PlayerCameraAddSystem() { - } - @Nonnull @Override public Query getQuery() { diff --git a/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerChunkTrackerSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerChunkTrackerSystems.java index 722693b..ba59f3e 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerChunkTrackerSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerChunkTrackerSystems.java @@ -5,26 +5,22 @@ import com.hypixel.hytale.component.ArchetypeChunk; import com.hypixel.hytale.component.CommandBuffer; import com.hypixel.hytale.component.ComponentType; import com.hypixel.hytale.component.Holder; -import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.RemoveReason; import com.hypixel.hytale.component.Store; import com.hypixel.hytale.component.query.Query; import com.hypixel.hytale.component.system.HolderSystem; import com.hypixel.hytale.component.system.tick.EntityTickingSystem; +import com.hypixel.hytale.server.core.entity.entities.Player; +import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent; +import com.hypixel.hytale.server.core.universe.PlayerRef; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class PlayerChunkTrackerSystems { - public PlayerChunkTrackerSystems() { - } - public static class AddSystem extends HolderSystem { @Nonnull private static final ComponentType CHUNK_TRACKER_COMPONENT_TYPE = ChunkTracker.getComponentType(); - public AddSystem() { - } - @Override public Query getQuery() { return CHUNK_TRACKER_COMPONENT_TYPE; @@ -47,13 +43,16 @@ public class PlayerChunkTrackerSystems { public static class UpdateSystem extends EntityTickingSystem { @Nonnull private static final ComponentType CHUNK_TRACKER_COMPONENT_TYPE = ChunkTracker.getComponentType(); - - public UpdateSystem() { - } + @Nonnull + private static final ComponentType PLAYER_COMPONENT_TYPE = Player.getComponentType(); + @Nonnull + private static final ComponentType PLAYER_REF_COMPONENT_TYPE = PlayerRef.getComponentType(); + @Nonnull + private static final ComponentType TRANSFORM_COMPONENT_TYPE = TransformComponent.getComponentType(); @Override public Query getQuery() { - return CHUNK_TRACKER_COMPONENT_TYPE; + return Query.and(CHUNK_TRACKER_COMPONENT_TYPE, PLAYER_COMPONENT_TYPE, PLAYER_REF_COMPONENT_TYPE, TRANSFORM_COMPONENT_TYPE); } @Override @@ -69,12 +68,23 @@ public class PlayerChunkTrackerSystems { @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { - Ref ref = archetypeChunk.getReferenceTo(index); ChunkTracker chunkTrackerComponent = archetypeChunk.getComponent(index, CHUNK_TRACKER_COMPONENT_TYPE); assert chunkTrackerComponent != null; - chunkTrackerComponent.tick(ref, dt, commandBuffer); + Player playerComponent = archetypeChunk.getComponent(index, PLAYER_COMPONENT_TYPE); + + assert playerComponent != null; + + PlayerRef playerRefComponent = archetypeChunk.getComponent(index, PLAYER_REF_COMPONENT_TYPE); + + assert playerRefComponent != null; + + TransformComponent transformComponent = archetypeChunk.getComponent(index, TRANSFORM_COMPONENT_TYPE); + + assert transformComponent != null; + + chunkTrackerComponent.tick(playerComponent, playerRefComponent, transformComponent, dt, commandBuffer); } } } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerHudManagerSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerHudManagerSystems.java index ab12721..6d8b3bb 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerHudManagerSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerHudManagerSystems.java @@ -16,9 +16,6 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class PlayerHudManagerSystems { - public PlayerHudManagerSystems() { - } - public static class InitializeSystem extends RefSystem { @Nonnull private static final ComponentType PLAYER_REF_COMPONENT_TYPE = PlayerRef.getComponentType(); @@ -27,9 +24,6 @@ public class PlayerHudManagerSystems { @Nonnull private static final Query QUERY = Query.and(PLAYER_REF_COMPONENT_TYPE, PLAYER_COMPONENT_TYPE); - public InitializeSystem() { - } - @Nonnull @Override public Query getQuery() { diff --git a/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerInput.java b/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerInput.java index eaf9dfd..8ef1961 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerInput.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerInput.java @@ -24,9 +24,6 @@ public class PlayerInput implements Component { private final List inputUpdateQueue = new ObjectArrayList<>(); private int mountId; - public PlayerInput() { - } - public static ComponentType getComponentType() { return EntityModule.get().getPlayerInputComponentType(); } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerItemEntityPickupSystem.java b/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerItemEntityPickupSystem.java index 16320a3..b7b99a3 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerItemEntityPickupSystem.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerItemEntityPickupSystem.java @@ -70,6 +70,7 @@ public class PlayerItemEntityPickupSystem extends EntityTickingSystem(Order.AFTER, PlayerSpatialSystem.class, OrderPriority.CLOSEST)); this.query = Query.and( itemComponentType, + TransformComponent.getComponentType(), Query.not(Interactable.getComponentType()), Query.not(PickupItemComponent.getComponentType()), Query.not(PreventPickup.getComponentType()) diff --git a/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerMovementManagerSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerMovementManagerSystems.java index e9e7330..90d4487 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerMovementManagerSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerMovementManagerSystems.java @@ -16,18 +16,12 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class PlayerMovementManagerSystems { - public PlayerMovementManagerSystems() { - } - public static class AssignmentSystem extends HolderSystem { @Nonnull private static final ComponentType MOVEMENT_MANAGER_COMPONENT_TYPE = MovementManager.getComponentType(); @Nonnull private static final Query QUERY = Query.and(PlayerRef.getComponentType(), Query.not(MOVEMENT_MANAGER_COMPONENT_TYPE)); - public AssignmentSystem() { - } - @Nonnull @Override public Query getQuery() { @@ -50,9 +44,6 @@ public class PlayerMovementManagerSystems { @Nonnull private static final Query QUERY = Query.and(MOVEMENT_MANAGER_COMPONENT_TYPE, PlayerRef.getComponentType()); - public PostAssignmentSystem() { - } - @Nonnull @Override public Query getQuery() { diff --git a/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerPingSystem.java b/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerPingSystem.java index a8a6098..881b8c2 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerPingSystem.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerPingSystem.java @@ -20,9 +20,6 @@ public class PlayerPingSystem extends EntityTickingSystem implement @Nonnull private static final ComponentType PLAYER_REF_COMPONENT_TYPE = PlayerRef.getComponentType(); - public PlayerPingSystem() { - } - @Override public Query getQuery() { return PLAYER_REF_COMPONENT_TYPE; diff --git a/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerProcessMovementSystem.java b/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerProcessMovementSystem.java index ee7903d..d2a234d 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerProcessMovementSystem.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerProcessMovementSystem.java @@ -62,7 +62,13 @@ public class PlayerProcessMovementSystem extends EntityTickingSystem= 100.0) { - if (playerComponent.getGameMode() == GameMode.Adventure) { - Entity.LOGGER - .at(Level.WARNING) - .log( - "%s, %s: Jump in location in processMovementBlockCollisions %s", - playerRefComponent.getUsername(), - playerRefComponent.getUuid(), - collisionResultComponent.getCollisionPositionOffsetCopy().length() - ); - } - - playerComponent.resetVelocity(velocityComponent); - } else { - BoundingBox boundingBoxComponent = archetypeChunk.getComponent(index, this.boundingBoxComponentType); - - assert boundingBoxComponent != null; - - Box boundingBox = boundingBoxComponent.getBoundingBox(); - if (pendingCollisionCheck) { - } - - CollisionModule.get() - .findIntersections( - world, boundingBox, collisionResultComponent.getCollisionStartPositionCopy(), collisionResultComponent.getCollisionResult(), true, false - ); - playerComponent.processVelocitySample(dt, collisionResultComponent.getCollisionPositionOffsetCopy(), velocityComponent); - Ref chunkRef = transformComponent.getChunkRef(); - if (chunkRef != null && chunkRef.isValid()) { - Store chunkStore = world.getChunkStore().getStore(); - WorldChunk worldChunkComponent = chunkStore.getComponent(chunkRef, WorldChunk.getComponentType()); - - assert worldChunkComponent != null; - - PositionDataComponent positionDataComponent = archetypeChunk.getComponent(index, this.positionDataComponentType); - - assert positionDataComponent != null; - - Vector3i blockPosition = transformComponent.getPosition().toVector3i(); - positionDataComponent.setInsideBlockTypeId(worldChunkComponent.getBlock(blockPosition)); - positionDataComponent.setStandingOnBlockTypeId(worldChunkComponent.getBlock(blockPosition.x, blockPosition.y - 1, blockPosition.z)); - } - - commandBuffer.run( - _store -> { - int damageToEntity = collisionResultComponent.getCollisionResult() - .defaultTriggerBlocksProcessing(interactionManagerComponent, playerComponent, ref, playerComponent.executeTriggers, commandBuffer); - if (playerComponent.executeBlockDamage && damageToEntity > 0) { - Damage damage = new Damage(Damage.NULL_SOURCE, DamageCause.ENVIRONMENT, damageToEntity); - DamageSystems.executeDamage(index, archetypeChunk, commandBuffer, damage); - } + boolean pendingCollisionCheck = collisionResultComponent.isPendingCollisionCheck(); + collisionResultComponent.getCollisionStartPositionCopy() + .assign(pendingCollisionCheck ? collisionResultComponent.getCollisionStartPosition() : transformComponent.getPosition()); + collisionResultComponent.getCollisionPositionOffsetCopy().assign(collisionResultComponent.getCollisionPositionOffset()); + collisionResultComponent.resetLocationChange(); + if (collisionResultComponent.getCollisionPositionOffsetCopy().squaredLength() >= 100.0) { + if (playerComponent.getGameMode() == GameMode.Adventure) { + Entity.LOGGER + .at(Level.WARNING) + .log( + "%s, %s: Jump in location in processMovementBlockCollisions %s", + playerRefComponent.getUsername(), + playerRefComponent.getUuid(), + collisionResultComponent.getCollisionPositionOffsetCopy().length() + ); } - ); + + playerComponent.resetVelocity(velocityComponent); + } else { + BoundingBox boundingBoxComponent = archetypeChunk.getComponent(index, this.boundingBoxComponentType); + + assert boundingBoxComponent != null; + + Box boundingBox = boundingBoxComponent.getBoundingBox(); + if (pendingCollisionCheck) { + } + + CollisionModule.get() + .findIntersections( + world, boundingBox, collisionResultComponent.getCollisionStartPositionCopy(), collisionResultComponent.getCollisionResult(), true, false + ); + playerComponent.processVelocitySample(dt, collisionResultComponent.getCollisionPositionOffsetCopy(), velocityComponent); + Ref chunkRef = transformComponent.getChunkRef(); + if (chunkRef != null && chunkRef.isValid()) { + Store chunkStore = world.getChunkStore().getStore(); + WorldChunk worldChunkComponent = chunkStore.getComponent(chunkRef, WorldChunk.getComponentType()); + + assert worldChunkComponent != null; + + PositionDataComponent positionDataComponent = archetypeChunk.getComponent(index, this.positionDataComponentType); + + assert positionDataComponent != null; + + Vector3i blockPosition = transformComponent.getPosition().toVector3i(); + positionDataComponent.setInsideBlockTypeId(worldChunkComponent.getBlock(blockPosition)); + positionDataComponent.setStandingOnBlockTypeId(worldChunkComponent.getBlock(blockPosition.x, blockPosition.y - 1, blockPosition.z)); + } + + commandBuffer.run( + _store -> { + int damageToEntity = collisionResultComponent.getCollisionResult() + .defaultTriggerBlocksProcessing(interactionManagerComponent, playerComponent, ref, playerComponent.executeTriggers, commandBuffer); + if (playerComponent.executeBlockDamage && damageToEntity > 0) { + Damage damage = new Damage(Damage.NULL_SOURCE, DamageCause.ENVIRONMENT, damageToEntity); + DamageSystems.executeDamage(index, archetypeChunk, commandBuffer, damage); + } + } + ); + } } } } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerSavingSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerSavingSystems.java index da30240..2eb1fc6 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerSavingSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerSavingSystems.java @@ -30,15 +30,9 @@ public class PlayerSavingSystems { private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); private static final float PLAYER_SAVE_INTERVAL_SECONDS = 10.0F; - public PlayerSavingSystems() { - } - public static class SaveDataResource implements Resource { private float delay = 10.0F; - public SaveDataResource() { - } - @Nonnull @Override public Resource clone() { diff --git a/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerSettings.java b/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerSettings.java index 3134966..4c9ef3e 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerSettings.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerSettings.java @@ -14,11 +14,25 @@ public record PlayerSettings( @Nonnull PickupLocation usableItemsItemsPreferredPickupLocation, @Nonnull PickupLocation solidBlockItemsPreferredPickupLocation, @Nonnull PickupLocation miscItemsPreferredPickupLocation, - PlayerCreativeSettings creativeSettings + PlayerCreativeSettings creativeSettings, + boolean hideHelmet, + boolean hideCuirass, + boolean hideGauntlets, + boolean hidePants ) implements Component { @Nonnull private static final PlayerSettings INSTANCE = new PlayerSettings( - false, PickupLocation.Hotbar, PickupLocation.Hotbar, PickupLocation.Hotbar, PickupLocation.Hotbar, PickupLocation.Hotbar, new PlayerCreativeSettings() + false, + PickupLocation.Hotbar, + PickupLocation.Hotbar, + PickupLocation.Hotbar, + PickupLocation.Hotbar, + PickupLocation.Hotbar, + new PlayerCreativeSettings(), + false, + false, + false, + false ); @Nonnull @@ -41,7 +55,11 @@ public record PlayerSettings( this.usableItemsItemsPreferredPickupLocation, this.solidBlockItemsPreferredPickupLocation, this.miscItemsPreferredPickupLocation, - this.creativeSettings.clone() + this.creativeSettings.clone(), + this.hideHelmet, + this.hideCuirass, + this.hideGauntlets, + this.hidePants ); } } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerSystems.java index d3d279e..655d65f 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/player/PlayerSystems.java @@ -25,11 +25,19 @@ import com.hypixel.hytale.logger.HytaleLogger; import com.hypixel.hytale.math.vector.Transform; import com.hypixel.hytale.math.vector.Vector3d; import com.hypixel.hytale.math.vector.Vector3f; +import com.hypixel.hytale.protocol.ComponentUpdate; +import com.hypixel.hytale.protocol.ComponentUpdateType; +import com.hypixel.hytale.protocol.EntityUpdate; +import com.hypixel.hytale.protocol.Equipment; +import com.hypixel.hytale.protocol.ItemArmorSlot; +import com.hypixel.hytale.protocol.ModelTransform; import com.hypixel.hytale.protocol.packets.buildertools.BuilderToolsSetSoundSet; +import com.hypixel.hytale.protocol.packets.entities.EntityUpdates; import com.hypixel.hytale.protocol.packets.inventory.SetActiveSlot; import com.hypixel.hytale.protocol.packets.player.SetBlockPlacementOverride; import com.hypixel.hytale.server.core.Message; import com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig; +import com.hypixel.hytale.server.core.asset.type.gameplay.PlayerConfig; import com.hypixel.hytale.server.core.asset.type.gameplay.SpawnConfig; import com.hypixel.hytale.server.core.asset.type.particle.config.WorldParticle; import com.hypixel.hytale.server.core.entity.Entity; @@ -41,45 +49,52 @@ import com.hypixel.hytale.server.core.entity.entities.player.movement.MovementMa import com.hypixel.hytale.server.core.entity.entities.player.pages.RespawnPage; import com.hypixel.hytale.server.core.entity.nameplate.Nameplate; import com.hypixel.hytale.server.core.inventory.Inventory; +import com.hypixel.hytale.server.core.inventory.ItemStack; +import com.hypixel.hytale.server.core.inventory.container.ItemContainer; import com.hypixel.hytale.server.core.io.PacketHandler; import com.hypixel.hytale.server.core.modules.entity.EntityModule; import com.hypixel.hytale.server.core.modules.entity.component.DisplayNameComponent; +import com.hypixel.hytale.server.core.modules.entity.component.EntityScaleComponent; import com.hypixel.hytale.server.core.modules.entity.component.HeadRotation; +import com.hypixel.hytale.server.core.modules.entity.component.Intangible; +import com.hypixel.hytale.server.core.modules.entity.component.Interactable; +import com.hypixel.hytale.server.core.modules.entity.component.Invulnerable; +import com.hypixel.hytale.server.core.modules.entity.component.ModelComponent; +import com.hypixel.hytale.server.core.modules.entity.component.RespondToHit; import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent; import com.hypixel.hytale.server.core.modules.entity.damage.DeathComponent; import com.hypixel.hytale.server.core.modules.entity.damage.event.KillFeedEvent; import com.hypixel.hytale.server.core.modules.entity.teleport.Teleport; -import com.hypixel.hytale.server.core.modules.entity.tracker.LegacyEntityTrackerSystems; +import com.hypixel.hytale.server.core.modules.entity.tracker.EntityTrackerSystems; +import com.hypixel.hytale.server.core.modules.entity.tracker.NetworkId; +import com.hypixel.hytale.server.core.modules.entitystats.EntityStatMap; +import com.hypixel.hytale.server.core.modules.projectile.component.PredictedProjectile; import com.hypixel.hytale.server.core.universe.PlayerRef; import com.hypixel.hytale.server.core.universe.world.ParticleUtil; import com.hypixel.hytale.server.core.universe.world.PlayerUtil; import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.WorldConfig; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; +import com.hypixel.hytale.server.core.util.PositionUtil; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectList; +import java.util.Arrays; import java.util.List; import java.util.Objects; import java.util.Set; import java.util.logging.Level; import javax.annotation.Nonnull; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class PlayerSystems { @Nonnull public static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); - public PlayerSystems() { - } - public static class BlockPausedMovementSystem implements RunWhenPausedSystem, QuerySystem { @Nonnull private final Query query = Query.and( Player.getComponentType(), PlayerInput.getComponentType(), TransformComponent.getComponentType(), HeadRotation.getComponentType() ); - public BlockPausedMovementSystem() { - } - @Override public void tick(float dt, int systemIndex, @Nonnull Store store) { store.forEachChunk(systemIndex, PlayerSystems.BlockPausedMovementSystem::onTick); @@ -124,13 +139,10 @@ public class PlayerSystems { movementUpdateQueue.clear(); if (shouldTeleport) { - commandBuffer.addComponent( - archetypeChunk.getReferenceTo(index), - Teleport.getComponentType(), - new Teleport(transformComponent.getPosition(), transformComponent.getRotation()) - .withHeadRotation(headRotationComponent.getRotation()) - .withoutVelocityReset() - ); + Teleport teleport = Teleport.createExact(transformComponent.getPosition(), transformComponent.getRotation(), headRotationComponent.getRotation()) + .withoutVelocityReset(); + Ref ref = archetypeChunk.getReferenceTo(index); + commandBuffer.addComponent(ref, Teleport.getComponentType(), teleport); } } } @@ -143,9 +155,6 @@ public class PlayerSystems { } public static class EnsureEffectControllerSystem extends HolderSystem { - public EnsureEffectControllerSystem() { - } - @Override public Query getQuery() { return PlayerRef.getComponentType(); @@ -162,9 +171,6 @@ public class PlayerSystems { } public static class EnsurePlayerInput extends HolderSystem { - public EnsurePlayerInput() { - } - @Override public Query getQuery() { return PlayerRef.getComponentType(); @@ -182,9 +188,6 @@ public class PlayerSystems { } public static class EnsureUniqueItemUsagesSystem extends HolderSystem { - public EnsureUniqueItemUsagesSystem() { - } - @Override public Query getQuery() { return Query.and(PlayerRef.getComponentType(), Query.not(UniqueItemUsagesComponent.getComponentType())); @@ -210,10 +213,10 @@ public class PlayerSystems { public void handle( int index, - @NonNullDecl ArchetypeChunk archetypeChunk, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer, - @NonNullDecl KillFeedEvent.DecedentMessage event + @Nonnull ArchetypeChunk archetypeChunk, + @Nonnull Store store, + @Nonnull CommandBuffer commandBuffer, + @Nonnull KillFeedEvent.DecedentMessage event ) { DisplayNameComponent displayNameComponent = archetypeChunk.getComponent(index, DisplayNameComponent.getComponentType()); Message displayName; @@ -247,10 +250,10 @@ public class PlayerSystems { public void handle( int index, - @NonNullDecl ArchetypeChunk archetypeChunk, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer, - @NonNullDecl KillFeedEvent.KillerMessage event + @Nonnull ArchetypeChunk archetypeChunk, + @Nonnull Store store, + @Nonnull CommandBuffer commandBuffer, + @Nonnull KillFeedEvent.KillerMessage event ) { DisplayNameComponent displayNameComponent = archetypeChunk.getComponent(index, DisplayNameComponent.getComponentType()); Message displayName; @@ -275,9 +278,6 @@ public class PlayerSystems { } public static class NameplateRefChangeSystem extends RefChangeSystem { - public NameplateRefChangeSystem() { - } - @Nonnull @Override public Query getQuery() { @@ -323,9 +323,6 @@ public class PlayerSystems { } public static class NameplateRefSystem extends RefSystem { - public NameplateRefSystem() { - } - @Nonnull @Override public Query getQuery() { @@ -334,10 +331,7 @@ public class PlayerSystems { @Override public void onEntityAdded( - @NonNullDecl Ref ref, - @NonNullDecl AddReason reason, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { DisplayNameComponent displayNameComponent = commandBuffer.getComponent(ref, DisplayNameComponent.getComponentType()); @@ -352,10 +346,7 @@ public class PlayerSystems { @Override public void onEntityRemove( - @NonNullDecl Ref ref, - @NonNullDecl RemoveReason reason, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, @Nonnull RemoveReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { } } @@ -471,16 +462,24 @@ public class PlayerSystems { public void onEntityRemove( @Nonnull Ref ref, @Nonnull RemoveReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { + Player playerComponent = commandBuffer.getComponent(ref, Player.getComponentType()); + + assert playerComponent != null; + + playerComponent.getWindowManager().closeAllWindows(ref, commandBuffer); } } public static class PlayerRemovedSystem extends HolderSystem { - public PlayerRemovedSystem() { - } - @Override public Query getQuery() { - return PlayerRef.getComponentType(); + return Query.and( + PlayerRef.getComponentType(), + Player.getComponentType(), + TransformComponent.getComponentType(), + HeadRotation.getComponentType(), + DisplayNameComponent.getComponentType() + ); } @Override @@ -537,9 +536,6 @@ public class PlayerSystems { } public static class PlayerSpawnedSystem extends RefSystem { - public PlayerSpawnedSystem() { - } - @Nonnull @Override public Query getQuery() { @@ -550,7 +546,7 @@ public class PlayerSystems { public void onEntityAdded( @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { - LegacyEntityTrackerSystems.sendPlayerSelf(ref, store); + sendPlayerSelf(ref, store); } @Override @@ -558,15 +554,158 @@ public class PlayerSystems { @Nonnull Ref ref, @Nonnull RemoveReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { } + + @Deprecated + public static void sendPlayerSelf(@Nonnull Ref viewerRef, @Nonnull Store store) { + EntityTrackerSystems.EntityViewer entityViewerComponent = store.getComponent(viewerRef, EntityTrackerSystems.EntityViewer.getComponentType()); + if (entityViewerComponent == null) { + throw new IllegalArgumentException("Viewer is missing EntityViewer component"); + } else { + NetworkId networkIdComponent = store.getComponent(viewerRef, NetworkId.getComponentType()); + if (networkIdComponent == null) { + throw new IllegalArgumentException("Viewer is missing NetworkId component"); + } else { + Player playerComponent = store.getComponent(viewerRef, Player.getComponentType()); + if (playerComponent == null) { + throw new IllegalArgumentException("Viewer is missing Player component"); + } else { + EntityUpdate entityUpdate = new EntityUpdate(); + entityUpdate.networkId = networkIdComponent.getId(); + ObjectArrayList list = new ObjectArrayList<>(); + Archetype viewerArchetype = store.getArchetype(viewerRef); + if (viewerArchetype.contains(Interactable.getComponentType())) { + ComponentUpdate update = new ComponentUpdate(); + update.type = ComponentUpdateType.Interactable; + list.add(update); + } + + if (viewerArchetype.contains(Intangible.getComponentType())) { + ComponentUpdate update = new ComponentUpdate(); + update.type = ComponentUpdateType.Intangible; + list.add(update); + } + + if (viewerArchetype.contains(Invulnerable.getComponentType())) { + ComponentUpdate update = new ComponentUpdate(); + update.type = ComponentUpdateType.Invulnerable; + list.add(update); + } + + if (viewerArchetype.contains(RespondToHit.getComponentType())) { + ComponentUpdate update = new ComponentUpdate(); + update.type = ComponentUpdateType.RespondToHit; + list.add(update); + } + + Nameplate nameplateComponent = store.getComponent(viewerRef, Nameplate.getComponentType()); + if (nameplateComponent != null) { + ComponentUpdate update = new ComponentUpdate(); + update.type = ComponentUpdateType.Nameplate; + update.nameplate = new com.hypixel.hytale.protocol.Nameplate(); + update.nameplate.text = nameplateComponent.getText(); + list.add(update); + } + + PredictedProjectile predictionComponent = store.getComponent(viewerRef, PredictedProjectile.getComponentType()); + if (predictionComponent != null) { + ComponentUpdate update = new ComponentUpdate(); + update.type = ComponentUpdateType.Prediction; + update.predictionId = predictionComponent.getUuid(); + list.add(update); + } + + ModelComponent modelComponent = store.getComponent(viewerRef, ModelComponent.getComponentType()); + ComponentUpdate update = new ComponentUpdate(); + update.type = ComponentUpdateType.Model; + update.model = modelComponent != null ? modelComponent.getModel().toPacket() : null; + EntityScaleComponent entityScaleComponent = store.getComponent(viewerRef, EntityScaleComponent.getComponentType()); + if (entityScaleComponent != null) { + update.entityScale = entityScaleComponent.getScale(); + } + + list.add(update); + update = new ComponentUpdate(); + update.type = ComponentUpdateType.PlayerSkin; + PlayerSkinComponent playerSkinComponent = store.getComponent(viewerRef, PlayerSkinComponent.getComponentType()); + update.skin = playerSkinComponent != null ? playerSkinComponent.getPlayerSkin() : null; + list.add(update); + Inventory inventory = playerComponent.getInventory(); + ComponentUpdate updatex = new ComponentUpdate(); + updatex.type = ComponentUpdateType.Equipment; + updatex.equipment = new Equipment(); + ItemContainer armor = inventory.getArmor(); + updatex.equipment.armorIds = new String[armor.getCapacity()]; + Arrays.fill(updatex.equipment.armorIds, ""); + armor.forEachWithMeta((slot, itemStack, armorIds) -> armorIds[slot] = itemStack.getItemId(), updatex.equipment.armorIds); + PlayerSettings playerSettingsComponent = store.getComponent(viewerRef, PlayerSettings.getComponentType()); + if (playerSettingsComponent != null) { + PlayerConfig.ArmorVisibilityOption armorVisibilityOption = store.getExternalData() + .getWorld() + .getGameplayConfig() + .getPlayerConfig() + .getArmorVisibilityOption(); + if (armorVisibilityOption.canHideHelmet() && playerSettingsComponent.hideHelmet()) { + updatex.equipment.armorIds[ItemArmorSlot.Head.ordinal()] = ""; + } + + if (armorVisibilityOption.canHideCuirass() && playerSettingsComponent.hideCuirass()) { + updatex.equipment.armorIds[ItemArmorSlot.Chest.ordinal()] = ""; + } + + if (armorVisibilityOption.canHideGauntlets() && playerSettingsComponent.hideGauntlets()) { + updatex.equipment.armorIds[ItemArmorSlot.Hands.ordinal()] = ""; + } + + if (armorVisibilityOption.canHidePants() && playerSettingsComponent.hidePants()) { + updatex.equipment.armorIds[ItemArmorSlot.Legs.ordinal()] = ""; + } + } + + ItemStack itemInHand = inventory.getItemInHand(); + updatex.equipment.rightHandItemId = itemInHand != null ? itemInHand.getItemId() : "Empty"; + ItemStack utilityItem = inventory.getUtilityItem(); + updatex.equipment.leftHandItemId = utilityItem != null ? utilityItem.getItemId() : "Empty"; + list.add(updatex); + TransformComponent transformComponent = store.getComponent(viewerRef, TransformComponent.getComponentType()); + HeadRotation headRotationComponent = store.getComponent(viewerRef, HeadRotation.getComponentType()); + if (transformComponent != null && headRotationComponent != null) { + ComponentUpdate updatexx = new ComponentUpdate(); + updatexx.type = ComponentUpdateType.Transform; + updatexx.transform = new ModelTransform(); + updatexx.transform.position = PositionUtil.toPositionPacket(transformComponent.getPosition()); + updatexx.transform.bodyOrientation = PositionUtil.toDirectionPacket(transformComponent.getRotation()); + updatexx.transform.lookOrientation = PositionUtil.toDirectionPacket(headRotationComponent.getRotation()); + list.add(updatexx); + } + + EffectControllerComponent effectControllerComponent = store.getComponent(viewerRef, EffectControllerComponent.getComponentType()); + if (effectControllerComponent != null) { + ComponentUpdate updatexx = new ComponentUpdate(); + updatexx.type = ComponentUpdateType.EntityEffects; + updatexx.entityEffectUpdates = effectControllerComponent.createInitUpdates(); + list.add(updatexx); + } + + EntityStatMap statMapComponent = store.getComponent(viewerRef, EntityStatMap.getComponentType()); + if (statMapComponent != null) { + ComponentUpdate updatexx = new ComponentUpdate(); + updatexx.type = ComponentUpdateType.EntityStats; + updatexx.entityStatUpdates = statMapComponent.createInitUpdate(true); + list.add(updatexx); + } + + entityUpdate.updates = list.toArray(ComponentUpdate[]::new); + entityViewerComponent.packetReceiver.writeNoCache(new EntityUpdates(null, new EntityUpdate[]{entityUpdate})); + } + } + } + } } public static class ProcessPlayerInput extends EntityTickingSystem { @Nonnull private final Query query = Query.and(Player.getComponentType(), PlayerInput.getComponentType(), TransformComponent.getComponentType()); - public ProcessPlayerInput() { - } - @Nonnull @Override public Query getQuery() { @@ -599,9 +738,6 @@ public class PlayerSystems { @Nonnull private final Query query = Query.and(PlayerRef.getComponentType(), TransformComponent.getComponentType(), HeadRotation.getComponentType()); - public UpdatePlayerRef() { - } - @Nonnull @Override public Query getQuery() { @@ -612,9 +748,9 @@ public class PlayerSystems { public void tick( float dt, int index, - @NonNullDecl ArchetypeChunk archetypeChunk, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull ArchetypeChunk archetypeChunk, + @Nonnull Store store, + @Nonnull CommandBuffer commandBuffer ) { World world = commandBuffer.getExternalData().getWorld(); TransformComponent transformComponent = archetypeChunk.getComponent(index, TransformComponent.getComponentType()); diff --git a/src/com/hypixel/hytale/server/core/modules/entity/repulsion/RepulsionConfigPacketGenerator.java b/src/com/hypixel/hytale/server/core/modules/entity/repulsion/RepulsionConfigPacketGenerator.java index f1198bb..564304a 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/repulsion/RepulsionConfigPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/repulsion/RepulsionConfigPacketGenerator.java @@ -14,9 +14,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class RepulsionConfigPacketGenerator extends AssetPacketGenerator> { - public RepulsionConfigPacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedLookupTableAssetMap assetMap, @Nonnull Map assets) { Int2ObjectMap repulsionConfigs = new Int2ObjectOpenHashMap<>(); diff --git a/src/com/hypixel/hytale/server/core/modules/entity/repulsion/RepulsionSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/repulsion/RepulsionSystems.java index f1c5d17..e5f7359 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/repulsion/RepulsionSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/repulsion/RepulsionSystems.java @@ -40,9 +40,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class RepulsionSystems { - public RepulsionSystems() { - } - public static class EntityTrackerRemove extends RefChangeSystem { private final ComponentType componentType; private final ComponentType visibleComponentType; @@ -257,33 +254,31 @@ public class RepulsionSystems { spatialResource.getSpatialStructure().ordered(transformComponent.getPosition(), radius, results); for (Ref entityRef : results) { - TransformComponent entityTransformComponent = store.getComponent(entityRef, this.transformComponentComponentType); + TransformComponent entityTransformComponent = commandBuffer.getComponent(entityRef, this.transformComponentComponentType); + if (entityTransformComponent != null) { + Vector2d entityPosition = new Vector2d(entityTransformComponent.getPosition().x, entityTransformComponent.getPosition().z); + if (!entityPosition.equals(position)) { + double distance = position.distanceTo(entityPosition); + if (!(distance < 0.1)) { + double fraction = (radius - distance) / radius; + float maxForce = repulsion.maxForce; + int flip = 1; + if (maxForce < 0.0F) { + flip = -1; + maxForce *= flip; + } - assert entityTransformComponent != null; - - Vector2d entityPosition = new Vector2d(entityTransformComponent.getPosition().x, entityTransformComponent.getPosition().z); - if (!entityPosition.equals(position)) { - double distance = position.distanceTo(entityPosition); - if (!(distance < 0.1)) { - double fraction = (radius - distance) / radius; - float maxForce = repulsion.maxForce; - int flip = 1; - if (maxForce < 0.0F) { - flip = -1; - maxForce *= flip; + double force = Math.max((double)repulsion.minForce, maxForce * fraction); + force *= flip; + Vector2d push = entityPosition.subtract(position); + push.normalize(); + push.scale(force); + Velocity entityVelocityComponent = commandBuffer.getComponent(entityRef, Velocity.getComponentType()); + if (entityVelocityComponent != null) { + Vector3d addedVelocity = new Vector3d((float)push.x, 0.0, (float)push.y); + entityVelocityComponent.addInstruction(addedVelocity, null, ChangeVelocityType.Add); + } } - - double force = Math.max((double)repulsion.minForce, maxForce * fraction); - force *= flip; - Vector2d push = entityPosition.subtract(position); - push.normalize(); - push.scale(force); - Velocity entityVelocityComponent = commandBuffer.getComponent(entityRef, Velocity.getComponentType()); - - assert entityVelocityComponent != null; - - Vector3d addedVelocity = new Vector3d((float)push.x, 0.0, (float)push.y); - entityVelocityComponent.addInstruction(addedVelocity, null, ChangeVelocityType.Add); } } } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/stamina/StaminaGameplayConfig.java b/src/com/hypixel/hytale/server/core/modules/entity/stamina/StaminaGameplayConfig.java index 19c2425..bed8a0c 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/stamina/StaminaGameplayConfig.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/stamina/StaminaGameplayConfig.java @@ -22,9 +22,6 @@ public class StaminaGameplayConfig { .build(); protected StaminaGameplayConfig.SprintRegenDelayConfig sprintRegenDelay; - public StaminaGameplayConfig() { - } - @Nonnull public StaminaGameplayConfig.SprintRegenDelayConfig getSprintRegenDelay() { return this.sprintRegenDelay; @@ -65,9 +62,6 @@ public class StaminaGameplayConfig { protected int statIndex; protected float statValue; - public SprintRegenDelayConfig() { - } - public int getIndex() { return this.statIndex; } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/stamina/StaminaSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/stamina/StaminaSystems.java index 955eb95..4e29bb7 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/stamina/StaminaSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/stamina/StaminaSystems.java @@ -22,9 +22,6 @@ import java.util.Set; import javax.annotation.Nonnull; public class StaminaSystems { - public StaminaSystems() { - } - public static class SprintStaminaEffectSystem extends EntityTickingSystem { private final ComponentType playerComponentType = Player.getComponentType(); private final ComponentType entityStatMapComponentType = EntityStatMap.getComponentType(); @@ -36,9 +33,6 @@ public class StaminaSystems { new SystemDependency<>(Order.BEFORE, EntityStatsModule.PlayerRegenerateStatsSystem.class) ); - public SprintStaminaEffectSystem() { - } - @Nonnull @Override public Query getQuery() { diff --git a/src/com/hypixel/hytale/server/core/modules/entity/system/AudioSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/system/AudioSystems.java index 8624fdc..f07c17e 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/system/AudioSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/system/AudioSystems.java @@ -31,17 +31,11 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class AudioSystems { - public AudioSystems() { - } - public static class EntityTrackerUpdate extends EntityTickingSystem { private final ComponentType visibleComponentType = EntityTrackerSystems.Visible.getComponentType(); private final ComponentType audioComponentType = AudioComponent.getComponentType(); private final Query query = Query.and(this.visibleComponentType, this.audioComponentType); - public EntityTrackerUpdate() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -97,9 +91,6 @@ public class AudioSystems { } public static class TickMovementAudio extends EntityTickingSystem { - public TickMovementAudio() { - } - @Nonnull @Override public Query getQuery() { diff --git a/src/com/hypixel/hytale/server/core/modules/entity/system/EntityInteractableSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/system/EntityInteractableSystems.java index 994acaa..6ecc671 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/system/EntityInteractableSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/system/EntityInteractableSystems.java @@ -24,9 +24,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class EntityInteractableSystems { - public EntityInteractableSystems() { - } - public static class EntityTrackerAddAndRemove extends RefChangeSystem { private final ComponentType interactableComponentType = Interactable.getComponentType(); private final ComponentType visibleComponentType; @@ -137,9 +134,6 @@ public class EntityInteractableSystems { public static class QueueResource implements Resource { private final Set> queue = ConcurrentHashMap.newKeySet(); - public QueueResource() { - } - public static ResourceType getResourceType() { return EntityModule.get().getInteractableQueueResourceType(); } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/system/EntitySystems.java b/src/com/hypixel/hytale/server/core/modules/entity/system/EntitySystems.java index 942a370..f58da52 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/system/EntitySystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/system/EntitySystems.java @@ -40,9 +40,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class EntitySystems { - public EntitySystems() { - } - public static class ClearFromPrefabMarker extends EntitySystems.ClearMarker { public ClearFromPrefabMarker(@Nonnull ComponentType componentType, @Nonnull SystemGroup preGroup) { super(componentType, preGroup); @@ -177,9 +174,6 @@ public class EntitySystems { @Nonnull private final Query query = Query.and(this.visibleComponentType, this.newSpawnComponentType); - public NewSpawnEntityTrackerUpdate() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -229,9 +223,6 @@ public class EntitySystems { @Nonnull private final ComponentType newSpawnComponentType = NewSpawnComponent.getComponentType(); - public NewSpawnTick() { - } - @Nonnull @Override public Query getQuery() { @@ -310,9 +301,6 @@ public class EntitySystems { } public static class UnloadEntityFromChunk extends RefSystem { - public UnloadEntityFromChunk() { - } - @Override public Query getQuery() { return TransformComponent.getComponentType(); diff --git a/src/com/hypixel/hytale/server/core/modules/entity/system/HideEntitySystems.java b/src/com/hypixel/hytale/server/core/modules/entity/system/HideEntitySystems.java index 212c4dd..15ac9dc 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/system/HideEntitySystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/system/HideEntitySystems.java @@ -25,9 +25,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class HideEntitySystems { - public HideEntitySystems() { - } - public static class AdventurePlayerSystem extends EntityTickingSystem { @Nonnull private final ComponentType entityViewerComponentType = EntityTrackerSystems.EntityViewer.getComponentType(); @@ -44,9 +41,6 @@ public class HideEntitySystems { new SystemDependency<>(Order.AFTER, EntityTrackerSystems.CollectVisible.class) ); - public AdventurePlayerSystem() { - } - @Nullable @Override public SystemGroup getGroup() { diff --git a/src/com/hypixel/hytale/server/core/modules/entity/system/IntangibleSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/system/IntangibleSystems.java index 6189e18..ca4b739 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/system/IntangibleSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/system/IntangibleSystems.java @@ -24,9 +24,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class IntangibleSystems { - public IntangibleSystems() { - } - public static class EntityTrackerAddAndRemove extends RefChangeSystem { private final ComponentType intangibleComponentType = Intangible.getComponentType(); private final ComponentType visibleComponentType; @@ -137,9 +134,6 @@ public class IntangibleSystems { public static class QueueResource implements Resource { private final Set> queue = ConcurrentHashMap.newKeySet(); - public QueueResource() { - } - public static ResourceType getResourceType() { return EntityModule.get().getIntangibleQueueResourceType(); } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/system/InvulnerableSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/system/InvulnerableSystems.java index f11e705..3222484 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/system/InvulnerableSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/system/InvulnerableSystems.java @@ -24,9 +24,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class InvulnerableSystems { - public InvulnerableSystems() { - } - public static class EntityTrackerAddAndRemove extends RefChangeSystem { private final ComponentType invulnerableComponentType = Invulnerable.getComponentType(); private final ComponentType visibleComponentType; @@ -137,9 +134,6 @@ public class InvulnerableSystems { public static class QueueResource implements Resource { private final Set> queue = ConcurrentHashMap.newKeySet(); - public QueueResource() { - } - public static ResourceType getResourceType() { return EntityModule.get().getInvulnerableQueueResourceType(); } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/system/ModelSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/system/ModelSystems.java index cf42c5e..cb4cf94 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/system/ModelSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/system/ModelSystems.java @@ -50,17 +50,11 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class ModelSystems { - public ModelSystems() { - } - public static class AnimationEntityTrackerUpdate extends EntityTickingSystem { private final ComponentType visibleComponentType = EntityTrackerSystems.Visible.getComponentType(); private final ComponentType activeAnimationComponentType = ActiveAnimationComponent.getComponentType(); private final Query query = Query.and(this.visibleComponentType, this.activeAnimationComponentType); - public AnimationEntityTrackerUpdate() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -122,9 +116,6 @@ public class ModelSystems { private final ComponentType randomSkinComponent = ApplyRandomSkinPersistedComponent.getComponentType(); private final Query query = Query.and(this.randomSkinComponent, this.modelComponentType); - public ApplyRandomSkin() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { PlayerSkin playerSkin = CosmeticsModule.get().generateRandomSkin(RandomUtil.getSecureRandom()); @@ -147,9 +138,6 @@ public class ModelSystems { private final ComponentType networkIdComponentType = NetworkId.getComponentType(); private final Query query = Query.and(this.propComponentType, Query.not(this.networkIdComponentType)); - public AssignNetworkIdToProps() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { holder.addComponent(this.networkIdComponentType, new NetworkId(store.getExternalData().takeNextNetworkId())); @@ -169,9 +157,6 @@ public class ModelSystems { public static class EnsurePropsPrefabCopyable extends HolderSystem { private final ComponentType propComponentType = PropComponent.getComponentType(); - public EnsurePropsPrefabCopyable() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { holder.ensureComponent(PrefabCopyableComponent.getComponentType()); @@ -192,9 +177,6 @@ public class ModelSystems { private final ComponentType modelComponentType = ModelComponent.getComponentType(); private final ComponentType persistentModelComponentType = PersistentModel.getComponentType(); - public ModelChange() { - } - @Override public Query getQuery() { return this.persistentModelComponentType; @@ -234,9 +216,6 @@ public class ModelSystems { private final ComponentType boundingBoxComponentType = BoundingBox.getComponentType(); private final Set> dependencies = Set.of(new SystemDependency<>(Order.AFTER, ModelSystems.SetRenderedModel.class)); - public ModelSpawned() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { Model model = holder.getComponent(this.modelComponentType).getModel(); @@ -275,9 +254,6 @@ public class ModelSystems { private final Query query = Query.and(this.playerComponentType, Query.not(this.modelComponentType)); private final Set> dependencies = Set.of(new SystemDependency<>(Order.BEFORE, ModelSystems.ModelSpawned.class)); - public PlayerConnect() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { Player player = holder.getComponent(this.playerComponentType); @@ -316,15 +292,13 @@ public class ModelSystems { public static class PlayerUpdateMovementManager extends RefChangeSystem { private final ComponentType modelComponentType = ModelComponent.getComponentType(); private final ComponentType playerComponentType = Player.getComponentType(); + private final Query query = Query.and(this.playerComponentType, MovementManager.getComponentType()); private final Set> dependencies = Set.of(new SystemDependency<>(Order.AFTER, ModelSystems.UpdateBoundingBox.class)); - public PlayerUpdateMovementManager() { - } - @Nonnull @Override public Query getQuery() { - return this.playerComponentType; + return this.query; } @Nonnull @@ -375,9 +349,6 @@ public class ModelSystems { private final ComponentType persistentModelComponentType = PersistentModel.getComponentType(); private final Query query = Query.and(this.persistentModelComponentType, Query.not(this.modelComponentType)); - public SetRenderedModel() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { PersistentModel persistentModel = holder.getComponent(this.persistentModelComponentType); @@ -400,9 +371,6 @@ public class ModelSystems { private final ComponentType boundingBoxComponentType = BoundingBox.getComponentType(); private final ComponentType movementStatesComponentType = MovementStatesComponent.getComponentType(); - public UpdateBoundingBox() { - } - @Override public Query getQuery() { return this.boundingBoxComponentType; @@ -463,9 +431,6 @@ public class ModelSystems { private final ComponentType modelComponentType = ModelComponent.getComponentType(); private final Query query = Query.and(this.movementStatesComponentType, this.boundingBoxComponentType, this.modelComponentType); - public UpdateCrouchingBoundingBox() { - } - @Override public boolean isParallel(int archetypeChunkSize, int taskCount) { return EntityTickingSystem.maybeUseParallel(archetypeChunkSize, taskCount); diff --git a/src/com/hypixel/hytale/server/core/modules/entity/system/RespondToHitSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/system/RespondToHitSystems.java index 44fdaa2..5872654 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/system/RespondToHitSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/system/RespondToHitSystems.java @@ -25,13 +25,8 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; public class RespondToHitSystems { - public RespondToHitSystems() { - } - public static class EntityTrackerAddAndRemove extends RefChangeSystem { private final ComponentType respondToHitComponentType = RespondToHit.getComponentType(); private final ComponentType visibleComponentType; @@ -140,20 +135,14 @@ public class RespondToHitSystems { } public static class OnPlayerSettingsChange extends RefChangeSystem { - public OnPlayerSettingsChange() { - } - - @NonNullDecl + @Nonnull @Override public ComponentType componentType() { return PlayerSettings.getComponentType(); } public void onComponentAdded( - @NonNullDecl Ref ref, - @NonNullDecl PlayerSettings component, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, @Nonnull PlayerSettings component, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { Player player = commandBuffer.getComponent(ref, Player.getComponentType()); if (player.getGameMode() == GameMode.Creative) { @@ -166,11 +155,11 @@ public class RespondToHitSystems { } public void onComponentSet( - @NonNullDecl Ref ref, - @NullableDecl PlayerSettings oldComponent, - @NonNullDecl PlayerSettings newComponent, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, + @Nullable PlayerSettings oldComponent, + @Nonnull PlayerSettings newComponent, + @Nonnull Store store, + @Nonnull CommandBuffer commandBuffer ) { Player player = commandBuffer.getComponent(ref, Player.getComponentType()); if (player.getGameMode() == GameMode.Creative) { @@ -183,14 +172,11 @@ public class RespondToHitSystems { } public void onComponentRemoved( - @NonNullDecl Ref ref, - @NonNullDecl PlayerSettings component, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer + @Nonnull Ref ref, @Nonnull PlayerSettings component, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { } - @NullableDecl + @Nullable @Override public Query getQuery() { return Player.getComponentType(); @@ -200,9 +186,6 @@ public class RespondToHitSystems { public static class QueueResource implements Resource { private final Set> queue = ConcurrentHashMap.newKeySet(); - public QueueResource() { - } - public static ResourceType getResourceType() { return EntityModule.get().getRespondToHitQueueResourceType(); } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/system/RotateObjectSystem.java b/src/com/hypixel/hytale/server/core/modules/entity/system/RotateObjectSystem.java index 6d1f2d2..1b9e448 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/system/RotateObjectSystem.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/system/RotateObjectSystem.java @@ -28,7 +28,7 @@ public class RotateObjectSystem extends EntityTickingSystem { @Override public Query getQuery() { - return this.rotateObjectComponentType; + return Query.and(this.rotateObjectComponentType, this.transformComponentType); } @Override @@ -39,14 +39,14 @@ public class RotateObjectSystem extends EntityTickingSystem { @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { - TransformComponent transformComponent = archetypeChunk.getComponent(index, this.transformComponentType); - - assert transformComponent != null; - RotateObjectComponent rotateObjectComponent = archetypeChunk.getComponent(index, this.rotateObjectComponentType); assert rotateObjectComponent != null; + TransformComponent transformComponent = archetypeChunk.getComponent(index, this.transformComponentType); + + assert transformComponent != null; + Vector3f rotation = transformComponent.getRotation(); rotation.y = rotation.y + rotateObjectComponent.getRotationSpeed() * dt; if (rotation.y >= 360.0F) { diff --git a/src/com/hypixel/hytale/server/core/modules/entity/system/SnapshotSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/system/SnapshotSystems.java index 51cec60..266eb25 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/system/SnapshotSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/system/SnapshotSystems.java @@ -30,13 +30,7 @@ public class SnapshotSystems { public static long HISTORY_LENGTH_NS = TimeUnit.MILLISECONDS.toNanos(500L); private static final HytaleLogger LOGGER = HytaleLogger.getLogger(); - public SnapshotSystems() { - } - public static class Add extends HolderSystem { - public Add() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { SnapshotBuffer buffer = holder.ensureAndGetComponent(SnapshotBuffer.getComponentType()); @@ -60,9 +54,6 @@ public class SnapshotSystems { @Nonnull private final Query query = Query.and(TransformComponent.getComponentType(), SnapshotBuffer.getComponentType()); - public Capture() { - } - @Override public void tick(float dt, int systemIndex, @Nonnull Store store) { SnapshotSystems.SnapshotWorldInfo info = store.getResource(SnapshotSystems.SnapshotWorldInfo.getResourceType()); @@ -103,9 +94,6 @@ public class SnapshotSystems { } public static class Resize extends EntityTickingSystem { - public Resize() { - } - @Nonnull @Override public Set> getDependencies() { diff --git a/src/com/hypixel/hytale/server/core/modules/entity/system/TransformSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/system/TransformSystems.java index 8b7cb6f..9b011a3 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/system/TransformSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/system/TransformSystems.java @@ -30,9 +30,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class TransformSystems { - public TransformSystems() { - } - public static class EntityTrackerUpdate extends EntityTickingSystem { @Nonnull private final ComponentType visibleComponentType = EntityTrackerSystems.Visible.getComponentType(); @@ -43,9 +40,6 @@ public class TransformSystems { @Nonnull private final Query query = Query.and(this.visibleComponentType, this.transformComponentType); - public EntityTrackerUpdate() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -121,9 +115,6 @@ public class TransformSystems { @Nonnull private final ComponentType transformComponentType = TransformComponent.getComponentType(); - public OnRemove() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/system/UpdateLocationSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/system/UpdateLocationSystems.java index 1bc70d1..3b70255 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/system/UpdateLocationSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/system/UpdateLocationSystems.java @@ -38,9 +38,6 @@ public class UpdateLocationSystems { @Nonnull private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); - public UpdateLocationSystems() { - } - private static void updateLocation( @Nonnull Ref ref, @Nonnull TransformComponent transformComponent, @Nullable World world, @Nonnull CommandBuffer commandBuffer ) { @@ -139,14 +136,14 @@ public class UpdateLocationSystems { } else { LOGGER.at(Level.SEVERE).log("Player is in a chunk that can't be loaded! Moving (-%d,0,0)! %s", 32, transformComponent); Vector3d position = transformComponent.getPosition(); - Vector3f bodyRotation = transformComponent.getRotation(); Vector3d targetPosition = position.clone().subtract(32.0, 0.0, 0.0); + Vector3f bodyRotation = transformComponent.getRotation(); + Teleport teleportComponent = Teleport.createForPlayer(targetPosition, bodyRotation); + entityComponentAccessor.addComponent(ref, Teleport.getComponentType(), teleportComponent); PlayerRef playerRefComponent = entityComponentAccessor.getComponent(ref, PlayerRef.getComponentType()); - - assert playerRefComponent != null; - - entityComponentAccessor.addComponent(ref, Teleport.getComponentType(), new Teleport(targetPosition, bodyRotation)); - playerRefComponent.sendMessage(MESSAGE_GENERAL_PLAYER_IN_INVALID_CHUNK); + if (playerRefComponent != null) { + playerRefComponent.sendMessage(MESSAGE_GENERAL_PLAYER_IN_INVALID_CHUNK); + } } } @@ -180,9 +177,6 @@ public class UpdateLocationSystems { } public static class SpawnSystem extends RefSystem { - public SpawnSystem() { - } - @Override public Query getQuery() { return TransformComponent.getComponentType(); @@ -210,9 +204,6 @@ public class UpdateLocationSystems { } public static class TickingSystem extends EntityTickingSystem { - public TickingSystem() { - } - @Override public Query getQuery() { return TransformComponent.getComponentType(); diff --git a/src/com/hypixel/hytale/server/core/modules/entity/teleport/PendingTeleport.java b/src/com/hypixel/hytale/server/core/modules/entity/teleport/PendingTeleport.java index e1ec871..aaa4d9f 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/teleport/PendingTeleport.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/teleport/PendingTeleport.java @@ -19,9 +19,6 @@ public class PendingTeleport implements Component { private int nextTeleportId = 0; private int lastTeleportId = 0; - public PendingTeleport() { - } - public static ComponentType getComponentType() { return EntityModule.get().getPendingTeleportComponentType(); } @@ -62,8 +59,5 @@ public class PendingTeleport implements Component { OK, INVALID_ID, INVALID_POSITION; - - private Result() { - } } } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/teleport/Teleport.java b/src/com/hypixel/hytale/server/core/modules/entity/teleport/Teleport.java index bf9e5df..b39e3ca 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/teleport/Teleport.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/teleport/Teleport.java @@ -27,20 +27,12 @@ public class Teleport implements Component { return EntityModule.get().getTeleportComponentType(); } - public Teleport(@Nullable World world, @Nonnull Transform transform) { - this(world, transform.getPosition(), transform.getRotation()); - } - public Teleport(@Nullable World world, @Nonnull Vector3d position, @Nonnull Vector3f rotation) { this.world = world; this.position.assign(position); this.rotation.assign(rotation); } - public Teleport(@Nonnull Transform transform) { - this(null, transform.getPosition(), transform.getRotation()); - } - public Teleport(@Nonnull Vector3d position, @Nonnull Vector3f rotation) { this.world = null; this.position.assign(position); @@ -48,13 +40,50 @@ public class Teleport implements Component { } @Nonnull - public Teleport withHeadRotation(@Nonnull Vector3f headRotation) { - this.headRotation = headRotation; - return this; + public static Teleport createForPlayer(@Nullable World world, @Nonnull Transform transform) { + Vector3f headRotation = transform.getRotation(); + Vector3f bodyRotation = new Vector3f(0.0F, headRotation.getYaw(), 0.0F); + return new Teleport(world, transform.getPosition(), bodyRotation).setHeadRotation(headRotation); } - public Teleport withResetRoll() { - this.rotation.setRoll(0.0F); + @Nonnull + public static Teleport createForPlayer(@Nullable World world, @Nonnull Vector3d position, @Nonnull Vector3f rotation) { + Vector3f headRotation = rotation.clone(); + Vector3f bodyRotation = new Vector3f(0.0F, headRotation.getYaw(), 0.0F); + return new Teleport(world, position, bodyRotation).setHeadRotation(headRotation); + } + + @Nonnull + public static Teleport createForPlayer(@Nonnull Vector3d position, @Nonnull Vector3f rotation) { + return createForPlayer(null, position, rotation); + } + + @Nonnull + public static Teleport createForPlayer(@Nonnull Transform transform) { + return createForPlayer(null, transform); + } + + @Nonnull + public static Teleport createExact(@Nonnull Vector3d position, @Nonnull Vector3f bodyRotation, @Nonnull Vector3f headRotation) { + return new Teleport(position, bodyRotation).setHeadRotation(headRotation); + } + + @Nonnull + public static Teleport createExact(@Nonnull Vector3d position, @Nonnull Vector3f bodyRotation) { + return new Teleport(position, bodyRotation); + } + + public void setPosition(@Nonnull Vector3d position) { + this.position.assign(position); + } + + public void setRotation(@Nonnull Vector3f rotation) { + this.rotation.assign(rotation); + } + + @Nonnull + public Teleport setHeadRotation(@Nonnull Vector3f headRotation) { + this.headRotation = headRotation.clone(); return this; } diff --git a/src/com/hypixel/hytale/server/core/modules/entity/teleport/TeleportRecord.java b/src/com/hypixel/hytale/server/core/modules/entity/teleport/TeleportRecord.java new file mode 100644 index 0000000..d9f7f34 --- /dev/null +++ b/src/com/hypixel/hytale/server/core/modules/entity/teleport/TeleportRecord.java @@ -0,0 +1,51 @@ +package com.hypixel.hytale.server.core.modules.entity.teleport; + +import com.hypixel.hytale.component.Component; +import com.hypixel.hytale.component.ComponentType; +import com.hypixel.hytale.math.vector.Location; +import com.hypixel.hytale.server.core.modules.entity.EntityModule; +import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; +import java.time.Duration; +import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.compatqual.NullableDecl; + +public class TeleportRecord implements Component { + private TeleportRecord.Entry lastTeleport; + + public static ComponentType getComponentType() { + return EntityModule.get().getTeleportRecordComponentType(); + } + + @Nullable + public TeleportRecord.Entry getLastTeleport() { + return this.lastTeleport; + } + + public void setLastTeleport(TeleportRecord.Entry lastTeleport) { + this.lastTeleport = lastTeleport; + } + + public boolean hasElapsedSinceLastTeleport(Duration duration) { + return this.hasElapsedSinceLastTeleport(System.nanoTime(), duration); + } + + public boolean hasElapsedSinceLastTeleport(long nowNanos, Duration duration) { + if (this.lastTeleport == null) { + return true; + } else { + long elapsedNanos = nowNanos - this.lastTeleport.timestampNanos(); + return elapsedNanos >= duration.toNanos(); + } + } + + @NullableDecl + @Override + public Component clone() { + TeleportRecord clone = new TeleportRecord(); + clone.lastTeleport = this.lastTeleport; + return clone; + } + + public record Entry(Location origin, Location destination, long timestampNanos) { + } +} diff --git a/src/com/hypixel/hytale/server/core/modules/entity/teleport/TeleportSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/teleport/TeleportSystems.java index 30332ec..a0fc099 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/teleport/TeleportSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/teleport/TeleportSystems.java @@ -9,6 +9,7 @@ import com.hypixel.hytale.component.RemoveReason; import com.hypixel.hytale.component.Store; import com.hypixel.hytale.component.query.Query; import com.hypixel.hytale.component.system.RefChangeSystem; +import com.hypixel.hytale.math.vector.Location; import com.hypixel.hytale.math.vector.Transform; import com.hypixel.hytale.math.vector.Vector3d; import com.hypixel.hytale.math.vector.Vector3f; @@ -25,9 +26,6 @@ import com.hypixel.hytale.server.core.util.PositionUtil; import javax.annotation.Nonnull; public class TeleportSystems { - public TeleportSystems() { - } - public static class MoveSystem extends RefChangeSystem { @Nonnull private final ComponentType teleportComponentType = Teleport.getComponentType(); @@ -38,9 +36,6 @@ public class TeleportSystems { @Nonnull private final Query query = Query.and(this.teleportComponentType, this.transformComponentType, Query.not(PlayerRef.getComponentType())); - public MoveSystem() { - } - @Nonnull @Override public Query getQuery() { @@ -105,9 +100,6 @@ public class TeleportSystems { @Nonnull private final Query query = Query.and(this.playerComponentType, this.transformComponentType); - public PlayerMoveCompleteSystem() { - } - @Nonnull @Override public Query getQuery() { @@ -178,9 +170,6 @@ public class TeleportSystems { this.teleportComponentType, this.playerRefComponentType, this.transformComponentType, this.playerComponentType ); - public PlayerMoveSystem() { - } - @Nonnull @Override public Query getQuery() { @@ -226,7 +215,13 @@ public class TeleportSystems { assert playerRefComponent != null; commandBuffer.removeComponent(ref, this.teleportComponentType); + TransformComponent transformComponent = commandBuffer.getComponent(ref, this.transformComponentType); + String originWorldName = commandBuffer.getExternalData().getWorld().getName(); + Location origin = new Location(originWorldName, transformComponent.getTransform().clone()); + Location destination = new Location(targetWorld.getName(), teleport.getPosition().clone(), teleport.getRotation().clone()); commandBuffer.run(s -> { + TeleportRecord teleportRecord = s.ensureAndGetComponent(ref, TeleportRecord.getComponentType()); + teleportRecord.setLastTeleport(new TeleportRecord.Entry(origin, destination, System.nanoTime())); playerRefComponent.removeFromStore(); targetWorld.addPlayer(playerRefComponent, new Transform(teleport.getPosition(), teleport.getRotation())); }); @@ -256,7 +251,12 @@ public class TeleportSystems { headRotationComponent.teleportRotation(teleportHeadRotation != null ? teleportHeadRotation : teleportRotation); } - playerComponent.getWindowManager().validateWindows(); + TeleportRecord teleportHistory = commandBuffer.ensureAndGetComponent(ref, TeleportRecord.getComponentType()); + World world = commandBuffer.getExternalData().getWorld(); + Location origin = new Location(world.getName(), teleportPosition.clone(), teleportRotation.clone()); + Location destination = new Location(world.getName(), teleportPosition.clone(), teleportRotation.clone()); + teleportHistory.setLastTeleport(new TeleportRecord.Entry(origin, destination, System.nanoTime())); + playerComponent.getWindowManager().validateWindows(ref, commandBuffer); int id = pendingTeleportComponent.queueTeleport(teleport); ClientTeleport teleportPacket = new ClientTeleport( (byte)id, diff --git a/src/com/hypixel/hytale/server/core/modules/entity/tracker/EntityTrackerSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/tracker/EntityTrackerSystems.java index a94f73a..0bff891 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/tracker/EntityTrackerSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/tracker/EntityTrackerSystems.java @@ -57,9 +57,6 @@ public class EntityTrackerSystems { public static final SystemGroup FIND_VISIBLE_ENTITIES_GROUP = EntityStore.REGISTRY.registerSystemGroup(); public static final SystemGroup QUEUE_UPDATE_GROUP = EntityStore.REGISTRY.registerSystemGroup(); - public EntityTrackerSystems() { - } - public static boolean despawnAll(@Nonnull Ref viewerRef, @Nonnull Store store) { EntityTrackerSystems.EntityViewer viewer = store.getComponent(viewerRef, EntityTrackerSystems.EntityViewer.getComponentType()); if (viewer == null) { @@ -709,9 +706,6 @@ public class EntityTrackerSystems { @Nonnull public Map, EntityTrackerSystems.EntityViewer> newlyVisibleTo = new Object2ObjectOpenHashMap<>(); - public Visible() { - } - @Nonnull public static ComponentType getComponentType() { return EntityModule.get().getVisibleComponentType(); diff --git a/src/com/hypixel/hytale/server/core/modules/entity/tracker/LegacyEntityTrackerSystems.java b/src/com/hypixel/hytale/server/core/modules/entity/tracker/LegacyEntityTrackerSystems.java index bb714cd..2932d4d 100644 --- a/src/com/hypixel/hytale/server/core/modules/entity/tracker/LegacyEntityTrackerSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entity/tracker/LegacyEntityTrackerSystems.java @@ -15,16 +15,13 @@ import com.hypixel.hytale.component.system.tick.EntityTickingSystem; import com.hypixel.hytale.math.vector.Vector3d; import com.hypixel.hytale.protocol.ComponentUpdate; import com.hypixel.hytale.protocol.ComponentUpdateType; -import com.hypixel.hytale.protocol.EntityUpdate; import com.hypixel.hytale.protocol.Equipment; -import com.hypixel.hytale.protocol.ModelTransform; -import com.hypixel.hytale.protocol.packets.entities.EntityUpdates; +import com.hypixel.hytale.protocol.ItemArmorSlot; +import com.hypixel.hytale.server.core.asset.type.gameplay.PlayerConfig; import com.hypixel.hytale.server.core.entity.Entity; import com.hypixel.hytale.server.core.entity.EntityUtils; import com.hypixel.hytale.server.core.entity.LivingEntity; -import com.hypixel.hytale.server.core.entity.effect.EffectControllerComponent; import com.hypixel.hytale.server.core.entity.entities.Player; -import com.hypixel.hytale.server.core.entity.nameplate.Nameplate; import com.hypixel.hytale.server.core.inventory.Inventory; import com.hypixel.hytale.server.core.inventory.ItemStack; import com.hypixel.hytale.server.core.inventory.container.ItemContainer; @@ -32,21 +29,12 @@ import com.hypixel.hytale.server.core.modules.entity.AllLegacyLivingEntityTypesQ import com.hypixel.hytale.server.core.modules.entity.EntityModule; import com.hypixel.hytale.server.core.modules.entity.component.BoundingBox; import com.hypixel.hytale.server.core.modules.entity.component.EntityScaleComponent; -import com.hypixel.hytale.server.core.modules.entity.component.HeadRotation; -import com.hypixel.hytale.server.core.modules.entity.component.Intangible; -import com.hypixel.hytale.server.core.modules.entity.component.Interactable; -import com.hypixel.hytale.server.core.modules.entity.component.Invulnerable; import com.hypixel.hytale.server.core.modules.entity.component.ModelComponent; -import com.hypixel.hytale.server.core.modules.entity.component.RespondToHit; import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent; import com.hypixel.hytale.server.core.modules.entity.player.PlayerSettings; import com.hypixel.hytale.server.core.modules.entity.player.PlayerSkinComponent; -import com.hypixel.hytale.server.core.modules.entitystats.EntityStatMap; -import com.hypixel.hytale.server.core.modules.projectile.component.PredictedProjectile; import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; -import com.hypixel.hytale.server.core.util.PositionUtil; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; @@ -56,117 +44,12 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class LegacyEntityTrackerSystems { - public LegacyEntityTrackerSystems() { - } - - @Deprecated - public static void sendPlayerSelf(@Nonnull Ref viewerRef, @Nonnull Store store) { - EntityTrackerSystems.EntityViewer viewer = store.getComponent(viewerRef, EntityTrackerSystems.EntityViewer.getComponentType()); - if (viewer == null) { - throw new IllegalArgumentException("Not EntityViewer"); - } else { - LivingEntity entity = (LivingEntity)EntityUtils.getEntity(viewerRef, store); - TransformComponent transformComponent = store.getComponent(viewerRef, TransformComponent.getComponentType()); - HeadRotation headRotationComponent = store.getComponent(viewerRef, HeadRotation.getComponentType()); - ModelComponent modelComponent = store.getComponent(viewerRef, ModelComponent.getComponentType()); - EntityStatMap statMapComponent = store.getComponent(viewerRef, EntityStatMap.getComponentType()); - PredictedProjectile predictionComponent = store.getComponent(viewerRef, PredictedProjectile.getComponentType()); - EffectControllerComponent effectControllerComponent = store.getComponent(viewerRef, EffectControllerComponent.getComponentType()); - Nameplate nameplateComponent = store.getComponent(viewerRef, Nameplate.getComponentType()); - EntityUpdate entityUpdate = new EntityUpdate(); - entityUpdate.networkId = entity.getNetworkId(); - ObjectArrayList list = new ObjectArrayList<>(); - if (store.getArchetype(viewerRef).contains(Interactable.getComponentType())) { - ComponentUpdate update = new ComponentUpdate(); - update.type = ComponentUpdateType.Interactable; - list.add(update); - } - - if (store.getArchetype(viewerRef).contains(Intangible.getComponentType())) { - ComponentUpdate update = new ComponentUpdate(); - update.type = ComponentUpdateType.Intangible; - list.add(update); - } - - if (store.getArchetype(viewerRef).contains(Invulnerable.getComponentType())) { - ComponentUpdate update = new ComponentUpdate(); - update.type = ComponentUpdateType.Invulnerable; - list.add(update); - } - - if (store.getArchetype(viewerRef).contains(RespondToHit.getComponentType())) { - ComponentUpdate update = new ComponentUpdate(); - update.type = ComponentUpdateType.RespondToHit; - list.add(update); - } - - if (nameplateComponent != null) { - ComponentUpdate update = new ComponentUpdate(); - update.type = ComponentUpdateType.Nameplate; - update.nameplate = new com.hypixel.hytale.protocol.Nameplate(); - update.nameplate.text = nameplateComponent.getText(); - list.add(update); - } - - if (predictionComponent != null) { - ComponentUpdate update = new ComponentUpdate(); - update.type = ComponentUpdateType.Prediction; - update.predictionId = predictionComponent.getUuid(); - list.add(update); - } - - ComponentUpdate update = new ComponentUpdate(); - update.type = ComponentUpdateType.Model; - update.model = modelComponent != null ? modelComponent.getModel().toPacket() : null; - EntityScaleComponent entityScaleComponent = store.getComponent(viewerRef, EntityScaleComponent.getComponentType()); - if (entityScaleComponent != null) { - update.entityScale = entityScaleComponent.getScale(); - } - - list.add(update); - update = new ComponentUpdate(); - update.type = ComponentUpdateType.PlayerSkin; - PlayerSkinComponent component = store.getComponent(viewerRef, PlayerSkinComponent.getComponentType()); - update.skin = component != null ? component.getPlayerSkin() : null; - list.add(update); - Inventory inventory = entity.getInventory(); - ComponentUpdate updatex = new ComponentUpdate(); - updatex.type = ComponentUpdateType.Equipment; - updatex.equipment = new Equipment(); - ItemContainer armor = inventory.getArmor(); - updatex.equipment.armorIds = new String[armor.getCapacity()]; - Arrays.fill(updatex.equipment.armorIds, ""); - armor.forEachWithMeta((slot, itemStack, armorIds) -> armorIds[slot] = itemStack.getItemId(), updatex.equipment.armorIds); - ItemStack itemInHand = inventory.getItemInHand(); - updatex.equipment.rightHandItemId = itemInHand != null ? itemInHand.getItemId() : "Empty"; - ItemStack utilityItem = inventory.getUtilityItem(); - updatex.equipment.leftHandItemId = utilityItem != null ? utilityItem.getItemId() : "Empty"; - list.add(updatex); - update = new ComponentUpdate(); - update.type = ComponentUpdateType.Transform; - update.transform = new ModelTransform(); - update.transform.position = PositionUtil.toPositionPacket(transformComponent.getPosition()); - update.transform.bodyOrientation = PositionUtil.toDirectionPacket(transformComponent.getRotation()); - update.transform.lookOrientation = PositionUtil.toDirectionPacket(headRotationComponent.getRotation()); - list.add(update); - update = new ComponentUpdate(); - update.type = ComponentUpdateType.EntityEffects; - update.entityEffectUpdates = effectControllerComponent.createInitUpdates(); - list.add(update); - update = new ComponentUpdate(); - update.type = ComponentUpdateType.EntityStats; - update.entityStatUpdates = statMapComponent.createInitUpdate(true); - list.add(update); - entityUpdate.updates = list.toArray(ComponentUpdate[]::new); - viewer.packetReceiver.writeNoCache(new EntityUpdates(null, new EntityUpdate[]{entityUpdate})); - } - } - @Deprecated public static boolean clear(@Nonnull Player player, @Nonnull Holder holder) { World world = player.getWorld(); if (world != null && world.isInThread()) { - return EntityTrackerSystems.clear(player.getReference(), world.getEntityStore().getStore()); + Ref ref = player.getReference(); + return ref != null && ref.isValid() ? EntityTrackerSystems.clear(ref, world.getEntityStore().getStore()) : false; } else { EntityTrackerSystems.EntityViewer entityViewerComponent = holder.getComponent(EntityTrackerSystems.EntityViewer.getComponentType()); if (entityViewerComponent == null) { @@ -297,14 +180,14 @@ public class LegacyEntityTrackerSystems { assert visibleComponent != null; - if (archetypeChunk.getComponent(index, this.playerSkinComponentComponentType).consumeNetworkOutdated()) { - queueUpdatesFor( - archetypeChunk.getReferenceTo(index), archetypeChunk.getComponent(index, this.playerSkinComponentComponentType), visibleComponent.visibleTo - ); + PlayerSkinComponent playerSkinComponent = archetypeChunk.getComponent(index, this.playerSkinComponentComponentType); + + assert playerSkinComponent != null; + + if (playerSkinComponent.consumeNetworkOutdated()) { + queueUpdatesFor(archetypeChunk.getReferenceTo(index), playerSkinComponent, visibleComponent.visibleTo); } else if (!visibleComponent.newlyVisibleTo.isEmpty()) { - queueUpdatesFor( - archetypeChunk.getReferenceTo(index), archetypeChunk.getComponent(index, this.playerSkinComponentComponentType), visibleComponent.newlyVisibleTo - ); + queueUpdatesFor(archetypeChunk.getReferenceTo(index), playerSkinComponent, visibleComponent.newlyVisibleTo); } } @@ -382,6 +265,31 @@ public class LegacyEntityTrackerSystems { update.equipment.armorIds = new String[armor.getCapacity()]; Arrays.fill(update.equipment.armorIds, ""); armor.forEachWithMeta((slot, itemStack, armorIds) -> armorIds[slot] = itemStack.getItemId(), update.equipment.armorIds); + Store store = ref.getStore(); + PlayerSettings playerSettings = store.getComponent(ref, PlayerSettings.getComponentType()); + if (playerSettings != null) { + PlayerConfig.ArmorVisibilityOption armorVisibilityOption = store.getExternalData() + .getWorld() + .getGameplayConfig() + .getPlayerConfig() + .getArmorVisibilityOption(); + if (armorVisibilityOption.canHideHelmet() && playerSettings.hideHelmet()) { + update.equipment.armorIds[ItemArmorSlot.Head.ordinal()] = ""; + } + + if (armorVisibilityOption.canHideCuirass() && playerSettings.hideCuirass()) { + update.equipment.armorIds[ItemArmorSlot.Chest.ordinal()] = ""; + } + + if (armorVisibilityOption.canHideGauntlets() && playerSettings.hideGauntlets()) { + update.equipment.armorIds[ItemArmorSlot.Hands.ordinal()] = ""; + } + + if (armorVisibilityOption.canHidePants() && playerSettings.hidePants()) { + update.equipment.armorIds[ItemArmorSlot.Legs.ordinal()] = ""; + } + } + ItemStack itemInHand = inventory.getItemInHand(); update.equipment.rightHandItemId = itemInHand != null ? itemInHand.getItemId() : "Empty"; ItemStack utilityItem = inventory.getUtilityItem(); @@ -469,17 +377,17 @@ public class LegacyEntityTrackerSystems { public static class LegacyLODCull extends EntityTickingSystem { public static final double ENTITY_LOD_RATIO_DEFAULT = 3.5E-5; public static double ENTITY_LOD_RATIO = 3.5E-5; - private final ComponentType componentType; + private final ComponentType entityViewerComponentType; private final ComponentType boundingBoxComponentType; @Nonnull private final Query query; @Nonnull private final Set> dependencies; - public LegacyLODCull(ComponentType componentType) { - this.componentType = componentType; + public LegacyLODCull(ComponentType entityViewerComponentType) { + this.entityViewerComponentType = entityViewerComponentType; this.boundingBoxComponentType = BoundingBox.getComponentType(); - this.query = Query.and(componentType, TransformComponent.getComponentType()); + this.query = Query.and(entityViewerComponentType, TransformComponent.getComponentType()); this.dependencies = Collections.singleton(new SystemDependency<>(Order.AFTER, EntityTrackerSystems.CollectVisible.class)); } @@ -514,7 +422,7 @@ public class LegacyEntityTrackerSystems { @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { - EntityTrackerSystems.EntityViewer entityViewerComponent = archetypeChunk.getComponent(index, this.componentType); + EntityTrackerSystems.EntityViewer entityViewerComponent = archetypeChunk.getComponent(index, this.entityViewerComponentType); assert entityViewerComponent != null; @@ -526,18 +434,17 @@ public class LegacyEntityTrackerSystems { Iterator> iterator = entityViewerComponent.visible.iterator(); while (iterator.hasNext()) { - Ref ref = iterator.next(); - BoundingBox boundingBoxComponent = commandBuffer.getComponent(ref, this.boundingBoxComponentType); - if (boundingBoxComponent != null) { - TransformComponent otherTransformComponent = commandBuffer.getComponent(ref, TransformComponent.getComponentType()); - - assert otherTransformComponent != null; - - double distanceSq = otherTransformComponent.getPosition().distanceSquaredTo(position); - double maximumThickness = boundingBoxComponent.getBoundingBox().getMaximumThickness(); - if (maximumThickness < ENTITY_LOD_RATIO * distanceSq) { - entityViewerComponent.lodExcludedCount++; - iterator.remove(); + Ref targetRef = iterator.next(); + BoundingBox targetBoundingBoxComponent = commandBuffer.getComponent(targetRef, this.boundingBoxComponentType); + if (targetBoundingBoxComponent != null) { + TransformComponent targetTransformComponent = commandBuffer.getComponent(targetRef, TransformComponent.getComponentType()); + if (targetTransformComponent != null) { + double distanceSq = targetTransformComponent.getPosition().distanceSquaredTo(position); + double maximumThickness = targetBoundingBoxComponent.getBoundingBox().getMaximumThickness(); + if (maximumThickness < ENTITY_LOD_RATIO * distanceSq) { + entityViewerComponent.lodExcludedCount++; + iterator.remove(); + } } } } diff --git a/src/com/hypixel/hytale/server/core/modules/entitystats/EntityStatMap.java b/src/com/hypixel/hytale/server/core/modules/entitystats/EntityStatMap.java index be1a85f..8902ce7 100644 --- a/src/com/hypixel/hytale/server/core/modules/entitystats/EntityStatMap.java +++ b/src/com/hypixel/hytale/server/core/modules/entitystats/EntityStatMap.java @@ -74,9 +74,6 @@ public class EntityStatMap implements Component { return EntityStatsModule.get().getEntityStatMapComponentType(); } - public EntityStatMap() { - } - public int size() { return this.values.length; } @@ -555,8 +552,5 @@ public class EntityStatMap implements Component { NONE, SELF, ALL; - - private Predictable() { - } } } diff --git a/src/com/hypixel/hytale/server/core/modules/entitystats/EntityStatValue.java b/src/com/hypixel/hytale/server/core/modules/entitystats/EntityStatValue.java index bd9f7c9..60a6023 100644 --- a/src/com/hypixel/hytale/server/core/modules/entitystats/EntityStatValue.java +++ b/src/com/hypixel/hytale/server/core/modules/entitystats/EntityStatValue.java @@ -60,7 +60,7 @@ public class EntityStatValue { } public float asPercentage() { - return (this.value - this.min) / (this.max - this.min); + return this.min == this.max ? 0.0F : (this.value - this.min) / (this.max - this.min); } public float getMin() { diff --git a/src/com/hypixel/hytale/server/core/modules/entitystats/EntityStatsSystems.java b/src/com/hypixel/hytale/server/core/modules/entitystats/EntityStatsSystems.java index 1430f1b..685dec4 100644 --- a/src/com/hypixel/hytale/server/core/modules/entitystats/EntityStatsSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/entitystats/EntityStatsSystems.java @@ -54,9 +54,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class EntityStatsSystems { - public EntityStatsSystems() { - } - public static class Changes extends EntityTickingSystem { private final ComponentType componentType; @Nonnull @@ -373,15 +370,18 @@ public class EntityStatsSystems { public static class Recalculate extends EntityTickingSystem { @Nonnull private final ComponentType entityStatMapComponentType; + @Nonnull + private final Query query; public Recalculate(@Nonnull ComponentType entityStatMapComponentType) { this.entityStatMapComponentType = entityStatMapComponentType; + this.query = Query.and(AllLegacyLivingEntityTypesQuery.INSTANCE, entityStatMapComponentType); } @Nonnull @Override public Query getQuery() { - return AllLegacyLivingEntityTypesQuery.INSTANCE; + return this.query; } @Override diff --git a/src/com/hypixel/hytale/server/core/modules/entitystats/asset/EntityStatType.java b/src/com/hypixel/hytale/server/core/modules/entitystats/asset/EntityStatType.java index efa3ae7..448a3f5 100644 --- a/src/com/hypixel/hytale/server/core/modules/entitystats/asset/EntityStatType.java +++ b/src/com/hypixel/hytale/server/core/modules/entitystats/asset/EntityStatType.java @@ -468,9 +468,6 @@ public class EntityStatType public static enum RegenType { ADDITIVE, PERCENTAGE; - - private RegenType() { - } } } } diff --git a/src/com/hypixel/hytale/server/core/modules/entitystats/asset/EntityStatTypePacketGenerator.java b/src/com/hypixel/hytale/server/core/modules/entitystats/asset/EntityStatTypePacketGenerator.java index e6123f9..b3bd114 100644 --- a/src/com/hypixel/hytale/server/core/modules/entitystats/asset/EntityStatTypePacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/modules/entitystats/asset/EntityStatTypePacketGenerator.java @@ -12,9 +12,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class EntityStatTypePacketGenerator extends SimpleAssetPacketGenerator> { - public EntityStatTypePacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedLookupTableAssetMap assetMap, @Nonnull Map assets) { UpdateEntityStatTypes packet = new UpdateEntityStatTypes(); diff --git a/src/com/hypixel/hytale/server/core/modules/entitystats/asset/condition/LogicCondition.java b/src/com/hypixel/hytale/server/core/modules/entitystats/asset/condition/LogicCondition.java index 903ffea..be175b9 100644 --- a/src/com/hypixel/hytale/server/core/modules/entitystats/asset/condition/LogicCondition.java +++ b/src/com/hypixel/hytale/server/core/modules/entitystats/asset/condition/LogicCondition.java @@ -85,9 +85,6 @@ public class LogicCondition extends Condition { } }; - private Operator() { - } - public abstract boolean eval( @Nonnull ComponentAccessor var1, @Nonnull Ref var2, @Nonnull Instant var3, @Nonnull Condition[] var4 ); diff --git a/src/com/hypixel/hytale/server/core/modules/entitystats/asset/condition/SuffocatingCondition.java b/src/com/hypixel/hytale/server/core/modules/entitystats/asset/condition/SuffocatingCondition.java index aef9b74..5cb8f6e 100644 --- a/src/com/hypixel/hytale/server/core/modules/entitystats/asset/condition/SuffocatingCondition.java +++ b/src/com/hypixel/hytale/server/core/modules/entitystats/asset/condition/SuffocatingCondition.java @@ -35,10 +35,10 @@ public class SuffocatingCondition extends Condition { @Override public boolean eval0(@Nonnull ComponentAccessor componentAccessor, @Nonnull Ref ref, @Nonnull Instant currentTime) { if (EntityUtils.getEntity(ref, componentAccessor) instanceof LivingEntity livingEntity) { - World world = componentAccessor.getExternalData().getWorld(); + World var16 = componentAccessor.getExternalData().getWorld(); Transform lookVec = TargetUtil.getLook(ref, componentAccessor); Vector3d position = lookVec.getPosition(); - ChunkStore chunkStore = world.getChunkStore(); + ChunkStore chunkStore = var16.getChunkStore(); long chunkIndex = ChunkUtil.indexChunkFromBlock(position.x, position.z); Ref chunkRef = chunkStore.getChunkReference(chunkIndex); if (chunkRef != null && chunkRef.isValid()) { diff --git a/src/com/hypixel/hytale/server/core/modules/entitystats/modifier/Modifier.java b/src/com/hypixel/hytale/server/core/modules/entitystats/modifier/Modifier.java index 856660d..c6f34a4 100644 --- a/src/com/hypixel/hytale/server/core/modules/entitystats/modifier/Modifier.java +++ b/src/com/hypixel/hytale/server/core/modules/entitystats/modifier/Modifier.java @@ -76,8 +76,5 @@ public abstract class Modifier implements NetworkSerializable { private final ComponentType uiComponentListComponentType; private final ComponentType visibleComponentType; diff --git a/src/com/hypixel/hytale/server/core/modules/entityui/asset/CombatTextUIComponent.java b/src/com/hypixel/hytale/server/core/modules/entityui/asset/CombatTextUIComponent.java index 9cb2cc2..d91098f 100644 --- a/src/com/hypixel/hytale/server/core/modules/entityui/asset/CombatTextUIComponent.java +++ b/src/com/hypixel/hytale/server/core/modules/entityui/asset/CombatTextUIComponent.java @@ -92,9 +92,6 @@ public class CombatTextUIComponent extends EntityUIComponent { private Color textColor = DEFAULT_TEXT_COLOR; private CombatTextUIComponentAnimationEvent[] animationEvents; - public CombatTextUIComponent() { - } - @Nonnull @Override protected com.hypixel.hytale.protocol.EntityUIComponent generatePacket() { diff --git a/src/com/hypixel/hytale/server/core/modules/entityui/asset/CombatTextUIComponentAnimationEvent.java b/src/com/hypixel/hytale/server/core/modules/entityui/asset/CombatTextUIComponentAnimationEvent.java index 0ddb17f..f1a85d0 100644 --- a/src/com/hypixel/hytale/server/core/modules/entityui/asset/CombatTextUIComponentAnimationEvent.java +++ b/src/com/hypixel/hytale/server/core/modules/entityui/asset/CombatTextUIComponentAnimationEvent.java @@ -38,9 +38,6 @@ public abstract class CombatTextUIComponentAnimationEvent private float startAt; private float endAt; - public CombatTextUIComponentAnimationEvent() { - } - public String getId() { return this.id; } diff --git a/src/com/hypixel/hytale/server/core/modules/entityui/asset/CombatTextUIComponentOpacityAnimationEvent.java b/src/com/hypixel/hytale/server/core/modules/entityui/asset/CombatTextUIComponentOpacityAnimationEvent.java index ebd5413..2d7a29e 100644 --- a/src/com/hypixel/hytale/server/core/modules/entityui/asset/CombatTextUIComponentOpacityAnimationEvent.java +++ b/src/com/hypixel/hytale/server/core/modules/entityui/asset/CombatTextUIComponentOpacityAnimationEvent.java @@ -36,9 +36,6 @@ public class CombatTextUIComponentOpacityAnimationEvent extends CombatTextUIComp private float startOpacity; private float endOpacity; - public CombatTextUIComponentOpacityAnimationEvent() { - } - @Nonnull @Override public CombatTextEntityUIComponentAnimationEvent generatePacket() { diff --git a/src/com/hypixel/hytale/server/core/modules/entityui/asset/CombatTextUIComponentPositionAnimationEvent.java b/src/com/hypixel/hytale/server/core/modules/entityui/asset/CombatTextUIComponentPositionAnimationEvent.java index fb9dc12..86aa778 100644 --- a/src/com/hypixel/hytale/server/core/modules/entityui/asset/CombatTextUIComponentPositionAnimationEvent.java +++ b/src/com/hypixel/hytale/server/core/modules/entityui/asset/CombatTextUIComponentPositionAnimationEvent.java @@ -27,9 +27,6 @@ public class CombatTextUIComponentPositionAnimationEvent extends CombatTextUICom .build(); private Vector2f positionOffset; - public CombatTextUIComponentPositionAnimationEvent() { - } - @Nonnull @Override public CombatTextEntityUIComponentAnimationEvent generatePacket() { diff --git a/src/com/hypixel/hytale/server/core/modules/entityui/asset/CombatTextUIComponentScaleAnimationEvent.java b/src/com/hypixel/hytale/server/core/modules/entityui/asset/CombatTextUIComponentScaleAnimationEvent.java index 25239ef..1c0c945 100644 --- a/src/com/hypixel/hytale/server/core/modules/entityui/asset/CombatTextUIComponentScaleAnimationEvent.java +++ b/src/com/hypixel/hytale/server/core/modules/entityui/asset/CombatTextUIComponentScaleAnimationEvent.java @@ -36,9 +36,6 @@ public class CombatTextUIComponentScaleAnimationEvent extends CombatTextUICompon private float startScale; private float endScale; - public CombatTextUIComponentScaleAnimationEvent() { - } - @Nonnull @Override public CombatTextEntityUIComponentAnimationEvent generatePacket() { diff --git a/src/com/hypixel/hytale/server/core/modules/entityui/asset/EntityStatUIComponent.java b/src/com/hypixel/hytale/server/core/modules/entityui/asset/EntityStatUIComponent.java index 61c4e58..7b6ec3e 100644 --- a/src/com/hypixel/hytale/server/core/modules/entityui/asset/EntityStatUIComponent.java +++ b/src/com/hypixel/hytale/server/core/modules/entityui/asset/EntityStatUIComponent.java @@ -28,9 +28,6 @@ public class EntityStatUIComponent extends EntityUIComponent { protected String entityStat; protected int entityStatIndex; - public EntityStatUIComponent() { - } - @Nonnull @Override protected com.hypixel.hytale.protocol.EntityUIComponent generatePacket() { diff --git a/src/com/hypixel/hytale/server/core/modules/entityui/asset/EntityUIComponentPacketGenerator.java b/src/com/hypixel/hytale/server/core/modules/entityui/asset/EntityUIComponentPacketGenerator.java index 3714f08..5d9c974 100644 --- a/src/com/hypixel/hytale/server/core/modules/entityui/asset/EntityUIComponentPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/modules/entityui/asset/EntityUIComponentPacketGenerator.java @@ -14,9 +14,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class EntityUIComponentPacketGenerator extends AssetPacketGenerator> { - public EntityUIComponentPacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedLookupTableAssetMap assetMap, @Nonnull Map assets) { Int2ObjectMap configs = new Int2ObjectOpenHashMap<>(); diff --git a/src/com/hypixel/hytale/server/core/modules/i18n/I18nModule.java b/src/com/hypixel/hytale/server/core/modules/i18n/I18nModule.java index 47afe0a..3b3e185 100644 --- a/src/com/hypixel/hytale/server/core/modules/i18n/I18nModule.java +++ b/src/com/hypixel/hytale/server/core/modules/i18n/I18nModule.java @@ -20,7 +20,6 @@ import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType; import com.hypixel.hytale.server.core.asset.type.blocktype.config.bench.Bench; import com.hypixel.hytale.server.core.asset.type.blocktype.config.bench.CraftingBench; import com.hypixel.hytale.server.core.asset.type.item.config.FieldcraftCategory; -import com.hypixel.hytale.server.core.asset.type.item.config.ResourceType; import com.hypixel.hytale.server.core.io.PacketHandler; import com.hypixel.hytale.server.core.modules.i18n.commands.EnableTmpTagsCommand; import com.hypixel.hytale.server.core.modules.i18n.commands.InternationalizationCommands; @@ -127,19 +126,6 @@ public class I18nModule extends JavaPlugin { }); this.addDefaultMessages(addedMessages, event.isInitial()); }); - this.getEventRegistry().register(LoadedAssetsEvent.class, ResourceType.class, event -> { - Map addedMessages = new Object2ObjectOpenHashMap<>(); - event.getLoadedAssets().values().forEach(resourceType -> { - if (resourceType.getName() != null) { - addedMessages.put("resourceTypes." + resourceType.getId() + ".name", resourceType.getName()); - } - - if (resourceType.getDescription() != null) { - addedMessages.put("resourceTypes." + resourceType.getId() + ".description", resourceType.getDescription()); - } - }); - this.addDefaultMessages(addedMessages, event.isInitial()); - }); } @Override diff --git a/src/com/hypixel/hytale/server/core/modules/i18n/parser/LangFileParser.java b/src/com/hypixel/hytale/server/core/modules/i18n/parser/LangFileParser.java index e5d215c..02fca70 100644 --- a/src/com/hypixel/hytale/server/core/modules/i18n/parser/LangFileParser.java +++ b/src/com/hypixel/hytale/server/core/modules/i18n/parser/LangFileParser.java @@ -7,9 +7,6 @@ import java.util.Map; import javax.annotation.Nonnull; public class LangFileParser { - public LangFileParser() { - } - @Nonnull private static String literal(@Nonnull String value) { String literal = value.trim(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/BlockHarvestUtils.java b/src/com/hypixel/hytale/server/core/modules/interaction/BlockHarvestUtils.java index c1b7249..0025d25 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/BlockHarvestUtils.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/BlockHarvestUtils.java @@ -64,9 +64,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class BlockHarvestUtils { - public BlockHarvestUtils() { - } - @Nullable public static ItemToolSpec getSpecPowerDamageBlock(@Nullable Item item, @Nullable BlockType blockType, @Nullable ItemTool tool) { if (blockType == null) { @@ -84,12 +81,18 @@ public class BlockHarvestUtils { if (gatherType == null) { return null; } else if (item == null || item.getWeapon() == null && item.getBuilderToolData() == null) { + int requiredQuality = breaking.getQuality(); if (tool == null) { - return ItemToolSpec.getAssetMap().getAsset(gatherType); + ItemToolSpec defaultSpec = ItemToolSpec.getAssetMap().getAsset(gatherType); + return defaultSpec != null && defaultSpec.getQuality() < requiredQuality ? null : defaultSpec; } else { if (tool.getSpecs() != null) { for (ItemToolSpec spec : tool.getSpecs()) { if (Objects.equals(spec.getGatherType(), gatherType)) { + if (spec.getQuality() < requiredQuality) { + return null; + } + return spec; } } diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/BlockInteractionUtils.java b/src/com/hypixel/hytale/server/core/modules/interaction/BlockInteractionUtils.java index bc89135..318a7de 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/BlockInteractionUtils.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/BlockInteractionUtils.java @@ -9,9 +9,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class BlockInteractionUtils { - public BlockInteractionUtils() { - } - public static boolean isNaturalAction(@Nullable Ref ref, @Nonnull ComponentAccessor componentAccessor) { if (ref == null) { return true; diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/BlockPlaceUtils.java b/src/com/hypixel/hytale/server/core/modules/interaction/BlockPlaceUtils.java index 0084a5d..cc292b8 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/BlockPlaceUtils.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/BlockPlaceUtils.java @@ -74,9 +74,6 @@ public class BlockPlaceUtils { @Nonnull private static final Message MESSAGE_MODULES_INTERACTION_BUILD_FORBIDDEN = Message.translation("server.modules.interaction.buildForbidden"); - public BlockPlaceUtils() { - } - public static void placeBlock( @Nonnull Ref ref, @Nonnull ItemStack itemStack, diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/InteractionModule.java b/src/com/hypixel/hytale/server/core/modules/interaction/InteractionModule.java index 38b2ee3..4775a2f 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/InteractionModule.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/InteractionModule.java @@ -127,6 +127,7 @@ import com.hypixel.hytale.server.core.modules.interaction.interaction.config.ser import com.hypixel.hytale.server.core.modules.interaction.interaction.config.server.OpenPageInteraction; import com.hypixel.hytale.server.core.modules.interaction.interaction.config.server.PlacementCountConditionInteraction; import com.hypixel.hytale.server.core.modules.interaction.interaction.config.server.RefillContainerInteraction; +import com.hypixel.hytale.server.core.modules.interaction.interaction.config.server.RunOnBlockTypesInteraction; import com.hypixel.hytale.server.core.modules.interaction.interaction.config.server.SpawnPrefabInteraction; import com.hypixel.hytale.server.core.modules.interaction.interaction.config.server.combat.DirectionalKnockback; import com.hypixel.hytale.server.core.modules.interaction.interaction.config.server.combat.ForceKnockback; @@ -292,6 +293,7 @@ public class InteractionModule extends JavaPlugin { Interaction.CODEC.register("AddItem", AddItemInteraction.class, AddItemInteraction.CODEC); Interaction.CODEC.register("Interrupt", InterruptInteraction.class, InterruptInteraction.CODEC); Interaction.CODEC.register("RunRootInteraction", RunRootInteraction.class, RunRootInteraction.CODEC); + Interaction.CODEC.register("RunOnBlockTypes", RunOnBlockTypesInteraction.class, RunOnBlockTypesInteraction.CODEC); Interaction.CODEC.register("Camera", CameraInteraction.class, CameraInteraction.CODEC); Interaction.CODEC.register("ToggleGlider", ToggleGliderInteraction.class, ToggleGliderInteraction.CODEC); OpenCustomUIInteraction.registerBlockEntityCustomPage( diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/InteractionSimulationHandler.java b/src/com/hypixel/hytale/server/core/modules/interaction/InteractionSimulationHandler.java index 243b8f1..ded16dd 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/InteractionSimulationHandler.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/InteractionSimulationHandler.java @@ -10,9 +10,6 @@ import javax.annotation.Nonnull; public class InteractionSimulationHandler implements IInteractionSimulationHandler { private final boolean[] isDown = new boolean[InteractionType.VALUES.length]; - public InteractionSimulationHandler() { - } - @Override public void setState(@Nonnull InteractionType type, boolean state) { this.isDown[type.ordinal()] = state; diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/Interactions.java b/src/com/hypixel/hytale/server/core/modules/interaction/Interactions.java index 5cf452b..7890329 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/Interactions.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/Interactions.java @@ -24,6 +24,13 @@ public class Interactions implements Component { (o, p) -> o.interactions = p.interactions ) .add() + .appendInherited( + new KeyedCodec<>("InteractionHint", Codec.STRING), + (o, v) -> o.interactionHint = v, + o -> o.interactionHint, + (o, p) -> o.interactionHint = p.interactionHint + ) + .add() .build(); @Nonnull private Map interactions = new EnumMap<>(InteractionType.class); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/blocktrack/TrackedPlacement.java b/src/com/hypixel/hytale/server/core/modules/interaction/blocktrack/TrackedPlacement.java index f9fcc46..e6a5e5f 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/blocktrack/TrackedPlacement.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/blocktrack/TrackedPlacement.java @@ -50,9 +50,6 @@ public class TrackedPlacement implements Component { private static final ComponentType COMPONENT_TYPE = TrackedPlacement.getComponentType(); private static final ResourceType BLOCK_COUNTER_RESOURCE_TYPE = BlockCounter.getResourceType(); - public OnAddRemove() { - } - @Override public void onEntityAdded( @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/CooldownHandler.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/CooldownHandler.java index d4c2580..dc7f377 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/CooldownHandler.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/CooldownHandler.java @@ -12,9 +12,6 @@ public final class CooldownHandler implements Tickable { @Nonnull private final Map cooldowns = new ConcurrentHashMap<>(); - public CooldownHandler() { - } - public boolean isOnCooldown(@Nonnull RootInteraction root, @Nonnull String id, float maxTime, @Nonnull float[] chargeTimes, boolean interruptRecharge) { if (maxTime <= 0.0F) { return false; diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/InteractionPacketGenerator.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/InteractionPacketGenerator.java index e526deb..f27a312 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/InteractionPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/InteractionPacketGenerator.java @@ -16,9 +16,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class InteractionPacketGenerator extends AssetPacketGenerator> { - public InteractionPacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedLookupTableAssetMap assetMap, @Nonnull Map assets) { Int2ObjectMap interactions = new Int2ObjectOpenHashMap<>(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/RootInteractionPacketGenerator.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/RootInteractionPacketGenerator.java index 1dc0493..b99b401 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/RootInteractionPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/RootInteractionPacketGenerator.java @@ -15,9 +15,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class RootInteractionPacketGenerator extends AssetPacketGenerator> { - public RootInteractionPacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedLookupTableAssetMap assetMap, @Nonnull Map assets) { Int2ObjectMap interactions = new Int2ObjectOpenHashMap<>(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/UnarmedInteractions.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/UnarmedInteractions.java index cea02d4..8670075 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/UnarmedInteractions.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/UnarmedInteractions.java @@ -43,9 +43,6 @@ public class UnarmedInteractions implements JsonAssetWithMap interactions; - public UnarmedInteractions() { - } - public static DefaultAssetMap getAssetMap() { if (ASSET_MAP == null) { ASSET_MAP = (DefaultAssetMap)AssetRegistry.getAssetStore(UnarmedInteractions.class).getAssetMap(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/UnarmedInteractionsPacketGenerator.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/UnarmedInteractionsPacketGenerator.java index a7142b3..c5e253a 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/UnarmedInteractionsPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/UnarmedInteractionsPacketGenerator.java @@ -14,9 +14,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class UnarmedInteractionsPacketGenerator extends DefaultAssetPacketGenerator { - public UnarmedInteractionsPacketGenerator() { - } - @Nonnull @Override public Packet generateInitPacket(@Nonnull DefaultAssetMap assetMap, Map assets) { diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/InteractionCameraSettings.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/InteractionCameraSettings.java index dea6acb..3eac82a 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/InteractionCameraSettings.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/InteractionCameraSettings.java @@ -39,9 +39,6 @@ public class InteractionCameraSettings implements NetworkSerializable getInteractionCameraValidator() { return (interactionCameras, results) -> { @@ -123,9 +120,6 @@ public class InteractionCameraSettings implements NetworkSerializable { PrioritySlot.class, Codec.INTEGER, () -> new EnumMap<>(PrioritySlot.class), false ); - public InteractionPriorityCodec() { - } - @Nonnull public InteractionPriority decode(@Nonnull BsonValue bsonValue, ExtraInfo extraInfo) { if (bsonValue.isInt32()) { diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/InteractionRules.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/InteractionRules.java index f2d47bc..9a507bc 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/InteractionRules.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/InteractionRules.java @@ -127,9 +127,6 @@ public class InteractionRules implements NetworkSerializable selfTags, diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/InteractionTypeUtils.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/InteractionTypeUtils.java index 3957945..ea61e24 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/InteractionTypeUtils.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/InteractionTypeUtils.java @@ -55,9 +55,6 @@ public class InteractionTypeUtils { ); public static final float DEFAULT_COOLDOWN = 0.35F; - public InteractionTypeUtils() { - } - public static float getDefaultCooldown(@Nonnull InteractionType type) { return switch (type) { case CollisionEnter, CollisionLeave, ProjectileSpawn, ProjectileHit, ProjectileMiss, ProjectileBounce, GameModeSwap, EntityStatEffect, Pickup -> 0.0F; diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/SimpleInstantInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/SimpleInstantInteraction.java index 3711e32..f1588de 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/SimpleInstantInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/SimpleInstantInteraction.java @@ -7,7 +7,6 @@ import com.hypixel.hytale.protocol.WaitForDataFrom; import com.hypixel.hytale.server.core.entity.InteractionContext; import com.hypixel.hytale.server.core.modules.interaction.interaction.CooldownHandler; import javax.annotation.Nonnull; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public abstract class SimpleInstantInteraction extends SimpleInteraction { public static final BuilderCodec CODEC = BuilderCodec.abstractBuilder(SimpleInstantInteraction.class, SimpleInteraction.CODEC) @@ -22,7 +21,7 @@ public abstract class SimpleInstantInteraction extends SimpleInteraction { @Override protected final void tick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { if (firstRun) { this.firstRun(type, context, cooldownHandler); @@ -32,7 +31,7 @@ public abstract class SimpleInstantInteraction extends SimpleInteraction { @Override protected void simulateTick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { if (firstRun) { this.simulateFirstRun(type, context, cooldownHandler); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/SimpleInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/SimpleInteraction.java index 33a39cd..76f417c 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/SimpleInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/SimpleInteraction.java @@ -14,7 +14,6 @@ import com.hypixel.hytale.server.core.modules.interaction.interaction.operation. import com.hypixel.hytale.server.core.modules.interaction.interaction.operation.OperationsBuilder; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class SimpleInteraction extends Interaction { public static final BuilderCodec CODEC = BuilderCodec.builder(SimpleInteraction.class, SimpleInteraction::new, Interaction.ABSTRACT_CODEC) @@ -63,7 +62,7 @@ public class SimpleInteraction extends Interaction { @Override protected void tick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { if (context.getState().state == InteractionState.Failed && context.hasLabels()) { context.jump(context.getLabel(0)); @@ -72,7 +71,7 @@ public class SimpleInteraction extends Interaction { @Override protected void simulateTick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { if (this.getWaitForDataFrom() == WaitForDataFrom.Server && context.getServerState() != null && context.getServerState().state == InteractionState.Failed) { context.getState().state = InteractionState.Failed; @@ -115,7 +114,7 @@ public class SimpleInteraction extends Interaction { : this.failed != null && InteractionManager.walkInteraction(collector, context, TAG_FAILED, this.failed); } - @NonNullDecl + @Nonnull @Override protected com.hypixel.hytale.protocol.Interaction generatePacket() { return new com.hypixel.hytale.protocol.SimpleInteraction(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/AddItemInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/AddItemInteraction.java index 20d13cb..2fd2e35 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/AddItemInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/AddItemInteraction.java @@ -37,9 +37,6 @@ public class AddItemInteraction extends SimpleBlockInteraction { protected String itemId; protected int quantity; - public AddItemInteraction() { - } - @Override protected void interactWithBlock( @Nonnull World world, diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ApplyForceInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ApplyForceInteraction.java index 8e7f17c..c941354 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ApplyForceInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ApplyForceInteraction.java @@ -43,7 +43,6 @@ import it.unimi.dsi.fastutil.objects.ObjectList; import java.util.Arrays; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class ApplyForceInteraction extends SimpleInteraction { @Nonnull @@ -192,9 +191,6 @@ public class ApplyForceInteraction extends SimpleInteraction { @Nullable private String collisionInteraction = null; - public ApplyForceInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { @@ -203,7 +199,7 @@ public class ApplyForceInteraction extends SimpleInteraction { @Override protected void tick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { InteractionSyncData contextState = context.getState(); if (firstRun) { @@ -237,7 +233,7 @@ public class ApplyForceInteraction extends SimpleInteraction { @Override protected void simulateTick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { InteractionSyncData contextState = context.getState(); Ref entityRef = context.getEntity(); @@ -424,9 +420,6 @@ public class ApplyForceInteraction extends SimpleInteraction { private boolean adjustVertical = false; private double force = 1.0; - public Force() { - } - @Nonnull public AppliedForce toPacket() { return new AppliedForce( diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/BlockConditionInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/BlockConditionInteraction.java index b0805ea..e147a63 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/BlockConditionInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/BlockConditionInteraction.java @@ -47,9 +47,6 @@ public class BlockConditionInteraction extends SimpleBlockInteraction { .build(); private BlockConditionInteraction.BlockMatcher[] matchers; - public BlockConditionInteraction() { - } - @Override protected void interactWithBlock( @Nonnull World world, @@ -220,9 +217,6 @@ public class BlockConditionInteraction extends SimpleBlockInteraction { protected String tag; protected int tagIndex = Integer.MIN_VALUE; - public BlockIdMatcher() { - } - @Nonnull public com.hypixel.hytale.protocol.BlockIdMatcher toPacket() { com.hypixel.hytale.protocol.BlockIdMatcher packet = new com.hypixel.hytale.protocol.BlockIdMatcher(); @@ -279,9 +273,6 @@ public class BlockConditionInteraction extends SimpleBlockInteraction { protected BlockFace face = BlockFace.None; protected boolean staticFace; - public BlockMatcher() { - } - @Nonnull public com.hypixel.hytale.protocol.BlockMatcher toPacket() { com.hypixel.hytale.protocol.BlockMatcher packet = new com.hypixel.hytale.protocol.BlockMatcher(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/BreakBlockInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/BreakBlockInteraction.java index cd717a8..c84c520 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/BreakBlockInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/BreakBlockInteraction.java @@ -48,9 +48,6 @@ public class BreakBlockInteraction extends SimpleBlockInteraction { protected String toolId; protected boolean matchTool; - public BreakBlockInteraction() { - } - @Override protected void tick0( boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ChainingInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ChainingInteraction.java index 049a110..0bd7861 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ChainingInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ChainingInteraction.java @@ -32,7 +32,6 @@ import java.util.Map; import java.util.Map.Entry; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class ChainingInteraction extends Interaction { @Nonnull @@ -88,9 +87,6 @@ public class ChainingInteraction extends Interaction { protected Object2IntMap flagIndex; private String[] sortedFlagKeys; - public ChainingInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { @@ -99,7 +95,7 @@ public class ChainingInteraction extends Interaction { @Override protected void tick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { InteractionSyncData clientState = context.getClientState(); @@ -119,7 +115,7 @@ public class ChainingInteraction extends Interaction { @Override protected void simulateTick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { if (firstRun) { CommandBuffer commandBuffer = context.getCommandBuffer(); @@ -277,9 +273,6 @@ public class ChainingInteraction extends Interaction { private final Object2IntMap namedMap = new Object2IntOpenHashMap<>(); private long lastAttack; - public Data() { - } - public static ComponentType getComponentType() { return InteractionModule.get().getChainingDataComponent(); } diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ChangeBlockInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ChangeBlockInteraction.java index 3f1675f..681e834 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ChangeBlockInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ChangeBlockInteraction.java @@ -80,9 +80,6 @@ public class ChangeBlockInteraction extends SimpleBlockInteraction { protected transient int soundEventIndex = 0; protected boolean requireNotBroken = false; - public ChangeBlockInteraction() { - } - protected void processConfig() { if (this.soundEventId != null) { this.soundEventIndex = SoundEvent.getAssetMap().getIndex(this.soundEventId); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ChangeStateInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ChangeStateInteraction.java index 103123b..3a7a248 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ChangeStateInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ChangeStateInteraction.java @@ -50,9 +50,6 @@ public class ChangeStateInteraction extends SimpleBlockInteraction { protected Map stateKeys; protected boolean updateBlockState = false; - public ChangeStateInteraction() { - } - @Override protected void interactWithBlock( @Nonnull World world, diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ChargingInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ChargingInteraction.java index 5eb1556..6794521 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ChargingInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ChargingInteraction.java @@ -40,7 +40,6 @@ import java.util.Map; import java.util.Map.Entry; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class ChargingInteraction extends Interaction { @Nonnull @@ -202,9 +201,6 @@ public class ChargingInteraction extends Interaction { protected ChargingDelay chargingDelay; protected float highestChargeValue; - public ChargingInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { @@ -213,7 +209,7 @@ public class ChargingInteraction extends Interaction { @Override protected void tick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { InteractionSyncData clientData = context.getClientState(); if (context.getClientState().state == InteractionState.Failed && context.hasLabels()) { @@ -274,7 +270,7 @@ public class ChargingInteraction extends Interaction { @Override protected void simulateTick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { Ref ref = context.getEntity(); IInteractionSimulationHandler simulationHandler = context.getInteractionManager().getInteractionSimulationHandler(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/CooldownConditionInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/CooldownConditionInteraction.java index b5d9941..c8d1e83 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/CooldownConditionInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/CooldownConditionInteraction.java @@ -30,9 +30,6 @@ public class CooldownConditionInteraction extends SimpleInstantInteraction { .build(); private String cooldown; - public CooldownConditionInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { assert this.cooldown != null; diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/CycleBlockGroupInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/CycleBlockGroupInteraction.java index 64e10cf..970283b 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/CycleBlockGroupInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/CycleBlockGroupInteraction.java @@ -42,9 +42,6 @@ public class CycleBlockGroupInteraction extends SimpleBlockInteraction { .documentation("Attempts to cycle the target block through its block set.") .build(); - public CycleBlockGroupInteraction() { - } - @Override protected void interactWithBlock( @Nonnull World world, diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/DestroyBlockInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/DestroyBlockInteraction.java index bec7c0b..112f7a9 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/DestroyBlockInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/DestroyBlockInteraction.java @@ -25,9 +25,6 @@ public class DestroyBlockInteraction extends SimpleInstantInteraction { .documentation("Destroys the target block.") .build(); - public DestroyBlockInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { BlockPosition blockPosition = context.getTargetBlock(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ExplodeInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ExplodeInteraction.java index bfba264..ff9db63 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ExplodeInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ExplodeInteraction.java @@ -55,9 +55,6 @@ public class ExplodeInteraction extends SimpleInstantInteraction { @Nullable private ExplosionConfig config; - public ExplodeInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { assert this.config != null; diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/FirstClickInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/FirstClickInteraction.java index 58627b0..7a71698 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/FirstClickInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/FirstClickInteraction.java @@ -19,7 +19,6 @@ import com.hypixel.hytale.server.core.modules.interaction.interaction.operation. import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class FirstClickInteraction extends Interaction { @Nonnull @@ -56,9 +55,6 @@ public class FirstClickInteraction extends Interaction { @Nullable protected String held; - public FirstClickInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { @@ -67,7 +63,7 @@ public class FirstClickInteraction extends Interaction { @Override protected void tick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { InteractionSyncData clientState = context.getClientState(); @@ -83,7 +79,7 @@ public class FirstClickInteraction extends Interaction { @Override protected void simulateTick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { Ref ref = context.getEntity(); InteractionManager interactionManager = context.getInteractionManager(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/IncrementCooldownInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/IncrementCooldownInteraction.java index d6a44e5..be49a5a 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/IncrementCooldownInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/IncrementCooldownInteraction.java @@ -51,9 +51,6 @@ public class IncrementCooldownInteraction extends SimpleInstantInteraction { private int charge; private boolean interruptRecharge; - public IncrementCooldownInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { String cooldownId = this.cooldown; diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/MovementConditionInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/MovementConditionInteraction.java index db0992d..69a9391 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/MovementConditionInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/MovementConditionInteraction.java @@ -14,7 +14,6 @@ import com.hypixel.hytale.server.core.modules.interaction.interaction.operation. import com.hypixel.hytale.server.core.modules.interaction.interaction.operation.OperationsBuilder; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class MovementConditionInteraction extends SimpleInteraction { @Nonnull @@ -121,12 +120,9 @@ public class MovementConditionInteraction extends SimpleInteraction { @Nullable private String backRight; - public MovementConditionInteraction() { - } - @Override protected void tick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { context.getState().state = InteractionState.Finished; @@ -156,7 +152,7 @@ public class MovementConditionInteraction extends SimpleInteraction { @Override protected void simulateTick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { context.getState().movementDirection = MovementDirection.None; context.jump(context.getLabel(0)); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/PickBlockInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/PickBlockInteraction.java index c074235..b1fda72 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/PickBlockInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/PickBlockInteraction.java @@ -12,8 +12,7 @@ import com.hypixel.hytale.server.core.modules.interaction.interaction.CooldownHa import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import javax.annotation.Nullable; public class PickBlockInteraction extends SimpleBlockInteraction { @Nonnull @@ -23,9 +22,6 @@ public class PickBlockInteraction extends SimpleBlockInteraction { .documentation("Performs a 'block pick', moving a the target block to the user's hand if they have it in their inventory or are in creative.") .build(); - public PickBlockInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { @@ -34,23 +30,19 @@ public class PickBlockInteraction extends SimpleBlockInteraction { @Override protected void interactWithBlock( - @NonNullDecl World world, - @NonNullDecl CommandBuffer commandBuffer, - @NonNullDecl InteractionType type, - @NonNullDecl InteractionContext context, - @NullableDecl ItemStack itemInHand, - @NonNullDecl Vector3i targetBlock, - @NonNullDecl CooldownHandler cooldownHandler + @Nonnull World world, + @Nonnull CommandBuffer commandBuffer, + @Nonnull InteractionType type, + @Nonnull InteractionContext context, + @Nullable ItemStack itemInHand, + @Nonnull Vector3i targetBlock, + @Nonnull CooldownHandler cooldownHandler ) { } @Override protected void simulateInteractWithBlock( - @NonNullDecl InteractionType type, - @NonNullDecl InteractionContext context, - @NullableDecl ItemStack itemInHand, - @NonNullDecl World world, - @NonNullDecl Vector3i targetBlock + @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nullable ItemStack itemInHand, @Nonnull World world, @Nonnull Vector3i targetBlock ) { } diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/PlaceBlockInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/PlaceBlockInteraction.java index 58d2876..42a1d7e 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/PlaceBlockInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/PlaceBlockInteraction.java @@ -38,7 +38,6 @@ import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class PlaceBlockInteraction extends SimpleInteraction { public static final int MAX_ADVENTURE_PLACEMENT_RANGE_SQUARED = 36; @@ -76,9 +75,6 @@ public class PlaceBlockInteraction extends SimpleInteraction { protected boolean removeItemInHand = true; protected boolean allowDragPlacement = true; - public PlaceBlockInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { @@ -87,7 +83,7 @@ public class PlaceBlockInteraction extends SimpleInteraction { @Override protected final void tick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { InteractionSyncData clientState = context.getClientState(); @@ -192,7 +188,7 @@ public class PlaceBlockInteraction extends SimpleInteraction { @Override protected void simulateTick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { super.simulateTick0(firstRun, time, type, context, cooldownHandler); if (!Interaction.failed(context.getState().state)) { diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/PlaceFluidInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/PlaceFluidInteraction.java index 4578876..25879f1 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/PlaceFluidInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/PlaceFluidInteraction.java @@ -53,9 +53,6 @@ public class PlaceFluidInteraction extends SimpleBlockInteraction { protected String fluidKey; protected boolean removeItemInHand = true; - public PlaceFluidInteraction() { - } - @Nullable public String getFluidKey() { return this.fluidKey; diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ResetCooldownInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ResetCooldownInteraction.java index 9d537d8..38dd54d 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ResetCooldownInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ResetCooldownInteraction.java @@ -32,9 +32,6 @@ public class ResetCooldownInteraction extends SimpleInstantInteraction { @Nullable private InteractionCooldown cooldown; - public ResetCooldownInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { String cooldownId = null; diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/SimpleBlockInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/SimpleBlockInteraction.java index 5f8df27..74ca859 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/SimpleBlockInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/SimpleBlockInteraction.java @@ -33,7 +33,6 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import com.hypixel.hytale.server.core.util.TargetUtil; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public abstract class SimpleBlockInteraction extends SimpleInteraction { @Nonnull @@ -130,7 +129,7 @@ public abstract class SimpleBlockInteraction extends SimpleInteraction { @Override protected void simulateTick0( - boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { if (firstRun) { Ref ref = context.getEntity(); @@ -184,7 +183,11 @@ public abstract class SimpleBlockInteraction extends SimpleInteraction { protected void computeCurrentBlockSyncData(@Nonnull InteractionContext context) { BlockPosition targetBlockPos = context.getTargetBlock(); if (targetBlockPos != null) { - World world = context.getCommandBuffer().getStore().getExternalData().getWorld(); + CommandBuffer commandBuffer = context.getCommandBuffer(); + + assert commandBuffer != null; + + World world = commandBuffer.getStore().getExternalData().getWorld(); ChunkStore chunkStore = world.getChunkStore(); long chunkIndex = ChunkUtil.indexChunkFromBlock(targetBlockPos.x, targetBlockPos.z); Ref chunkReference = chunkStore.getChunkReference(chunkIndex); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ToggleGliderInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ToggleGliderInteraction.java index 8c4e696..f8da066 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ToggleGliderInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/ToggleGliderInteraction.java @@ -15,9 +15,6 @@ public class ToggleGliderInteraction extends SimpleInstantInteraction { .documentation("Toggles Glider movement for the player.") .build(); - public ToggleGliderInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { } diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/TriggerCooldownInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/TriggerCooldownInteraction.java index 7aa6c8d..7b0a9bd 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/TriggerCooldownInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/TriggerCooldownInteraction.java @@ -32,9 +32,6 @@ public class TriggerCooldownInteraction extends SimpleInstantInteraction { @Nullable private InteractionCooldown cooldown; - public TriggerCooldownInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { String cooldownId = null; diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/UseBlockInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/UseBlockInteraction.java index bfed64b..988fc98 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/UseBlockInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/UseBlockInteraction.java @@ -28,9 +28,6 @@ public class UseBlockInteraction extends SimpleBlockInteraction { .documentation("Attempts to use the target block, executing interactions on it if any.") .build(); - public UseBlockInteraction() { - } - @Override protected void interactWithBlock( @Nonnull World world, diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/UseEntityInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/UseEntityInteraction.java index 518cf18..3b538f8 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/UseEntityInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/UseEntityInteraction.java @@ -24,9 +24,6 @@ public class UseEntityInteraction extends SimpleInstantInteraction { .documentation("Attempts to use the target entity, executing interactions on it if any.") .build(); - public UseEntityInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/WieldingInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/WieldingInteraction.java index f39a2f4..fda2b5f 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/WieldingInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/client/WieldingInteraction.java @@ -41,7 +41,6 @@ import it.unimi.dsi.fastutil.objects.Object2FloatOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2DoubleMap.Entry; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class WieldingInteraction extends ChargingInteraction { public static final float WIELDING_INDEX = 0.0F; @@ -140,9 +139,6 @@ public class WieldingInteraction extends ChargingInteraction { @Nonnull protected transient Int2FloatMap damageModifiers = Int2FloatMaps.EMPTY_MAP; - public WieldingInteraction() { - } - @Nonnull public Int2DoubleMap getKnockbackModifiers() { return this.knockbackModifiers; @@ -171,7 +167,7 @@ public class WieldingInteraction extends ChargingInteraction { @Override protected void tick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { CommandBuffer commandBuffer = context.getCommandBuffer(); @@ -214,7 +210,7 @@ public class WieldingInteraction extends ChargingInteraction { @Override protected void simulateTick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { CommandBuffer commandBuffer = context.getCommandBuffer(); @@ -360,9 +356,6 @@ public class WieldingInteraction extends ChargingInteraction { @Nonnull protected transient Int2FloatMap damageModifiers = Int2FloatMaps.EMPTY_MAP; - public AngledWielding() { - } - public double getAngleRad() { return this.angleRad; } @@ -414,9 +407,6 @@ public class WieldingInteraction extends ChargingInteraction { private WieldingInteraction.StaminaCost.CostType costType = WieldingInteraction.StaminaCost.CostType.MAX_HEALTH_PERCENTAGE; private float value = 0.04F; - public StaminaCost() { - } - public float computeStaminaAmountToConsume(float damageRaw, @Nonnull EntityStatMap entityStatMap) { return switch (this.costType) { case MAX_HEALTH_PERCENTAGE -> damageRaw / (this.value * entityStatMap.get(DefaultEntityStatTypes.getHealth()).getMax()); @@ -433,9 +423,6 @@ public class WieldingInteraction extends ChargingInteraction { static enum CostType { MAX_HEALTH_PERCENTAGE, DAMAGE; - - private CostType() { - } } } } diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/BuilderToolInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/BuilderToolInteraction.java index 1381d79..402a11b 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/BuilderToolInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/BuilderToolInteraction.java @@ -8,7 +8,6 @@ import com.hypixel.hytale.server.core.entity.InteractionContext; import com.hypixel.hytale.server.core.modules.interaction.interaction.CooldownHandler; import com.hypixel.hytale.server.core.modules.interaction.interaction.config.SimpleInteraction; import javax.annotation.Nonnull; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class BuilderToolInteraction extends SimpleInteraction { @Nonnull @@ -18,9 +17,6 @@ public class BuilderToolInteraction extends SimpleInteraction { .documentation("Runs a builder tool") .build(); - public BuilderToolInteraction() { - } - @Nonnull @Override protected Interaction generatePacket() { @@ -40,7 +36,7 @@ public class BuilderToolInteraction extends SimpleInteraction { @Override protected void tick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { context.getState().state = context.getClientState().state; super.tick0(firstRun, time, type, context, cooldownHandler); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/CameraInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/CameraInteraction.java index 02896f2..bb6bb85 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/CameraInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/CameraInteraction.java @@ -14,7 +14,6 @@ import com.hypixel.hytale.server.core.entity.InteractionContext; import com.hypixel.hytale.server.core.modules.interaction.interaction.CooldownHandler; import com.hypixel.hytale.server.core.modules.interaction.interaction.config.SimpleInteraction; import javax.annotation.Nonnull; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class CameraInteraction extends SimpleInteraction { @Nonnull @@ -57,9 +56,6 @@ public class CameraInteraction extends SimpleInteraction { protected boolean persistCameraState; protected float cameraInteractionTime; - public CameraInteraction() { - } - @Nonnull @Override protected Interaction generatePacket() { @@ -93,7 +89,7 @@ public class CameraInteraction extends SimpleInteraction { @Override protected void tick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { super.tick0(firstRun, time, type, context, cooldownHandler); InteractionSyncData clientState = context.getClientState(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/CancelChainInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/CancelChainInteraction.java index 3703f4d..05868d8 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/CancelChainInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/CancelChainInteraction.java @@ -28,9 +28,6 @@ public class CancelChainInteraction extends SimpleInstantInteraction { .build(); protected String chainId; - public CancelChainInteraction() { - } - @Nonnull @Override protected Interaction generatePacket() { diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/ChainFlagInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/ChainFlagInteraction.java index b14947f..19968de 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/ChainFlagInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/ChainFlagInteraction.java @@ -27,9 +27,6 @@ public class ChainFlagInteraction extends SimpleInstantInteraction { protected String chainId; protected String flag; - public ChainFlagInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { } diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/ChangeActiveSlotInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/ChangeActiveSlotInteraction.java index 68301bc..1446323 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/ChangeActiveSlotInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/ChangeActiveSlotInteraction.java @@ -22,7 +22,6 @@ import com.hypixel.hytale.server.core.modules.interaction.interaction.config.Roo import com.hypixel.hytale.server.core.modules.interaction.interaction.config.data.Collector; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class ChangeActiveSlotInteraction extends Interaction { @Nonnull @@ -69,7 +68,7 @@ public class ChangeActiveSlotInteraction extends Interaction { @Override protected void tick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { if (!firstRun) { context.getState().state = InteractionState.Finished; @@ -121,7 +120,7 @@ public class ChangeActiveSlotInteraction extends Interaction { @Override protected void simulateTick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { context.getState().state = context.getServerState().state; } diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/ConditionInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/ConditionInteraction.java index bf25272..19aeb89 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/ConditionInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/ConditionInteraction.java @@ -19,7 +19,6 @@ import com.hypixel.hytale.server.core.modules.interaction.interaction.config.Sim import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class ConditionInteraction extends SimpleInteraction { @Nonnull @@ -84,12 +83,9 @@ public class ConditionInteraction extends SimpleInteraction { @Nullable private Boolean flying; - public ConditionInteraction() { - } - @Override protected void tick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { boolean success = true; CommandBuffer commandBuffer = context.getCommandBuffer(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/EffectConditionInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/EffectConditionInteraction.java index 5bcd15c..354eed4 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/EffectConditionInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/EffectConditionInteraction.java @@ -39,7 +39,7 @@ public class EffectConditionInteraction extends SimpleInstantInteraction { ) .addValidator(Validators.nonNull()) .addValidator(Validators.nonEmptyArray()) - .addValidator(EntityEffect.VALIDATOR_CACHE.getArrayValidator()) + .addValidatorLate(() -> EntityEffect.VALIDATOR_CACHE.getArrayValidator().late()) .add() .append( new KeyedCodec<>("Match", new EnumCodec<>(Match.class)), @@ -67,9 +67,6 @@ public class EffectConditionInteraction extends SimpleInstantInteraction { @Nonnull private InteractionTarget entityTarget = InteractionTarget.USER; - public EffectConditionInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { CommandBuffer commandBuffer = context.getCommandBuffer(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/ParallelInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/ParallelInteraction.java index d5d737b..642b486 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/ParallelInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/ParallelInteraction.java @@ -18,7 +18,6 @@ import com.hypixel.hytale.server.core.modules.interaction.interaction.config.dat import java.util.Arrays; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class ParallelInteraction extends Interaction { public static final BuilderCodec CODEC = BuilderCodec.builder( @@ -39,9 +38,6 @@ public class ParallelInteraction extends Interaction { .build(); protected String[] interactions; - public ParallelInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { @@ -50,7 +46,7 @@ public class ParallelInteraction extends Interaction { @Override protected void tick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { IndexedLookupTableAssetMap assetMap = RootInteraction.getAssetMap(); context.execute(RootInteraction.getRootInteractionOrUnknown(this.interactions[0])); @@ -65,7 +61,7 @@ public class ParallelInteraction extends Interaction { @Override protected void simulateTick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { IndexedLookupTableAssetMap assetMap = RootInteraction.getAssetMap(); context.execute(RootInteraction.getRootInteractionOrUnknown(this.interactions[0])); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/RepeatInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/RepeatInteraction.java index 4b91977..0174c7e 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/RepeatInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/RepeatInteraction.java @@ -19,7 +19,6 @@ import com.hypixel.hytale.server.core.modules.interaction.interaction.config.Sim import com.hypixel.hytale.server.core.modules.interaction.interaction.config.data.Collector; import com.hypixel.hytale.server.core.modules.interaction.interaction.config.data.StringTag; import javax.annotation.Nonnull; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class RepeatInteraction extends SimpleInteraction { public static final BuilderCodec CODEC = BuilderCodec.builder(RepeatInteraction.class, RepeatInteraction::new, SimpleInteraction.CODEC) @@ -49,9 +48,6 @@ public class RepeatInteraction extends SimpleInteraction { protected String forkInteractions; protected int repeat = 1; - public RepeatInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { @@ -60,7 +56,7 @@ public class RepeatInteraction extends SimpleInteraction { @Override protected void tick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { DynamicMetaStore instanceStore = context.getInstanceStore(); if (firstRun && this.repeat != -1) { @@ -99,7 +95,7 @@ public class RepeatInteraction extends SimpleInteraction { @Override protected void simulateTick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { InteractionChain chain = context.getInstanceStore().getMetaObject(FORKED_CHAIN); DynamicMetaStore instanceStore = context.getInstanceStore(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/ReplaceInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/ReplaceInteraction.java index fde0c9d..1598244 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/ReplaceInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/ReplaceInteraction.java @@ -20,7 +20,6 @@ import java.util.concurrent.TimeUnit; import java.util.logging.Level; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class ReplaceInteraction extends Interaction { @Nonnull @@ -49,9 +48,6 @@ public class ReplaceInteraction extends Interaction { protected String variable; protected boolean defaultOk; - public ReplaceInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { @@ -60,7 +56,7 @@ public class ReplaceInteraction extends Interaction { @Override protected void tick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { if (!Interaction.failed(context.getState().state)) { if (firstRun) { @@ -71,7 +67,7 @@ public class ReplaceInteraction extends Interaction { @Override protected void simulateTick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { if (!Interaction.failed(context.getState().state)) { if (firstRun) { diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/RunRootInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/RunRootInteraction.java index a1cc2cc..33f5b92 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/RunRootInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/RunRootInteraction.java @@ -32,9 +32,6 @@ public class RunRootInteraction extends SimpleInstantInteraction { .build(); protected String rootInteraction; - public RunRootInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { context.getState().state = InteractionState.Finished; diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/SelectInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/SelectInteraction.java index d53fe9c..8857a98 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/SelectInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/SelectInteraction.java @@ -48,10 +48,10 @@ import java.util.HashSet; import java.util.Set; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class SelectInteraction extends SimpleInteraction { public static boolean SHOW_VISUAL_DEBUG; + @Nonnull public static SelectInteraction.SnapshotSource SNAPSHOT_SOURCE = SelectInteraction.SnapshotSource.CLIENT; @Nonnull public static final BuilderCodec CODEC = BuilderCodec.builder(SelectInteraction.class, SelectInteraction::new, SimpleInteraction.CODEC) @@ -102,20 +102,24 @@ public class SelectInteraction extends SimpleInteraction { ) .add() .build(); + @Nonnull public static final MetaKey HIT_ENTITIES = META_REGISTRY.registerMetaObject(i -> new IntOpenHashSet()); + @Nonnull public static final MetaKey> HIT_BLOCKS = META_REGISTRY.registerMetaObject(i -> new HashSet<>()); + @Nonnull public static final MetaKey> SELECT_META_STORE = CONTEXT_META_REGISTRY.registerMetaObject(data -> null); private static final MetaKey ENTITY_SELECTOR = META_REGISTRY.registerMetaObject(data -> null); protected SelectorType selector; + @Nullable protected String hitEntity; + @Nullable protected SelectInteraction.HitEntity[] hitEntityRules; + @Nullable protected String hitBlock; + @Nonnull protected FailOnType failOn = FailOnType.Neither; protected boolean ignoreOwner = true; - public SelectInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { @@ -129,33 +133,33 @@ public class SelectInteraction extends SimpleInteraction { @Override protected void tick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { Ref ref = context.getEntity(); CommandBuffer commandBuffer = context.getCommandBuffer(); assert commandBuffer != null; + DynamicMetaStore instanceStore = context.getInstanceStore(); + Player playerComponent = commandBuffer.getComponent(ref, Player.getComponentType()); if (firstRun) { - Player playerComponent = commandBuffer.getComponent(ref, Player.getComponentType()); Selector selector = this.selector.newSelector(); if (playerComponent != null && SNAPSHOT_SOURCE == SelectInteraction.SnapshotSource.CLIENT) { selector = new ClientSourcedSelector(selector, context); } - context.getInstanceStore().putMetaObject(ENTITY_SELECTOR, selector); + instanceStore.putMetaObject(ENTITY_SELECTOR, selector); if ((playerComponent == null || SNAPSHOT_SOURCE != SelectInteraction.SnapshotSource.CLIENT) && time <= 0.0F && this.getRunTime() > 0.0F) { return; } } - Player playerComponentx = commandBuffer.getComponent(ref, Player.getComponentType()); World world = commandBuffer.getExternalData().getWorld(); - Selector selectorx = context.getInstanceStore().getMetaObject(ENTITY_SELECTOR); + Selector selectorx = instanceStore.getMetaObject(ENTITY_SELECTOR); selectorx.tick(commandBuffer, context.getEntity(), Math.min(time, this.getRunTime()), this.getRunTime()); boolean checkEntities = this.hitEntity != null || this.hitEntityRules != null; if (checkEntities) { - IntSet hitEntities = context.getInstanceStore().getMetaObject(HIT_ENTITIES); + IntSet hitEntities = instanceStore.getMetaObject(HIT_ENTITIES); selectorx.selectTargetEntities(commandBuffer, context.getEntity(), (targetRef, hit) -> { NetworkId networkIdComponent = targetRef.getStore().getComponent(targetRef, NetworkId.getComponentType()); if (networkIdComponent != null) { @@ -200,7 +204,7 @@ public class SelectInteraction extends SimpleInteraction { DynamicMetaStore metaStore = subCtx.getMetaStore(); metaStore.putMetaObject(TARGET_ENTITY, targetRef); metaStore.putMetaObject(HIT_LOCATION, hit); - metaStore.putMetaObject(SELECT_META_STORE, context.getInstanceStore()); + metaStore.putMetaObject(SELECT_META_STORE, instanceStore); metaStore.removeMetaObject(TARGET_BLOCK); metaStore.removeMetaObject(TARGET_BLOCK_RAW); if (playerComponent != null && SNAPSHOT_SOURCE == SelectInteraction.SnapshotSource.CLIENT) { @@ -235,7 +239,7 @@ public class SelectInteraction extends SimpleInteraction { } if (this.hitBlock != null) { - Set hitBlocks = context.getInstanceStore().getMetaObject(HIT_BLOCKS); + Set hitBlocks = instanceStore.getMetaObject(HIT_BLOCKS); RootInteraction hitBlock = RootInteraction.getRootInteractionOrUnknown(this.hitBlock); selectorx.selectTargetBlocks(commandBuffer, context.getEntity(), (x, y, z) -> { BlockPosition rawBlock = new BlockPosition(x, y, z); @@ -245,7 +249,7 @@ public class SelectInteraction extends SimpleInteraction { DynamicMetaStore metaStore = subCtx.getMetaStore(); metaStore.putMetaObject(TARGET_BLOCK, targetBlock); metaStore.putMetaObject(TARGET_BLOCK_RAW, rawBlock); - metaStore.putMetaObject(SELECT_META_STORE, context.getInstanceStore()); + metaStore.putMetaObject(SELECT_META_STORE, instanceStore); metaStore.removeMetaObject(TARGET_ENTITY); context.fork(new InteractionChainData(), context.getChain().getType(), subCtx, hitBlock, false); } @@ -258,7 +262,7 @@ public class SelectInteraction extends SimpleInteraction { } } - if (playerComponentx != null && SNAPSHOT_SOURCE == SelectInteraction.SnapshotSource.CLIENT && context.getState().state != InteractionState.Failed) { + if (playerComponent != null && SNAPSHOT_SOURCE == SelectInteraction.SnapshotSource.CLIENT && context.getState().state != InteractionState.Failed) { context.getState().state = context.getClientState().state; } @@ -267,7 +271,7 @@ public class SelectInteraction extends SimpleInteraction { @Override protected void simulateTick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @NonNullDecl InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { } @@ -333,7 +337,9 @@ public class SelectInteraction extends SimpleInteraction { } public abstract static class EntityMatcher implements NetworkSerializable { + @Nonnull public static final CodecMapCodec CODEC = new CodecMapCodec<>("Type"); + @Nonnull public static final BuilderCodec BASE_CODEC = BuilderCodec.abstractBuilder(SelectInteraction.EntityMatcher.class) .appendInherited(new KeyedCodec<>("Invert", Codec.BOOLEAN), (o, i) -> o.invert = i, o -> o.invert, (o, p) -> o.invert = p.invert) .documentation("Inverts the result of the matcher") @@ -341,14 +347,11 @@ public class SelectInteraction extends SimpleInteraction { .build(); protected boolean invert; - public EntityMatcher() { + public final boolean test(@Nonnull Ref sourceRef, @Nonnull Ref targetRef, @Nonnull CommandBuffer commandBuffer) { + return this.test0(sourceRef, targetRef, commandBuffer) ^ this.invert; } - public final boolean test(Ref attacker, Ref target, CommandBuffer commandBuffer) { - return this.test0(attacker, target, commandBuffer) ^ this.invert; - } - - public abstract boolean test0(Ref var1, Ref var2, CommandBuffer var3); + public abstract boolean test0(@Nonnull Ref var1, @Nonnull Ref var2, @Nonnull CommandBuffer var3); @Nonnull public com.hypixel.hytale.protocol.EntityMatcher toPacket() { @@ -360,6 +363,7 @@ public class SelectInteraction extends SimpleInteraction { } public static class HitEntity implements NetworkSerializable { + @Nonnull public static final BuilderCodec CODEC = BuilderCodec.builder( SelectInteraction.HitEntity.class, SelectInteraction.HitEntity::new ) @@ -379,9 +383,6 @@ public class SelectInteraction extends SimpleInteraction { protected String next; protected SelectInteraction.EntityMatcher[] matchers; - public HitEntity() { - } - @Nonnull public com.hypixel.hytale.protocol.HitEntity toPacket() { com.hypixel.hytale.protocol.EntityMatcher[] protoMatchers = new com.hypixel.hytale.protocol.EntityMatcher[this.matchers.length]; @@ -398,8 +399,5 @@ public class SelectInteraction extends SimpleInteraction { SERVER, @Deprecated CLIENT; - - private SnapshotSource() { - } } } diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/SerialInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/SerialInteraction.java index 579bbc8..c66a6c8 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/SerialInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/SerialInteraction.java @@ -14,7 +14,6 @@ import com.hypixel.hytale.server.core.modules.interaction.interaction.config.dat import com.hypixel.hytale.server.core.modules.interaction.interaction.operation.OperationsBuilder; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class SerialInteraction extends Interaction { @Nonnull @@ -35,19 +34,16 @@ public class SerialInteraction extends Interaction { .build(); protected String[] interactions; - public SerialInteraction() { - } - @Override protected void tick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @NonNullDecl InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { throw new IllegalStateException("Should not be reached"); } @Override protected void simulateTick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @NonNullDecl InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { throw new IllegalStateException("Should not be reached"); } diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/StatsConditionBaseInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/StatsConditionBaseInteraction.java index e6b8b24..73b475e 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/StatsConditionBaseInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/StatsConditionBaseInteraction.java @@ -72,9 +72,6 @@ public abstract class StatsConditionBaseInteraction extends SimpleInstantInterac protected boolean lenient; protected ValueType valueType = ValueType.Absolute; - public StatsConditionBaseInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { Ref ref = context.getEntity(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/StatsConditionInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/StatsConditionInteraction.java index 5c2e7d8..c4b5ba5 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/StatsConditionInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/StatsConditionInteraction.java @@ -24,9 +24,6 @@ public class StatsConditionInteraction extends StatsConditionBaseInteraction { .documentation("Interaction that is successful if the given stat conditions match.") .build(); - public StatsConditionInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { CommandBuffer commandBuffer = context.getCommandBuffer(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/StatsConditionWithModifierInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/StatsConditionWithModifierInteraction.java index 77baa63..8894521 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/StatsConditionWithModifierInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/StatsConditionWithModifierInteraction.java @@ -44,9 +44,6 @@ public class StatsConditionWithModifierInteraction extends StatsConditionBaseInt .build(); protected ItemArmor.InteractionModifierId interactionModifierId; - public StatsConditionWithModifierInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { CommandBuffer commandBuffer = context.getCommandBuffer(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/simple/ApplyEffectInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/simple/ApplyEffectInteraction.java index 2219065..3100359 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/simple/ApplyEffectInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/simple/ApplyEffectInteraction.java @@ -43,9 +43,6 @@ public class ApplyEffectInteraction extends SimpleInstantInteraction { @Nonnull private InteractionTarget entityTarget = InteractionTarget.USER; - public ApplyEffectInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { if (this.effectId != null) { diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/simple/RemoveEntityInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/simple/RemoveEntityInteraction.java index ab0627d..4ad653e 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/simple/RemoveEntityInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/simple/RemoveEntityInteraction.java @@ -34,9 +34,6 @@ public class RemoveEntityInteraction extends SimpleInstantInteraction { @Nonnull private InteractionTarget entityTarget = InteractionTarget.USER; - public RemoveEntityInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { CommandBuffer commandBuffer = context.getCommandBuffer(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/AOECircleSelector.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/AOECircleSelector.java index 7628131..264cb1b 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/AOECircleSelector.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/AOECircleSelector.java @@ -48,9 +48,6 @@ public class AOECircleSelector extends SelectorType { @Nonnull protected Vector3d offset = Vector3d.ZERO; - public AOECircleSelector() { - } - @Nonnull @Override public Selector newSelector() { @@ -87,9 +84,6 @@ public class AOECircleSelector extends SelectorType { } private class RuntimeSelector implements Selector { - private RuntimeSelector() { - } - @Override public void tick(@Nonnull CommandBuffer commandBuffer, @Nonnull Ref ref, float time, float runTime) { if (SelectInteraction.SHOW_VISUAL_DEBUG) { diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/AOECylinderSelector.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/AOECylinderSelector.java index ae537ad..aeb5878 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/AOECylinderSelector.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/AOECylinderSelector.java @@ -41,9 +41,6 @@ public class AOECylinderSelector extends AOECircleSelector { private final AOECylinderSelector.RuntimeSelector instance = new AOECylinderSelector.RuntimeSelector(); protected float height; - public AOECylinderSelector() { - } - @Nonnull @Override public Selector newSelector() { @@ -56,9 +53,6 @@ public class AOECylinderSelector extends AOECircleSelector { } private class RuntimeSelector implements Selector { - private RuntimeSelector() { - } - @Override public void tick(@Nonnull CommandBuffer commandBuffer, @Nonnull Ref ref, float time, float runTime) { if (SelectInteraction.SHOW_VISUAL_DEBUG) { diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/HorizontalSelector.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/HorizontalSelector.java index 0c37a64..b6d9d13 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/HorizontalSelector.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/HorizontalSelector.java @@ -39,6 +39,7 @@ import java.util.function.Predicate; import javax.annotation.Nonnull; public class HorizontalSelector extends SelectorType { + @Nonnull public static final BuilderCodec CODEC = BuilderCodec.builder(HorizontalSelector.class, HorizontalSelector::new, BASE_CODEC) .documentation("A selector that swings in a horizontal arc over a given period of time.") .appendInherited( @@ -134,9 +135,6 @@ public class HorizontalSelector extends SelectorType { protected HorizontalSelector.Direction direction; protected boolean testLineOfSight = true; - public HorizontalSelector() { - } - @Nonnull @Override public Selector newSelector() { @@ -166,12 +164,13 @@ public class HorizontalSelector extends SelectorType { TO_RIGHT(-1.0), TO_LEFT(1.0); + @Nonnull public static final EnumCodec CODEC = new EnumCodec<>(HorizontalSelector.Direction.class) .documentKey(TO_LEFT, "A arc that starts at the right and moves towards the left.") .documentKey(TO_RIGHT, "A arc that starts at the left and moves towards the right."); private final double yawModifier; - private Direction(double yawModifier) { + private Direction(final double yawModifier) { this.yawModifier = yawModifier; } } @@ -185,17 +184,25 @@ public class HorizontalSelector extends SelectorType { protected FrustumProjectionProvider projectionProvider = new FrustumProjectionProvider(); @Nonnull protected DirectionViewProvider viewProvider = new DirectionViewProvider(); - protected float lastTime = 0.0F; + protected float lastTime; protected double runTimeDeltaPercentageSum; - private RuntimeSelector() { - } - @Override public void tick(@Nonnull CommandBuffer commandBuffer, @Nonnull Ref attacker, float time, float runTime) { - float yOffset = commandBuffer.getComponent(attacker, ModelComponent.getComponentType()).getModel().getEyeHeight(attacker, commandBuffer); - Vector3d position = commandBuffer.getComponent(attacker, TransformComponent.getComponentType()).getPosition(); - HeadRotation look = commandBuffer.getComponent(attacker, HeadRotation.getComponentType()); + ModelComponent modelComponent = commandBuffer.getComponent(attacker, ModelComponent.getComponentType()); + + assert modelComponent != null; + + float yOffset = modelComponent.getModel().getEyeHeight(attacker, commandBuffer); + TransformComponent transformComponent = commandBuffer.getComponent(attacker, TransformComponent.getComponentType()); + + assert transformComponent != null; + + Vector3d position = transformComponent.getPosition(); + HeadRotation headRotationComponent = commandBuffer.getComponent(attacker, HeadRotation.getComponentType()); + + assert headRotationComponent != null; + double posX = position.getX(); double posY = position.getY() + yOffset; double posZ = position.getZ(); @@ -216,23 +223,49 @@ public class HorizontalSelector extends SelectorType { .setBottom(HorizontalSelector.this.extendBottom * stretchFactor) .setRotation(yawOffset, HorizontalSelector.this.pitchOffset, HorizontalSelector.this.rollOffset) .setTop(HorizontalSelector.this.extendTop * stretchFactor); - this.viewProvider.setPosition(posX, posY, posZ).setDirection(look.getRotation().getYaw(), look.getRotation().getPitch()); + this.viewProvider + .setPosition(posX, posY, posZ) + .setDirection(headRotationComponent.getRotation().getYaw(), headRotationComponent.getRotation().getPitch()); this.executor.setOrigin(posX, posY, posZ).setProjectionProvider(this.projectionProvider).setViewProvider(this.viewProvider); if (HorizontalSelector.this.testLineOfSight) { + World world = commandBuffer.getStore().getExternalData().getWorld(); LineOfSightProvider provider = (fromX, fromY, fromZ, toX, toY, toZ) -> { LocalCachedChunkAccessor localAccessor = LocalCachedChunkAccessor.atWorldCoords( - commandBuffer.getStore().getExternalData().getWorld(), (int)fromX, (int)fromZ, (int)(HorizontalSelector.this.endDistance + 1.0) - ); - return BlockIterator.iterateFromTo( - fromX, - fromY, - fromZ, - toX, - toY, - toZ, - (x, y, z, px, py, pz, qx, qy, qz, accessor) -> accessor.getBlockType(x, y, z).getMaterial() != BlockMaterial.Solid, - localAccessor + world, (int)fromX, (int)fromZ, (int)(HorizontalSelector.this.endDistance + 1.0) ); + return BlockIterator.iterateFromTo(fromX, fromY, fromZ, toX, toY, toZ, (x, y, z, px, py, pz, qx, qy, qz, accessor) -> { + long chunkIndex = ChunkUtil.indexChunkFromBlock(x, z); + WorldChunk worldChunk = accessor.getChunkIfInMemory(chunkIndex); + if (worldChunk == null) { + return true; + } else { + BlockType blockType = worldChunk.getBlockType(x, y, z); + if (blockType == null) { + return true; + } else { + if (blockType.getMaterial() == BlockMaterial.Solid) { + int hitboxTypeIndex = blockType.getHitboxTypeIndex(); + BlockBoundingBoxes blockHitboxes = BlockBoundingBoxes.getAssetMap().getAsset(hitboxTypeIndex); + if (blockHitboxes == null) { + return true; + } + + Vector3d lineFrom = new Vector3d(fromX, fromY, fromZ); + Vector3d lineTo = new Vector3d(toX, toY, toZ); + BlockBoundingBoxes.RotatedVariantBoxes rotatedHitboxes = blockHitboxes.get(accessor.getBlockRotationIndex(x, y, z)); + + for (Box box : rotatedHitboxes.getDetailBoxes()) { + Box offsetBox = box.clone().offset(x, y, z); + if (offsetBox.intersectsLine(lineFrom, lineTo)) { + return false; + } + } + } + + return true; + } + } + }, localAccessor); }; this.executor.setLineOfSightProvider(provider); } else { @@ -244,8 +277,8 @@ public class HorizontalSelector extends SelectorType { Matrix4d matrix = new Matrix4d(); matrix.identity() .translate(posX, posY, posZ) - .rotateAxis(-look.getRotation().getYaw(), 0.0, 1.0, 0.0, tmp) - .rotateAxis(-look.getRotation().getPitch(), 1.0, 0.0, 0.0, tmp); + .rotateAxis(-headRotationComponent.getRotation().getYaw(), 0.0, 1.0, 0.0, tmp) + .rotateAxis(-headRotationComponent.getRotation().getPitch(), 1.0, 0.0, 0.0, tmp); Vector3f color = new Vector3f( (float)HashUtil.random(attacker.getIndex(), this.hashCode(), 10L), (float)HashUtil.random(attacker.getIndex(), this.hashCode(), 11L), @@ -264,17 +297,29 @@ public class HorizontalSelector extends SelectorType { @Nonnull BiConsumer, Vector4d> consumer, Predicate> filter ) { - Selector.selectNearbyEntities(commandBuffer, attacker, HorizontalSelector.this.endDistance + 3.0, entity -> { - BoundingBox hitboxComponent = commandBuffer.getComponent(entity, BoundingBox.getComponentType()); - if (hitboxComponent != null) { - Box hitbox = hitboxComponent.getBoundingBox(); - TransformComponent transform = commandBuffer.getComponent(entity, TransformComponent.getComponentType()); - this.modelMatrix.identity().translate(transform.getPosition()).translate(hitbox.getMin()).scale(hitbox.width(), hitbox.height(), hitbox.depth()); - if (this.executor.test(HitDetectionExecutor.CUBE_QUADS, this.modelMatrix)) { - consumer.accept(entity, this.executor.getHitLocation()); + Selector.selectNearbyEntities( + commandBuffer, + attacker, + HorizontalSelector.this.endDistance + 3.0, + entity -> { + BoundingBox boundingBoxComponent = commandBuffer.getComponent(entity, BoundingBox.getComponentType()); + if (boundingBoxComponent != null) { + Box hitbox = boundingBoxComponent.getBoundingBox(); + TransformComponent transformComponent = commandBuffer.getComponent(entity, TransformComponent.getComponentType()); + if (transformComponent != null) { + this.modelMatrix + .identity() + .translate(transformComponent.getPosition()) + .translate(hitbox.getMin()) + .scale(hitbox.width(), hitbox.height(), hitbox.depth()); + if (this.executor.test(HitDetectionExecutor.CUBE_QUADS, this.modelMatrix)) { + consumer.accept(entity, this.executor.getHitLocation()); + } + } } - } - }, filter); + }, + filter + ); } @Override @@ -284,16 +329,20 @@ public class HorizontalSelector extends SelectorType { WorldChunk chunk = world.getChunkIfInMemory(ChunkUtil.indexChunkFromBlock(x, z)); if (chunk != null) { BlockType blockType = chunk.getBlockType(x, y, z); - if (blockType != BlockType.EMPTY) { + if (blockType != null && blockType != BlockType.EMPTY) { int rotation = chunk.getRotationIndex(x, y, z); - Box[] hitboxes = BlockBoundingBoxes.getAssetMap().getAsset(blockType.getHitboxTypeIndex()).get(rotation).getDetailBoxes(); + int hitboxTypeIndex = blockType.getHitboxTypeIndex(); + BlockBoundingBoxes boundingBoxAsset = BlockBoundingBoxes.getAssetMap().getAsset(hitboxTypeIndex); + if (boundingBoxAsset != null) { + Box[] hitboxes = boundingBoxAsset.get(rotation).getDetailBoxes(); - for (int i = 0; i < hitboxes.length; i++) { - Box hitbox = hitboxes[i]; - this.modelMatrix.identity().translate(x, y, z).translate(hitbox.getMin()).scale(hitbox.width(), hitbox.height(), hitbox.depth()); - if (this.executor.test(HitDetectionExecutor.CUBE_QUADS, this.modelMatrix)) { - consumer.accept(x, y, z); - break; + for (int i = 0; i < hitboxes.length; i++) { + Box hitbox = hitboxes[i]; + this.modelMatrix.identity().translate(x, y, z).translate(hitbox.getMin()).scale(hitbox.width(), hitbox.height(), hitbox.depth()); + if (this.executor.test(HitDetectionExecutor.CUBE_QUADS, this.modelMatrix)) { + consumer.accept(x, y, z); + break; + } } } } diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/PlayerMatcher.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/PlayerMatcher.java index 00a42fb..862249e 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/PlayerMatcher.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/PlayerMatcher.java @@ -11,16 +11,14 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class PlayerMatcher extends SelectInteraction.EntityMatcher { + @Nonnull public static final BuilderCodec CODEC = BuilderCodec.builder(PlayerMatcher.class, PlayerMatcher::new, BASE_CODEC) .documentation("Matches only players") .build(); - public PlayerMatcher() { - } - @Override - public boolean test0(Ref attacker, @Nonnull Ref target, @Nonnull CommandBuffer commandBuffer) { - return commandBuffer.getArchetype(target).contains(Player.getComponentType()); + public boolean test0(@Nonnull Ref sourceRef, @Nonnull Ref targetRef, @Nonnull CommandBuffer commandBuffer) { + return commandBuffer.getArchetype(targetRef).contains(Player.getComponentType()); } @Nonnull diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/RaycastSelector.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/RaycastSelector.java index 8e5cc88..b40610f 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/RaycastSelector.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/RaycastSelector.java @@ -65,9 +65,6 @@ public class RaycastSelector extends SelectorType { protected String blockTag; protected int blockTagIndex = Integer.MIN_VALUE; - public RaycastSelector() { - } - @Nonnull @Override public Selector newSelector() { @@ -104,9 +101,6 @@ public class RaycastSelector extends SelectorType { public double distance = Double.MAX_VALUE; @Nonnull public Vector4d hitPosition = new Vector4d(); - - private Result() { - } } private class RuntimeSelector implements Selector { @@ -115,9 +109,6 @@ public class RaycastSelector extends SelectorType { @Nullable private Vector3i blockPosition; - private RuntimeSelector() { - } - @Override public void tick(@Nonnull CommandBuffer commandBuffer, @Nonnull Ref ref, float time, float runTime) { Vector3d position = RaycastSelector.this.selectTargetPosition(commandBuffer, ref); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/SelectorType.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/SelectorType.java index 76a21de..95396bc 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/SelectorType.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/SelectorType.java @@ -3,13 +3,14 @@ package com.hypixel.hytale.server.core.modules.interaction.interaction.config.se import com.hypixel.hytale.codec.builder.BuilderCodec; import com.hypixel.hytale.codec.lookup.CodecMapCodec; import com.hypixel.hytale.server.core.io.NetworkSerializable; +import javax.annotation.Nonnull; public abstract class SelectorType implements NetworkSerializable { + @Nonnull public static final CodecMapCodec CODEC = new CodecMapCodec<>(); + @Nonnull public static final BuilderCodec BASE_CODEC = BuilderCodec.abstractBuilder(SelectorType.class).build(); - public SelectorType() { - } - + @Nonnull public abstract Selector newSelector(); } diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/StabSelector.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/StabSelector.java index d595a09..8cf707e 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/StabSelector.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/StabSelector.java @@ -18,6 +18,7 @@ import com.hypixel.hytale.math.util.HashUtil; import com.hypixel.hytale.math.vector.Vector3d; import com.hypixel.hytale.math.vector.Vector3f; import com.hypixel.hytale.math.vector.Vector4d; +import com.hypixel.hytale.protocol.BlockMaterial; import com.hypixel.hytale.server.core.asset.type.blockhitbox.BlockBoundingBoxes; import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType; import com.hypixel.hytale.server.core.modules.debug.DebugUtils; @@ -35,6 +36,7 @@ import java.util.function.Predicate; import javax.annotation.Nonnull; public class StabSelector extends SelectorType { + @Nonnull public static final BuilderCodec CODEC = BuilderCodec.builder(StabSelector.class, StabSelector::new, BASE_CODEC) .documentation("A selector that stabs in a straight line over a given period of time.") .appendInherited( @@ -129,9 +131,6 @@ public class StabSelector extends SelectorType { protected double endDistance; protected boolean testLineOfSight; - public StabSelector() { - } - @Nonnull @Override public Selector newSelector() { @@ -162,17 +161,25 @@ public class StabSelector extends SelectorType { protected OrthogonalProjectionProvider projectionProvider = new OrthogonalProjectionProvider(); @Nonnull protected DirectionViewProvider viewProvider = new DirectionViewProvider(); - protected float lastTime = 0.0F; + protected float lastTime; protected double runTimeDeltaPercentageSum; - private RuntimeSelector() { - } - @Override public void tick(@Nonnull CommandBuffer commandBuffer, @Nonnull Ref attacker, float time, float runTime) { - float yOffset = commandBuffer.getComponent(attacker, ModelComponent.getComponentType()).getModel().getEyeHeight(attacker, commandBuffer); - Vector3d position = commandBuffer.getComponent(attacker, TransformComponent.getComponentType()).getPosition(); - HeadRotation look = commandBuffer.getComponent(attacker, HeadRotation.getComponentType()); + ModelComponent modelComponent = commandBuffer.getComponent(attacker, ModelComponent.getComponentType()); + + assert modelComponent != null; + + float yOffset = modelComponent.getModel().getEyeHeight(attacker, commandBuffer); + TransformComponent transformComponent = commandBuffer.getComponent(attacker, TransformComponent.getComponentType()); + + assert transformComponent != null; + + Vector3d position = transformComponent.getPosition(); + HeadRotation headRotationComponent = commandBuffer.getComponent(attacker, HeadRotation.getComponentType()); + + assert headRotationComponent != null; + double posX = position.getX(); double posY = position.getY() + yOffset; double posZ = position.getZ(); @@ -190,21 +197,51 @@ public class StabSelector extends SelectorType { .setBottom(StabSelector.this.extendBottom) .setTop(StabSelector.this.extendTop) .setRotation(StabSelector.this.yawOffset, StabSelector.this.pitchOffset, StabSelector.this.rollOffset); - this.viewProvider.setPosition(posX, posY, posZ).setDirection(look.getRotation().getYaw(), look.getRotation().getPitch()); + this.viewProvider + .setPosition(posX, posY, posZ) + .setDirection(headRotationComponent.getRotation().getYaw(), headRotationComponent.getRotation().getPitch()); this.executor.setOrigin(posX, posY, posZ).setProjectionProvider(this.projectionProvider).setViewProvider(this.viewProvider); if (StabSelector.this.testLineOfSight) { - this.executor - .setLineOfSightProvider( - (fromX, fromY, fromZ, toX, toY, toZ) -> { - LocalCachedChunkAccessor localAccessor = LocalCachedChunkAccessor.atWorldCoords( - commandBuffer.getStore().getExternalData().getWorld(), (int)fromX, (int)fromZ, (int)(StabSelector.this.endDistance + 1.0) - ); - return BlockIterator.iterateFromTo(fromX, fromY, fromZ, toX, toY, toZ, (x, y, z, px, py, pz, qx, qy, qz, accessor) -> { - int blockId = accessor.getBlock(x, y, z); - return blockId == 0; - }, localAccessor); - } + World world = commandBuffer.getStore().getExternalData().getWorld(); + LineOfSightProvider provider = (fromX, fromY, fromZ, toX, toY, toZ) -> { + LocalCachedChunkAccessor localAccessor = LocalCachedChunkAccessor.atWorldCoords( + world, (int)fromX, (int)fromZ, (int)(StabSelector.this.endDistance + 1.0) ); + return BlockIterator.iterateFromTo(fromX, fromY, fromZ, toX, toY, toZ, (x, y, z, px, py, pz, qx, qy, qz, accessor) -> { + long chunkIndex = ChunkUtil.indexChunkFromBlock(x, z); + WorldChunk worldChunk = accessor.getChunkIfInMemory(chunkIndex); + if (worldChunk == null) { + return true; + } else { + BlockType blockType = worldChunk.getBlockType(x, y, z); + if (blockType == null) { + return true; + } else { + if (blockType.getMaterial() == BlockMaterial.Solid) { + int hitboxTypeIndex = blockType.getHitboxTypeIndex(); + BlockBoundingBoxes blockHitboxes = BlockBoundingBoxes.getAssetMap().getAsset(hitboxTypeIndex); + if (blockHitboxes == null) { + return true; + } + + Vector3d lineFrom = new Vector3d(fromX, fromY, fromZ); + Vector3d lineTo = new Vector3d(toX, toY, toZ); + BlockBoundingBoxes.RotatedVariantBoxes rotatedHitboxes = blockHitboxes.get(accessor.getBlockRotationIndex(x, y, z)); + + for (Box box : rotatedHitboxes.getDetailBoxes()) { + Box offsetBox = box.clone().offset(x, y, z); + if (offsetBox.intersectsLine(lineFrom, lineTo)) { + return false; + } + } + } + + return true; + } + } + }, localAccessor); + }; + this.executor.setLineOfSightProvider(provider); } else { this.executor.setLineOfSightProvider(LineOfSightProvider.DEFAULT_TRUE); } @@ -214,8 +251,8 @@ public class StabSelector extends SelectorType { Matrix4d matrix = new Matrix4d(); matrix.identity() .translate(posX, posY, posZ) - .rotateAxis(-look.getRotation().getYaw(), 0.0, 1.0, 0.0, tmp) - .rotateAxis(-look.getRotation().getPitch(), 1.0, 0.0, 0.0, tmp); + .rotateAxis(-headRotationComponent.getRotation().getYaw(), 0.0, 1.0, 0.0, tmp) + .rotateAxis(-headRotationComponent.getRotation().getPitch(), 1.0, 0.0, 0.0, tmp); Vector3f color = new Vector3f( (float)HashUtil.random(attacker.getIndex(), this.hashCode(), 10L), (float)HashUtil.random(attacker.getIndex(), this.hashCode(), 11L), @@ -234,17 +271,29 @@ public class StabSelector extends SelectorType { @Nonnull BiConsumer, Vector4d> consumer, Predicate> filter ) { - Selector.selectNearbyEntities(commandBuffer, attacker, StabSelector.this.endDistance + 3.0, entity -> { - BoundingBox hitboxComponent = commandBuffer.getComponent(entity, BoundingBox.getComponentType()); - if (hitboxComponent != null) { - Box hitbox = hitboxComponent.getBoundingBox(); - TransformComponent transform = commandBuffer.getComponent(entity, TransformComponent.getComponentType()); - this.modelMatrix.identity().translate(transform.getPosition()).translate(hitbox.getMin()).scale(hitbox.width(), hitbox.height(), hitbox.depth()); - if (this.executor.test(HitDetectionExecutor.CUBE_QUADS, this.modelMatrix)) { - consumer.accept(entity, this.executor.getHitLocation()); + Selector.selectNearbyEntities( + commandBuffer, + attacker, + StabSelector.this.endDistance + 3.0, + entity -> { + BoundingBox boundingBoxComponent = commandBuffer.getComponent(entity, BoundingBox.getComponentType()); + if (boundingBoxComponent != null) { + Box hitbox = boundingBoxComponent.getBoundingBox(); + TransformComponent transformComponent = commandBuffer.getComponent(entity, TransformComponent.getComponentType()); + if (transformComponent != null) { + this.modelMatrix + .identity() + .translate(transformComponent.getPosition()) + .translate(hitbox.getMin()) + .scale(hitbox.width(), hitbox.height(), hitbox.depth()); + if (this.executor.test(HitDetectionExecutor.CUBE_QUADS, this.modelMatrix)) { + consumer.accept(entity, this.executor.getHitLocation()); + } + } } - } - }, filter); + }, + filter + ); } @Override @@ -254,16 +303,20 @@ public class StabSelector extends SelectorType { WorldChunk chunk = world.getChunkIfInMemory(ChunkUtil.indexChunkFromBlock(x, z)); if (chunk != null) { BlockType blockType = chunk.getBlockType(x, y, z); - if (blockType != BlockType.EMPTY) { + if (blockType != null && blockType != BlockType.EMPTY) { int rotation = chunk.getRotationIndex(x, y, z); - Box[] hitboxes = BlockBoundingBoxes.getAssetMap().getAsset(blockType.getHitboxTypeIndex()).get(rotation).getDetailBoxes(); + int hitboxTypeIndex = blockType.getHitboxTypeIndex(); + BlockBoundingBoxes boundingBoxAsset = BlockBoundingBoxes.getAssetMap().getAsset(hitboxTypeIndex); + if (boundingBoxAsset != null) { + Box[] hitboxes = boundingBoxAsset.get(rotation).getDetailBoxes(); - for (int i = 0; i < hitboxes.length; i++) { - Box hitbox = hitboxes[i]; - this.modelMatrix.identity().translate(x, y, z).translate(hitbox.getMin()).scale(hitbox.width(), hitbox.height(), hitbox.depth()); - if (this.executor.test(HitDetectionExecutor.CUBE_QUADS, this.modelMatrix)) { - consumer.accept(x, y, z); - break; + for (int i = 0; i < hitboxes.length; i++) { + Box hitbox = hitboxes[i]; + this.modelMatrix.identity().translate(x, y, z).translate(hitbox.getMin()).scale(hitbox.width(), hitbox.height(), hitbox.depth()); + if (this.executor.test(HitDetectionExecutor.CUBE_QUADS, this.modelMatrix)) { + consumer.accept(x, y, z); + break; + } } } } diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/VulnerableMatcher.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/VulnerableMatcher.java index 3b34889..839410f 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/VulnerableMatcher.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/VulnerableMatcher.java @@ -16,13 +16,9 @@ public class VulnerableMatcher extends SelectInteraction.EntityMatcher { .documentation("Used to match any entity that is attackable") .build(); - public VulnerableMatcher() { - } - @Override - public boolean test0(Ref attacker, @Nonnull Ref target, @Nonnull CommandBuffer commandBuffer) { - boolean invulnerable = commandBuffer.getArchetype(target).contains(Invulnerable.getComponentType()); - return !invulnerable; + public boolean test0(@Nonnull Ref sourceRef, @Nonnull Ref targetRef, @Nonnull CommandBuffer commandBuffer) { + return !commandBuffer.getArchetype(targetRef).contains(Invulnerable.getComponentType()); } @Nonnull diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/ChangeStatBaseInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/ChangeStatBaseInteraction.java index bc8dcc2..fddd1bb 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/ChangeStatBaseInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/ChangeStatBaseInteraction.java @@ -64,9 +64,6 @@ public abstract class ChangeStatBaseInteraction extends SimpleInstantInteraction protected ChangeStatBehaviour changeStatBehaviour = ChangeStatBehaviour.Add; protected InteractionTarget entityTarget = InteractionTarget.USER; - public ChangeStatBaseInteraction() { - } - @Nonnull @Override public String toString() { diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/ChangeStatInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/ChangeStatInteraction.java index 8b6f8d8..88a1c94 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/ChangeStatInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/ChangeStatInteraction.java @@ -18,9 +18,6 @@ public class ChangeStatInteraction extends ChangeStatBaseInteraction { .documentation("Changes the given stats.") .build(); - public ChangeStatInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { CommandBuffer commandBuffer = context.getCommandBuffer(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/ChangeStatWithModifierInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/ChangeStatWithModifierInteraction.java index ff659ba..edda67b 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/ChangeStatWithModifierInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/ChangeStatWithModifierInteraction.java @@ -39,13 +39,13 @@ public class ChangeStatWithModifierInteraction extends ChangeStatBaseInteraction .build(); protected ItemArmor.InteractionModifierId interactionModifierId; - public ChangeStatWithModifierInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { Ref ref = context.getEntity(); CommandBuffer commandBuffer = context.getCommandBuffer(); + + assert commandBuffer != null; + EntityStatMap entityStatMapComponent = commandBuffer.getComponent(ref, EntityStatMap.getComponentType()); assert entityStatMapComponent != null; diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/CheckUniqueItemUsageInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/CheckUniqueItemUsageInteraction.java index 55afbcc..45a9c3b 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/CheckUniqueItemUsageInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/CheckUniqueItemUsageInteraction.java @@ -15,7 +15,6 @@ import com.hypixel.hytale.server.core.universe.PlayerRef; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import com.hypixel.hytale.server.core.util.NotificationUtil; import javax.annotation.Nonnull; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class CheckUniqueItemUsageInteraction extends SimpleInstantInteraction { public static final BuilderCodec CODEC = BuilderCodec.builder( @@ -23,9 +22,6 @@ public class CheckUniqueItemUsageInteraction extends SimpleInstantInteraction { ) .build(); - public CheckUniqueItemUsageInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { @@ -33,7 +29,7 @@ public class CheckUniqueItemUsageInteraction extends SimpleInstantInteraction { } @Override - protected void firstRun(@NonNullDecl InteractionType type, @NonNullDecl InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler) { + protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { CommandBuffer commandBuffer = context.getCommandBuffer(); assert commandBuffer != null; diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/ClearEntityEffectInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/ClearEntityEffectInteraction.java index abafdee..b7a3b68 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/ClearEntityEffectInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/ClearEntityEffectInteraction.java @@ -41,9 +41,6 @@ public class ClearEntityEffectInteraction extends SimpleInstantInteraction { @Nonnull private InteractionTarget entityTarget = InteractionTarget.USER; - public ClearEntityEffectInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { Ref ref = context.getEntity(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/DamageEntityInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/DamageEntityInteraction.java index e408a48..6087f03 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/DamageEntityInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/DamageEntityInteraction.java @@ -63,7 +63,6 @@ import java.util.Map.Entry; import java.util.stream.IntStream; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class DamageEntityInteraction extends Interaction { @Nonnull @@ -171,12 +170,9 @@ public class DamageEntityInteraction extends Interaction { @Nullable protected String failed; - public DamageEntityInteraction() { - } - @Override protected void tick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { Ref targetRef = context.getTargetEntity(); if (targetRef != null && targetRef.isValid() && context.getEntity().isValid()) { @@ -202,7 +198,7 @@ public class DamageEntityInteraction extends Interaction { @Override protected void simulateTick0( - boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + boolean firstRun, float time, @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler ) { this.tick0(firstRun, time, type, context, cooldownHandler); } @@ -572,9 +568,6 @@ public class DamageEntityInteraction extends Interaction { protected float angleRad; protected float angleDistanceRad; - public AngledDamage() { - } - @Nonnull public com.hypixel.hytale.protocol.AngledDamage toAngledDamagePacket() { com.hypixel.hytale.protocol.DamageEffects damageEffectsPacket = this.damageEffects == null ? null : this.damageEffects.toPacket(); @@ -645,9 +638,6 @@ public class DamageEntityInteraction extends Interaction { protected float multiplierPerExtraEntityHit = 0.05F; private int entityStatIndex; - public EntityStatOnHit() { - } - public void processEntityStatsOnHit(int hits, @Nonnull EntityStatMap statMap) { if (hits != 0) { float multiplier; @@ -727,9 +717,6 @@ public class DamageEntityInteraction extends Interaction { @Nullable protected String next; - public TargetedDamage() { - } - @Nonnull public com.hypixel.hytale.protocol.TargetedDamage toTargetedDamagePacket() { return new com.hypixel.hytale.protocol.TargetedDamage(this.index, this.damageEffects.toPacket(), Interaction.getInteractionIdOrUnknown(this.next)); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/DestroyConditionInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/DestroyConditionInteraction.java index bfaface..b2dbfec 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/DestroyConditionInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/DestroyConditionInteraction.java @@ -27,9 +27,6 @@ public class DestroyConditionInteraction extends SimpleBlockInteraction { .documentation("Checks if the target block is destroyable") .build(); - public DestroyConditionInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/DoorInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/DoorInteraction.java index 56792aa..b8d7b4c 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/DoorInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/DoorInteraction.java @@ -51,9 +51,6 @@ public class DoorInteraction extends SimpleBlockInteraction { .build(); private boolean horizontal; - public DoorInteraction() { - } - @Override protected void interactWithBlock( @Nonnull World world, @@ -395,9 +392,6 @@ public class DoorInteraction extends SimpleBlockInteraction { OPENED_IN, OPENED_OUT; - private DoorState() { - } - @Nonnull public static DoorInteraction.DoorState fromBlockState(@Nullable String state) { if (state == null) { diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/EquipItemInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/EquipItemInteraction.java index 60bc0f3..ab309ac 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/EquipItemInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/EquipItemInteraction.java @@ -28,9 +28,6 @@ public class EquipItemInteraction extends SimpleInstantInteraction { .documentation("Equips the item being held.") .build(); - public EquipItemInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { @@ -40,6 +37,9 @@ public class EquipItemInteraction extends SimpleInstantInteraction { @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { CommandBuffer commandBuffer = context.getCommandBuffer(); + + assert commandBuffer != null; + Ref ref = context.getEntity(); if (EntityUtils.getEntity(ref, commandBuffer) instanceof LivingEntity livingEntity) { Inventory var15 = livingEntity.getInventory(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/IncreaseBackpackCapacityInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/IncreaseBackpackCapacityInteraction.java index 9d79db0..0d25322 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/IncreaseBackpackCapacityInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/IncreaseBackpackCapacityInteraction.java @@ -15,7 +15,6 @@ import com.hypixel.hytale.server.core.modules.interaction.interaction.CooldownHa import com.hypixel.hytale.server.core.modules.interaction.interaction.config.SimpleInstantInteraction; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class IncreaseBackpackCapacityInteraction extends SimpleInstantInteraction { public static final BuilderCodec CODEC = BuilderCodec.builder( @@ -29,9 +28,6 @@ public class IncreaseBackpackCapacityInteraction extends SimpleInstantInteractio .build(); private short capacity = 1; - public IncreaseBackpackCapacityInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { @@ -39,7 +35,7 @@ public class IncreaseBackpackCapacityInteraction extends SimpleInstantInteractio } @Override - protected void firstRun(@NonNullDecl InteractionType type, @NonNullDecl InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler) { + protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { Ref ref = context.getEntity(); Player playerComponent = context.getCommandBuffer().getComponent(ref, Player.getComponentType()); if (playerComponent != null) { diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/InterruptInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/InterruptInteraction.java index d608acc..d6120c5 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/InterruptInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/InterruptInteraction.java @@ -70,9 +70,6 @@ public class InterruptInteraction extends SimpleInstantInteraction { private String excludedTag; private int excludedTagIndex = Integer.MIN_VALUE; - public InterruptInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { Ref ref = context.getEntity(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/LaunchPadInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/LaunchPadInteraction.java index 6e1156b..84173b1 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/LaunchPadInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/LaunchPadInteraction.java @@ -35,9 +35,6 @@ public class LaunchPadInteraction extends SimpleBlockInteraction { .documentation("Applies the launchpad forces.") .build(); - public LaunchPadInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/LaunchProjectileInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/LaunchProjectileInteraction.java index f059719..a8a010a 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/LaunchProjectileInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/LaunchProjectileInteraction.java @@ -52,9 +52,6 @@ public class LaunchProjectileInteraction extends SimpleInstantInteraction implem .build(); protected String projectileId; - public LaunchProjectileInteraction() { - } - public String getProjectileId() { return this.projectileId; } @@ -72,50 +69,49 @@ public class LaunchProjectileInteraction extends SimpleInstantInteraction implem assert commandBuffer != null; World world = commandBuffer.getExternalData().getWorld(); - Ref attackerRef = context.getEntity(); - if (EntityUtils.getEntity(attackerRef, commandBuffer) instanceof LivingEntity attackerLivingEntity) { - Transform lookVec = TargetUtil.getLook(attackerRef, commandBuffer); + Ref sourceRef = context.getEntity(); + if (EntityUtils.getEntity(sourceRef, commandBuffer) instanceof LivingEntity attackerLivingEntity) { + Transform lookVec = TargetUtil.getLook(sourceRef, commandBuffer); Vector3d lookPosition = lookVec.getPosition(); Vector3f lookRotation = lookVec.getRotation(); - UUIDComponent attackerUuidComponent = commandBuffer.getComponent(attackerRef, UUIDComponent.getComponentType()); + UUIDComponent sourceUuidComponent = commandBuffer.getComponent(sourceRef, UUIDComponent.getComponentType()); + if (sourceUuidComponent != null) { + UUID sourceUuid = sourceUuidComponent.getUuid(); + TimeResource timeResource = commandBuffer.getResource(TimeResource.getResourceType()); + Holder holder = ProjectileComponent.assembleDefaultProjectile(timeResource, this.projectileId, lookPosition, lookRotation); + ProjectileComponent projectileComponent = holder.getComponent(ProjectileComponent.getComponentType()); - assert attackerUuidComponent != null; + assert projectileComponent != null; - UUID attackerUuid = attackerUuidComponent.getUuid(); - TimeResource timeResource = commandBuffer.getResource(TimeResource.getResourceType()); - Holder holder = ProjectileComponent.assembleDefaultProjectile(timeResource, this.projectileId, lookPosition, lookRotation); - ProjectileComponent projectileComponent = holder.getComponent(ProjectileComponent.getComponentType()); - - assert projectileComponent != null; - - holder.ensureComponent(Intangible.getComponentType()); - if (projectileComponent.getProjectile() == null) { - projectileComponent.initialize(); + holder.ensureComponent(Intangible.getComponentType()); if (projectileComponent.getProjectile() == null) { - return; - } - } - - projectileComponent.shoot( - holder, attackerUuid, lookPosition.getX(), lookPosition.getY(), lookPosition.getZ(), lookRotation.getYaw(), lookRotation.getPitch() - ); - commandBuffer.addEntity(holder, AddReason.SPAWN); - ItemStack itemInHand = context.getHeldItem(); - if (itemInHand != null && !itemInHand.isEmpty()) { - Item item = itemInHand.getItem(); - if (attackerLivingEntity.canDecreaseItemStackDurability(attackerRef, commandBuffer) && !itemInHand.isUnbreakable() && item.getWeapon() != null) { - Inventory inventory = attackerLivingEntity.getInventory(); - ItemContainer section = inventory.getSectionById(context.getHeldItemSectionId()); - if (section != null) { - attackerLivingEntity.updateItemStackDurability( - attackerRef, itemInHand, section, context.getHeldItemSlot(), -item.getDurabilityLossOnHit(), commandBuffer - ); + projectileComponent.initialize(); + if (projectileComponent.getProjectile() == null) { + return; } } - if (itemInHand.isBroken()) { - BrokenPenalties brokenPenalties = world.getGameplayConfig().getItemDurabilityConfig().getBrokenPenalties(); - projectileComponent.applyBrokenPenalty((float)brokenPenalties.getWeapon(1.0)); + projectileComponent.shoot( + holder, sourceUuid, lookPosition.getX(), lookPosition.getY(), lookPosition.getZ(), lookRotation.getYaw(), lookRotation.getPitch() + ); + commandBuffer.addEntity(holder, AddReason.SPAWN); + ItemStack itemInHand = context.getHeldItem(); + if (itemInHand != null && !itemInHand.isEmpty()) { + Item item = itemInHand.getItem(); + if (attackerLivingEntity.canDecreaseItemStackDurability(sourceRef, commandBuffer) && !itemInHand.isUnbreakable() && item.getWeapon() != null) { + Inventory inventory = attackerLivingEntity.getInventory(); + ItemContainer section = inventory.getSectionById(context.getHeldItemSectionId()); + if (section != null) { + attackerLivingEntity.updateItemStackDurability( + sourceRef, itemInHand, section, context.getHeldItemSlot(), -item.getDurabilityLossOnHit(), commandBuffer + ); + } + } + + if (itemInHand.isBroken()) { + BrokenPenalties brokenPenalties = world.getGameplayConfig().getItemDurabilityConfig().getBrokenPenalties(); + projectileComponent.applyBrokenPenalty((float)brokenPenalties.getWeapon(1.0)); + } } } } diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/ModifyInventoryInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/ModifyInventoryInteraction.java index 3b82d61..b582645 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/ModifyInventoryInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/ModifyInventoryInteraction.java @@ -105,9 +105,6 @@ public class ModifyInventoryInteraction extends SimpleInstantInteraction { private Boolean notifyOnBreak; private String notifyOnBreakMessage; - public ModifyInventoryInteraction() { - } - @Nonnull @Override public WaitForDataFrom getWaitForDataFrom() { @@ -119,7 +116,9 @@ public class ModifyInventoryInteraction extends SimpleInstantInteraction { Ref ref = context.getEntity(); CommandBuffer commandBuffer = context.getCommandBuffer(); Player playerComponent = commandBuffer.getComponent(ref, Player.getComponentType()); - if (playerComponent != null) { + if (playerComponent == null) { + context.getState().state = InteractionState.Failed; + } else { boolean hasRequiredGameMode = this.requiredGameMode == null || playerComponent.getGameMode() == this.requiredGameMode; if (hasRequiredGameMode) { CombinedItemContainer combinedHotbarFirst = playerComponent.getInventory().getCombinedHotbarFirst(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/OpenContainerInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/OpenContainerInteraction.java index ab31a35..66167f3 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/OpenContainerInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/OpenContainerInteraction.java @@ -36,9 +36,6 @@ public class OpenContainerInteraction extends SimpleBlockInteraction { .documentation("Opens the container of the block currently being interacted with.") .build(); - public OpenContainerInteraction() { - } - @Override protected void interactWithBlock( @Nonnull World world, diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/OpenCustomUIInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/OpenCustomUIInteraction.java index 48aaf50..e4a62e1 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/OpenCustomUIInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/OpenCustomUIInteraction.java @@ -53,9 +53,6 @@ public class OpenCustomUIInteraction extends SimpleInstantInteraction { .build(); private OpenCustomUIInteraction.CustomPageSupplier customPageSupplier; - public OpenCustomUIInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { Ref ref = context.getEntity(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/OpenItemStackContainerInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/OpenItemStackContainerInteraction.java index 15dcfcb..6245151 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/OpenItemStackContainerInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/OpenItemStackContainerInteraction.java @@ -27,9 +27,6 @@ public class OpenItemStackContainerInteraction extends SimpleInstantInteraction .documentation("Opens a container contained within the current held item.") .build(); - public OpenItemStackContainerInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { CommandBuffer commandBuffer = context.getCommandBuffer(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/OpenPageInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/OpenPageInteraction.java index 0d86533..c02a8cb 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/OpenPageInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/OpenPageInteraction.java @@ -40,9 +40,6 @@ public class OpenPageInteraction extends SimpleInstantInteraction { protected Page page; protected boolean canCloseThroughInteraction; - public OpenPageInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { Ref ref = context.getEntity(); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/PlacementCountConditionInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/PlacementCountConditionInteraction.java index 42dcbc2..3573c2a 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/PlacementCountConditionInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/PlacementCountConditionInteraction.java @@ -29,9 +29,6 @@ public class PlacementCountConditionInteraction extends SimpleInstantInteraction private int value = 0; private boolean lessThan = true; - public PlacementCountConditionInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { BlockCounter counter = context.getCommandBuffer().getExternalData().getWorld().getChunkStore().getStore().getResource(BlockCounter.getResourceType()); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/RefillContainerInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/RefillContainerInteraction.java index 7db9891..a487f57 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/RefillContainerInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/RefillContainerInteraction.java @@ -8,25 +8,31 @@ import com.hypixel.hytale.codec.codecs.map.MapCodec; import com.hypixel.hytale.codec.validation.Validators; import com.hypixel.hytale.component.CommandBuffer; import com.hypixel.hytale.component.Ref; +import com.hypixel.hytale.math.iterator.BlockIterator; import com.hypixel.hytale.math.util.ChunkUtil; import com.hypixel.hytale.math.util.MathUtil; -import com.hypixel.hytale.math.vector.Vector3i; -import com.hypixel.hytale.protocol.BlockPosition; -import com.hypixel.hytale.protocol.Interaction; +import com.hypixel.hytale.math.vector.Vector3d; import com.hypixel.hytale.protocol.InteractionState; import com.hypixel.hytale.protocol.InteractionSyncData; import com.hypixel.hytale.protocol.InteractionType; +import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType; import com.hypixel.hytale.server.core.asset.type.fluid.Fluid; +import com.hypixel.hytale.server.core.asset.type.fluid.FluidTicker; import com.hypixel.hytale.server.core.asset.type.item.config.Item; -import com.hypixel.hytale.server.core.entity.EntityUtils; import com.hypixel.hytale.server.core.entity.InteractionContext; -import com.hypixel.hytale.server.core.entity.LivingEntity; +import com.hypixel.hytale.server.core.entity.entities.Player; +import com.hypixel.hytale.server.core.inventory.Inventory; import com.hypixel.hytale.server.core.inventory.ItemStack; import com.hypixel.hytale.server.core.inventory.container.SimpleItemContainer; import com.hypixel.hytale.server.core.inventory.transaction.ItemStackSlotTransaction; +import com.hypixel.hytale.server.core.modules.entity.component.HeadRotation; +import com.hypixel.hytale.server.core.modules.entity.component.ModelComponent; +import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent; import com.hypixel.hytale.server.core.modules.interaction.interaction.CooldownHandler; -import com.hypixel.hytale.server.core.modules.interaction.interaction.config.client.SimpleBlockInteraction; +import com.hypixel.hytale.server.core.modules.interaction.interaction.config.InteractionConfiguration; +import com.hypixel.hytale.server.core.modules.interaction.interaction.config.SimpleInstantInteraction; import com.hypixel.hytale.server.core.universe.world.World; +import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection; import com.hypixel.hytale.server.core.universe.world.chunk.section.FluidSection; import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; @@ -35,12 +41,14 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.compatqual.NonNullDecl; -public class RefillContainerInteraction extends SimpleBlockInteraction { +public class RefillContainerInteraction extends SimpleInstantInteraction { public static final BuilderCodec CODEC = BuilderCodec.builder( - RefillContainerInteraction.class, RefillContainerInteraction::new, SimpleBlockInteraction.CODEC + RefillContainerInteraction.class, RefillContainerInteraction::new, SimpleInstantInteraction.CODEC ) .documentation("Refills a container item that is currently held.") .appendInherited( @@ -62,9 +70,6 @@ public class RefillContainerInteraction extends SimpleBlockInteraction { @Nullable protected Int2ObjectMap fluidToState; - public RefillContainerInteraction() { - } - protected int[] getAllowedFluidIds() { if (this.allowedFluidIds != null) { return this.allowedFluidIds; @@ -96,101 +101,162 @@ public class RefillContainerInteraction extends SimpleBlockInteraction { } @Override - protected void interactWithBlock( - @Nonnull World world, - @Nonnull CommandBuffer commandBuffer, - @Nonnull InteractionType type, - @Nonnull InteractionContext context, - @Nullable ItemStack itemInHand, - @Nonnull Vector3i targetBlock, - @Nonnull CooldownHandler cooldownHandler - ) { + protected void firstRun(@NonNullDecl InteractionType type, @NonNullDecl InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler) { + CommandBuffer commandBuffer = context.getCommandBuffer(); + + assert commandBuffer != null; + + InteractionSyncData state = context.getState(); + World world = commandBuffer.getExternalData().getWorld(); Ref ref = context.getEntity(); - if (EntityUtils.getEntity(ref, commandBuffer) instanceof LivingEntity livingEntity) { - BlockPosition var24 = context.getClientState().blockPosition; - InteractionSyncData state = context.getState(); - if (var24 == null) { + Ref targetRef = context.getTargetEntity(); + if (targetRef != null) { + context.getState().state = InteractionState.Failed; + } else { + Player playerComponent = commandBuffer.getComponent(ref, Player.getComponentType()); + if (playerComponent == null) { state.state = InteractionState.Failed; } else { - Ref section = world.getChunkStore() - .getChunkSectionReference(ChunkUtil.chunkCoordinate(var24.x), ChunkUtil.chunkCoordinate(var24.y), ChunkUtil.chunkCoordinate(var24.z)); - if (section != null) { - FluidSection fluidSection = section.getStore().getComponent(section, FluidSection.getComponentType()); - if (fluidSection != null) { - int fluidId = fluidSection.getFluidId(var24.x, var24.y, var24.z); - int[] allowedBlockIds = this.getAllowedFluidIds(); - if (allowedBlockIds != null && Arrays.binarySearch(allowedBlockIds, fluidId) < 0) { + Inventory inventory = playerComponent.getInventory(); + if (inventory == null) { + state.state = InteractionState.Failed; + } else { + TransformComponent transformComponent = commandBuffer.getComponent(ref, TransformComponent.getComponentType()); + if (transformComponent == null) { + state.state = InteractionState.Failed; + } else { + HeadRotation headRotationComponent = commandBuffer.getComponent(ref, HeadRotation.getComponentType()); + if (headRotationComponent == null) { state.state = InteractionState.Failed; } else { - String newState = this.getFluidToState().get(fluidId); - if (newState == null) { + ModelComponent modelComponent = commandBuffer.getComponent(ref, ModelComponent.getComponentType()); + if (modelComponent == null) { state.state = InteractionState.Failed; } else { - ItemStack current = context.getHeldItem(); - Item newItemAsset = current.getItem().getItemForState(newState); - if (newItemAsset == null) { + ItemStack heldItem = context.getHeldItem(); + if (heldItem == null) { state.state = InteractionState.Failed; } else { - RefillContainerInteraction.RefillState refillState = this.refillStateMap.get(newState); - if (newItemAsset.getId().equals(current.getItemId())) { - if (refillState != null) { - double newDurability = MathUtil.maxValue(refillState.durability, current.getMaxDurability()); - if (newDurability <= current.getDurability()) { - state.state = InteractionState.Failed; - return; + InteractionConfiguration heldItemInteractionConfig = heldItem.getItem().getInteractionConfig(); + float distance = heldItemInteractionConfig.getUseDistance(playerComponent.getGameMode()); + Vector3d fromPos = transformComponent.getPosition().clone(); + fromPos.y = fromPos.y + modelComponent.getModel().getEyeHeight(ref, commandBuffer); + Vector3d lookDir = headRotationComponent.getDirection(); + Vector3d toPos = fromPos.clone().add(lookDir.scale(distance)); + AtomicBoolean refilled = new AtomicBoolean(false); + BlockIterator.iterateFromTo( + fromPos, + toPos, + (x, y, z, px, py, pz, qx, qy, qz) -> { + Ref section = world.getChunkStore() + .getChunkSectionReference(ChunkUtil.chunkCoordinate(x), ChunkUtil.chunkCoordinate(y), ChunkUtil.chunkCoordinate(z)); + if (section == null) { + return true; + } else { + BlockSection blockSection = section.getStore().getComponent(section, BlockSection.getComponentType()); + if (blockSection == null) { + return true; + } else if (FluidTicker.isSolid(BlockType.getAssetMap().getAsset(blockSection.get(x, y, z)))) { + state.state = InteractionState.Failed; + return false; + } else { + FluidSection fluidSection = section.getStore().getComponent(section, FluidSection.getComponentType()); + if (fluidSection == null) { + return true; + } else { + int fluidId = fluidSection.getFluidId(x, y, z); + int[] allowedBlockIds = this.getAllowedFluidIds(); + if (allowedBlockIds != null && Arrays.binarySearch(allowedBlockIds, fluidId) < 0) { + state.state = InteractionState.Failed; + return true; + } else { + String newState = this.getFluidToState().get(fluidId); + if (newState == null) { + state.state = InteractionState.Failed; + return false; + } else { + ItemStack current = context.getHeldItem(); + Item newItemAsset = current.getItem().getItemForState(newState); + if (newItemAsset == null) { + state.state = InteractionState.Failed; + return false; + } else { + RefillContainerInteraction.RefillState refillState = this.refillStateMap.get(newState); + if (newItemAsset.getId().equals(current.getItemId())) { + if (refillState != null) { + double newDurability = MathUtil.maxValue(refillState.durability, current.getMaxDurability()); + if (newDurability <= current.getDurability()) { + state.state = InteractionState.Failed; + return false; + } + + ItemStack newItem = current.withIncreasedDurability(newDurability); + ItemStackSlotTransaction transaction = context.getHeldItemContainer() + .setItemStackForSlot(context.getHeldItemSlot(), newItem); + if (!transaction.succeeded()) { + state.state = InteractionState.Failed; + return false; + } + + context.setHeldItem(newItem); + refilled.set(true); + } + } else { + ItemStackSlotTransaction removeEmptyTransaction = context.getHeldItemContainer() + .removeItemStackFromSlot(context.getHeldItemSlot(), current, 1); + if (!removeEmptyTransaction.succeeded()) { + state.state = InteractionState.Failed; + return false; + } + + ItemStack refilledContainer = new ItemStack(newItemAsset.getId(), 1); + if (refillState != null && refillState.durability > 0.0) { + refilledContainer = refilledContainer.withDurability(refillState.durability); + } + + if (current.getQuantity() == 1) { + ItemStackSlotTransaction addFilledTransaction = context.getHeldItemContainer() + .setItemStackForSlot(context.getHeldItemSlot(), refilledContainer); + if (!addFilledTransaction.succeeded()) { + state.state = InteractionState.Failed; + return false; + } + + context.setHeldItem(refilledContainer); + } else { + SimpleItemContainer.addOrDropItemStack( + commandBuffer, ref, inventory.getCombinedHotbarFirst(), refilledContainer + ); + context.setHeldItem(context.getHeldItemContainer().getItemStack(context.getHeldItemSlot())); + } + } + + if (refillState != null && refillState.getTransformFluid() != null) { + int transformedFluid = Fluid.getFluidIdOrUnknown( + refillState.getTransformFluid(), "Unknown fluid %s", refillState.getTransformFluid() + ); + boolean placed = fluidSection.setFluid( + x, y, z, transformedFluid, (byte)Fluid.getAssetMap().getAsset(transformedFluid).getMaxFluidLevel() + ); + if (!placed) { + state.state = InteractionState.Failed; + } + + world.performBlockUpdate(x, y, z); + refilled.set(true); + } + + return false; + } + } + } + } + } } - - ItemStack newItem = current.withIncreasedDurability(newDurability); - ItemStackSlotTransaction transaction = context.getHeldItemContainer().setItemStackForSlot(context.getHeldItemSlot(), newItem); - if (!transaction.succeeded()) { - state.state = InteractionState.Failed; - return; - } - - context.setHeldItem(newItem); } - } else { - ItemStackSlotTransaction removeEmptyTransaction = context.getHeldItemContainer() - .removeItemStackFromSlot(context.getHeldItemSlot(), current, 1); - if (!removeEmptyTransaction.succeeded()) { - state.state = InteractionState.Failed; - return; - } - - ItemStack refilledContainer = new ItemStack(newItemAsset.getId(), 1); - if (refillState != null && refillState.durability > 0.0) { - refilledContainer = refilledContainer.withDurability(refillState.durability); - } - - if (current.getQuantity() == 1) { - ItemStackSlotTransaction addFilledTransaction = context.getHeldItemContainer() - .setItemStackForSlot(context.getHeldItemSlot(), refilledContainer); - if (!addFilledTransaction.succeeded()) { - state.state = InteractionState.Failed; - return; - } - - context.setHeldItem(refilledContainer); - } else { - SimpleItemContainer.addOrDropItemStack( - commandBuffer, ref, livingEntity.getInventory().getCombinedHotbarFirst(), refilledContainer - ); - context.setHeldItem(context.getHeldItemContainer().getItemStack(context.getHeldItemSlot())); - } - } - - if (refillState != null && refillState.getTransformFluid() != null) { - int transformedFluid = Fluid.getFluidIdOrUnknown( - refillState.getTransformFluid(), "Unknown fluid %s", refillState.getTransformFluid() - ); - boolean placed = fluidSection.setFluid( - var24.x, var24.y, var24.z, transformedFluid, (byte)Fluid.getAssetMap().getAsset(transformedFluid).getMaxFluidLevel() - ); - if (!placed) { - state.state = InteractionState.Failed; - } - - world.performBlockUpdate(var24.x, var24.y, var24.z); + ); + if (!refilled.get()) { + context.getState().state = InteractionState.Failed; } } } @@ -201,25 +267,6 @@ public class RefillContainerInteraction extends SimpleBlockInteraction { } } - @Override - protected void simulateInteractWithBlock( - @Nonnull InteractionType type, @Nonnull InteractionContext context, @Nullable ItemStack itemInHand, @Nonnull World world, @Nonnull Vector3i targetBlock - ) { - } - - @Nonnull - @Override - protected Interaction generatePacket() { - return new com.hypixel.hytale.protocol.RefillContainerInteraction(); - } - - @Override - protected void configurePacket(Interaction packet) { - super.configurePacket(packet); - com.hypixel.hytale.protocol.RefillContainerInteraction p = (com.hypixel.hytale.protocol.RefillContainerInteraction)packet; - p.refillFluids = this.getAllowedFluidIds(); - } - @Nonnull @Override public String toString() { @@ -255,9 +302,6 @@ public class RefillContainerInteraction extends SimpleBlockInteraction { protected String transformFluid; protected double durability = -1.0; - protected RefillState() { - } - public String[] getAllowedFluids() { return this.allowedFluids; } diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/RunOnBlockTypesInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/RunOnBlockTypesInteraction.java new file mode 100644 index 0000000..c012821 --- /dev/null +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/RunOnBlockTypesInteraction.java @@ -0,0 +1,376 @@ +package com.hypixel.hytale.server.core.modules.interaction.interaction.config.server; + +import com.hypixel.hytale.codec.Codec; +import com.hypixel.hytale.codec.KeyedCodec; +import com.hypixel.hytale.codec.builder.BuilderCodec; +import com.hypixel.hytale.codec.codecs.array.ArrayCodec; +import com.hypixel.hytale.codec.validation.Validators; +import com.hypixel.hytale.component.CommandBuffer; +import com.hypixel.hytale.component.Ref; +import com.hypixel.hytale.math.util.ChunkUtil; +import com.hypixel.hytale.math.util.MathUtil; +import com.hypixel.hytale.math.vector.Vector3d; +import com.hypixel.hytale.math.vector.Vector3i; +import com.hypixel.hytale.protocol.BlockPosition; +import com.hypixel.hytale.protocol.InteractionState; +import com.hypixel.hytale.protocol.InteractionType; +import com.hypixel.hytale.protocol.WaitForDataFrom; +import com.hypixel.hytale.server.core.asset.type.blockset.config.BlockSet; +import com.hypixel.hytale.server.core.entity.InteractionChain; +import com.hypixel.hytale.server.core.entity.InteractionContext; +import com.hypixel.hytale.server.core.meta.DynamicMetaStore; +import com.hypixel.hytale.server.core.meta.MetaKey; +import com.hypixel.hytale.server.core.modules.blockset.BlockSetModule; +import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent; +import com.hypixel.hytale.server.core.modules.interaction.interaction.CooldownHandler; +import com.hypixel.hytale.server.core.modules.interaction.interaction.config.Interaction; +import com.hypixel.hytale.server.core.modules.interaction.interaction.config.RootInteraction; +import com.hypixel.hytale.server.core.modules.interaction.interaction.config.SimpleInteraction; +import com.hypixel.hytale.server.core.modules.interaction.interaction.operation.Label; +import com.hypixel.hytale.server.core.modules.interaction.interaction.operation.OperationsBuilder; +import com.hypixel.hytale.server.core.universe.world.World; +import com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk; +import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk; +import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection; +import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.IntArrayList; +import it.unimi.dsi.fastutil.ints.IntConsumer; +import it.unimi.dsi.fastutil.ints.IntList; +import it.unimi.dsi.fastutil.ints.IntOpenHashSet; +import it.unimi.dsi.fastutil.ints.IntSet; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import java.util.List; +import java.util.concurrent.ThreadLocalRandom; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import org.checkerframework.checker.nullness.compatqual.NonNullDecl; + +public class RunOnBlockTypesInteraction extends SimpleInteraction { + @Nonnull + public static final BuilderCodec CODEC = BuilderCodec.builder( + RunOnBlockTypesInteraction.class, RunOnBlockTypesInteraction::new, SimpleInteraction.CODEC + ) + .documentation("Searches for matching block types within a radius and runs interactions on each found block up to a configured maximum number of blocks.") + .appendInherited( + new KeyedCodec<>("Range", Codec.INTEGER, true), + (interaction, value) -> interaction.range = value, + interaction -> interaction.range, + (interaction, parent) -> interaction.range = parent.range + ) + .documentation("The spherical radius to search for matching block types.") + .addValidator(Validators.greaterThan(0)) + .add() + .appendInherited( + new KeyedCodec<>("BlockSets", new ArrayCodec<>(Codec.STRING, String[]::new), true), + (interaction, value) -> interaction.blockSets = value, + interaction -> interaction.blockSets, + (interaction, parent) -> interaction.blockSets = parent.blockSets + ) + .documentation("Array of BlockSet IDs to match within the search radius.") + .addValidator(Validators.nonEmptyArray()) + .addValidatorLate(() -> BlockSet.VALIDATOR_CACHE.getArrayValidator().late()) + .add() + .appendInherited( + new KeyedCodec<>("MaxCount", Codec.INTEGER, true), + (interaction, value) -> interaction.maxCount = value, + interaction -> interaction.maxCount, + (interaction, parent) -> interaction.maxCount = parent.maxCount + ) + .documentation("Maximum number of block positions to select for running interactions (uses reservoir sampling).") + .addValidator(Validators.greaterThan(0)) + .add() + .appendInherited( + new KeyedCodec<>("Interactions", RootInteraction.CHILD_ASSET_CODEC, true), + (interaction, value) -> interaction.interactions = value, + interaction -> interaction.interactions, + (interaction, parent) -> interaction.interactions = parent.interactions + ) + .documentation("The interaction chain to run on each found block. Can be defined inline or as a reference.") + .addValidatorLate(() -> RootInteraction.VALIDATOR_CACHE.getValidator().late()) + .add() + .build(); + private static final MetaKey> FORKED_CHAINS = Interaction.META_REGISTRY.registerMetaObject(i -> null); + private static final MetaKey ANY_SUCCEEDED = Interaction.META_REGISTRY.registerMetaObject(i -> Boolean.FALSE); + public static final String[] EMPTY_BLOCKSETS = new String[0]; + protected int range; + @Nonnull + protected String[] blockSets = EMPTY_BLOCKSETS; + protected int maxCount; + @Nullable + protected String interactions; + + protected RunOnBlockTypesInteraction() { + } + + @Nonnull + @Override + public WaitForDataFrom getWaitForDataFrom() { + return WaitForDataFrom.Server; + } + + @Override + protected void tick0( + boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + ) { + DynamicMetaStore instanceStore = context.getInstanceStore(); + if (!firstRun) { + List chains = instanceStore.getMetaObject(FORKED_CHAINS); + if (chains != null && !chains.isEmpty()) { + boolean allFinished = true; + boolean anySucceeded = instanceStore.getMetaObject(ANY_SUCCEEDED); + + for (InteractionChain chain : chains) { + switch (chain.getServerState()) { + case NotFinished: + allFinished = false; + break; + case Finished: + anySucceeded = true; + case Failed: + } + } + + instanceStore.putMetaObject(ANY_SUCCEEDED, anySucceeded); + if (!allFinished) { + context.getState().state = InteractionState.NotFinished; + } else { + if (anySucceeded) { + context.getState().state = InteractionState.Finished; + } else { + context.getState().state = InteractionState.Failed; + } + + super.tick0(firstRun, time, type, context, cooldownHandler); + } + } else { + context.getState().state = InteractionState.Failed; + super.tick0(firstRun, time, type, context, cooldownHandler); + } + } else { + CommandBuffer commandBuffer = context.getCommandBuffer(); + + assert commandBuffer != null; + + Ref ref = context.getEntity(); + TransformComponent transformComponent = commandBuffer.getComponent(ref, TransformComponent.getComponentType()); + if (transformComponent == null) { + context.getState().state = InteractionState.Failed; + super.tick0(firstRun, time, type, context, cooldownHandler); + } else { + World world = commandBuffer.getExternalData().getWorld(); + Vector3d position = transformComponent.getPosition(); + List selectedPositions = this.searchBlocks(world, position); + if (selectedPositions.isEmpty()) { + context.getState().state = InteractionState.Failed; + super.tick0(firstRun, time, type, context, cooldownHandler); + } else if (this.interactions == null) { + context.getState().state = InteractionState.Failed; + super.tick0(firstRun, time, type, context, cooldownHandler); + } else { + RootInteraction rootInteraction = RootInteraction.getRootInteractionOrUnknown(this.interactions); + ObjectArrayList chains = new ObjectArrayList<>(selectedPositions.size()); + + for (Vector3i blockPos : selectedPositions) { + InteractionContext forkedContext = context.duplicate(); + BlockPosition blockPosition = new BlockPosition(blockPos.x, blockPos.y, blockPos.z); + forkedContext.getMetaStore().putMetaObject(Interaction.TARGET_BLOCK, blockPosition); + forkedContext.getMetaStore().putMetaObject(Interaction.TARGET_BLOCK_RAW, blockPosition); + BlockPosition baseBlock = world.getBaseBlock(blockPosition); + forkedContext.getMetaStore().putMetaObject(Interaction.TARGET_BLOCK, baseBlock); + InteractionChain chain = context.fork(forkedContext, rootInteraction, false); + chains.add(chain); + } + + instanceStore.putMetaObject(FORKED_CHAINS, chains); + instanceStore.putMetaObject(ANY_SUCCEEDED, Boolean.FALSE); + context.getState().state = InteractionState.NotFinished; + } + } + } + } + + @Override + protected void simulateTick0( + boolean firstRun, float time, @NonNullDecl InteractionType type, @Nonnull InteractionContext context, @NonNullDecl CooldownHandler cooldownHandler + ) { + } + + @Override + public void compile(@Nonnull OperationsBuilder builder) { + if (this.next == null && this.failed == null) { + builder.addOperation(this); + } else { + Label failedLabel = builder.createUnresolvedLabel(); + Label endLabel = builder.createUnresolvedLabel(); + builder.addOperation(this, failedLabel); + if (this.next != null) { + Interaction nextInteraction = Interaction.getInteractionOrUnknown(this.next); + nextInteraction.compile(builder); + } + + if (this.failed != null) { + builder.jump(endLabel); + } + + builder.resolveLabel(failedLabel); + if (this.failed != null) { + Interaction failedInteraction = Interaction.getInteractionOrUnknown(this.failed); + failedInteraction.compile(builder); + } + + builder.resolveLabel(endLabel); + } + } + + @Nonnull + private List searchBlocks(@Nonnull World world, @Nonnull Vector3d position) { + IntList blockIds = this.getBlockIds(); + if (blockIds.isEmpty()) { + return List.of(); + } else { + int originX = MathUtil.floor(position.x); + int originY = MathUtil.floor(position.y); + int originZ = MathUtil.floor(position.z); + int radiusSquared = this.range * this.range; + RunOnBlockTypesInteraction.BlockSearchConsumer consumer = new RunOnBlockTypesInteraction.BlockSearchConsumer( + originX, originY, originZ, radiusSquared, this.maxCount + ); + IntOpenHashSet internalIdHolder = new IntOpenHashSet(); + int minY = Math.max(0, originY - this.range); + int maxY = Math.min(319, originY + this.range); + + for (int x = originX - this.range & -32; x < originX + this.range; x += 32) { + for (int z = originZ - this.range & -32; z < originZ + this.range; z += 32) { + WorldChunk chunk = world.getChunkIfInMemory(ChunkUtil.indexChunkFromBlock(x, z)); + if (chunk != null) { + BlockChunk blockChunk = chunk.getBlockChunk(); + + for (int y = minY; y < maxY; y += 32) { + int sectionIndex = ChunkUtil.indexSection(y); + if (sectionIndex >= 0 && sectionIndex < 10) { + BlockSection section = blockChunk.getSectionAtIndex(sectionIndex); + if (!section.isSolidAir() && section.containsAny(blockIds)) { + consumer.setSection(x, z, sectionIndex); + section.find(blockIds, internalIdHolder, consumer); + internalIdHolder.clear(); + } + } + } + } + } + } + + return consumer.getPickedPositions(); + } + } + + @Nonnull + private IntList getBlockIds() { + IntArrayList result = new IntArrayList(); + BlockSetModule blockSetModule = BlockSetModule.getInstance(); + Int2ObjectMap blockSetMap = blockSetModule.getBlockSets(); + + for (String blockSetName : this.blockSets) { + int blockSetIndex = BlockSet.getAssetMap().getIndex(blockSetName); + if (blockSetIndex != Integer.MIN_VALUE) { + IntSet blockIdsInSet = blockSetMap.get(blockSetIndex); + if (blockIdsInSet != null) { + result.addAll(blockIdsInSet); + } + } + } + + return result; + } + + @Override + public boolean needsRemoteSync() { + return true; + } + + @Nonnull + @Override + protected com.hypixel.hytale.protocol.Interaction generatePacket() { + return new com.hypixel.hytale.protocol.SimpleInteraction(); + } + + @Override + protected void configurePacket(com.hypixel.hytale.protocol.Interaction packet) { + super.configurePacket(packet); + com.hypixel.hytale.protocol.SimpleInteraction p = (com.hypixel.hytale.protocol.SimpleInteraction)packet; + p.next = Interaction.getInteractionIdOrUnknown(this.next); + p.failed = Interaction.getInteractionIdOrUnknown(this.failed); + } + + @Nonnull + @Override + public String toString() { + return "RunOnBlockTypesInteraction{range=" + + this.range + + ", maxCount=" + + this.maxCount + + ", interactions='" + + this.interactions + + "'} " + + super.toString(); + } + + private static class BlockSearchConsumer implements IntConsumer { + private final int originX; + private final int originY; + private final int originZ; + private final int radiusSquared; + private final int maxCount; + private final List picked; + private int seen = 0; + private int chunkWorldX; + private int chunkWorldZ; + private int sectionBaseY; + + BlockSearchConsumer(int originX, int originY, int originZ, int radiusSquared, int maxCount) { + this.originX = originX; + this.originY = originY; + this.originZ = originZ; + this.radiusSquared = radiusSquared; + this.maxCount = maxCount; + this.picked = new ObjectArrayList<>(maxCount); + } + + void setSection(int chunkWorldX, int chunkWorldZ, int sectionIndex) { + this.chunkWorldX = chunkWorldX; + this.chunkWorldZ = chunkWorldZ; + this.sectionBaseY = sectionIndex * 32; + } + + @Override + public void accept(int blockIndex) { + int localX = ChunkUtil.xFromIndex(blockIndex); + int localY = ChunkUtil.yFromIndex(blockIndex); + int localZ = ChunkUtil.zFromIndex(blockIndex); + int worldX = this.chunkWorldX + localX; + int worldY = this.sectionBaseY + localY; + int worldZ = this.chunkWorldZ + localZ; + int dx = worldX - this.originX; + int dy = worldY - this.originY; + int dz = worldZ - this.originZ; + if (dx * dx + dy * dy + dz * dz <= this.radiusSquared) { + if (this.picked.size() < this.maxCount) { + this.picked.add(new Vector3i(worldX, worldY, worldZ)); + } else { + int j = ThreadLocalRandom.current().nextInt(this.seen + 1); + if (j < this.maxCount) { + this.picked.set(j, new Vector3i(worldX, worldY, worldZ)); + } + } + + this.seen++; + } + } + + @Nonnull + List getPickedPositions() { + return this.picked; + } + } +} diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/SpawnPrefabInteraction.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/SpawnPrefabInteraction.java index 8797679..11f0870 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/SpawnPrefabInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/SpawnPrefabInteraction.java @@ -61,9 +61,6 @@ public class SpawnPrefabInteraction extends SimpleInstantInteraction { private SpawnPrefabInteraction.OriginSource originSource = SpawnPrefabInteraction.OriginSource.ENTITY; private boolean force; - public SpawnPrefabInteraction() { - } - @Override protected void firstRun(@Nonnull InteractionType type, @Nonnull InteractionContext context, @Nonnull CooldownHandler cooldownHandler) { Path prefabRoot = PrefabStore.get().getAssetPrefabsPath(); @@ -112,8 +109,5 @@ public class SpawnPrefabInteraction extends SimpleInstantInteraction { private static enum OriginSource { ENTITY, BLOCK; - - private OriginSource() { - } } } diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/combat/DamageCalculator.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/combat/DamageCalculator.java index 533c4fc..8791f73 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/combat/DamageCalculator.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/combat/DamageCalculator.java @@ -185,8 +185,5 @@ public class DamageCalculator { ABSOLUTE; public static final EnumCodec CODEC = new EnumCodec<>(DamageCalculator.Type.class); - - private Type() { - } } } diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/combat/DamageClass.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/combat/DamageClass.java index 26c2f0e..923535f 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/combat/DamageClass.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/combat/DamageClass.java @@ -9,7 +9,4 @@ public enum DamageClass { SIGNATURE; public static final EnumCodec CODEC = new EnumCodec<>(DamageClass.class); - - private DamageClass() { - } } diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/combat/DirectionalKnockback.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/combat/DirectionalKnockback.java index 332469c..1783f6b 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/combat/DirectionalKnockback.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/combat/DirectionalKnockback.java @@ -33,9 +33,6 @@ public class DirectionalKnockback extends Knockback { protected float velocityY; protected float relativeZ; - public DirectionalKnockback() { - } - @Nonnull @Override public Vector3d calculateVector(@Nonnull Vector3d source, float yaw, @Nonnull Vector3d target) { diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/combat/ForceKnockback.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/combat/ForceKnockback.java index 789bf60..5102e11 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/combat/ForceKnockback.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/combat/ForceKnockback.java @@ -15,9 +15,6 @@ public class ForceKnockback extends Knockback { .build(); private Vector3d direction = Vector3d.UP; - public ForceKnockback() { - } - @Nonnull @Override public Vector3d calculateVector(Vector3d source, float yaw, Vector3d target) { diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/combat/PointKnockback.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/combat/PointKnockback.java index 4f47226..26099ff 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/combat/PointKnockback.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/combat/PointKnockback.java @@ -38,9 +38,6 @@ public class PointKnockback extends Knockback { protected int offsetX; protected int offsetZ; - public PointKnockback() { - } - @Nonnull @Override public Vector3d calculateVector(@Nonnull Vector3d source, float yaw, @Nonnull Vector3d target) { diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/operation/OperationsBuilder.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/operation/OperationsBuilder.java index 21ec721..c27e105 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/operation/OperationsBuilder.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/operation/OperationsBuilder.java @@ -17,9 +17,6 @@ public class OperationsBuilder { @Nonnull private final List operationList = new ObjectArrayList<>(); - public OperationsBuilder() { - } - @Nonnull public Label createLabel() { return new Label(this.operationList.size()); diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/util/InteractionTarget.java b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/util/InteractionTarget.java index 2bb321f..64ade66 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/interaction/util/InteractionTarget.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/interaction/util/InteractionTarget.java @@ -2,8 +2,6 @@ package com.hypixel.hytale.server.core.modules.interaction.interaction.util; import com.hypixel.hytale.codec.codecs.EnumCodec; import com.hypixel.hytale.component.Ref; -import com.hypixel.hytale.server.core.entity.Entity; -import com.hypixel.hytale.server.core.entity.EntityUtils; import com.hypixel.hytale.server.core.entity.InteractionContext; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; @@ -14,13 +12,12 @@ public enum InteractionTarget { OWNER, TARGET; + @Nonnull public static final EnumCodec CODEC = new EnumCodec<>(InteractionTarget.class) .documentKey(USER, "Causes the interaction to target the entity that triggered/owns the interaction chain.") + .documentKey(OWNER, "Causes the interaction to target the entity that owns the interaction chain.") .documentKey(TARGET, "Causes the interaction to target the entity that is the target of the interaction chain."); - private InteractionTarget() { - } - @Nullable public Ref getEntity(@Nonnull InteractionContext ctx, @Nonnull Ref ref) { return switch (this) { @@ -30,14 +27,6 @@ public enum InteractionTarget { }; } - @Nullable - @Deprecated - public T getEntity(@Nonnull InteractionContext ctx, @Nonnull Ref ref, @Nonnull Class clazz) { - Ref e = this.getEntity(ctx, ref); - Entity legacy = EntityUtils.getEntity(e, ctx.getCommandBuffer()); - return (T)(clazz.isInstance(legacy) ? legacy : null); - } - @Nonnull public com.hypixel.hytale.protocol.InteractionTarget toProtocol() { return switch (this) { diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/suppliers/ItemRepairPageSupplier.java b/src/com/hypixel/hytale/server/core/modules/interaction/suppliers/ItemRepairPageSupplier.java index b46e37c..c44d3ca 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/suppliers/ItemRepairPageSupplier.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/suppliers/ItemRepairPageSupplier.java @@ -27,9 +27,6 @@ public class ItemRepairPageSupplier implements OpenCustomUIInteraction.CustomPag .build(); protected double repairPenalty; - public ItemRepairPageSupplier() { - } - @Override public CustomUIPage tryCreate( @Nonnull Ref ref, diff --git a/src/com/hypixel/hytale/server/core/modules/interaction/system/InteractionSystems.java b/src/com/hypixel/hytale/server/core/modules/interaction/system/InteractionSystems.java index f84021f..d0e62bd 100644 --- a/src/com/hypixel/hytale/server/core/modules/interaction/system/InteractionSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/interaction/system/InteractionSystems.java @@ -40,16 +40,10 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class InteractionSystems { - public InteractionSystems() { - } - public static class CleanUpSystem extends RefSystem { @Nonnull private final ComponentType interactionComponentType = InteractionModule.get().getInteractionManagerComponent(); - public CleanUpSystem() { - } - @Override public void onEntityAdded( @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer @@ -120,10 +114,9 @@ public class InteractionSystems { public static class PlayerAddManagerSystem extends HolderSystem { @Nonnull - private final Query query = Query.and(Player.getComponentType(), Query.not(InteractionModule.get().getInteractionManagerComponent())); - - public PlayerAddManagerSystem() { - } + private final Query query = Query.and( + Player.getComponentType(), PlayerRef.getComponentType(), Query.not(InteractionModule.get().getInteractionManagerComponent()) + ); @Nonnull @Override @@ -158,9 +151,6 @@ public class InteractionSystems { @Nonnull private final ComponentType interactionManagerComponent = InteractionModule.get().getInteractionManagerComponent(); - public TickInteractionManagerSystem() { - } - @Override public Query getQuery() { return this.interactionManagerComponent; @@ -207,9 +197,6 @@ public class InteractionSystems { @Nonnull private final Query query = Query.and(this.visibleComponentType, Interactions.getComponentType()); - public TrackerTickSystem() { - } - @Nullable @Override public SystemGroup getGroup() { diff --git a/src/com/hypixel/hytale/server/core/modules/item/CraftingRecipePacketGenerator.java b/src/com/hypixel/hytale/server/core/modules/item/CraftingRecipePacketGenerator.java index 14627a2..8521e2c 100644 --- a/src/com/hypixel/hytale/server/core/modules/item/CraftingRecipePacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/modules/item/CraftingRecipePacketGenerator.java @@ -14,9 +14,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class CraftingRecipePacketGenerator extends AssetPacketGenerator> { - public CraftingRecipePacketGenerator() { - } - @Nonnull public Packet generateInitPacket(DefaultAssetMap assetMap, @Nonnull Map assets) { UpdateRecipes packet = new UpdateRecipes(); diff --git a/src/com/hypixel/hytale/server/core/modules/item/ItemPacketGenerator.java b/src/com/hypixel/hytale/server/core/modules/item/ItemPacketGenerator.java index 3a5e508..f3ff26d 100644 --- a/src/com/hypixel/hytale/server/core/modules/item/ItemPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/modules/item/ItemPacketGenerator.java @@ -14,9 +14,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class ItemPacketGenerator extends AssetPacketGenerator> { - public ItemPacketGenerator() { - } - @Nonnull public Packet generateInitPacket(DefaultAssetMap assetMap, @Nonnull Map assets) { UpdateItems packet = new UpdateItems(); diff --git a/src/com/hypixel/hytale/server/core/modules/item/ItemQualityPacketGenerator.java b/src/com/hypixel/hytale/server/core/modules/item/ItemQualityPacketGenerator.java index 51dfaf5..f9d6ad7 100644 --- a/src/com/hypixel/hytale/server/core/modules/item/ItemQualityPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/modules/item/ItemQualityPacketGenerator.java @@ -13,9 +13,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class ItemQualityPacketGenerator extends SimpleAssetPacketGenerator> { - public ItemQualityPacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedLookupTableAssetMap assetMap, @Nonnull Map assets) { UpdateItemQualities packet = new UpdateItemQualities(); diff --git a/src/com/hypixel/hytale/server/core/modules/item/ItemReticleConfigPacketGenerator.java b/src/com/hypixel/hytale/server/core/modules/item/ItemReticleConfigPacketGenerator.java index bb6e898..a105b63 100644 --- a/src/com/hypixel/hytale/server/core/modules/item/ItemReticleConfigPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/modules/item/ItemReticleConfigPacketGenerator.java @@ -14,9 +14,6 @@ import javax.annotation.Nonnull; public class ItemReticleConfigPacketGenerator extends SimpleAssetPacketGenerator> { - public ItemReticleConfigPacketGenerator() { - } - @Nonnull public Packet generateInitPacket(@Nonnull IndexedLookupTableAssetMap assetMap, @Nonnull Map assets) { UpdateItemReticles packet = new UpdateItemReticles(); diff --git a/src/com/hypixel/hytale/server/core/modules/item/RecipePacketGenerator.java b/src/com/hypixel/hytale/server/core/modules/item/RecipePacketGenerator.java index e0da2bc..9fc4cf7 100644 --- a/src/com/hypixel/hytale/server/core/modules/item/RecipePacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/modules/item/RecipePacketGenerator.java @@ -14,9 +14,6 @@ import java.util.Map.Entry; import javax.annotation.Nonnull; public class RecipePacketGenerator extends AssetPacketGenerator> { - public RecipePacketGenerator() { - } - @Nonnull public Packet generateInitPacket(DefaultAssetMap assetMap, @Nonnull Map assets) { UpdateRecipes packet = new UpdateRecipes(); diff --git a/src/com/hypixel/hytale/server/core/modules/migrations/ChunkColumnMigrationSystem.java b/src/com/hypixel/hytale/server/core/modules/migrations/ChunkColumnMigrationSystem.java index 3a34816..ffa64e3 100644 --- a/src/com/hypixel/hytale/server/core/modules/migrations/ChunkColumnMigrationSystem.java +++ b/src/com/hypixel/hytale/server/core/modules/migrations/ChunkColumnMigrationSystem.java @@ -4,6 +4,4 @@ import com.hypixel.hytale.component.system.HolderSystem; import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore; public abstract class ChunkColumnMigrationSystem extends HolderSystem { - public ChunkColumnMigrationSystem() { - } } diff --git a/src/com/hypixel/hytale/server/core/modules/migrations/ChunkSectionMigrationSystem.java b/src/com/hypixel/hytale/server/core/modules/migrations/ChunkSectionMigrationSystem.java index 12e7560..498c44d 100644 --- a/src/com/hypixel/hytale/server/core/modules/migrations/ChunkSectionMigrationSystem.java +++ b/src/com/hypixel/hytale/server/core/modules/migrations/ChunkSectionMigrationSystem.java @@ -4,6 +4,4 @@ import com.hypixel.hytale.component.system.HolderSystem; import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore; public abstract class ChunkSectionMigrationSystem extends HolderSystem { - public ChunkSectionMigrationSystem() { - } } diff --git a/src/com/hypixel/hytale/server/core/modules/physics/RestingSupport.java b/src/com/hypixel/hytale/server/core/modules/physics/RestingSupport.java index 5355cf6..34f3880 100644 --- a/src/com/hypixel/hytale/server/core/modules/physics/RestingSupport.java +++ b/src/com/hypixel/hytale/server/core/modules/physics/RestingSupport.java @@ -19,9 +19,6 @@ public class RestingSupport { @Nullable protected int[] supportBlocks; - public RestingSupport() { - } - public boolean hasChanged(@Nonnull World world) { if (this.supportBlocks == null) { return false; diff --git a/src/com/hypixel/hytale/server/core/modules/physics/SimplePhysicsProvider.java b/src/com/hypixel/hytale/server/core/modules/physics/SimplePhysicsProvider.java index 5bbe447..a49b7fa 100644 --- a/src/com/hypixel/hytale/server/core/modules/physics/SimplePhysicsProvider.java +++ b/src/com/hypixel/hytale/server/core/modules/physics/SimplePhysicsProvider.java @@ -297,10 +297,7 @@ public class SimplePhysicsProvider implements IBlockCollisionConsumer { if (this.provideCharacterCollisions) { Ref creatorReference = null; if (this.creatorUuid != null) { - Entity creator = entityWorld.getEntity(this.creatorUuid); - if (creator != null) { - creatorReference = creator.getReference(); - } + creatorReference = entityWorld.getEntityRef(this.creatorUuid); } maxRelativeDistance = this.entityCollisionProvider @@ -608,17 +605,11 @@ public class SimplePhysicsProvider implements IBlockCollisionConsumer { None, Velocity, VelocityDamped; - - private ROTATION_MODE() { - } } public static enum STATE { Active, Resting, Inactive; - - private STATE() { - } } } diff --git a/src/com/hypixel/hytale/server/core/modules/physics/systems/GenericVelocityInstructionSystem.java b/src/com/hypixel/hytale/server/core/modules/physics/systems/GenericVelocityInstructionSystem.java index 3cae599..b517af7 100644 --- a/src/com/hypixel/hytale/server/core/modules/physics/systems/GenericVelocityInstructionSystem.java +++ b/src/com/hypixel/hytale/server/core/modules/physics/systems/GenericVelocityInstructionSystem.java @@ -22,9 +22,6 @@ public class GenericVelocityInstructionSystem extends EntityTickingSystem query = Query.and(Velocity.getComponentType()); - public GenericVelocityInstructionSystem() { - } - @Override public void tick( float dt, diff --git a/src/com/hypixel/hytale/server/core/modules/physics/systems/VelocitySystems.java b/src/com/hypixel/hytale/server/core/modules/physics/systems/VelocitySystems.java index 93d1c35..104b8a1 100644 --- a/src/com/hypixel/hytale/server/core/modules/physics/systems/VelocitySystems.java +++ b/src/com/hypixel/hytale/server/core/modules/physics/systems/VelocitySystems.java @@ -13,9 +13,6 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class VelocitySystems { - public VelocitySystems() { - } - public static class AddSystem extends HolderSystem { private final ComponentType velocityComponentType; @Nonnull diff --git a/src/com/hypixel/hytale/server/core/modules/physics/util/ForceAccumulator.java b/src/com/hypixel/hytale/server/core/modules/physics/util/ForceAccumulator.java index 3c81e52..a90e9d5 100644 --- a/src/com/hypixel/hytale/server/core/modules/physics/util/ForceAccumulator.java +++ b/src/com/hypixel/hytale/server/core/modules/physics/util/ForceAccumulator.java @@ -8,9 +8,6 @@ public class ForceAccumulator { public final Vector3d force = new Vector3d(); public final Vector3d resistanceForceLimit = new Vector3d(); - public ForceAccumulator() { - } - public void initialize(@Nonnull PhysicsBodyState state, double mass, double timeStep) { this.force.assign(Vector3d.ZERO); this.speed = state.velocity.length(); diff --git a/src/com/hypixel/hytale/server/core/modules/physics/util/ForceProviderStandard.java b/src/com/hypixel/hytale/server/core/modules/physics/util/ForceProviderStandard.java index ba6e605..a742c47 100644 --- a/src/com/hypixel/hytale/server/core/modules/physics/util/ForceProviderStandard.java +++ b/src/com/hypixel/hytale/server/core/modules/physics/util/ForceProviderStandard.java @@ -10,9 +10,6 @@ public abstract class ForceProviderStandard implements ForceProvider { @Nonnull protected Vector3d dragForce = new Vector3d(); - public ForceProviderStandard() { - } - public abstract double getMass(double var1); public abstract double getVolume(); diff --git a/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsBodyState.java b/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsBodyState.java index 593c1c8..5e8b864 100644 --- a/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsBodyState.java +++ b/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsBodyState.java @@ -5,7 +5,4 @@ import com.hypixel.hytale.math.vector.Vector3d; public class PhysicsBodyState { public final Vector3d position = new Vector3d(); public final Vector3d velocity = new Vector3d(); - - public PhysicsBodyState() { - } } diff --git a/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsBodyStateUpdater.java b/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsBodyStateUpdater.java index fda5487..2b2bbee 100644 --- a/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsBodyStateUpdater.java +++ b/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsBodyStateUpdater.java @@ -9,9 +9,6 @@ public class PhysicsBodyStateUpdater { protected Vector3d acceleration = new Vector3d(); protected final ForceAccumulator accumulator = new ForceAccumulator(); - public PhysicsBodyStateUpdater() { - } - public void update( @Nonnull PhysicsBodyState before, @Nonnull PhysicsBodyState after, double mass, double dt, boolean onGround, @Nonnull ForceProvider[] forceProvider ) { diff --git a/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsBodyStateUpdaterMidpoint.java b/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsBodyStateUpdaterMidpoint.java index 2a40113..1584451 100644 --- a/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsBodyStateUpdaterMidpoint.java +++ b/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsBodyStateUpdaterMidpoint.java @@ -3,9 +3,6 @@ package com.hypixel.hytale.server.core.modules.physics.util; import javax.annotation.Nonnull; public class PhysicsBodyStateUpdaterMidpoint extends PhysicsBodyStateUpdater { - public PhysicsBodyStateUpdaterMidpoint() { - } - @Override public void update( @Nonnull PhysicsBodyState before, @Nonnull PhysicsBodyState after, double mass, double dt, boolean onGround, @Nonnull ForceProvider[] forceProvider diff --git a/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsBodyStateUpdaterRK4.java b/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsBodyStateUpdaterRK4.java index f99833e..435c984 100644 --- a/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsBodyStateUpdaterRK4.java +++ b/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsBodyStateUpdaterRK4.java @@ -5,9 +5,6 @@ import javax.annotation.Nonnull; public class PhysicsBodyStateUpdaterRK4 extends PhysicsBodyStateUpdater { private final PhysicsBodyState state = new PhysicsBodyState(); - public PhysicsBodyStateUpdaterRK4() { - } - @Override public void update( @Nonnull PhysicsBodyState before, @Nonnull PhysicsBodyState after, double mass, double dt, boolean onGround, @Nonnull ForceProvider[] forceProvider diff --git a/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsBodyStateUpdaterSymplecticEuler.java b/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsBodyStateUpdaterSymplecticEuler.java index c615965..c99a0a4 100644 --- a/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsBodyStateUpdaterSymplecticEuler.java +++ b/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsBodyStateUpdaterSymplecticEuler.java @@ -3,9 +3,6 @@ package com.hypixel.hytale.server.core.modules.physics.util; import javax.annotation.Nonnull; public class PhysicsBodyStateUpdaterSymplecticEuler extends PhysicsBodyStateUpdater { - public PhysicsBodyStateUpdaterSymplecticEuler() { - } - @Override public void update( @Nonnull PhysicsBodyState before, @Nonnull PhysicsBodyState after, double mass, double dt, boolean onGround, @Nonnull ForceProvider[] forceProvider diff --git a/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsConstants.java b/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsConstants.java index 8857710..8beb95d 100644 --- a/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsConstants.java +++ b/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsConstants.java @@ -2,7 +2,4 @@ package com.hypixel.hytale.server.core.modules.physics.util; public class PhysicsConstants { public static final double GRAVITY_ACCELERATION = 32.0; - - public PhysicsConstants() { - } } diff --git a/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsFlags.java b/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsFlags.java index e460c93..3a5eeb1 100644 --- a/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsFlags.java +++ b/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsFlags.java @@ -5,7 +5,4 @@ public class PhysicsFlags { public static final int ENTITY_COLLISIONS = 1; public static final int BLOCK_COLLISIONS = 2; public static final int ALL_COLLISIONS = 3; - - public PhysicsFlags() { - } } diff --git a/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsMath.java b/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsMath.java index e15bce3..074f09a 100644 --- a/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsMath.java +++ b/src/com/hypixel/hytale/server/core/modules/physics/util/PhysicsMath.java @@ -11,9 +11,6 @@ public class PhysicsMath { public static final double AIR_DENSITY = 0.001225; public static final float HEADING_DIRECTION = 1.0F; - public PhysicsMath() { - } - public static double getAcceleration(double speed, double terminalSpeed) { double ratio = Math.abs(speed / terminalSpeed); return 32.0 * (1.0 - ratio * ratio * ratio); diff --git a/src/com/hypixel/hytale/server/core/modules/prefabspawner/PrefabSpawnerState.java b/src/com/hypixel/hytale/server/core/modules/prefabspawner/PrefabSpawnerState.java index 03175b1..7279167 100644 --- a/src/com/hypixel/hytale/server/core/modules/prefabspawner/PrefabSpawnerState.java +++ b/src/com/hypixel/hytale/server/core/modules/prefabspawner/PrefabSpawnerState.java @@ -56,9 +56,6 @@ public class PrefabSpawnerState extends BlockState { private boolean inheritHeightCondition = true; private PrefabWeights prefabWeights = PrefabWeights.NONE; - public PrefabSpawnerState() { - } - public String getPrefabPath() { return this.prefabPath; } @@ -183,8 +180,5 @@ public class PrefabSpawnerState extends BlockState { private boolean inheritHeightCondition; private double defaultWeight; private String prefabWeights; - - public PrefabSpawnerSettingsPageEventData() { - } } } diff --git a/src/com/hypixel/hytale/server/core/modules/projectile/config/ProjectileConfig.java b/src/com/hypixel/hytale/server/core/modules/projectile/config/ProjectileConfig.java index f62b702..6fd2506 100644 --- a/src/com/hypixel/hytale/server/core/modules/projectile/config/ProjectileConfig.java +++ b/src/com/hypixel/hytale/server/core/modules/projectile/config/ProjectileConfig.java @@ -133,9 +133,6 @@ public class ProjectileConfig protected int launchWorldSoundEventIndex = 0; protected int projectileSoundEventIndex = 0; - public ProjectileConfig() { - } - @Nonnull public static AssetStore> getAssetStore() { if (ASSET_STORE == null) { diff --git a/src/com/hypixel/hytale/server/core/modules/projectile/config/ProjectileConfigPacketGenerator.java b/src/com/hypixel/hytale/server/core/modules/projectile/config/ProjectileConfigPacketGenerator.java index 0cd3760..afc33ac 100644 --- a/src/com/hypixel/hytale/server/core/modules/projectile/config/ProjectileConfigPacketGenerator.java +++ b/src/com/hypixel/hytale/server/core/modules/projectile/config/ProjectileConfigPacketGenerator.java @@ -13,9 +13,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class ProjectileConfigPacketGenerator extends DefaultAssetPacketGenerator { - public ProjectileConfigPacketGenerator() { - } - @Nonnull @Override public Packet generateInitPacket(@Nonnull DefaultAssetMap assetMap, Map assets) { diff --git a/src/com/hypixel/hytale/server/core/modules/projectile/config/StandardPhysicsConfig.java b/src/com/hypixel/hytale/server/core/modules/projectile/config/StandardPhysicsConfig.java index 2167fcd..26abb74 100644 --- a/src/com/hypixel/hytale/server/core/modules/projectile/config/StandardPhysicsConfig.java +++ b/src/com/hypixel/hytale/server/core/modules/projectile/config/StandardPhysicsConfig.java @@ -152,9 +152,6 @@ public class StandardPhysicsConfig implements PhysicsConfig { protected float speedRotationFactor = 2.0F; protected double swimmingDampingFactor = 1.0; - public StandardPhysicsConfig() { - } - @Override public double getGravity() { return this.gravity; diff --git a/src/com/hypixel/hytale/server/core/modules/projectile/config/StandardPhysicsProvider.java b/src/com/hypixel/hytale/server/core/modules/projectile/config/StandardPhysicsProvider.java index 2168b9c..0ac6749 100644 --- a/src/com/hypixel/hytale/server/core/modules/projectile/config/StandardPhysicsProvider.java +++ b/src/com/hypixel/hytale/server/core/modules/projectile/config/StandardPhysicsProvider.java @@ -611,8 +611,5 @@ public class StandardPhysicsProvider implements IBlockCollisionConsumer, Compone ACTIVE, RESTING, INACTIVE; - - private STATE() { - } } } diff --git a/src/com/hypixel/hytale/server/core/modules/projectile/interaction/ProjectileInteraction.java b/src/com/hypixel/hytale/server/core/modules/projectile/interaction/ProjectileInteraction.java index 7bc2c2a..591dc8a 100644 --- a/src/com/hypixel/hytale/server/core/modules/projectile/interaction/ProjectileInteraction.java +++ b/src/com/hypixel/hytale/server/core/modules/projectile/interaction/ProjectileInteraction.java @@ -40,9 +40,6 @@ public class ProjectileInteraction extends SimpleInstantInteraction implements B .build(); protected String config; - public ProjectileInteraction() { - } - @Nullable public ProjectileConfig getConfig() { return ProjectileConfig.getAssetMap().getAsset(this.config); diff --git a/src/com/hypixel/hytale/server/core/modules/projectile/system/PredictedProjectileSystems.java b/src/com/hypixel/hytale/server/core/modules/projectile/system/PredictedProjectileSystems.java index 43b6b52..b40b775 100644 --- a/src/com/hypixel/hytale/server/core/modules/projectile/system/PredictedProjectileSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/projectile/system/PredictedProjectileSystems.java @@ -19,9 +19,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class PredictedProjectileSystems { - public PredictedProjectileSystems() { - } - public static class EntityTrackerUpdate extends EntityTickingSystem { @Nonnull private final ComponentType visibleComponentType = EntityTrackerSystems.Visible.getComponentType(); @@ -30,9 +27,6 @@ public class PredictedProjectileSystems { @Nonnull private final Query query = Query.and(this.visibleComponentType, this.predictedProjectileComponentType); - public EntityTrackerUpdate() { - } - @Nullable @Override public SystemGroup getGroup() { diff --git a/src/com/hypixel/hytale/server/core/modules/projectile/system/StandardPhysicsTickSystem.java b/src/com/hypixel/hytale/server/core/modules/projectile/system/StandardPhysicsTickSystem.java index 97ac54a..27fee6e 100644 --- a/src/com/hypixel/hytale/server/core/modules/projectile/system/StandardPhysicsTickSystem.java +++ b/src/com/hypixel/hytale/server/core/modules/projectile/system/StandardPhysicsTickSystem.java @@ -52,9 +52,6 @@ public class StandardPhysicsTickSystem extends EntityTickingSystem new SystemDependency<>(Order.BEFORE, TransformSystems.EntityTrackerUpdate.class) ); - public StandardPhysicsTickSystem() { - } - @Nonnull @Override public Set> getDependencies() { diff --git a/src/com/hypixel/hytale/server/core/modules/splitvelocity/VelocityConfig.java b/src/com/hypixel/hytale/server/core/modules/splitvelocity/VelocityConfig.java index 53f5f7d..83eedd5 100644 --- a/src/com/hypixel/hytale/server/core/modules/splitvelocity/VelocityConfig.java +++ b/src/com/hypixel/hytale/server/core/modules/splitvelocity/VelocityConfig.java @@ -57,9 +57,6 @@ public class VelocityConfig implements NetworkSerializable { @Nonnull private final UpdateTimeSettings tempSettings = new UpdateTimeSettings(); - public WorldTimeResource() { - } - @Nonnull public static ResourceType getResourceType() { return TimeModule.get().getWorldTimeResourceType(); diff --git a/src/com/hypixel/hytale/server/core/modules/time/WorldTimeSystems.java b/src/com/hypixel/hytale/server/core/modules/time/WorldTimeSystems.java index 6134254..7b4ea19 100644 --- a/src/com/hypixel/hytale/server/core/modules/time/WorldTimeSystems.java +++ b/src/com/hypixel/hytale/server/core/modules/time/WorldTimeSystems.java @@ -10,9 +10,6 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class WorldTimeSystems { - public WorldTimeSystems() { - } - public static class Init extends StoreSystem { @Nonnull private final ResourceType worldTimeResourceType; diff --git a/src/com/hypixel/hytale/server/core/permissions/HytalePermissions.java b/src/com/hypixel/hytale/server/core/permissions/HytalePermissions.java index 520d14a..8783737 100644 --- a/src/com/hypixel/hytale/server/core/permissions/HytalePermissions.java +++ b/src/com/hypixel/hytale/server/core/permissions/HytalePermissions.java @@ -19,9 +19,9 @@ public class HytalePermissions { public static final String EDITOR_SELECTION_MODIFY = "hytale.editor.selection.modify"; public static final String EDITOR_HISTORY = "hytale.editor.history"; public static final String FLY_CAM = "hytale.camera.flycam"; - - public HytalePermissions() { - } + public static final String WORLD_MAP_COORDINATE_TELEPORT = "hytale.world_map.teleport.coordinate"; + public static final String WORLD_MAP_MARKER_TELEPORT = "hytale.world_map.teleport.marker"; + public static final String UPDATE_NOTIFY = "hytale.system.update.notify"; @Nonnull public static String fromCommand(@Nonnull String name) { diff --git a/src/com/hypixel/hytale/server/core/permissions/commands/op/OpAddCommand.java b/src/com/hypixel/hytale/server/core/permissions/commands/op/OpAddCommand.java index 9816b4d..27e0dfa 100644 --- a/src/com/hypixel/hytale/server/core/permissions/commands/op/OpAddCommand.java +++ b/src/com/hypixel/hytale/server/core/permissions/commands/op/OpAddCommand.java @@ -14,13 +14,9 @@ import java.util.UUID; import javax.annotation.Nonnull; public class OpAddCommand extends CommandBase { - @Nonnull - private static final Message MESSAGE_COMMANDS_OP_ADDED = Message.translation("server.commands.op.added"); @Nonnull private static final Message MESSAGE_COMMANDS_OP_ADDED_TARGET = Message.translation("server.commands.op.added.target"); @Nonnull - private static final Message MESSAGE_COMMANDS_OP_ALREADY = Message.translation("server.commands.op.already"); - @Nonnull private final RequiredArg playerArg = this.withRequiredArg("player", "server.commands.op.add.player.desc", ArgTypes.PLAYER_UUID); public OpAddCommand() { @@ -33,17 +29,17 @@ public class OpAddCommand extends CommandBase { UUID uuid = this.playerArg.get(context); PermissionsModule permissionsModule = PermissionsModule.get(); String opGroup = "OP"; - String rawInput = context.getInput(this.playerArg)[0]; - Message displayMessage = Message.raw(rawInput).bold(true); + PlayerRef playerRef = Universe.get().getPlayer(uuid); + String displayName = playerRef != null ? playerRef.getUsername() : uuid.toString(); + Message displayMessage = Message.raw(displayName).bold(true); Set groups = permissionsModule.getGroupsForUser(uuid); if (groups.contains("OP")) { - context.sendMessage(MESSAGE_COMMANDS_OP_ALREADY.param("username", displayMessage)); + context.sendMessage(Message.translation("server.commands.op.already").param("username", displayMessage)); } else { permissionsModule.addUserToGroup(uuid, "OP"); - context.sendMessage(MESSAGE_COMMANDS_OP_ADDED.param("username", displayMessage)); - PlayerRef oppedPlayerRef = Universe.get().getPlayer(uuid); - if (oppedPlayerRef != null) { - oppedPlayerRef.sendMessage(MESSAGE_COMMANDS_OP_ADDED_TARGET); + context.sendMessage(Message.translation("server.commands.op.added").param("username", displayMessage)); + if (playerRef != null) { + playerRef.sendMessage(MESSAGE_COMMANDS_OP_ADDED_TARGET); } } } diff --git a/src/com/hypixel/hytale/server/core/permissions/commands/op/OpRemoveCommand.java b/src/com/hypixel/hytale/server/core/permissions/commands/op/OpRemoveCommand.java index 8de1304..57947c7 100644 --- a/src/com/hypixel/hytale/server/core/permissions/commands/op/OpRemoveCommand.java +++ b/src/com/hypixel/hytale/server/core/permissions/commands/op/OpRemoveCommand.java @@ -14,13 +14,9 @@ import java.util.UUID; import javax.annotation.Nonnull; public class OpRemoveCommand extends CommandBase { - @Nonnull - private static final Message MESSAGE_COMMANDS_OP_REMOVED = Message.translation("server.commands.op.removed"); @Nonnull private static final Message MESSAGE_COMMANDS_OP_REMOVED_TARGET = Message.translation("server.commands.op.removed.target"); @Nonnull - private static final Message MESSAGE_COMMANDS_OP_NOT_OP = Message.translation("server.commands.op.notOp"); - @Nonnull private final RequiredArg playerArg = this.withRequiredArg("player", "server.commands.op.remove.player.desc", ArgTypes.PLAYER_UUID); public OpRemoveCommand() { @@ -33,18 +29,18 @@ public class OpRemoveCommand extends CommandBase { UUID uuid = this.playerArg.get(context); PermissionsModule permissionsModule = PermissionsModule.get(); String opGroup = "OP"; - String rawInput = context.getInput(this.playerArg)[0]; - Message displayMessage = Message.raw(rawInput).bold(true); + PlayerRef playerRef = Universe.get().getPlayer(uuid); + String displayName = playerRef != null ? playerRef.getUsername() : uuid.toString(); + Message displayMessage = Message.raw(displayName).bold(true); Set groups = permissionsModule.getGroupsForUser(uuid); if (groups.contains("OP")) { permissionsModule.removeUserFromGroup(uuid, "OP"); - context.sendMessage(MESSAGE_COMMANDS_OP_REMOVED.param("username", displayMessage)); - PlayerRef oppedPlayerRef = Universe.get().getPlayer(uuid); - if (oppedPlayerRef != null) { - oppedPlayerRef.sendMessage(MESSAGE_COMMANDS_OP_REMOVED_TARGET); + context.sendMessage(Message.translation("server.commands.op.removed").param("username", displayMessage)); + if (playerRef != null) { + playerRef.sendMessage(MESSAGE_COMMANDS_OP_REMOVED_TARGET); } } else { - context.sendMessage(MESSAGE_COMMANDS_OP_NOT_OP.param("username", displayMessage)); + context.sendMessage(Message.translation("server.commands.op.notOp").param("username", displayMessage)); } } } diff --git a/src/com/hypixel/hytale/server/core/permissions/commands/op/OpSelfCommand.java b/src/com/hypixel/hytale/server/core/permissions/commands/op/OpSelfCommand.java index 27fbeba..bf0f932 100644 --- a/src/com/hypixel/hytale/server/core/permissions/commands/op/OpSelfCommand.java +++ b/src/com/hypixel/hytale/server/core/permissions/commands/op/OpSelfCommand.java @@ -13,14 +13,17 @@ import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import java.util.Set; import java.util.UUID; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; +import javax.annotation.Nonnull; public class OpSelfCommand extends AbstractPlayerCommand { + @Nonnull private static final Message MESSAGE_COMMANDS_OP_ADDED = Message.translation("server.commands.op.self.added"); + @Nonnull private static final Message MESSAGE_COMMANDS_OP_REMOVED = Message.translation("server.commands.op.self.removed"); + @Nonnull private static final Message MESSAGE_COMMANDS_NON_VANILLA_PERMISSIONS = Message.translation("server.commands.op.self.nonVanillaPermissions"); + @Nonnull private static final Message MESSAGE_COMMANDS_SINGLEPLAYER_OWNER_REQ = Message.translation("server.commands.op.self.singleplayerOwnerReq"); - private static final Message MESSAGE_COMMANDS_MULTIPLAYER_TIP = Message.translation("server.commands.op.self.multiplayerTip"); public OpSelfCommand() { super("self", "server.commands.op.self.desc"); @@ -33,11 +36,7 @@ public class OpSelfCommand extends AbstractPlayerCommand { @Override protected void execute( - @NonNullDecl CommandContext context, - @NonNullDecl Store store, - @NonNullDecl Ref ref, - @NonNullDecl PlayerRef playerRef, - @NonNullDecl World world + @Nonnull CommandContext context, @Nonnull Store store, @Nonnull Ref ref, @Nonnull PlayerRef playerRef, @Nonnull World world ) { if (PermissionsModule.get().areProvidersTampered()) { playerRef.sendMessage(MESSAGE_COMMANDS_NON_VANILLA_PERMISSIONS); @@ -45,7 +44,10 @@ public class OpSelfCommand extends AbstractPlayerCommand { playerRef.sendMessage(MESSAGE_COMMANDS_SINGLEPLAYER_OWNER_REQ); } else if (!Constants.SINGLEPLAYER && !Constants.ALLOWS_SELF_OP_COMMAND) { playerRef.sendMessage( - MESSAGE_COMMANDS_MULTIPLAYER_TIP.param("uuidCommand", "uuid").param("permissionFile", "permissions.json").param("launchArg", "--allow-op") + Message.translation("server.commands.op.self.multiplayerTip") + .param("uuidCommand", "uuid") + .param("permissionFile", "permissions.json") + .param("launchArg", "--allow-op") ); } else { UUID uuid = playerRef.getUuid(); diff --git a/src/com/hypixel/hytale/server/core/plugin/PluginState.java b/src/com/hypixel/hytale/server/core/plugin/PluginState.java index 201ea8d..7a6967f 100644 --- a/src/com/hypixel/hytale/server/core/plugin/PluginState.java +++ b/src/com/hypixel/hytale/server/core/plugin/PluginState.java @@ -7,7 +7,4 @@ public enum PluginState { ENABLED, SHUTDOWN, DISABLED; - - private PluginState() { - } } diff --git a/src/com/hypixel/hytale/server/core/plugin/pages/PluginListPage.java b/src/com/hypixel/hytale/server/core/plugin/pages/PluginListPage.java index cd542c2..b772270 100644 --- a/src/com/hypixel/hytale/server/core/plugin/pages/PluginListPage.java +++ b/src/com/hypixel/hytale/server/core/plugin/pages/PluginListPage.java @@ -254,8 +254,5 @@ public class PluginListPage extends InteractiveCustomUIPage { public static final PrefabCopyableComponent INSTANCE = new PrefabCopyableComponent(); - - public PrefabCopyableComponent() { - } + public static final BuilderCodec CODEC = BuilderCodec.builder(PrefabCopyableComponent.class, () -> INSTANCE).build(); public static ComponentType getComponentType() { return EntityModule.get().getPrefabCopyableComponentType(); diff --git a/src/com/hypixel/hytale/server/core/prefab/PrefabLoadException.java b/src/com/hypixel/hytale/server/core/prefab/PrefabLoadException.java index 0172496..940da1c 100644 --- a/src/com/hypixel/hytale/server/core/prefab/PrefabLoadException.java +++ b/src/com/hypixel/hytale/server/core/prefab/PrefabLoadException.java @@ -32,8 +32,5 @@ public class PrefabLoadException extends RuntimeException { public static enum Type { ERROR, NOT_FOUND; - - private Type() { - } } } diff --git a/src/com/hypixel/hytale/server/core/prefab/PrefabRotation.java b/src/com/hypixel/hytale/server/core/prefab/PrefabRotation.java index db6558c..199fd05 100644 --- a/src/com/hypixel/hytale/server/core/prefab/PrefabRotation.java +++ b/src/com/hypixel/hytale/server/core/prefab/PrefabRotation.java @@ -108,9 +108,6 @@ public enum PrefabRotation { } private static class RotationExecutor_0 implements PrefabRotation.RotationExecutor { - private RotationExecutor_0() { - } - @Override public float getYaw() { return 0.0F; @@ -148,9 +145,6 @@ public enum PrefabRotation { } private static class RotationExecutor_180 implements PrefabRotation.RotationExecutor { - private RotationExecutor_180() { - } - @Override public float getYaw() { return (float) -Math.PI; @@ -188,9 +182,6 @@ public enum PrefabRotation { } private static class RotationExecutor_270 implements PrefabRotation.RotationExecutor { - private RotationExecutor_270() { - } - @Override public float getYaw() { return (float) (-Math.PI * 3.0 / 2.0); @@ -228,9 +219,6 @@ public enum PrefabRotation { } private static class RotationExecutor_90 implements PrefabRotation.RotationExecutor { - private RotationExecutor_90() { - } - @Override public float getYaw() { return (float) (-Math.PI / 2); diff --git a/src/com/hypixel/hytale/server/core/prefab/PrefabSaveException.java b/src/com/hypixel/hytale/server/core/prefab/PrefabSaveException.java index 671fddb..97180d2 100644 --- a/src/com/hypixel/hytale/server/core/prefab/PrefabSaveException.java +++ b/src/com/hypixel/hytale/server/core/prefab/PrefabSaveException.java @@ -29,8 +29,5 @@ public class PrefabSaveException extends RuntimeException { public static enum Type { ERROR, ALREADY_EXISTS; - - private Type() { - } } } diff --git a/src/com/hypixel/hytale/server/core/prefab/PrefabStore.java b/src/com/hypixel/hytale/server/core/prefab/PrefabStore.java index 37f86bd..1cb76f1 100644 --- a/src/com/hypixel/hytale/server/core/prefab/PrefabStore.java +++ b/src/com/hypixel/hytale/server/core/prefab/PrefabStore.java @@ -243,7 +243,7 @@ public class PrefabStore { if (this.pack == null) { return "Server"; } else if (this.isBasePack()) { - return "Assets"; + return "HytaleAssets"; } else { PluginManifest manifest = this.pack.getManifest(); return manifest != null ? manifest.getName() : this.pack.getName(); diff --git a/src/com/hypixel/hytale/server/core/prefab/PrefabWeights.java b/src/com/hypixel/hytale/server/core/prefab/PrefabWeights.java index 6921ca5..8dd6f56 100644 --- a/src/com/hypixel/hytale/server/core/prefab/PrefabWeights.java +++ b/src/com/hypixel/hytale/server/core/prefab/PrefabWeights.java @@ -202,9 +202,6 @@ public class PrefabWeights { } private static class WeightMapValidator implements LegacyValidator> { - private WeightMapValidator() { - } - public void accept(@Nonnull Object2DoubleMap stringObject2DoubleMap, ValidationResults results) { for (Entry entry : Object2DoubleMaps.fastIterable(stringObject2DoubleMap)) { PrefabWeights.checkWeight(entry.getKey(), entry.getDoubleValue()); diff --git a/src/com/hypixel/hytale/server/core/prefab/config/SelectionPrefabSerializer.java b/src/com/hypixel/hytale/server/core/prefab/config/SelectionPrefabSerializer.java index 3169714..80a9056 100644 --- a/src/com/hypixel/hytale/server/core/prefab/config/SelectionPrefabSerializer.java +++ b/src/com/hypixel/hytale/server/core/prefab/config/SelectionPrefabSerializer.java @@ -27,7 +27,9 @@ import com.hypixel.hytale.server.core.universe.world.meta.BlockStateModule; import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import com.hypixel.hytale.server.core.util.FillerBlockUtil; +import java.util.ArrayList; import java.util.Comparator; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.function.Function; @@ -330,9 +332,11 @@ public class SelectionPrefabSerializer { out.put("fluids", fluidContentOut); } - BsonArray entities = new BsonArray(); - prefab.forEachEntity(holder -> entities.add((BsonValue)EntityStore.REGISTRY.serialize(holder))); - if (!entities.isEmpty()) { + List entityList = new ArrayList<>(); + prefab.forEachEntity(holder -> entityList.add(EntityStore.REGISTRY.serialize(holder))); + if (!entityList.isEmpty()) { + BsonArray entities = new BsonArray(); + entityList.forEach(entities::add); out.put("entities", entities); } diff --git a/src/com/hypixel/hytale/server/core/prefab/selection/buffer/BinaryPrefabBufferCodec.java b/src/com/hypixel/hytale/server/core/prefab/selection/buffer/BinaryPrefabBufferCodec.java index 0261649..9275eae 100644 --- a/src/com/hypixel/hytale/server/core/prefab/selection/buffer/BinaryPrefabBufferCodec.java +++ b/src/com/hypixel/hytale/server/core/prefab/selection/buffer/BinaryPrefabBufferCodec.java @@ -36,9 +36,6 @@ public class BinaryPrefabBufferCodec implements PrefabBufferCodec { private static final int MASK_FILLER = 16; private static final int MASK_ROTATION = 32; - public BinaryPrefabBufferCodec() { - } - @Nonnull public PrefabBuffer deserialize(Path path, @Nonnull ByteBuf buffer) { int version = buffer.readUnsignedShort(); diff --git a/src/com/hypixel/hytale/server/core/prefab/selection/buffer/BsonPrefabBufferDeserializer.java b/src/com/hypixel/hytale/server/core/prefab/selection/buffer/BsonPrefabBufferDeserializer.java index 2f001c8..90f3b2b 100644 --- a/src/com/hypixel/hytale/server/core/prefab/selection/buffer/BsonPrefabBufferDeserializer.java +++ b/src/com/hypixel/hytale/server/core/prefab/selection/buffer/BsonPrefabBufferDeserializer.java @@ -38,9 +38,6 @@ public class BsonPrefabBufferDeserializer implements PrefabBufferDeserializer> CACHE = new ConcurrentHashMap<>(); - public PrefabBufferUtil() { - } - @Nonnull public static IPrefabBuffer getCached(@Nonnull Path path) { WeakReference reference = CACHE.get(path); @@ -240,8 +237,5 @@ public class PrefabBufferUtil { private static class CachedEntry { private final StampedLock lock = new StampedLock(); private PrefabBuffer buffer; - - private CachedEntry() { - } } } diff --git a/src/com/hypixel/hytale/server/core/prefab/selection/mask/BlockPattern.java b/src/com/hypixel/hytale/server/core/prefab/selection/mask/BlockPattern.java index ae9c167..7e04901 100644 --- a/src/com/hypixel/hytale/server/core/prefab/selection/mask/BlockPattern.java +++ b/src/com/hypixel/hytale/server/core/prefab/selection/mask/BlockPattern.java @@ -167,6 +167,10 @@ public class BlockPattern { } blockId = BlockType.getAssetMap().getIndex(blockText); + if (blockId == Integer.MIN_VALUE) { + LOGGER.at(Level.WARNING).log("Invalid block name '%s' - using empty block", blockText); + return 0; + } } return blockId; diff --git a/src/com/hypixel/hytale/server/core/prefab/selection/standard/BlockSelection.java b/src/com/hypixel/hytale/server/core/prefab/selection/standard/BlockSelection.java index 0e77069..b42b5e4 100644 --- a/src/com/hypixel/hytale/server/core/prefab/selection/standard/BlockSelection.java +++ b/src/com/hypixel/hytale/server/core/prefab/selection/standard/BlockSelection.java @@ -6,6 +6,7 @@ import com.hypixel.hytale.codec.Codec; import com.hypixel.hytale.component.AddReason; import com.hypixel.hytale.component.ComponentAccessor; import com.hypixel.hytale.component.ComponentRegistry; +import com.hypixel.hytale.component.ComponentType; import com.hypixel.hytale.component.Holder; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.RemoveReason; @@ -587,7 +588,9 @@ public class BlockSelection implements NetworkSerializable, } } - if (holder == null) { + if (holder != null && b.filler != 0) { + return new BlockSelection.BlockHolder(b.blockId(), b.rotation(), b.filler(), b.supportValue(), null); + } else if (holder == null) { return (BlockSelection.BlockHolder)b; } else { try { @@ -650,6 +653,45 @@ public class BlockSelection implements NetworkSerializable, } } + public void sortEntitiesByPosition() { + this.entitiesLock.writeLock().lock(); + + try { + ComponentType transformType = TransformComponent.getComponentType(); + this.entities.sort((a, b) -> { + TransformComponent ta = a.getComponent(transformType); + TransformComponent tb = b.getComponent(transformType); + if (ta == null && tb == null) { + return 0; + } else if (ta == null) { + return 1; + } else if (tb == null) { + return -1; + } else { + Vector3d pa = ta.getPosition(); + Vector3d pb = tb.getPosition(); + if (pa == null && pb == null) { + return 0; + } else if (pa == null) { + return 1; + } else if (pb == null) { + return -1; + } else { + int cmp = Double.compare(pa.getX(), pb.getX()); + if (cmp != 0) { + return cmp; + } else { + cmp = Double.compare(pa.getY(), pb.getY()); + return cmp != 0 ? cmp : Double.compare(pa.getZ(), pb.getZ()); + } + } + } + }); + } finally { + this.entitiesLock.writeLock().unlock(); + } + } + public void placeNoReturn(@Nonnull World world, Vector3i position, ComponentAccessor componentAccessor) { this.placeNoReturn(null, null, FeedbackConsumer.DEFAULT, world, position, null, componentAccessor); } @@ -1813,9 +1855,6 @@ public class BlockSelection implements NetworkSerializable, public static enum FallbackMode { PASS_THOUGH, COPY; - - private FallbackMode() { - } } public record FluidHolder(int fluidId, byte fluidLevel) { diff --git a/src/com/hypixel/hytale/server/core/ui/Anchor.java b/src/com/hypixel/hytale/server/core/ui/Anchor.java index 6a3d62a..f868a6a 100644 --- a/src/com/hypixel/hytale/server/core/ui/Anchor.java +++ b/src/com/hypixel/hytale/server/core/ui/Anchor.java @@ -29,9 +29,6 @@ public class Anchor { private Value minWidth; private Value maxWidth; - public Anchor() { - } - public void setLeft(Value left) { this.left = left; } diff --git a/src/com/hypixel/hytale/server/core/ui/Area.java b/src/com/hypixel/hytale/server/core/ui/Area.java index f2fa278..6ab04fb 100644 --- a/src/com/hypixel/hytale/server/core/ui/Area.java +++ b/src/com/hypixel/hytale/server/core/ui/Area.java @@ -17,9 +17,6 @@ public class Area { private int width; private int height; - public Area() { - } - @Nonnull public Area setX(int x) { this.x = x; diff --git a/src/com/hypixel/hytale/server/core/ui/LocalizableString.java b/src/com/hypixel/hytale/server/core/ui/LocalizableString.java index 601ef46..7a40191 100644 --- a/src/com/hypixel/hytale/server/core/ui/LocalizableString.java +++ b/src/com/hypixel/hytale/server/core/ui/LocalizableString.java @@ -23,9 +23,6 @@ public class LocalizableString { private String messageId; private Map messageParams; - public LocalizableString() { - } - @Nonnull public static LocalizableString fromString(String str) { LocalizableString instance = new LocalizableString(); @@ -47,9 +44,6 @@ public class LocalizableString { } public static class LocalizableStringCodec implements Codec { - public LocalizableStringCodec() { - } - public LocalizableString decode(BsonValue bsonValue, @Nonnull ExtraInfo extraInfo) { return bsonValue instanceof BsonString ? LocalizableString.fromString(bsonValue.asString().getValue()) diff --git a/src/com/hypixel/hytale/server/core/ui/browser/FileBrowserConfig.java b/src/com/hypixel/hytale/server/core/ui/browser/FileBrowserConfig.java index f92b5e6..f3e6b08 100644 --- a/src/com/hypixel/hytale/server/core/ui/browser/FileBrowserConfig.java +++ b/src/com/hypixel/hytale/server/core/ui/browser/FileBrowserConfig.java @@ -4,6 +4,7 @@ import com.hypixel.hytale.server.core.ui.LocalizableString; import java.nio.file.Path; import java.util.List; import java.util.Set; +import java.util.function.Predicate; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -19,7 +20,10 @@ public record FileBrowserConfig( boolean enableDirectoryNav, boolean enableMultiSelect, int maxResults, - @Nullable FileListProvider customProvider + @Nullable FileListProvider customProvider, + boolean assetPackMode, + @Nullable String assetPackSubPath, + @Nullable Predicate terminalDirectoryPredicate ) { public static FileBrowserConfig.Builder builder() { return new FileBrowserConfig.Builder(); @@ -38,9 +42,9 @@ public record FileBrowserConfig( private boolean enableMultiSelect = false; private int maxResults = 50; private FileListProvider customProvider = null; - - public Builder() { - } + private boolean assetPackMode = false; + private String assetPackSubPath = null; + private Predicate terminalDirectoryPredicate = null; public FileBrowserConfig.Builder listElementId(@Nonnull String listElementId) { this.listElementId = listElementId; @@ -107,6 +111,21 @@ public record FileBrowserConfig( return this; } + public FileBrowserConfig.Builder assetPackMode(boolean enable, @Nullable String subPath) { + if (enable && subPath == null) { + throw new IllegalArgumentException("assetPackSubPath cannot be null when assetPackMode is enabled"); + } else { + this.assetPackMode = enable; + this.assetPackSubPath = subPath; + return this; + } + } + + public FileBrowserConfig.Builder terminalDirectoryPredicate(@Nullable Predicate predicate) { + this.terminalDirectoryPredicate = predicate; + return this; + } + public FileBrowserConfig build() { return new FileBrowserConfig( this.listElementId, @@ -120,7 +139,10 @@ public record FileBrowserConfig( this.enableDirectoryNav, this.enableMultiSelect, this.maxResults, - this.customProvider + this.customProvider, + this.assetPackMode, + this.assetPackSubPath, + this.terminalDirectoryPredicate ); } } diff --git a/src/com/hypixel/hytale/server/core/ui/browser/FileBrowserEventData.java b/src/com/hypixel/hytale/server/core/ui/browser/FileBrowserEventData.java index 49cd7bf..803e47e 100644 --- a/src/com/hypixel/hytale/server/core/ui/browser/FileBrowserEventData.java +++ b/src/com/hypixel/hytale/server/core/ui/browser/FileBrowserEventData.java @@ -33,9 +33,6 @@ public class FileBrowserEventData { @Nullable private Boolean browse; - public FileBrowserEventData() { - } - @Nullable public String getFile() { return this.file; diff --git a/src/com/hypixel/hytale/server/core/ui/browser/FileListProvider.java b/src/com/hypixel/hytale/server/core/ui/browser/FileListProvider.java index 619cf92..6be4dc9 100644 --- a/src/com/hypixel/hytale/server/core/ui/browser/FileListProvider.java +++ b/src/com/hypixel/hytale/server/core/ui/browser/FileListProvider.java @@ -9,13 +9,17 @@ public interface FileListProvider { @Nonnull List getFiles(@Nonnull Path var1, @Nonnull String var2); - public record FileEntry(@Nonnull String name, @Nonnull String displayName, boolean isDirectory, int matchScore) { + public record FileEntry(@Nonnull String name, @Nonnull String displayName, boolean isDirectory, boolean isTerminal, int matchScore) { public FileEntry(@Nonnull String name, boolean isDirectory) { - this(name, name, isDirectory, 0); + this(name, name, isDirectory, false, 0); } public FileEntry(@Nonnull String name, @Nonnull String displayName, boolean isDirectory) { - this(name, displayName, isDirectory, 0); + this(name, displayName, isDirectory, false, 0); + } + + public FileEntry(@Nonnull String name, @Nonnull String displayName, boolean isDirectory, boolean isTerminal) { + this(name, displayName, isDirectory, isTerminal, 0); } } } diff --git a/src/com/hypixel/hytale/server/core/ui/browser/ServerFileBrowser.java b/src/com/hypixel/hytale/server/core/ui/browser/ServerFileBrowser.java index 2ce017f..ad82b11 100644 --- a/src/com/hypixel/hytale/server/core/ui/browser/ServerFileBrowser.java +++ b/src/com/hypixel/hytale/server/core/ui/browser/ServerFileBrowser.java @@ -1,9 +1,12 @@ package com.hypixel.hytale.server.core.ui.browser; +import com.hypixel.hytale.assetstore.AssetPack; +import com.hypixel.hytale.common.plugin.PluginManifest; import com.hypixel.hytale.common.util.PathUtil; import com.hypixel.hytale.common.util.StringCompareUtil; import com.hypixel.hytale.logger.HytaleLogger; import com.hypixel.hytale.protocol.packets.interface_.CustomUIEventBindingType; +import com.hypixel.hytale.server.core.asset.AssetModule; import com.hypixel.hytale.server.core.ui.DropdownEntryInfo; import com.hypixel.hytale.server.core.ui.Value; import com.hypixel.hytale.server.core.ui.builder.EventData; @@ -26,6 +29,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Locale; import java.util.Set; +import java.util.function.Predicate; import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -33,6 +37,7 @@ import javax.annotation.Nullable; public class ServerFileBrowser { private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); private static final Value BUTTON_HIGHLIGHTED = Value.ref("Pages/BasicTextButton.ui", "SelectedLabelStyle"); + private static final String BASE_ASSET_PACK_DISPLAY_NAME = "HytaleAssets"; @Nonnull private final FileBrowserConfig config; @Nonnull @@ -106,9 +111,27 @@ public class ServerFileBrowser { public void buildCurrentPath(@Nonnull UICommandBuilder commandBuilder) { if (this.config.currentPathId() != null) { - String rootDisplay = this.root.toString().replace("\\", "/"); - String relativeDisplay = this.currentDir.toString().isEmpty() ? "" : "/" + this.currentDir.toString().replace("\\", "/"); - String displayPath = rootDisplay + relativeDisplay; + String displayPath; + if (this.config.assetPackMode()) { + String currentDirStr = this.currentDir.toString().replace('\\', '/'); + if (currentDirStr.isEmpty()) { + displayPath = "Assets"; + } else { + String[] parts = currentDirStr.split("/", 2); + String packName = parts[0]; + String subPath = parts.length > 1 ? "/" + parts[1] : ""; + if ("HytaleAssets".equals(packName)) { + displayPath = packName + subPath; + } else { + displayPath = "Mods/" + packName + subPath; + } + } + } else { + String rootDisplay = this.root.toString().replace("\\", "/"); + String relativeDisplay = this.currentDir.toString().isEmpty() ? "" : "/" + this.currentDir.toString().replace("\\", "/"); + displayPath = rootDisplay + relativeDisplay; + } + commandBuilder.set(this.config.currentPathId() + ".Text", displayPath); } } @@ -118,6 +141,12 @@ public class ServerFileBrowser { List entries; if (this.config.customProvider() != null) { entries = this.config.customProvider().getFiles(this.currentDir, this.searchQuery); + } else if (this.config.assetPackMode()) { + if (!this.searchQuery.isEmpty() && this.config.enableSearch()) { + entries = this.buildAssetPackSearchResults(); + } else { + entries = this.buildAssetPackListing(); + } } else if (!this.searchQuery.isEmpty() && this.config.enableSearch()) { entries = this.buildSearchResults(); } else { @@ -133,14 +162,15 @@ public class ServerFileBrowser { } for (FileListProvider.FileEntry entry : entries) { - String displayText = entry.isDirectory() ? entry.displayName() + "/" : entry.displayName(); + boolean isNavigableDir = entry.isDirectory() && !entry.isTerminal(); + String displayText = isNavigableDir ? entry.displayName() + "/" : entry.displayName(); commandBuilder.append(this.config.listElementId(), "Pages/BasicTextButton.ui"); commandBuilder.set(this.config.listElementId() + "[" + buttonIndex + "].Text", displayText); - if (!entry.isDirectory()) { + if (!entry.isDirectory() || entry.isTerminal()) { commandBuilder.set(this.config.listElementId() + "[" + buttonIndex + "].Style", BUTTON_HIGHLIGHTED); } - String eventKey = !this.searchQuery.isEmpty() && !entry.isDirectory() ? "SearchResult" : "File"; + String eventKey = !this.searchQuery.isEmpty() && !isNavigableDir ? "SearchResult" : "File"; eventBuilder.addEventBinding( CustomUIEventBindingType.Activating, this.config.listElementId() + "[" + buttonIndex + "]", EventData.of(eventKey, entry.name()) ); @@ -174,6 +204,8 @@ public class ServerFileBrowser { if ("..".equals(fileName)) { this.navigateUp(); return true; + } else if (this.config.assetPackMode()) { + return this.handleAssetPackNavigation(fileName); } else { if (this.config.enableDirectoryNav()) { Path targetPath = this.root.resolve(this.currentDir.toString()).resolve(fileName); @@ -257,7 +289,7 @@ public class ServerFileBrowser { Path relativePath = PathUtil.relativize(this.root, filex); String fileNamex = filex.getFileName().toString(); String displayName = this.removeExtensions(fileNamex); - return new FileListProvider.FileEntry(relativePath.toString(), displayName, false, matchScores.getInt(filex)); + return new FileListProvider.FileEntry(relativePath.toString(), displayName, false, false, matchScores.getInt(filex)); }).collect(Collectors.toList()); } } @@ -276,6 +308,246 @@ public class ServerFileBrowser { } } + private List buildAssetPackListing() { + List entries = new ObjectArrayList<>(); + String currentDirStr = this.currentDir.toString().replace('\\', '/'); + if (currentDirStr.isEmpty()) { + for (AssetPack pack : AssetModule.get().getAssetPacks()) { + Path subPath = this.getAssetPackSubPath(pack); + if (subPath != null && Files.isDirectory(subPath)) { + String displayName = this.getAssetPackDisplayName(pack); + entries.add(new FileListProvider.FileEntry(displayName, displayName, true)); + } + } + } else { + String[] parts = currentDirStr.split("/", 2); + String packName = parts[0]; + String subDir = parts.length > 1 ? parts[1] : ""; + AssetPack packx = this.findAssetPackByDisplayName(packName); + if (packx != null) { + Path packSubPath = this.getAssetPackSubPath(packx); + if (packSubPath != null) { + Path targetDir = subDir.isEmpty() ? packSubPath : packSubPath.resolve(subDir); + if (Files.isDirectory(targetDir)) { + try (DirectoryStream stream = Files.newDirectoryStream(targetDir)) { + for (Path file : stream) { + String fileName = file.getFileName().toString(); + if (!fileName.startsWith(".")) { + boolean isDirectory = Files.isDirectory(file); + if (isDirectory || this.matchesExtension(fileName)) { + String displayName = isDirectory ? fileName : this.removeExtensions(fileName); + boolean isTerminal = isDirectory && this.isTerminalDirectory(file); + entries.add(new FileListProvider.FileEntry(fileName, displayName, isDirectory, isTerminal)); + } + } + } + } catch (IOException var18) { + LOGGER.atSevere().withCause(var18).log("Error listing asset pack directory: %s", targetDir); + } + } + } + } + } + + entries.sort((a, b) -> { + boolean aIsBase = "HytaleAssets".equals(a.name()); + boolean bIsBase = "HytaleAssets".equals(b.name()); + if (aIsBase != bIsBase) { + return aIsBase ? -1 : 1; + } else if (a.isDirectory() == b.isDirectory()) { + return a.displayName().compareToIgnoreCase(b.displayName()); + } else { + return a.isDirectory() ? -1 : 1; + } + }); + return entries; + } + + private List buildAssetPackSearchResults() { + List allResults = new ObjectArrayList<>(); + String currentDirStr = this.currentDir.toString().replace('\\', '/'); + if (currentDirStr.isEmpty()) { + for (AssetPack pack : AssetModule.get().getAssetPacks()) { + Path subPath = this.getAssetPackSubPath(pack); + if (subPath != null && Files.isDirectory(subPath)) { + String packDisplayName = this.getAssetPackDisplayName(pack); + this.searchInAssetPackDirectory(subPath, packDisplayName, "", allResults); + } + } + } else { + String[] parts = currentDirStr.split("/", 2); + String packName = parts[0]; + String subDir = parts.length > 1 ? parts[1] : ""; + AssetPack packx = this.findAssetPackByDisplayName(packName); + if (packx != null) { + Path packSubPath = this.getAssetPackSubPath(packx); + if (packSubPath != null) { + Path searchRoot = subDir.isEmpty() ? packSubPath : packSubPath.resolve(subDir); + if (Files.isDirectory(searchRoot)) { + this.searchInAssetPackDirectory(searchRoot, packName, subDir, allResults); + } + } + } + } + + allResults.sort(Comparator.comparingInt(ServerFileBrowser.AssetPackSearchResult::score).reversed()); + return allResults.stream() + .limit(this.config.maxResults()) + .map(r -> new FileListProvider.FileEntry(r.virtualPath(), r.displayName(), r.isTerminal(), r.isTerminal(), r.score())) + .collect(Collectors.toList()); + } + + private void searchInAssetPackDirectory( + @Nonnull final Path searchRoot, + @Nonnull final String packName, + @Nonnull final String basePath, + @Nonnull final List results + ) { + try { + Files.walkFileTree(searchRoot, new SimpleFileVisitor() { + @Nonnull + public FileVisitResult preVisitDirectory(@Nonnull Path dir, @Nonnull BasicFileAttributes attrs) { + if (dir.equals(searchRoot)) { + return FileVisitResult.CONTINUE; + } else if (ServerFileBrowser.this.isTerminalDirectory(dir)) { + String dirName = dir.getFileName().toString(); + int score = StringCompareUtil.getFuzzyDistance(dirName.toLowerCase(), ServerFileBrowser.this.searchQuery, Locale.ENGLISH); + if (score > 0) { + Path relativePath = searchRoot.relativize(dir); + String relativeStr = relativePath.toString().replace('\\', '/'); + String virtualPath = basePath.isEmpty() ? packName + "/" + relativeStr : packName + "/" + basePath + "/" + relativeStr; + results.add(new ServerFileBrowser.AssetPackSearchResult(virtualPath, dirName, score, true)); + } + + return FileVisitResult.SKIP_SUBTREE; + } else { + return FileVisitResult.CONTINUE; + } + } + + @Nonnull + public FileVisitResult visitFile(@Nonnull Path file, @Nonnull BasicFileAttributes attrs) { + String fileName = file.getFileName().toString(); + if (ServerFileBrowser.this.matchesExtension(fileName)) { + String baseName = ServerFileBrowser.this.removeExtensions(fileName); + int score = StringCompareUtil.getFuzzyDistance(baseName.toLowerCase(), ServerFileBrowser.this.searchQuery, Locale.ENGLISH); + if (score > 0) { + Path relativePath = searchRoot.relativize(file); + String relativeStr = relativePath.toString().replace('\\', '/'); + String virtualPath = basePath.isEmpty() ? packName + "/" + relativeStr : packName + "/" + basePath + "/" + relativeStr; + results.add(new ServerFileBrowser.AssetPackSearchResult(virtualPath, baseName, score, false)); + } + } + + return FileVisitResult.CONTINUE; + } + }); + } catch (IOException var6) { + LOGGER.atSevere().withCause(var6).log("Error searching asset pack directory: %s", searchRoot); + } + } + + private boolean handleAssetPackNavigation(@Nonnull String fileName) { + String currentDirStr = this.currentDir.toString().replace('\\', '/'); + if (currentDirStr.isEmpty()) { + AssetPack pack = this.findAssetPackByDisplayName(fileName); + if (pack != null) { + Path subPath = this.getAssetPackSubPath(pack); + if (subPath != null && Files.isDirectory(subPath)) { + this.currentDir = Paths.get(fileName); + return true; + } + } + + return false; + } else { + String[] parts = currentDirStr.split("/", 2); + String packName = parts[0]; + String subDir = parts.length > 1 ? parts[1] : ""; + AssetPack pack = this.findAssetPackByDisplayName(packName); + if (pack == null) { + return false; + } else { + Path packSubPath = this.getAssetPackSubPath(pack); + if (packSubPath == null) { + return false; + } else { + Path targetDir = subDir.isEmpty() ? packSubPath : packSubPath.resolve(subDir); + Path targetPath = targetDir.resolve(fileName); + if (Files.isDirectory(targetPath)) { + if (this.isTerminalDirectory(targetPath)) { + return false; + } else { + String newPath = subDir.isEmpty() ? packName + "/" + fileName : packName + "/" + subDir + "/" + fileName; + this.currentDir = Paths.get(newPath); + return true; + } + } else { + return false; + } + } + } + } + } + + @Nullable + private Path getAssetPackSubPath(@Nonnull AssetPack pack) { + return this.config.assetPackSubPath() == null ? null : pack.getRoot().resolve(this.config.assetPackSubPath()); + } + + @Nonnull + private String getAssetPackDisplayName(@Nonnull AssetPack pack) { + if (pack.equals(AssetModule.get().getBaseAssetPack())) { + return "HytaleAssets"; + } else { + PluginManifest manifest = pack.getManifest(); + return manifest != null ? manifest.getName() : pack.getName(); + } + } + + @Nullable + private AssetPack findAssetPackByDisplayName(@Nonnull String displayName) { + for (AssetPack pack : AssetModule.get().getAssetPacks()) { + if (this.getAssetPackDisplayName(pack).equals(displayName)) { + return pack; + } + } + + return null; + } + + private boolean isTerminalDirectory(@Nonnull Path path) { + Predicate predicate = this.config.terminalDirectoryPredicate(); + return predicate != null && predicate.test(path); + } + + @Nullable + public Path resolveAssetPackPath(@Nonnull String virtualPath) { + if (this.config.assetPackMode() && !virtualPath.isEmpty()) { + String[] parts = virtualPath.replace('\\', '/').split("/", 2); + String packName = parts[0]; + String subPath = parts.length > 1 ? parts[1] : ""; + AssetPack pack = this.findAssetPackByDisplayName(packName); + if (pack == null) { + return null; + } else { + Path packSubPath = this.getAssetPackSubPath(pack); + if (packSubPath == null) { + return null; + } else { + return subPath.isEmpty() ? packSubPath : packSubPath.resolve(subPath); + } + } + } else { + return null; + } + } + + @Nonnull + public String getAssetPackCurrentPath() { + return this.currentDir.toString().replace('\\', '/'); + } + private String removeExtensions(@Nonnull String fileName) { for (String ext : this.config.allowedExtensions()) { if (fileName.endsWith(ext)) { @@ -292,9 +564,7 @@ public class ServerFileBrowser { } public void setRoot(@Nonnull Path root) { - if (Files.isDirectory(root)) { - this.root = root; - } + this.root = root; } @Nonnull @@ -376,4 +646,7 @@ public class ServerFileBrowser { return null; } + + private record AssetPackSearchResult(@Nonnull String virtualPath, @Nonnull String displayName, int score, boolean isTerminal) { + } } diff --git a/src/com/hypixel/hytale/server/core/ui/builder/UICommandBuilder.java b/src/com/hypixel/hytale/server/core/ui/builder/UICommandBuilder.java index 426de15..845cc70 100644 --- a/src/com/hypixel/hytale/server/core/ui/builder/UICommandBuilder.java +++ b/src/com/hypixel/hytale/server/core/ui/builder/UICommandBuilder.java @@ -34,9 +34,6 @@ public class UICommandBuilder { @Nonnull private final List commands = new ObjectArrayList<>(); - public UICommandBuilder() { - } - @Nonnull public UICommandBuilder clear(String selector) { this.commands.add(new CustomUICommand(CustomUICommandType.Clear, selector, null, null)); diff --git a/src/com/hypixel/hytale/server/core/ui/builder/UIEventBuilder.java b/src/com/hypixel/hytale/server/core/ui/builder/UIEventBuilder.java index 3869b34..543987c 100644 --- a/src/com/hypixel/hytale/server/core/ui/builder/UIEventBuilder.java +++ b/src/com/hypixel/hytale/server/core/ui/builder/UIEventBuilder.java @@ -16,9 +16,6 @@ public class UIEventBuilder { @Nonnull private final List events = new ObjectArrayList<>(); - public UIEventBuilder() { - } - @Nonnull public UIEventBuilder addEventBinding(CustomUIEventBindingType type, String selector) { return this.addEventBinding(type, selector, null); diff --git a/src/com/hypixel/hytale/server/core/universe/Universe.java b/src/com/hypixel/hytale/server/core/universe/Universe.java index ee0447c..5b584fd 100644 --- a/src/com/hypixel/hytale/server/core/universe/Universe.java +++ b/src/com/hypixel/hytale/server/core/universe/Universe.java @@ -752,13 +752,20 @@ public class Universe extends JavaPlugin implements IMessageReceiver, MetricProv this.finalizePlayerRemoval(playerRef); } else { + CompletableFuture removedFuture = new CompletableFuture<>(); CompletableFuture.runAsync(() -> { - Player playerComponentx = ref.getStore().getComponent(ref, Player.getComponentType()); - if (playerComponentx != null) { - playerComponentx.remove(); - } - }, world) - .orTimeout(5L, TimeUnit.SECONDS) + Player playerComponent = ref.getStore().getComponent(ref, Player.getComponentType()); + if (playerComponent != null) { + playerComponent.remove(); + } + }, world).whenComplete((unused, throwable) -> { + if (throwable != null) { + removedFuture.completeExceptionally(throwable); + } else { + removedFuture.complete(unused); + } + }); + removedFuture.orTimeout(5L, TimeUnit.SECONDS) .whenComplete( (result, error) -> { if (error != null) { diff --git a/src/com/hypixel/hytale/server/core/universe/WorldLoadCancelledException.java b/src/com/hypixel/hytale/server/core/universe/WorldLoadCancelledException.java index a65cb7d..b183992 100644 --- a/src/com/hypixel/hytale/server/core/universe/WorldLoadCancelledException.java +++ b/src/com/hypixel/hytale/server/core/universe/WorldLoadCancelledException.java @@ -1,6 +1,4 @@ package com.hypixel.hytale.server.core.universe; public class WorldLoadCancelledException extends RuntimeException { - public WorldLoadCancelledException() { - } } diff --git a/src/com/hypixel/hytale/server/core/universe/playerdata/DefaultPlayerStorageProvider.java b/src/com/hypixel/hytale/server/core/universe/playerdata/DefaultPlayerStorageProvider.java index 036e164..bdde0f6 100644 --- a/src/com/hypixel/hytale/server/core/universe/playerdata/DefaultPlayerStorageProvider.java +++ b/src/com/hypixel/hytale/server/core/universe/playerdata/DefaultPlayerStorageProvider.java @@ -9,9 +9,6 @@ public class DefaultPlayerStorageProvider implements PlayerStorageProvider { public static final BuilderCodec CODEC = BuilderCodec.builder(DefaultPlayerStorageProvider.class, () -> INSTANCE).build(); public static final DiskPlayerStorageProvider DEFAULT = new DiskPlayerStorageProvider(); - public DefaultPlayerStorageProvider() { - } - @Nonnull @Override public PlayerStorage getPlayerStorage() { diff --git a/src/com/hypixel/hytale/server/core/universe/playerdata/DiskPlayerStorageProvider.java b/src/com/hypixel/hytale/server/core/universe/playerdata/DiskPlayerStorageProvider.java index 35adfe8..391df20 100644 --- a/src/com/hypixel/hytale/server/core/universe/playerdata/DiskPlayerStorageProvider.java +++ b/src/com/hypixel/hytale/server/core/universe/playerdata/DiskPlayerStorageProvider.java @@ -30,9 +30,6 @@ public class DiskPlayerStorageProvider implements PlayerStorageProvider { @Nonnull private Path path = Constants.UNIVERSE_PATH.resolve("players"); - public DiskPlayerStorageProvider() { - } - @Nonnull public Path getPath() { return this.path; diff --git a/src/com/hypixel/hytale/server/core/universe/system/PlayerVelocityInstructionSystem.java b/src/com/hypixel/hytale/server/core/universe/system/PlayerVelocityInstructionSystem.java index 98bf025..35be533 100644 --- a/src/com/hypixel/hytale/server/core/universe/system/PlayerVelocityInstructionSystem.java +++ b/src/com/hypixel/hytale/server/core/universe/system/PlayerVelocityInstructionSystem.java @@ -33,9 +33,6 @@ public class PlayerVelocityInstructionSystem extends EntityTickingSystem query = Query.and(PlayerRef.getComponentType(), Velocity.getComponentType()); - public PlayerVelocityInstructionSystem() { - } - @Override public void tick( float dt, @@ -69,11 +66,10 @@ public class PlayerVelocityInstructionSystem extends EntityTickingSystem componentAccessor) { SpatialResource, EntityStore> playerSpatialResource = componentAccessor.getResource(EntityModule.get().getPlayerSpatialResourceType()); ObjectList> playerRefs = SpatialResource.getThreadLocalReferenceList(); diff --git a/src/com/hypixel/hytale/server/core/universe/world/PlaceBlockSettings.java b/src/com/hypixel/hytale/server/core/universe/world/PlaceBlockSettings.java index 43e0005..0ba7d17 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/PlaceBlockSettings.java +++ b/src/com/hypixel/hytale/server/core/universe/world/PlaceBlockSettings.java @@ -4,7 +4,4 @@ public class PlaceBlockSettings { public static final int NONE = 0; public static final int PERFORM_BLOCK_UPDATE = 2; public static final int UPDATE_CONNECTIONS = 8; - - public PlaceBlockSettings() { - } } diff --git a/src/com/hypixel/hytale/server/core/universe/world/PlayerUtil.java b/src/com/hypixel/hytale/server/core/universe/world/PlayerUtil.java index 48a3195..ede7be5 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/PlayerUtil.java +++ b/src/com/hypixel/hytale/server/core/universe/world/PlayerUtil.java @@ -20,9 +20,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class PlayerUtil { - public PlayerUtil() { - } - public static void forEachPlayerThatCanSeeEntity( @Nonnull Ref ref, @Nonnull TriConsumer, PlayerRef, ComponentAccessor> consumer, diff --git a/src/com/hypixel/hytale/server/core/universe/world/SetBlockSettings.java b/src/com/hypixel/hytale/server/core/universe/world/SetBlockSettings.java index 776cf10..10bea63 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/SetBlockSettings.java +++ b/src/com/hypixel/hytale/server/core/universe/world/SetBlockSettings.java @@ -14,7 +14,4 @@ public class SetBlockSettings { public static final int NO_UPDATE_HEIGHTMAP = 512; public static final int NO_SEND_AUDIO = 1024; public static final int NO_DROP_ITEMS = 2048; - - public SetBlockSettings() { - } } diff --git a/src/com/hypixel/hytale/server/core/universe/world/SoundUtil.java b/src/com/hypixel/hytale/server/core/universe/world/SoundUtil.java index e3d684c..c4d5b64 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/SoundUtil.java +++ b/src/com/hypixel/hytale/server/core/universe/world/SoundUtil.java @@ -22,9 +22,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class SoundUtil { - public SoundUtil() { - } - public static void playSoundEventEntity(int soundEventIndex, int networkId, @Nonnull ComponentAccessor componentAccessor) { playSoundEventEntity(soundEventIndex, networkId, 1.0F, 1.0F, componentAccessor); } diff --git a/src/com/hypixel/hytale/server/core/universe/world/SpawnUtil.java b/src/com/hypixel/hytale/server/core/universe/world/SpawnUtil.java index 8fd4c25..745b05d 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/SpawnUtil.java +++ b/src/com/hypixel/hytale/server/core/universe/world/SpawnUtil.java @@ -12,9 +12,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public final class SpawnUtil { - public SpawnUtil() { - } - @Nullable public static TransformComponent applyFirstSpawnTransform( @Nonnull Holder holder, @Nonnull World world, @Nonnull WorldConfig worldConfig, @Nonnull UUID playerUuid diff --git a/src/com/hypixel/hytale/server/core/universe/world/ValidationOption.java b/src/com/hypixel/hytale/server/core/universe/world/ValidationOption.java index a5810f6..a2c39f5 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/ValidationOption.java +++ b/src/com/hypixel/hytale/server/core/universe/world/ValidationOption.java @@ -6,7 +6,4 @@ public enum ValidationOption { BLOCK_STATES, ENTITIES, BLOCK_FILLER; - - private ValidationOption() { - } } diff --git a/src/com/hypixel/hytale/server/core/universe/world/World.java b/src/com/hypixel/hytale/server/core/universe/world/World.java index 69fd762..ce02880 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/World.java +++ b/src/com/hypixel/hytale/server/core/universe/world/World.java @@ -38,6 +38,7 @@ import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType; import com.hypixel.hytale.server.core.asset.type.gameplay.CombatConfig; import com.hypixel.hytale.server.core.asset.type.gameplay.DeathConfig; import com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig; +import com.hypixel.hytale.server.core.asset.type.gameplay.PlayerConfig; import com.hypixel.hytale.server.core.blocktype.component.BlockPhysics; import com.hypixel.hytale.server.core.console.ConsoleModule; import com.hypixel.hytale.server.core.entity.Entity; @@ -182,9 +183,15 @@ public class World extends TickingThread implements Executor, ExecutorMetricsReg this.features.put(feature, true); } - CombatConfig combatConfig = this.getGameplayConfig().getCombatConfig(); + GameplayConfig gameplayConfig = this.getGameplayConfig(); + CombatConfig combatConfig = gameplayConfig.getCombatConfig(); this.features.put(ClientFeature.DisplayHealthBars, combatConfig.isDisplayHealthBars()); this.features.put(ClientFeature.DisplayCombatText, combatConfig.isDisplayCombatText()); + PlayerConfig.ArmorVisibilityOption armorVisibilityOption = gameplayConfig.getPlayerConfig().getArmorVisibilityOption(); + this.features.put(ClientFeature.CanHideHelmet, armorVisibilityOption.canHideHelmet()); + this.features.put(ClientFeature.CanHideCuirass, armorVisibilityOption.canHideCuirass()); + this.features.put(ClientFeature.CanHideGauntlets, armorVisibilityOption.canHideGauntlets()); + this.features.put(ClientFeature.CanHidePants, armorVisibilityOption.canHidePants()); this.logger.at(Level.INFO).log("Added world '%s' - Seed: %s, GameTime: %s", name, Long.toString(worldConfig.getSeed()), worldConfig.getGameTime()); } @@ -595,8 +602,8 @@ public class World extends TickingThread implements Executor, ExecutorMetricsReg if (!this.isInThread()) { return CompletableFuture.supplyAsync(() -> this.getEntity(uuid), this).join(); } else { - Ref reference = this.entityStore.getRefFromUUID(uuid); - return EntityUtils.getEntity(reference, this.entityStore.getStore()); + Ref ref = this.entityStore.getRefFromUUID(uuid); + return EntityUtils.getEntity(ref, this.entityStore.getStore()); } } @@ -1065,7 +1072,7 @@ public class World extends TickingThread implements Executor, ExecutorMetricsReg int worldX = ChunkUtil.minBlock(chunk.getX()) + x; int worldZ = ChunkUtil.minBlock(chunk.getZ()) + z; blockValidator.accept( - worldX, y, worldZ, blockId, 0, 1.0F, holder, blockPhys != null ? blockPhys.get(x, y, z) : 0, rotation, filler, null + worldX, worldY, worldZ, blockId, 0, 1.0F, holder, blockPhys != null ? blockPhys.get(x, y, z) : 0, rotation, filler, null ); if (options.contains(ValidationOption.BLOCK_FILLER)) { var fetcher = new FillerBlockUtil.FillerFetcher() { diff --git a/src/com/hypixel/hytale/server/core/universe/world/WorldConfig.java b/src/com/hypixel/hytale/server/core/universe/world/WorldConfig.java index 5e649e2..4df8241 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/WorldConfig.java +++ b/src/com/hypixel/hytale/server/core/universe/world/WorldConfig.java @@ -613,9 +613,6 @@ public class WorldConfig { @Nullable private Box2D keepLoadedRegion; - public ChunkConfig() { - } - @Nullable public Box2D getPregenerateRegion() { return this.pregenerateRegion; diff --git a/src/com/hypixel/hytale/server/core/universe/world/WorldConfigProvider.java b/src/com/hypixel/hytale/server/core/universe/world/WorldConfigProvider.java index 75bbf38..3d7036e 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/WorldConfigProvider.java +++ b/src/com/hypixel/hytale/server/core/universe/world/WorldConfigProvider.java @@ -27,7 +27,5 @@ public interface WorldConfigProvider { } public static class Default implements WorldConfigProvider { - public Default() { - } } } diff --git a/src/com/hypixel/hytale/server/core/universe/world/WorldMapTracker.java b/src/com/hypixel/hytale/server/core/universe/world/WorldMapTracker.java index 4ca7417..e29c577 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/WorldMapTracker.java +++ b/src/com/hypixel/hytale/server/core/universe/world/WorldMapTracker.java @@ -7,16 +7,12 @@ import com.hypixel.hytale.common.util.CompletableFutureUtil; import com.hypixel.hytale.component.ComponentAccessor; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.Store; -import com.hypixel.hytale.function.function.TriFunction; import com.hypixel.hytale.logger.HytaleLogger; import com.hypixel.hytale.math.iterator.CircleSpiralIterator; import com.hypixel.hytale.math.shape.Box2D; import com.hypixel.hytale.math.util.ChunkUtil; import com.hypixel.hytale.math.util.MathUtil; -import com.hypixel.hytale.math.vector.Vector2d; import com.hypixel.hytale.math.vector.Vector3d; -import com.hypixel.hytale.protocol.GameMode; -import com.hypixel.hytale.protocol.Position; import com.hypixel.hytale.protocol.SoundCategory; import com.hypixel.hytale.protocol.packets.worldmap.ClearWorldMap; import com.hypixel.hytale.protocol.packets.worldmap.MapChunk; @@ -33,6 +29,7 @@ import com.hypixel.hytale.server.core.universe.PlayerRef; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager; import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapSettings; +import com.hypixel.hytale.server.core.universe.world.worldmap.markers.MapMarkerTracker; import com.hypixel.hytale.server.core.util.EventTitleUtil; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import it.unimi.dsi.fastutil.longs.LongIterator; @@ -42,9 +39,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Map.Entry; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.function.Predicate; import java.util.logging.Level; @@ -54,7 +49,6 @@ import javax.annotation.Nullable; public class WorldMapTracker implements Tickable { private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); public static final float UPDATE_SPEED = 1.0F; - public static final float MIN_PLAYER_MARKER_UPDATE_SPEED = 10.0F; public static final int RADIUS_MAX = 512; public static final int EMPTY_UPDATE_WORLD_MAP_SIZE = 13; private static final int EMPTY_MAP_CHUNK_SIZE = 10; @@ -67,9 +61,8 @@ public class WorldMapTracker implements Tickable { private final HLongSet loaded = new HLongOpenHashSet(); private final HLongSet pendingReloadChunks = new HLongOpenHashSet(); private final Long2ObjectOpenHashMap> pendingReloadFutures = new Long2ObjectOpenHashMap<>(); - private final Map sentMarkers = new ConcurrentHashMap<>(); + private final MapMarkerTracker markerTracker; private float updateTimer; - private float playerMarkersUpdateTimer; private Integer viewRadiusOverride; private boolean started; private int sentViewRadius; @@ -79,21 +72,13 @@ public class WorldMapTracker implements Tickable { private String currentBiomeName; @Nullable private WorldMapTracker.ZoneDiscoveryInfo currentZone; - private boolean allowTeleportToCoordinates = true; - private boolean allowTeleportToMarkers = true; private boolean clientHasWorldMapVisible; - private Predicate playerMapFilter; - @Nonnull - private final Set tempToRemove = new HashSet<>(); - @Nonnull - private final Set tempToAdd = new HashSet<>(); - @Nonnull - private final Set tempTestedMarkers = new HashSet<>(); @Nullable private TransformComponent transformComponent; public WorldMapTracker(@Nonnull Player player) { this.player = player; + this.markerTracker = new MapMarkerTracker(this); } @Override @@ -127,8 +112,7 @@ public class WorldMapTracker implements Tickable { int playerChunkX = playerX >> 5; int playerChunkZ = playerZ >> 5; if (world.isCompassUpdating()) { - this.playerMarkersUpdateTimer -= dt; - this.updatePointsOfInterest(world, viewRadius, playerChunkX, playerChunkZ); + this.markerTracker.updatePointsOfInterest(dt, world, viewRadius, playerChunkX, playerChunkZ); } if (worldMapManager.isWorldMapEnabled()) { @@ -227,110 +211,6 @@ public class WorldMapTracker implements Tickable { } } - private void updatePointsOfInterest(@Nonnull World world, int chunkViewRadius, int playerChunkX, int playerChunkZ) { - if (this.transformComponent != null) { - WorldMapManager worldMapManager = world.getWorldMapManager(); - Map markerProviders = worldMapManager.getMarkerProviders(); - this.tempToAdd.clear(); - this.tempTestedMarkers.clear(); - - for (WorldMapManager.MarkerProvider provider : markerProviders.values()) { - provider.update(world, world.getGameplayConfig(), this, chunkViewRadius, playerChunkX, playerChunkZ); - } - - this.tempToRemove.clear(); - this.tempToRemove.addAll(this.sentMarkers.keySet()); - if (!this.tempTestedMarkers.isEmpty()) { - this.tempToRemove.removeAll(this.tempTestedMarkers); - } - - for (String removedMarkerId : this.tempToRemove) { - this.sentMarkers.remove(removedMarkerId); - } - - if (!this.tempToAdd.isEmpty() || !this.tempToRemove.isEmpty()) { - MapMarker[] addedMarkers = !this.tempToAdd.isEmpty() ? this.tempToAdd.toArray(MapMarker[]::new) : null; - String[] removedMarkers = !this.tempToRemove.isEmpty() ? this.tempToRemove.toArray(String[]::new) : null; - this.player.getPlayerConnection().writeNoCache(new UpdateWorldMap(null, addedMarkers, removedMarkers)); - } - } - } - - public void trySendMarker(int chunkViewRadius, int playerChunkX, int playerChunkZ, @Nonnull MapMarker marker) { - this.trySendMarker( - chunkViewRadius, - playerChunkX, - playerChunkZ, - marker.transform.position.x, - marker.transform.position.z, - marker.transform.orientation.yaw, - marker.id, - marker.name, - marker, - (id, name, m) -> m - ); - } - - public void trySendMarker( - int chunkViewRadius, - int playerChunkX, - int playerChunkZ, - @Nonnull Vector3d markerPos, - float markerYaw, - @Nonnull String markerId, - @Nonnull String markerDisplayName, - @Nonnull T param, - @Nonnull TriFunction markerSupplier - ) { - this.trySendMarker(chunkViewRadius, playerChunkX, playerChunkZ, markerPos.x, markerPos.z, markerYaw, markerId, markerDisplayName, param, markerSupplier); - } - - private void trySendMarker( - int chunkViewRadius, - int playerChunkX, - int playerChunkZ, - double markerX, - double markerZ, - float markerYaw, - @Nonnull String markerId, - @Nonnull String markerName, - @Nonnull T param, - @Nonnull TriFunction markerSupplier - ) { - int markerXBlock = MathUtil.floor(markerX); - int markerZBlock = MathUtil.floor(markerZ); - boolean shouldBeVisible = chunkViewRadius == -1 || shouldBeVisible(chunkViewRadius, markerXBlock >> 5, markerZBlock >> 5, playerChunkX, playerChunkZ); - if (shouldBeVisible) { - this.tempTestedMarkers.add(markerId); - boolean needsUpdate = false; - MapMarker oldMarker = this.sentMarkers.get(markerId); - if (oldMarker != null) { - if (!markerName.equals(oldMarker.name)) { - needsUpdate = true; - } - - if (!needsUpdate) { - double distance = Math.abs(oldMarker.transform.orientation.yaw - markerYaw); - needsUpdate = distance > 0.05 || this.playerMarkersUpdateTimer < 0.0F && distance > 0.001; - } - - if (!needsUpdate) { - Position oldPosition = oldMarker.transform.position; - double distance = Vector2d.distance(oldPosition.x, oldPosition.z, markerX, markerZ); - needsUpdate = distance > 5.0 || this.playerMarkersUpdateTimer < 0.0F && distance > 0.1; - } - } else { - needsUpdate = true; - } - - if (needsUpdate) { - MapMarker marker = markerSupplier.apply(markerId, markerName, param); - this.sentMarkers.put(markerId, marker); - this.tempToAdd.add(marker); - } - } - } - private void unloadImages(int chunkViewRadius, int playerChunkX, int playerChunkZ) { List currentUnloadList = null; List> allUnloadLists = null; @@ -546,7 +426,7 @@ public class WorldMapTracker implements Tickable { @Nonnull public Map getSentMarkers() { - return this.sentMarkers; + return this.markerTracker.getSentMarkers(); } @Nonnull @@ -554,13 +434,18 @@ public class WorldMapTracker implements Tickable { return this.player; } + @Nullable + public TransformComponent getTransformComponent() { + return this.transformComponent; + } + public void clear() { this.loadedLock.writeLock().lock(); try { this.loaded.clear(); this.sentViewRadius = 0; - this.sentMarkers.clear(); + this.markerTracker.getSentMarkers().clear(); } finally { this.loadedLock.writeLock().unlock(); } @@ -598,8 +483,8 @@ public class WorldMapTracker implements Tickable { assert playerRefComponent != null; - worldMapSettingsPacket.allowTeleportToCoordinates = this.allowTeleportToCoordinates && playerComponent.getGameMode() != GameMode.Adventure; - worldMapSettingsPacket.allowTeleportToMarkers = this.allowTeleportToMarkers && playerComponent.getGameMode() != GameMode.Adventure; + worldMapSettingsPacket.allowTeleportToCoordinates = this.isAllowTeleportToCoordinates(); + worldMapSettingsPacket.allowTeleportToMarkers = this.isAllowTeleportToMarkers(); playerRefComponent.getPacketHandler().write(worldMapSettingsPacket); } }); @@ -662,43 +547,21 @@ public class WorldMapTracker implements Tickable { } public boolean isAllowTeleportToCoordinates() { - return this.allowTeleportToCoordinates; - } - - public void setAllowTeleportToCoordinates(@Nonnull World world, boolean allowTeleportToCoordinates) { - this.allowTeleportToCoordinates = allowTeleportToCoordinates; - this.sendSettings(world); + return this.player.hasPermission("hytale.world_map.teleport.coordinate"); } public boolean isAllowTeleportToMarkers() { - return this.allowTeleportToMarkers; - } - - public void setAllowTeleportToMarkers(@Nonnull World world, boolean allowTeleportToMarkers) { - this.allowTeleportToMarkers = allowTeleportToMarkers; - this.sendSettings(world); - } - - public Predicate getPlayerMapFilter() { - return this.playerMapFilter; + return this.player.hasPermission("hytale.world_map.teleport.marker"); } public void setPlayerMapFilter(Predicate playerMapFilter) { - this.playerMapFilter = playerMapFilter; + this.markerTracker.setPlayerMapFilter(playerMapFilter); } public void setClientHasWorldMapVisible(boolean visible) { this.clientHasWorldMapVisible = visible; } - public boolean shouldUpdatePlayerMarkers() { - return this.clientHasWorldMapVisible || this.playerMarkersUpdateTimer < 0.0F; - } - - public void resetPlayerMarkersUpdateTimer() { - this.playerMarkersUpdateTimer = 10.0F; - } - @Nullable public Integer getViewRadiusOverride() { return this.viewRadiusOverride; @@ -746,10 +609,7 @@ public class WorldMapTracker implements Tickable { try { this.loaded.addAll(worldMapTracker.loaded); - - for (Entry entry : worldMapTracker.sentMarkers.entrySet()) { - this.sentMarkers.put(entry.getKey(), new MapMarker(entry.getValue())); - } + this.markerTracker.copyFrom(worldMapTracker.markerTracker); } finally { worldMapTracker.loadedLock.readLock().unlock(); } @@ -758,7 +618,7 @@ public class WorldMapTracker implements Tickable { } } - private static boolean shouldBeVisible(int chunkViewRadius, int chunkX, int chunkZ, int x, int z) { + public static boolean shouldBeVisible(int chunkViewRadius, int chunkX, int chunkZ, int x, int z) { int xDiff = Math.abs(x - chunkX); int zDiff = Math.abs(z - chunkZ); int distanceSq = xDiff * xDiff + zDiff * zDiff; diff --git a/src/com/hypixel/hytale/server/core/universe/world/accessor/BlockAccessor.java b/src/com/hypixel/hytale/server/core/universe/world/accessor/BlockAccessor.java index 23cfe35..87ed168 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/accessor/BlockAccessor.java +++ b/src/com/hypixel/hytale/server/core/universe/world/accessor/BlockAccessor.java @@ -204,13 +204,15 @@ public interface BlockAccessor { } default void setBlockInteractionState(int x, int y, int z, @Nonnull BlockType blockType, @Nonnull String state, boolean force) { - String currentState = getCurrentInteractionState(blockType); - if (force || currentState == null || !currentState.equals(state)) { - BlockType newState = blockType.getBlockForState(state); - if (newState != null) { - int settings = 198; - int currentRotation = this.getRotationIndex(x, y, z); - this.setBlock(x, y, z, BlockType.getAssetMap().getIndex(newState.getId()), newState, currentRotation, 0, 198); + if (blockType.getData() != null) { + String currentState = getCurrentInteractionState(blockType); + if (force || currentState == null || !currentState.equals(state)) { + BlockType newState = blockType.getBlockForState(state); + if (newState != null) { + int settings = 198; + int currentRotation = this.getRotationIndex(x, y, z); + this.setBlock(x, y, z, BlockType.getAssetMap().getIndex(newState.getId()), newState, currentRotation, 0, 198); + } } } } diff --git a/src/com/hypixel/hytale/server/core/universe/world/accessor/EmptyBlockAccessor.java b/src/com/hypixel/hytale/server/core/universe/world/accessor/EmptyBlockAccessor.java index 20240fa..8c086ff 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/accessor/EmptyBlockAccessor.java +++ b/src/com/hypixel/hytale/server/core/universe/world/accessor/EmptyBlockAccessor.java @@ -10,9 +10,6 @@ import javax.annotation.Nullable; public class EmptyBlockAccessor implements BlockAccessor { public static final EmptyBlockAccessor INSTANCE = new EmptyBlockAccessor(); - public EmptyBlockAccessor() { - } - @Override public int getX() { throw new UnsupportedOperationException("Empty block accessor doesn't have a position!"); diff --git a/src/com/hypixel/hytale/server/core/universe/world/accessor/IChunkAccessorSync.java b/src/com/hypixel/hytale/server/core/universe/world/accessor/IChunkAccessorSync.java index 7526707..67df38d 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/accessor/IChunkAccessorSync.java +++ b/src/com/hypixel/hytale/server/core/universe/world/accessor/IChunkAccessorSync.java @@ -116,6 +116,10 @@ public interface IChunkAccessorSync { : position; } + default int getBlockRotationIndex(int x, int y, int z) { + return this.getChunk(ChunkUtil.indexChunkFromBlock(x, z)).getRotationIndex(x, y, z); + } + @FunctionalInterface public interface TestBlockFunction { boolean test(int var1, int var2, int var3, BlockType var4, int var5, int var6); diff --git a/src/com/hypixel/hytale/server/core/universe/world/chunk/BlockComponentChunk.java b/src/com/hypixel/hytale/server/core/universe/world/chunk/BlockComponentChunk.java index 24a6992..d9f547d 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/chunk/BlockComponentChunk.java +++ b/src/com/hypixel/hytale/server/core/universe/world/chunk/BlockComponentChunk.java @@ -114,15 +114,22 @@ public class BlockComponentChunk implements Component { @Nonnull @Override public Component cloneSerializable() { + ComponentRegistry.Data data = ChunkStore.REGISTRY.getData(); Int2ObjectOpenHashMap> entityHoldersClone = new Int2ObjectOpenHashMap<>(this.entityHolders.size() + this.entityReferences.size()); for (Entry> entry : this.entityHolders.int2ObjectEntrySet()) { - entityHoldersClone.put(entry.getIntKey(), entry.getValue().clone()); + Holder holder = entry.getValue(); + if (holder.getArchetype().hasSerializableComponents(data)) { + entityHoldersClone.put(entry.getIntKey(), holder.cloneSerializable(data)); + } } - for (Entry> entry : this.entityReferences.int2ObjectEntrySet()) { - Ref reference = entry.getValue(); - entityHoldersClone.put(entry.getIntKey(), reference.getStore().copySerializableEntity(reference)); + for (Entry> entryx : this.entityReferences.int2ObjectEntrySet()) { + Ref reference = entryx.getValue(); + Store store = reference.getStore(); + if (store.getArchetype(reference).hasSerializableComponents(data)) { + entityHoldersClone.put(entryx.getIntKey(), store.copySerializableEntity(reference)); + } } return new BlockComponentChunk(entityHoldersClone, new Int2ObjectOpenHashMap<>()); @@ -259,9 +266,6 @@ public class BlockComponentChunk implements Component { private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); private final Archetype archetype = Archetype.of(WorldChunk.getComponentType(), BlockComponentChunk.getComponentType()); - public BlockComponentChunkLoadingSystem() { - } - @Override public Query getQuery() { return this.archetype; @@ -343,6 +347,7 @@ public class BlockComponentChunk implements Component { LOGGER.at(Level.SEVERE).log("Empty archetype entity holder: %s (#%d)", holder, i); holders[i] = holders[--holderCount]; holders[holderCount] = holder; + chunk.markNeedsSaving(); } else { int index = indexes[i]; int x = ChunkUtil.xFromBlockInColumn(index); diff --git a/src/com/hypixel/hytale/server/core/universe/world/chunk/BlockRotationUtil.java b/src/com/hypixel/hytale/server/core/universe/world/chunk/BlockRotationUtil.java index c6790d4..4d8e844 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/chunk/BlockRotationUtil.java +++ b/src/com/hypixel/hytale/server/core/universe/world/chunk/BlockRotationUtil.java @@ -9,9 +9,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class BlockRotationUtil { - public BlockRotationUtil() { - } - @Nullable public static RotationTuple getFlipped( @Nonnull RotationTuple blockRotation, @Nullable BlockFlipType flipType, @Nonnull Axis axis, @Nonnull VariantRotation variantRotation diff --git a/src/com/hypixel/hytale/server/core/universe/world/chunk/ChunkFlag.java b/src/com/hypixel/hytale/server/core/universe/world/chunk/ChunkFlag.java index 91886c2..76f4309 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/chunk/ChunkFlag.java +++ b/src/com/hypixel/hytale/server/core/universe/world/chunk/ChunkFlag.java @@ -12,9 +12,6 @@ public enum ChunkFlag implements Flag { public static final ChunkFlag[] VALUES = values(); private final int mask = 1 << this.ordinal(); - private ChunkFlag() { - } - @Override public int mask() { return this.mask; diff --git a/src/com/hypixel/hytale/server/core/universe/world/chunk/EntityChunk.java b/src/com/hypixel/hytale/server/core/universe/world/chunk/EntityChunk.java index 1dbbd1b..f24e5c0 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/chunk/EntityChunk.java +++ b/src/com/hypixel/hytale/server/core/universe/world/chunk/EntityChunk.java @@ -18,8 +18,6 @@ import com.hypixel.hytale.component.Store; import com.hypixel.hytale.component.query.Query; import com.hypixel.hytale.component.system.RefChangeSystem; import com.hypixel.hytale.logger.HytaleLogger; -import com.hypixel.hytale.server.core.entity.Entity; -import com.hypixel.hytale.server.core.entity.EntityUtils; import com.hypixel.hytale.server.core.entity.nameplate.Nameplate; import com.hypixel.hytale.server.core.modules.LegacyModule; import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent; @@ -30,7 +28,6 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Objects; import java.util.Set; @@ -111,14 +108,20 @@ public class EntityChunk implements Component { @Nonnull @Override public Component cloneSerializable() { + ComponentRegistry.Data data = EntityStore.REGISTRY.getData(); ObjectArrayList> entityHoldersClone = new ObjectArrayList<>(this.entityHolders.size() + this.entityReferences.size()); for (Holder entityHolder : this.entityHolders) { - entityHoldersClone.add(entityHolder.clone()); + if (entityHolder.getArchetype().hasSerializableComponents(data)) { + entityHoldersClone.add(entityHolder.cloneSerializable(data)); + } } for (Ref reference : this.entityReferences) { - entityHoldersClone.add(reference.getStore().copySerializableEntity(reference)); + Store store = reference.getStore(); + if (store.getArchetype(reference).hasSerializableComponents(data)) { + entityHoldersClone.add(store.copySerializableEntity(reference)); + } } return new EntityChunk(entityHoldersClone, new HashSet<>()); @@ -197,52 +200,12 @@ public class EntityChunk implements Component { return out; } - @Nonnull - @Deprecated(forRemoval = true) - public Iterable getEntities() { - if (this.entityReferences.isEmpty()) { - return Collections.emptyList(); - } else { - Ref[] references = this.entityReferences.toArray(Ref[]::new); - return () -> new Iterator() { - int index = references.length; - - @Override - public boolean hasNext() { - if (this.index <= 0) { - return false; - } else { - for (Ref reference = references[this.index - 1]; - !reference.isValid() || EntityUtils.getEntity(reference, reference.getStore()) == null; - reference = references[this.index - 1] - ) { - this.index--; - if (this.index <= 0) { - return false; - } - } - - return true; - } - } - - public Entity next() { - Ref reference = references[--this.index]; - return EntityUtils.getEntity(reference, reference.getStore()); - } - }; - } - } - public static class EntityChunkLoadingSystem extends RefChangeSystem> { @Nonnull private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); @Nonnull private final Archetype archetype = Archetype.of(WorldChunk.getComponentType(), EntityChunk.getComponentType()); - public EntityChunkLoadingSystem() { - } - @Override public Query getQuery() { return this.archetype; @@ -319,6 +282,7 @@ public class EntityChunk implements Component { LOGGER.at(Level.SEVERE).log("Empty archetype entity holder: %s (#%d)", holder, i); holders[i] = holders[--holderCount]; holders[holderCount] = holder; + worldChunkComponent.markNeedsSaving(); } else if (archetype.count() == 1 && archetype.contains(Nameplate.getComponentType())) { LOGGER.at(Level.SEVERE).log("Nameplate only entity holder: %s (#%d)", holder, i); holders[i] = holders[--holderCount]; diff --git a/src/com/hypixel/hytale/server/core/universe/world/chunk/WorldChunk.java b/src/com/hypixel/hytale/server/core/universe/world/chunk/WorldChunk.java index 3680b89..42cbcac 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/chunk/WorldChunk.java +++ b/src/com/hypixel/hytale/server/core/universe/world/chunk/WorldChunk.java @@ -38,6 +38,7 @@ import com.hypixel.hytale.server.core.universe.world.meta.state.ItemContainerSta import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore; import com.hypixel.hytale.server.core.util.FillerBlockUtil; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.locks.StampedLock; import java.util.logging.Level; @@ -62,7 +63,7 @@ public class WorldChunk implements BlockAccessor, Component { private int activeTimer = 15; private boolean needsSaving; private boolean isSaving; - private boolean keepLoaded; + private final AtomicInteger keepLoaded = new AtomicInteger(); private boolean lightingUpdatesEnabled = true; @Deprecated public final AtomicLong chunkLightTiming = new AtomicLong(); @@ -284,11 +285,15 @@ public class WorldChunk implements BlockAccessor, Component { } public boolean shouldKeepLoaded() { - return this.keepLoaded; + return this.keepLoaded.get() > 0; } - public void setKeepLoaded(boolean keepLoaded) { - this.keepLoaded = keepLoaded; + public void addKeepLoaded() { + this.keepLoaded.incrementAndGet(); + } + + public void removeKeepLoaded() { + this.keepLoaded.decrementAndGet(); } public int pollKeepAlive(int pollCount) { @@ -323,6 +328,7 @@ public class WorldChunk implements BlockAccessor, Component { short oldHeight = this.blockChunk.getHeight(x, z); BlockSection blockSection = this.blockChunk.getSectionAtBlockY(y); int oldRotation = blockSection.getRotationIndex(x, y, z); + int oldFiller = blockSection.getFiller(x, y, z); int oldBlock = blockSection.get(x, y, z); boolean changed = (oldBlock != id || rotation != oldRotation) && blockSection.set(x, y, z, id, rotation, filler); if (changed || (settings & 64) != 0) { @@ -400,11 +406,14 @@ public class WorldChunk implements BlockAccessor, Component { int settingsWithoutFiller = settings | 8 | 16; BlockType oldBlockType = blockTypeAssetMap.getAsset(oldBlock); String oldBlockKey = oldBlockType.getId(); + int baseX = worldX - FillerBlockUtil.unpackX(oldFiller); + int baseY = y - FillerBlockUtil.unpackY(oldFiller); + int baseZ = worldZ - FillerBlockUtil.unpackZ(oldFiller); FillerBlockUtil.forEachFillerBlock(hitboxAssetMap.getAsset(oldBlockType.getHitboxTypeIndex()).get(oldRotation), (x1, y1, z1) -> { if (x1 != 0 || y1 != 0 || z1 != 0) { - int blockX = worldX + x1; - int blockY = y + y1; - int blockZ = worldZ + z1; + int blockX = baseX + x1; + int blockY = baseY + y1; + int blockZ = baseZ + z1; if (ChunkUtil.isSameChunk(worldX, worldZ, blockX, blockZ)) { String blockTypeKey1 = this.getBlockType(blockX, blockY, blockZ).getId(); if (blockTypeKey1.equals(oldBlockKey)) { @@ -552,7 +561,12 @@ public class WorldChunk implements BlockAccessor, Component { } else { int index = ChunkUtil.indexBlockInColumn(x, y, z); Ref reference = this.blockComponentChunk.getEntityReference(index); - return reference == null ? null : reference.getStore().copyEntity(reference); + if (reference != null) { + return reference.getStore().copyEntity(reference); + } else { + Holder holder = this.blockComponentChunk.getEntityHolder(index); + return holder != null ? holder.clone() : null; + } } } diff --git a/src/com/hypixel/hytale/server/core/universe/world/chunk/section/BlockSection.java b/src/com/hypixel/hytale/server/core/universe/world/chunk/section/BlockSection.java index 2fc3b2b..7e3b5e2 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/chunk/section/BlockSection.java +++ b/src/com/hypixel/hytale/server/core/universe/world/chunk/section/BlockSection.java @@ -642,11 +642,13 @@ public class BlockSection implements Component { if (blockId != 0) { int rotation = this.rotationSection.get(idx); BlockType blockType = blockTypeMap.getAsset(blockId); - BlockBoundingBoxes asset = hitBoxAssetMap.getAsset(blockType.getHitboxTypeIndex()); - if (asset != BlockBoundingBoxes.UNIT_BOX) { - double boxMaximumExtent = asset.get(rotation).getBoundingBox().getMaximumExtent(); - if (boxMaximumExtent > maximumExtent) { - maximumExtent = boxMaximumExtent; + if (blockType != null && !blockType.isUnknown()) { + BlockBoundingBoxes asset = hitBoxAssetMap.getAsset(blockType.getHitboxTypeIndex()); + if (asset != BlockBoundingBoxes.UNIT_BOX) { + double boxMaximumExtent = asset.get(rotation).getBoundingBox().getMaximumExtent(); + if (boxMaximumExtent > maximumExtent) { + maximumExtent = boxMaximumExtent; + } } } } diff --git a/src/com/hypixel/hytale/server/core/universe/world/chunk/section/FluidSection.java b/src/com/hypixel/hytale/server/core/universe/world/chunk/section/FluidSection.java index dd4b115..07e1174 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/chunk/section/FluidSection.java +++ b/src/com/hypixel/hytale/server/core/universe/world/chunk/section/FluidSection.java @@ -53,9 +53,6 @@ public class FluidSection implements Component { @Nullable private transient SoftReference>> cachedPacket = null; - public FluidSection() { - } - public static ComponentType getComponentType() { return LegacyModule.get().getFluidSectionComponentType(); } diff --git a/src/com/hypixel/hytale/server/core/universe/world/chunk/section/palette/ISectionPalette.java b/src/com/hypixel/hytale/server/core/universe/world/chunk/section/palette/ISectionPalette.java index fbac56e..4fac9bd 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/chunk/section/palette/ISectionPalette.java +++ b/src/com/hypixel/hytale/server/core/universe/world/chunk/section/palette/ISectionPalette.java @@ -73,8 +73,5 @@ public interface ISectionPalette { CHANGED, UNCHANGED, REQUIRES_PROMOTE; - - private SetResult() { - } } } diff --git a/src/com/hypixel/hytale/server/core/universe/world/chunk/systems/ChunkSystems.java b/src/com/hypixel/hytale/server/core/universe/world/chunk/systems/ChunkSystems.java index ed63063..93387e6 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/chunk/systems/ChunkSystems.java +++ b/src/com/hypixel/hytale/server/core/universe/world/chunk/systems/ChunkSystems.java @@ -51,15 +51,9 @@ public class ChunkSystems { private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); private static final int MAX_CHANGES_PER_PACKET = 1024; - public ChunkSystems() { - } - public static class EnsureBlockSection extends HolderSystem { private static final Query QUERY = Query.and(ChunkSection.getComponentType(), Query.not(BlockSection.getComponentType())); - public EnsureBlockSection() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { holder.ensureComponent(BlockSection.getComponentType()); @@ -83,9 +77,6 @@ public class ChunkSystems { } public static class LoadBlockSection extends HolderSystem { - public LoadBlockSection() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { BlockSection section = holder.getComponent(BlockSection.getComponentType()); @@ -109,9 +100,6 @@ public class ChunkSystems { private static final Query QUERY = Query.and(ChunkColumn.getComponentType(), WorldChunk.getComponentType()); private static final Set> DEPENDENCIES = Set.of(new SystemDependency<>(Order.AFTER, ChunkSystems.OnNewChunk.class)); - public OnChunkLoad() { - } - @Override public void onEntityAdded( @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer @@ -198,9 +186,6 @@ public class ChunkSystems { public static class OnNewChunk extends ChunkColumnMigrationSystem { private static final Query QUERY = Query.and(WorldChunk.getComponentType(), Query.not(ChunkColumn.getComponentType())); - public OnNewChunk() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { Holder[] sectionHolders = new Holder[10]; @@ -232,9 +217,6 @@ public class ChunkSystems { public static class OnNonTicking extends RefChangeSystem> { private final Archetype archetype = Archetype.of(WorldChunk.getComponentType(), ChunkColumn.getComponentType()); - public OnNonTicking() { - } - @Nonnull @Override public ComponentType> componentType() { @@ -295,9 +277,6 @@ public class ChunkSystems { public static class ReplicateChanges extends EntityTickingSystem implements RunWhenPausedSystem { private static final Query QUERY = Query.and(ChunkSection.getComponentType(), BlockSection.getComponentType()); - public ReplicateChanges() { - } - @Override public boolean isParallel(int archetypeChunkSize, int taskCount) { return EntityTickingSystem.maybeUseParallel(archetypeChunkSize, taskCount); diff --git a/src/com/hypixel/hytale/server/core/universe/world/commands/world/perf/WorldPerfResetCommand.java b/src/com/hypixel/hytale/server/core/universe/world/commands/world/perf/WorldPerfResetCommand.java index 5b3c8ca..4e8ec38 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/commands/world/perf/WorldPerfResetCommand.java +++ b/src/com/hypixel/hytale/server/core/universe/world/commands/world/perf/WorldPerfResetCommand.java @@ -9,7 +9,6 @@ import com.hypixel.hytale.server.core.universe.Universe; import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class WorldPerfResetCommand extends AbstractWorldCommand { @Nonnull @@ -21,7 +20,7 @@ public class WorldPerfResetCommand extends AbstractWorldCommand { } @Override - protected void execute(@NonNullDecl CommandContext context, @NonNullDecl World world, @NonNullDecl Store store) { + protected void execute(@Nonnull CommandContext context, @Nonnull World world, @Nonnull Store store) { if (this.allFlag.provided(context)) { Universe.get().getWorlds().forEach((name, w) -> w.clearMetrics()); context.sendMessage(MESSAGE_COMMANDS_WORLD_PERF_RESET_ALL); diff --git a/src/com/hypixel/hytale/server/core/universe/world/commands/world/tps/WorldTpsCommand.java b/src/com/hypixel/hytale/server/core/universe/world/commands/world/tps/WorldTpsCommand.java index 9d49d13..43b933f 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/commands/world/tps/WorldTpsCommand.java +++ b/src/com/hypixel/hytale/server/core/universe/world/commands/world/tps/WorldTpsCommand.java @@ -11,10 +11,6 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class WorldTpsCommand extends AbstractWorldCommand { - @Nonnull - private static final Message MESSAGE_COMMANDS_WORLD_TPS_SET_SUCCESS = Message.translation("server.commands.world.tps.set.success"); - @Nonnull - private static final Message MESSAGE_COMMANDS_WORLD_TPS_SET_INVALID = Message.translation("server.commands.world.tps.set.invalid"); @Nonnull private final RequiredArg tickRateArg = this.withRequiredArg("rate", "server.commands.world.tps.rate.desc", ArgTypes.TICK_RATE); @@ -31,10 +27,13 @@ public class WorldTpsCommand extends AbstractWorldCommand { world.setTps(newTickRate); double newMs = 1000.0 / newTickRate; context.sendMessage( - MESSAGE_COMMANDS_WORLD_TPS_SET_SUCCESS.param("worldName", world.getName()).param("tps", newTickRate).param("ms", String.format("%.2f", newMs)) + Message.translation("server.commands.world.tps.set.success") + .param("worldName", world.getName()) + .param("tps", newTickRate) + .param("ms", String.format("%.2f", newMs)) ); } else { - context.sendMessage(MESSAGE_COMMANDS_WORLD_TPS_SET_INVALID.param("value", newTickRate)); + context.sendMessage(Message.translation("server.commands.world.tps.set.invalid").param("value", newTickRate)); } } } diff --git a/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlockFaceTags.java b/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlockFaceTags.java index 5d6cec0..e46fa01 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlockFaceTags.java +++ b/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlockFaceTags.java @@ -56,9 +56,6 @@ public class ConnectedBlockFaceTags { @Nonnull private final Map> blockFaceTags = new Object2ObjectOpenHashMap<>(); - public ConnectedBlockFaceTags() { - } - public boolean contains(Vector3i direction, String blockFaceTag) { return this.blockFaceTags.containsKey(direction) && this.blockFaceTags.get(direction).contains(blockFaceTag); } diff --git a/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlockPatternRule.java b/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlockPatternRule.java index 44edc96..be3e02b 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlockPatternRule.java +++ b/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlockPatternRule.java @@ -85,9 +85,6 @@ public class ConnectedBlockPatternRule { private ConnectedBlockFaceTags faceTags = ConnectedBlockFaceTags.EMPTY; private ConnectedBlockPatternRule.AdjacentSide[] placementNormals; - public ConnectedBlockPatternRule() { - } - public Vector3i getRelativePosition() { return this.relativePosition; } @@ -137,8 +134,5 @@ public class ConnectedBlockPatternRule { public static enum IncludeOrExclude { INCLUDE, EXCLUDE; - - private IncludeOrExclude() { - } } } diff --git a/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlockRuleSet.java b/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlockRuleSet.java index 6b99b66..61639fa 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlockRuleSet.java +++ b/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlockRuleSet.java @@ -11,9 +11,6 @@ import javax.annotation.Nullable; public abstract class ConnectedBlockRuleSet { public static final CodecMapCodec CODEC = new CodecMapCodec<>("Type"); - public ConnectedBlockRuleSet() { - } - public abstract boolean onlyUpdateOnPlacement(); public abstract Optional getConnectedBlockType( diff --git a/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlockShape.java b/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlockShape.java index 508a2ca..76fbc52 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlockShape.java +++ b/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlockShape.java @@ -18,9 +18,6 @@ public class ConnectedBlockShape { private CustomTemplateConnectedBlockPattern[] patternsToMatchAnyOf; private ConnectedBlockFaceTags faceTags; - public ConnectedBlockShape() { - } - public CustomTemplateConnectedBlockPattern[] getPatternsToMatchAnyOf() { return this.patternsToMatchAnyOf; } diff --git a/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlocksUtil.java b/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlocksUtil.java index 394665e..fdefa16 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlocksUtil.java +++ b/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlocksUtil.java @@ -25,9 +25,6 @@ import javax.annotation.Nonnull; public class ConnectedBlocksUtil { private static final int MAX_UPDATE_DEPTH = 3; - public ConnectedBlocksUtil() { - } - public static void setConnectedBlockAndNotifyNeighbors( int blockTypeId, @Nonnull RotationTuple blockTypeRotation, diff --git a/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomConnectedBlockPattern.java b/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomConnectedBlockPattern.java index bfbae2f..8595af1 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomConnectedBlockPattern.java +++ b/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomConnectedBlockPattern.java @@ -89,9 +89,6 @@ public class CustomConnectedBlockPattern extends CustomTemplateConnectedBlockPat private boolean onlyOnUpdate; private boolean onlyOnPlacement; - public CustomConnectedBlockPattern() { - } - private static boolean checkPatternRuleAgainstBlockType( @Nonnull CustomTemplateConnectedBlockRuleSet placedRuleset, @Nonnull CustomConnectedBlockTemplateAsset template, diff --git a/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomConnectedBlockTemplateAsset.java b/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomConnectedBlockTemplateAsset.java index eeb3508..83a14b8 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomConnectedBlockTemplateAsset.java +++ b/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomConnectedBlockTemplateAsset.java @@ -68,9 +68,6 @@ public class CustomConnectedBlockTemplateAsset implements JsonAssetWithMap connectedBlockShapes; - public CustomConnectedBlockTemplateAsset() { - } - public static AssetStore> getAssetStore() { if (ASSET_STORE == null) { ASSET_STORE = AssetRegistry.getAssetStore(CustomConnectedBlockTemplateAsset.class); diff --git a/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomTemplateConnectedBlockPattern.java b/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomTemplateConnectedBlockPattern.java index 16567f8..011123a 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomTemplateConnectedBlockPattern.java +++ b/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomTemplateConnectedBlockPattern.java @@ -10,9 +10,6 @@ import javax.annotation.Nonnull; public abstract class CustomTemplateConnectedBlockPattern { public static final CodecMapCodec CODEC = new CodecMapCodec<>("Type"); - public CustomTemplateConnectedBlockPattern() { - } - public abstract Optional getConnectedBlockTypeKey( String var1, @Nonnull World var2, diff --git a/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomTemplateConnectedBlockRuleSet.java b/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomTemplateConnectedBlockRuleSet.java index d8bdf39..bc62602 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomTemplateConnectedBlockRuleSet.java +++ b/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomTemplateConnectedBlockRuleSet.java @@ -44,9 +44,6 @@ public class CustomTemplateConnectedBlockRuleSet extends ConnectedBlockRuleSet { private Map shapeNameToBlockPatternMap = new Object2ObjectOpenHashMap<>(); private final Int2ObjectMap> shapesPerBlockType = new Int2ObjectOpenHashMap<>(); - public CustomTemplateConnectedBlockRuleSet() { - } - public Map getShapeNameToBlockPatternMap() { return this.shapeNameToBlockPatternMap; } diff --git a/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/PatternRotationDefinition.java b/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/PatternRotationDefinition.java index 5cb3bc0..46fa1ac 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/PatternRotationDefinition.java +++ b/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/PatternRotationDefinition.java @@ -32,9 +32,6 @@ public class PatternRotationDefinition { private boolean isMirrorX; public static final List> ROTATIONS = new ArrayList<>(); - public PatternRotationDefinition() { - } - @Nonnull public List> getRotations() { return new AbstractList>() { @@ -87,8 +84,5 @@ public class PatternRotationDefinition { NONE, X, Z; - - private MirrorAxis() { - } } } diff --git a/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/builtin/RoofConnectedBlockRuleSet.java b/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/builtin/RoofConnectedBlockRuleSet.java index b1004dc..015a398 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/builtin/RoofConnectedBlockRuleSet.java +++ b/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/builtin/RoofConnectedBlockRuleSet.java @@ -44,9 +44,6 @@ public class RoofConnectedBlockRuleSet extends ConnectedBlockRuleSet implements private String materialName; private int width = 1; - public RoofConnectedBlockRuleSet() { - } - private static StairConnectedBlockRuleSet.StairType getConnectedBlockStairType( World world, Vector3i coordinate, StairLikeConnectedBlockRuleSet currentRuleSet, int blockId, int rotation, int width ) { @@ -64,7 +61,7 @@ public class RoofConnectedBlockRuleSet extends ConnectedBlockRuleSet implements world, currentRuleSet, coordinate, mutablePos, currentYaw, upsideDown ); if (frontConnection != null) { - boolean valid = isWidthFulfilled(world, coordinate, mutablePos, frontConnection, currentYaw, blockId, width); + boolean valid = isWidthFulfilled(world, coordinate, mutablePos, frontConnection, currentYaw, blockId, rotation, width); if (valid) { resultingStair = frontConnection.getStairType(true); } @@ -74,7 +71,7 @@ public class RoofConnectedBlockRuleSet extends ConnectedBlockRuleSet implements world, currentRuleSet, coordinate, mutablePos, rotation, currentYaw, upsideDown, width ); if (backConnection != null) { - boolean valid = isWidthFulfilled(world, coordinate, mutablePos, backConnection, currentYaw, blockId, width); + boolean valid = isWidthFulfilled(world, coordinate, mutablePos, backConnection, currentYaw, blockId, rotation, width); if (valid) { resultingStair = backConnection.getStairType(false); } @@ -83,7 +80,7 @@ public class RoofConnectedBlockRuleSet extends ConnectedBlockRuleSet implements if (resultingStair == StairConnectedBlockRuleSet.StairType.STRAIGHT) { Vector3i aboveCoordinate = new Vector3i(coordinate).add(0, 1, 0); StairConnectedBlockRuleSet.StairConnection resultingConnection = getValleyConnection( - world, aboveCoordinate, currentRuleSet, currentRotation, mutablePos, false, width + world, coordinate, aboveCoordinate, currentRuleSet, currentRotation, mutablePos, false, blockId, rotation, width ); if (resultingConnection != null) { resultingStair = resultingConnection.getStairType(true); @@ -93,7 +90,7 @@ public class RoofConnectedBlockRuleSet extends ConnectedBlockRuleSet implements if (resultingStair == StairConnectedBlockRuleSet.StairType.STRAIGHT) { Vector3i belowCoordinate = new Vector3i(coordinate).add(0, -1, 0); StairConnectedBlockRuleSet.StairConnection resultingConnection = getValleyConnection( - world, belowCoordinate, currentRuleSet, currentRotation, mutablePos, true, width + world, coordinate, belowCoordinate, currentRuleSet, currentRotation, mutablePos, true, blockId, rotation, width ); if (resultingConnection != null) { resultingStair = resultingConnection.getStairType(false); @@ -120,6 +117,7 @@ public class RoofConnectedBlockRuleSet extends ConnectedBlockRuleSet implements StairConnectedBlockRuleSet.StairConnection backConnection, Rotation currentYaw, int blockId, + int rotation, int width ) { boolean valid = true; @@ -131,9 +129,11 @@ public class RoofConnectedBlockRuleSet extends ConnectedBlockRuleSet implements mutablePos.add(coordinate.x, coordinate.y, coordinate.z); WorldChunk chunk = world.getChunkIfLoaded(ChunkUtil.indexChunkFromBlock(mutablePos.x, mutablePos.z)); if (chunk != null) { + int otherRotation = chunk.getRotationIndex(mutablePos.x, mutablePos.y, mutablePos.z); int otherFiller = chunk.getFiller(mutablePos.x, mutablePos.y, mutablePos.z); int otherBlockId = chunk.getBlock(mutablePos); - if ((otherFiller != 0 || otherBlockId != blockId) && (otherFiller != requiredFiller || otherBlockId != blockId)) { + if ((otherFiller != 0 || otherBlockId != blockId || otherRotation != rotation) + && (otherFiller != requiredFiller || otherBlockId != blockId || otherRotation != rotation)) { valid = false; break; } @@ -144,12 +144,21 @@ public class RoofConnectedBlockRuleSet extends ConnectedBlockRuleSet implements } private static StairConnectedBlockRuleSet.StairConnection getValleyConnection( - World world, Vector3i coordinate, StairLikeConnectedBlockRuleSet currentRuleSet, RotationTuple rotation, Vector3i mutablePos, boolean reverse, int width + World world, + Vector3i placementCoordinate, + Vector3i checkCoordinate, + StairLikeConnectedBlockRuleSet currentRuleSet, + RotationTuple rotation, + Vector3i mutablePos, + boolean reverse, + int blockId, + int blockRotation, + int width ) { Rotation yaw = rotation.yaw(); mutablePos.assign(reverse ? Vector3i.SOUTH : Vector3i.NORTH).scale(width); yaw.rotateY(mutablePos, mutablePos); - mutablePos.add(coordinate.x, coordinate.y, coordinate.z); + mutablePos.add(checkCoordinate.x, checkCoordinate.y, checkCoordinate.z); ObjectIntPair backStair = StairConnectedBlockRuleSet.getStairData( world, mutablePos, currentRuleSet.getMaterialName() ); @@ -164,13 +173,13 @@ public class RoofConnectedBlockRuleSet extends ConnectedBlockRuleSet implements } else { mutablePos.assign(reverse ? Vector3i.EAST : Vector3i.WEST).scale(width); yaw.rotateY(mutablePos, mutablePos); - mutablePos.add(coordinate.x, coordinate.y, coordinate.z); + mutablePos.add(checkCoordinate.x, checkCoordinate.y, checkCoordinate.z); ObjectIntPair leftStair = StairConnectedBlockRuleSet.getStairData( world, mutablePos, currentRuleSet.getMaterialName() ); mutablePos.assign(reverse ? Vector3i.WEST : Vector3i.EAST).scale(width); yaw.rotateY(mutablePos, mutablePos); - mutablePos.add(coordinate.x, coordinate.y, coordinate.z); + mutablePos.add(checkCoordinate.x, checkCoordinate.y, checkCoordinate.z); ObjectIntPair rightStair = StairConnectedBlockRuleSet.getStairData( world, mutablePos, currentRuleSet.getMaterialName() ); @@ -183,7 +192,10 @@ public class RoofConnectedBlockRuleSet extends ConnectedBlockRuleSet implements if (leftConnection == rightConnection) { return null; } else { - return leftConnection ? StairConnectedBlockRuleSet.StairConnection.CORNER_LEFT : StairConnectedBlockRuleSet.StairConnection.CORNER_RIGHT; + StairConnectedBlockRuleSet.StairConnection connection = leftConnection + ? StairConnectedBlockRuleSet.StairConnection.CORNER_LEFT + : StairConnectedBlockRuleSet.StairConnection.CORNER_RIGHT; + return !isWidthFulfilled(world, placementCoordinate, mutablePos, connection, yaw, blockId, blockRotation, width) ? null : connection; } } } diff --git a/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/builtin/StairConnectedBlockRuleSet.java b/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/builtin/StairConnectedBlockRuleSet.java index 50bc578..2415dbe 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/builtin/StairConnectedBlockRuleSet.java +++ b/src/com/hypixel/hytale/server/core/universe/world/connectedblocks/builtin/StairConnectedBlockRuleSet.java @@ -64,9 +64,6 @@ public class StairConnectedBlockRuleSet extends ConnectedBlockRuleSet implements private Int2ObjectMap blockIdToStairType; protected Object2IntMap stairTypeToBlockId; - public StairConnectedBlockRuleSet() { - } - @Override public boolean onlyUpdateOnPlacement() { return false; @@ -318,9 +315,6 @@ public class StairConnectedBlockRuleSet extends ConnectedBlockRuleSet implements CORNER_LEFT, CORNER_RIGHT; - private StairConnection() { - } - public StairConnectedBlockRuleSet.StairType getStairType(boolean inverted) { return switch (this) { case CORNER_LEFT -> inverted ? StairConnectedBlockRuleSet.StairType.INVERTED_CORNER_LEFT : StairConnectedBlockRuleSet.StairType.CORNER_LEFT; @@ -338,9 +332,6 @@ public class StairConnectedBlockRuleSet extends ConnectedBlockRuleSet implements private static final StairConnectedBlockRuleSet.StairType[] VALUES = values(); - private StairType() { - } - public static StairConnectedBlockRuleSet.StairType corner(boolean right) { return right ? CORNER_RIGHT : CORNER_LEFT; } diff --git a/src/com/hypixel/hytale/server/core/universe/world/events/AllWorldsLoadedEvent.java b/src/com/hypixel/hytale/server/core/universe/world/events/AllWorldsLoadedEvent.java index 72e972d..fa7475a 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/events/AllWorldsLoadedEvent.java +++ b/src/com/hypixel/hytale/server/core/universe/world/events/AllWorldsLoadedEvent.java @@ -4,9 +4,6 @@ import com.hypixel.hytale.event.IEvent; import javax.annotation.Nonnull; public class AllWorldsLoadedEvent implements IEvent { - public AllWorldsLoadedEvent() { - } - @Nonnull @Override public String toString() { diff --git a/src/com/hypixel/hytale/server/core/universe/world/events/RemoveWorldEvent.java b/src/com/hypixel/hytale/server/core/universe/world/events/RemoveWorldEvent.java index 555fce2..eaa346e 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/events/RemoveWorldEvent.java +++ b/src/com/hypixel/hytale/server/core/universe/world/events/RemoveWorldEvent.java @@ -38,8 +38,5 @@ public class RemoveWorldEvent extends WorldEvent implements ICancellable { public static enum RemovalReason { GENERAL, EXCEPTIONAL; - - private RemovalReason() { - } } } diff --git a/src/com/hypixel/hytale/server/core/universe/world/lighting/CalculationResult.java b/src/com/hypixel/hytale/server/core/universe/world/lighting/CalculationResult.java index 686ce5f..b2c70f8 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/lighting/CalculationResult.java +++ b/src/com/hypixel/hytale/server/core/universe/world/lighting/CalculationResult.java @@ -5,7 +5,4 @@ public enum CalculationResult { DONE, INVALIDATED, WAITING_FOR_NEIGHBOUR; - - private CalculationResult() { - } } diff --git a/src/com/hypixel/hytale/server/core/universe/world/meta/BlockState.java b/src/com/hypixel/hytale/server/core/universe/world/meta/BlockState.java index d59959f..096581e 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/meta/BlockState.java +++ b/src/com/hypixel/hytale/server/core/universe/world/meta/BlockState.java @@ -38,7 +38,7 @@ public abstract class BlockState implements Component { .addField( new KeyedCodec<>("Position", Vector3i.CODEC), (entity, o) -> entity.position = o, - entity -> Vector3i.ZERO.equals(entity.position) ? null : entity.position + entity -> entity.position != null && !Vector3i.ZERO.equals(entity.position) ? entity.position : null ) .build(); public static final KeyedCodec TYPE_STRUCTURE = new KeyedCodec<>("Type", Codec.STRING); @@ -50,9 +50,6 @@ public abstract class BlockState implements Component { private Vector3i position; protected Ref reference; - public BlockState() { - } - public void setReference(Ref reference) { if (this.reference != null && this.reference.isValid()) { throw new IllegalArgumentException("Entity already has a valid EntityReference: " + this.reference + " new reference " + reference); @@ -120,6 +117,10 @@ public abstract class BlockState implements Component { return this.position; } + public void clearPositionForSerialization() { + this.position = null; + } + public int getBlockX() { return this.chunk.getX() << 5 | this.position.getX(); } diff --git a/src/com/hypixel/hytale/server/core/universe/world/meta/BlockStateModule.java b/src/com/hypixel/hytale/server/core/universe/world/meta/BlockStateModule.java index 54a52a3..eaa50c6 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/meta/BlockStateModule.java +++ b/src/com/hypixel/hytale/server/core/universe/world/meta/BlockStateModule.java @@ -184,9 +184,6 @@ public class BlockStateModule extends JavaPlugin { public static class ItemContainerStateRefSystem extends RefSystem { private static final Query query = BlockStateModule.get().getComponentType(ItemContainerState.class); - public ItemContainerStateRefSystem() { - } - @Override public Query getQuery() { return query; @@ -244,8 +241,8 @@ public class BlockStateModule extends JavaPlugin { T blockState = holder.getComponent(this.componentType); switch (reason) { case REMOVE: - if (blockState instanceof DestroyableBlockState) { - ((DestroyableBlockState)blockState).onDestroy(); + if (blockState instanceof DestroyableBlockState destroyableBlockState) { + destroyableBlockState.onDestroy(); } blockState.unloadFromWorld(); diff --git a/src/com/hypixel/hytale/server/core/universe/world/meta/state/BlockMapMarker.java b/src/com/hypixel/hytale/server/core/universe/world/meta/state/BlockMapMarker.java index 8dcc4ec..a7b023d 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/meta/state/BlockMapMarker.java +++ b/src/com/hypixel/hytale/server/core/universe/world/meta/state/BlockMapMarker.java @@ -20,14 +20,13 @@ import com.hypixel.hytale.protocol.Direction; import com.hypixel.hytale.protocol.Position; import com.hypixel.hytale.protocol.Transform; import com.hypixel.hytale.protocol.packets.worldmap.MapMarker; -import com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig; import com.hypixel.hytale.server.core.modules.block.BlockModule; import com.hypixel.hytale.server.core.universe.world.World; -import com.hypixel.hytale.server.core.universe.world.WorldMapTracker; import com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk; import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk; import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore; import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager; +import com.hypixel.hytale.server.core.universe.world.worldmap.markers.MapMarkerTracker; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -73,11 +72,8 @@ public class BlockMapMarker implements Component { public static class MarkerProvider implements WorldMapManager.MarkerProvider { public static final BlockMapMarker.MarkerProvider INSTANCE = new BlockMapMarker.MarkerProvider(); - public MarkerProvider() { - } - @Override - public void update(World world, GameplayConfig gameplayConfig, WorldMapTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ) { + public void update(World world, MapMarkerTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ) { BlockMapMarkersResource resource = world.getChunkStore().getStore().getResource(BlockMapMarkersResource.getResourceType()); Long2ObjectMap markers = resource.getMarkers(); @@ -96,9 +92,6 @@ public class BlockMapMarker implements Component { private static final ComponentType COMPONENT_TYPE = BlockMapMarker.getComponentType(); private static final ResourceType BLOCK_MAP_MARKERS_RESOURCE_TYPE = BlockMapMarkersResource.getResourceType(); - public OnAddRemove() { - } - @Override public void onEntityAdded( @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer diff --git a/src/com/hypixel/hytale/server/core/universe/world/meta/state/ItemContainerState.java b/src/com/hypixel/hytale/server/core/universe/world/meta/state/ItemContainerState.java index 7995c8d..a5a1637 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/meta/state/ItemContainerState.java +++ b/src/com/hypixel/hytale/server/core/universe/world/meta/state/ItemContainerState.java @@ -51,9 +51,6 @@ public class ItemContainerState extends BlockState implements ItemContainerBlock protected SimpleItemContainer itemContainer; protected WorldMapManager.MarkerReference marker; - public ItemContainerState() { - } - @Override public boolean initialize(@Nonnull BlockType blockType) { if (!super.initialize(blockType)) { diff --git a/src/com/hypixel/hytale/server/core/universe/world/meta/state/LaunchPad.java b/src/com/hypixel/hytale/server/core/universe/world/meta/state/LaunchPad.java index 23d3cdc..101a3fa 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/meta/state/LaunchPad.java +++ b/src/com/hypixel/hytale/server/core/universe/world/meta/state/LaunchPad.java @@ -175,9 +175,6 @@ public class LaunchPad implements Component { private double y; private double z; private boolean playersOnly; - - public LaunchPadSettingsPageEventData() { - } } } } diff --git a/src/com/hypixel/hytale/server/core/universe/world/meta/state/RespawnBlock.java b/src/com/hypixel/hytale/server/core/universe/world/meta/state/RespawnBlock.java index 782f75b..b61d0ea 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/meta/state/RespawnBlock.java +++ b/src/com/hypixel/hytale/server/core/universe/world/meta/state/RespawnBlock.java @@ -22,6 +22,7 @@ import com.hypixel.hytale.server.core.entity.entities.player.data.PlayerWorldDat import com.hypixel.hytale.server.core.modules.block.BlockModule; import com.hypixel.hytale.server.core.universe.PlayerRef; import com.hypixel.hytale.server.core.universe.Universe; +import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk; import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore; import java.util.UUID; @@ -66,12 +67,12 @@ public class RespawnBlock implements Component { } public static class OnRemove extends RefSystem { - public static final ComponentType COMPONENT_TYPE = RespawnBlock.getComponentType(); - public static final ComponentType BLOCK_INFO_TYPE = BlockModule.BlockStateInfo.getComponentType(); - public static final Query QUERY = Query.and(COMPONENT_TYPE, BLOCK_INFO_TYPE); - - public OnRemove() { - } + @Nonnull + private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); + public static final ComponentType COMPONENT_TYPE_RESPAWN_BLOCK = RespawnBlock.getComponentType(); + public static final ComponentType COMPONENT_TYPE_BLOCK_STATE_INFO = BlockModule.BlockStateInfo.getComponentType(); + @Nonnull + public static final Query QUERY = Query.and(COMPONENT_TYPE_RESPAWN_BLOCK, COMPONENT_TYPE_BLOCK_STATE_INFO); @Override public void onEntityAdded( @@ -84,36 +85,57 @@ public class RespawnBlock implements Component { @Nonnull Ref ref, @Nonnull RemoveReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { if (reason != RemoveReason.UNLOAD) { - RespawnBlock respawnState = commandBuffer.getComponent(ref, COMPONENT_TYPE); + RespawnBlock respawnState = commandBuffer.getComponent(ref, COMPONENT_TYPE_RESPAWN_BLOCK); assert respawnState != null; if (respawnState.ownerUUID != null) { - BlockModule.BlockStateInfo blockInfo = commandBuffer.getComponent(ref, BLOCK_INFO_TYPE); + BlockModule.BlockStateInfo blockStateInfoComponent = commandBuffer.getComponent(ref, COMPONENT_TYPE_BLOCK_STATE_INFO); - assert blockInfo != null; + assert blockStateInfoComponent != null; PlayerRef playerRef = Universe.get().getPlayer(respawnState.ownerUUID); if (playerRef == null) { - HytaleLogger.getLogger().at(Level.WARNING).log("Need to load PlayerConfig to remove RespawnPoint!"); + LOGGER.at(Level.WARNING).log("Failed to fetch player ref during removal of respawn block entity."); } else { - Player player = playerRef.getComponent(Player.getComponentType()); - Ref chunkRef = blockInfo.getChunkRef(); - if (chunkRef != null && chunkRef.isValid()) { - PlayerWorldData playerWorldData = player.getPlayerConfigData().getPerWorldData(store.getExternalData().getWorld().getName()); - PlayerRespawnPointData[] respawnPoints = playerWorldData.getRespawnPoints(); - WorldChunk wc = commandBuffer.getComponent(chunkRef, WorldChunk.getComponentType()); - Vector3i blockPosition = new Vector3i( - ChunkUtil.worldCoordFromLocalCoord(wc.getX(), ChunkUtil.xFromBlockInColumn(blockInfo.getIndex())), - ChunkUtil.yFromBlockInColumn(blockInfo.getIndex()), - ChunkUtil.worldCoordFromLocalCoord(wc.getZ(), ChunkUtil.zFromBlockInColumn(blockInfo.getIndex())) - ); + Player playerComponent = playerRef.getComponent(Player.getComponentType()); + if (playerComponent == null) { + LOGGER.at(Level.WARNING).log("Failed to fetch player component during removal of respawn block entity."); + } else { + Ref chunkRef = blockStateInfoComponent.getChunkRef(); + if (chunkRef.isValid()) { + World world = commandBuffer.getExternalData().getWorld(); + PlayerWorldData playerWorldData = playerComponent.getPlayerConfigData().getPerWorldData(world.getName()); + PlayerRespawnPointData[] respawnPoints = playerWorldData.getRespawnPoints(); + if (respawnPoints == null) { + LOGGER.at(Level.WARNING) + .log("Failed to find valid respawn points for player " + respawnState.ownerUUID + " during removal of respawn block entity."); + } else { + WorldChunk worldChunkComponent = commandBuffer.getComponent(chunkRef, WorldChunk.getComponentType()); - for (int i = 0; i < respawnPoints.length; i++) { - PlayerRespawnPointData respawnPoint = respawnPoints[i]; - if (respawnPoint.getBlockPosition().equals(blockPosition)) { - playerWorldData.setRespawnPoints(ArrayUtil.remove(respawnPoints, i)); - return; + assert worldChunkComponent != null; + + Vector3i blockPosition = new Vector3i( + ChunkUtil.worldCoordFromLocalCoord(worldChunkComponent.getX(), ChunkUtil.xFromBlockInColumn(blockStateInfoComponent.getIndex())), + ChunkUtil.yFromBlockInColumn(blockStateInfoComponent.getIndex()), + ChunkUtil.worldCoordFromLocalCoord(worldChunkComponent.getZ(), ChunkUtil.zFromBlockInColumn(blockStateInfoComponent.getIndex())) + ); + + for (int i = 0; i < respawnPoints.length; i++) { + PlayerRespawnPointData respawnPoint = respawnPoints[i]; + if (respawnPoint.getBlockPosition().equals(blockPosition)) { + LOGGER.at(Level.INFO) + .log( + "Removing respawn point for player " + + respawnState.ownerUUID + + " at position " + + blockPosition + + " due to respawn block removal." + ); + playerWorldData.setRespawnPoints(ArrayUtil.remove(respawnPoints, i)); + return; + } + } } } } diff --git a/src/com/hypixel/hytale/server/core/universe/world/path/SimplePathWaypoint.java b/src/com/hypixel/hytale/server/core/universe/world/path/SimplePathWaypoint.java index 568ff95..8713819 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/path/SimplePathWaypoint.java +++ b/src/com/hypixel/hytale/server/core/universe/world/path/SimplePathWaypoint.java @@ -6,7 +6,6 @@ import com.hypixel.hytale.math.vector.Vector3d; import com.hypixel.hytale.math.vector.Vector3f; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class SimplePathWaypoint implements IPathWaypoint { private int order; @@ -24,7 +23,7 @@ public class SimplePathWaypoint implements IPathWaypoint { @Nonnull @Override - public Vector3d getWaypointPosition(@NonNullDecl ComponentAccessor componentAccessor) { + public Vector3d getWaypointPosition(@Nonnull ComponentAccessor componentAccessor) { return this.transform.getPosition(); } diff --git a/src/com/hypixel/hytale/server/core/universe/world/path/WorldPathConfig.java b/src/com/hypixel/hytale/server/core/universe/world/path/WorldPathConfig.java index df06e22..c79df9d 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/path/WorldPathConfig.java +++ b/src/com/hypixel/hytale/server/core/universe/world/path/WorldPathConfig.java @@ -31,9 +31,6 @@ public class WorldPathConfig { .build(); protected Map paths = new ConcurrentHashMap<>(); - public WorldPathConfig() { - } - public WorldPath getPath(String name) { return this.paths.get(name); } diff --git a/src/com/hypixel/hytale/server/core/universe/world/spawn/FitToHeightMapSpawnProvider.java b/src/com/hypixel/hytale/server/core/universe/world/spawn/FitToHeightMapSpawnProvider.java index b6ae56c..04ce202 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/spawn/FitToHeightMapSpawnProvider.java +++ b/src/com/hypixel/hytale/server/core/universe/world/spawn/FitToHeightMapSpawnProvider.java @@ -26,7 +26,7 @@ public class FitToHeightMapSpawnProvider implements ISpawnProvider { protected FitToHeightMapSpawnProvider() { } - public FitToHeightMapSpawnProvider(ISpawnProvider spawnProvider) { + public FitToHeightMapSpawnProvider(@Nonnull ISpawnProvider spawnProvider) { this.spawnProvider = spawnProvider; } diff --git a/src/com/hypixel/hytale/server/core/universe/world/spawn/GlobalSpawnProvider.java b/src/com/hypixel/hytale/server/core/universe/world/spawn/GlobalSpawnProvider.java index 43ee05a..587e67b 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/spawn/GlobalSpawnProvider.java +++ b/src/com/hypixel/hytale/server/core/universe/world/spawn/GlobalSpawnProvider.java @@ -21,13 +21,13 @@ public class GlobalSpawnProvider implements ISpawnProvider { public GlobalSpawnProvider() { } - public GlobalSpawnProvider(Transform spawnPoint) { + public GlobalSpawnProvider(@Nonnull Transform spawnPoint) { this.spawnPoint = spawnPoint; } @Override public Transform getSpawnPoint(@Nonnull World world, @Nonnull UUID uuid) { - return this.spawnPoint; + return this.spawnPoint.clone(); } @Nonnull diff --git a/src/com/hypixel/hytale/server/core/universe/world/spawn/IndividualSpawnProvider.java b/src/com/hypixel/hytale/server/core/universe/world/spawn/IndividualSpawnProvider.java index f5b13d5..f0aad84 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/spawn/IndividualSpawnProvider.java +++ b/src/com/hypixel/hytale/server/core/universe/world/spawn/IndividualSpawnProvider.java @@ -28,18 +28,18 @@ public class IndividualSpawnProvider implements ISpawnProvider { public IndividualSpawnProvider() { } - public IndividualSpawnProvider(Transform spawnPoint) { + public IndividualSpawnProvider(@Nonnull Transform spawnPoint) { this.spawnPoints = new Transform[1]; this.spawnPoints[0] = spawnPoint; } - public IndividualSpawnProvider(Transform[] spawnPoints) { + public IndividualSpawnProvider(@Nonnull Transform[] spawnPoints) { this.spawnPoints = spawnPoints; } @Override public Transform getSpawnPoint(@Nonnull World world, @Nonnull UUID uuid) { - return this.spawnPoints[Math.abs((int)HashUtil.hashUuid(uuid)) % this.spawnPoints.length]; + return this.spawnPoints[Math.abs((int)HashUtil.hashUuid(uuid)) % this.spawnPoints.length].clone(); } @Override diff --git a/src/com/hypixel/hytale/server/core/universe/world/storage/ChunkStore.java b/src/com/hypixel/hytale/server/core/universe/world/storage/ChunkStore.java index 614ba6d..44d38fa 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/storage/ChunkStore.java +++ b/src/com/hypixel/hytale/server/core/universe/world/storage/ChunkStore.java @@ -101,6 +101,7 @@ public class ChunkStore implements WorldProvider { private IWorldGen generator; @Nonnull private CompletableFuture generatorLoaded = new CompletableFuture<>(); + private final StampedLock generatorLock = new StampedLock(); private final AtomicInteger totalGeneratedChunksCount = new AtomicInteger(); private final AtomicInteger totalLoadedChunksCount = new AtomicInteger(); @@ -131,19 +132,38 @@ public class ChunkStore implements WorldProvider { @Nullable public IWorldGen getGenerator() { - return this.generator; + long readStamp = this.generatorLock.readLock(); + + IWorldGen var3; + try { + var3 = this.generator; + } finally { + this.generatorLock.unlockRead(readStamp); + } + + return var3; + } + + public void shutdownGenerator() { + this.setGenerator(null); } public void setGenerator(@Nullable IWorldGen generator) { - if (this.generator != null) { - this.generator.shutdown(); - } + long writeStamp = this.generatorLock.writeLock(); - this.totalGeneratedChunksCount.set(0); - this.generator = generator; - if (generator != null) { - this.generatorLoaded.complete(null); - this.generatorLoaded = new CompletableFuture<>(); + try { + if (this.generator != null) { + this.generator.shutdown(); + } + + this.totalGeneratedChunksCount.set(0); + this.generator = generator; + if (generator != null) { + this.generatorLoaded.complete(null); + this.generatorLoaded = new CompletableFuture<>(); + } + } finally { + this.generatorLock.unlockWrite(writeStamp); } } @@ -474,12 +494,18 @@ public class ChunkStore implements WorldProvider { if ((isNew || (chunkState.flags & 2) != 0) && (flags & 2) == 0) { int seed = (int)this.world.getWorldConfig().getSeed(); if (chunkState.future == null) { + long readStamp = this.generatorLock.readLock(); + CompletableFuture future; - if (this.generator == null) { - future = this.generatorLoaded - .thenCompose(aVoid -> this.generator.generate(seed, index, x, z, (flags & 16) != 0 ? this::isChunkStillNeeded : null)); - } else { - future = this.generator.generate(seed, index, x, z, (flags & 16) != 0 ? this::isChunkStillNeeded : null); + try { + if (this.generator == null) { + future = this.generatorLoaded + .thenCompose(aVoid -> this.generator.generate(seed, index, x, z, (flags & 16) != 0 ? this::isChunkStillNeeded : null)); + } else { + future = this.generator.generate(seed, index, x, z, (flags & 16) != 0 ? this::isChunkStillNeeded : null); + } + } finally { + this.generatorLock.unlockRead(readStamp); } chunkState.future = future.>thenApplyAsync(generatedChunk -> { @@ -500,11 +526,17 @@ public class ChunkStore implements WorldProvider { if (reference != null) { return CompletableFuture.completedFuture((Ref)reference); } else { - CompletableFuture futurex; - if (this.generator == null) { - futurex = this.generatorLoaded.thenCompose(aVoid -> this.generator.generate(seed, index, x, z, null)); - } else { - futurex = this.generator.generate(seed, index, x, z, null); + long readStampx = this.generatorLock.readLock(); + + CompletableFuture future; + try { + if (this.generator == null) { + futurex = this.generatorLoaded.thenCompose(aVoid -> this.generator.generate(seed, index, x, z, null)); + } else { + futurex = this.generator.generate(seed, index, x, z, null); + } + } finally { + this.generatorLock.unlockRead(readStampx); } return futurex.>thenApplyAsync(generatedChunk -> { @@ -705,9 +737,6 @@ public class ChunkStore implements WorldProvider { private long failedWhen; private int failedCounter; - private ChunkLoadState() { - } - private void fail(Throwable throwable) { long stamp = this.lock.writeLock(); @@ -724,9 +753,6 @@ public class ChunkStore implements WorldProvider { } public static class ChunkLoaderSaverSetupSystem extends StoreSystem { - public ChunkLoaderSaverSetupSystem() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -770,17 +796,11 @@ public class ChunkStore implements WorldProvider { } public abstract static class LoadFuturePacketDataQuerySystem extends EntityDataSystem> { - public LoadFuturePacketDataQuerySystem() { - } } public abstract static class LoadPacketDataQuerySystem extends EntityDataSystem { - public LoadPacketDataQuerySystem() { - } } public abstract static class UnloadPacketDataQuerySystem extends EntityDataSystem { - public UnloadPacketDataQuerySystem() { - } } } diff --git a/src/com/hypixel/hytale/server/core/universe/world/storage/EntityStore.java b/src/com/hypixel/hytale/server/core/universe/world/storage/EntityStore.java index 809897f..0b71451 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/storage/EntityStore.java +++ b/src/com/hypixel/hytale/server/core/universe/world/storage/EntityStore.java @@ -91,9 +91,6 @@ public class EntityStore implements WorldProvider { } public static class NetworkIdSystem extends RefSystem { - public NetworkIdSystem() { - } - @Nonnull @Override public Query getQuery() { @@ -134,9 +131,6 @@ public class EntityStore implements WorldProvider { @Nonnull private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); - public UUIDSystem() { - } - @Nonnull @Override public Query getQuery() { diff --git a/src/com/hypixel/hytale/server/core/universe/world/storage/GetChunkFlags.java b/src/com/hypixel/hytale/server/core/universe/world/storage/GetChunkFlags.java index b3e5b7e..c11e801 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/storage/GetChunkFlags.java +++ b/src/com/hypixel/hytale/server/core/universe/world/storage/GetChunkFlags.java @@ -8,7 +8,4 @@ public class GetChunkFlags { public static final int BYPASS_LOADED = 8; public static final int POLL_STILL_NEEDED = 16; public static final int NO_SET_TICKING_SYNC = Integer.MIN_VALUE; - - public GetChunkFlags() { - } } diff --git a/src/com/hypixel/hytale/server/core/universe/world/storage/component/ChunkSavingSystems.java b/src/com/hypixel/hytale/server/core/universe/world/storage/component/ChunkSavingSystems.java index c63b85d..246345c 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/storage/component/ChunkSavingSystems.java +++ b/src/com/hypixel/hytale/server/core/universe/world/storage/component/ChunkSavingSystems.java @@ -23,7 +23,6 @@ import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk; import com.hypixel.hytale.server.core.universe.world.events.ecs.ChunkSaveEvent; import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore; import com.hypixel.hytale.server.core.universe.world.storage.IChunkSaver; -import com.hypixel.hytale.server.core.universe.world.worldgen.IWorldGen; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import java.util.Deque; import java.util.List; @@ -46,9 +45,6 @@ public class ChunkSavingSystems { @Nonnull public static final Query QUERY = Query.and(WORLD_CHUNK_COMPONENT_TYPE, Query.not(ChunkStore.REGISTRY.getNonSerializedComponentType())); - public ChunkSavingSystems() { - } - @Nonnull public static CompletableFuture saveChunksInWorld(@Nonnull Store store) { HytaleLogger logger = store.getExternalData().getWorld().getLogger(); @@ -205,9 +201,6 @@ public class ChunkSavingSystems { } public static class Ticking extends TickingSystem implements RunWhenPausedSystem { - public Ticking() { - } - @Nonnull @Override public Set> getDependencies() { @@ -267,9 +260,6 @@ public class ChunkSavingSystems { @Nonnull private final Set> dependencies = Set.of(new SystemDependency<>(Order.AFTER, ChunkStore.ChunkLoaderSaverSetupSystem.class)); - public WorldRemoved() { - } - @Nonnull @Override public Set> getDependencies() { @@ -283,12 +273,8 @@ public class ChunkSavingSystems { @Override public void onSystemRemovedFromStore(@Nonnull Store store) { World world = store.getExternalData().getWorld(); - IWorldGen generator = world.getChunkStore().getGenerator(); - if (generator != null) { - world.getLogger().at(Level.INFO).log("Shutting down chunk generator..."); - generator.shutdown(); - } - + world.getLogger().at(Level.INFO).log("Shutting down chunk generator..."); + world.getChunkStore().shutdownGenerator(); if (!world.getWorldConfig().canSaveChunks()) { world.getLogger().at(Level.INFO).log("This world has opted to disable chunk saving so it will not be saved on shutdown"); } else { diff --git a/src/com/hypixel/hytale/server/core/universe/world/storage/component/ChunkUnloadingSystem.java b/src/com/hypixel/hytale/server/core/universe/world/storage/component/ChunkUnloadingSystem.java index e1a8356..8ec8839 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/storage/component/ChunkUnloadingSystem.java +++ b/src/com/hypixel/hytale/server/core/universe/world/storage/component/ChunkUnloadingSystem.java @@ -29,9 +29,6 @@ public class ChunkUnloadingSystem extends TickingSystem implements R public static final int TICKS_BEFORE_CHUNK_UNLOADING_REMINDER = 5000; public int ticksUntilUnloadingReminder = 5000; - public ChunkUnloadingSystem() { - } - @Override public void tick(float dt, int systemIndex, @Nonnull Store store) { ChunkUnloadingSystem.Data dataResource = store.getResource(ChunkStore.UNLOAD_RESOURCE); diff --git a/src/com/hypixel/hytale/server/core/universe/world/storage/provider/DefaultChunkStorageProvider.java b/src/com/hypixel/hytale/server/core/universe/world/storage/provider/DefaultChunkStorageProvider.java index a16ce3a..a3bf827 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/storage/provider/DefaultChunkStorageProvider.java +++ b/src/com/hypixel/hytale/server/core/universe/world/storage/provider/DefaultChunkStorageProvider.java @@ -7,7 +7,6 @@ import com.hypixel.hytale.server.core.universe.world.storage.IChunkLoader; import com.hypixel.hytale.server.core.universe.world.storage.IChunkSaver; import java.io.IOException; import javax.annotation.Nonnull; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class DefaultChunkStorageProvider implements IChunkStorageProvider { @Nonnull @@ -20,18 +19,15 @@ public class DefaultChunkStorageProvider implements IChunkStorageProvider { @Nonnull public static final IChunkStorageProvider DEFAULT = new IndexedStorageChunkStorageProvider(); - public DefaultChunkStorageProvider() { - } - - @NonNullDecl + @Nonnull @Override - public IChunkLoader getLoader(@NonNullDecl Store store) throws IOException { + public IChunkLoader getLoader(@Nonnull Store store) throws IOException { return DEFAULT.getLoader(store); } @Nonnull @Override - public IChunkSaver getSaver(@NonNullDecl Store store) throws IOException { + public IChunkSaver getSaver(@Nonnull Store store) throws IOException { return DEFAULT.getSaver(store); } diff --git a/src/com/hypixel/hytale/server/core/universe/world/storage/provider/EmptyChunkStorageProvider.java b/src/com/hypixel/hytale/server/core/universe/world/storage/provider/EmptyChunkStorageProvider.java index 23956f7..52d2020 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/storage/provider/EmptyChunkStorageProvider.java +++ b/src/com/hypixel/hytale/server/core/universe/world/storage/provider/EmptyChunkStorageProvider.java @@ -10,7 +10,6 @@ import it.unimi.dsi.fastutil.longs.LongSet; import it.unimi.dsi.fastutil.longs.LongSets; import java.util.concurrent.CompletableFuture; import javax.annotation.Nonnull; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class EmptyChunkStorageProvider implements IChunkStorageProvider { public static final String ID = "Empty"; @@ -25,18 +24,15 @@ public class EmptyChunkStorageProvider implements IChunkStorageProvider { @Nonnull public static final EmptyChunkStorageProvider.EmptyChunkSaver EMPTY_CHUNK_SAVER = new EmptyChunkStorageProvider.EmptyChunkSaver(); - public EmptyChunkStorageProvider() { - } - - @NonNullDecl + @Nonnull @Override - public IChunkLoader getLoader(@NonNullDecl Store store) { + public IChunkLoader getLoader(@Nonnull Store store) { return EMPTY_CHUNK_LOADER; } @Nonnull @Override - public IChunkSaver getSaver(@NonNullDecl Store store) { + public IChunkSaver getSaver(@Nonnull Store store) { return EMPTY_CHUNK_SAVER; } @@ -47,9 +43,6 @@ public class EmptyChunkStorageProvider implements IChunkStorageProvider { } private static class EmptyChunkLoader implements IChunkLoader { - private EmptyChunkLoader() { - } - @Override public void close() { } @@ -68,9 +61,6 @@ public class EmptyChunkStorageProvider implements IChunkStorageProvider { } private static class EmptyChunkSaver implements IChunkSaver { - private EmptyChunkSaver() { - } - @Override public void close() { } diff --git a/src/com/hypixel/hytale/server/core/universe/world/storage/provider/IndexedStorageChunkStorageProvider.java b/src/com/hypixel/hytale/server/core/universe/world/storage/provider/IndexedStorageChunkStorageProvider.java index 0d0e0a9..7c4ae4e 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/storage/provider/IndexedStorageChunkStorageProvider.java +++ b/src/com/hypixel/hytale/server/core/universe/world/storage/provider/IndexedStorageChunkStorageProvider.java @@ -50,21 +50,26 @@ public class IndexedStorageChunkStorageProvider implements IChunkStorageProvider IndexedStorageChunkStorageProvider.class, IndexedStorageChunkStorageProvider::new ) .documentation("Uses the indexed storage file format to store chunks.") + .appendInherited( + new KeyedCodec<>("FlushOnWrite", Codec.BOOLEAN), (o, i) -> o.flushOnWrite = i, o -> o.flushOnWrite, (o, p) -> o.flushOnWrite = p.flushOnWrite + ) + .documentation( + "Controls whether the indexed storage flushes during writes.\nRecommended to be enabled to prevent corruption of chunks during unclean shutdowns." + ) + .add() .build(); - - public IndexedStorageChunkStorageProvider() { - } + private boolean flushOnWrite = true; @Nonnull @Override public IChunkLoader getLoader(@Nonnull Store store) { - return new IndexedStorageChunkStorageProvider.IndexedStorageChunkLoader(store); + return new IndexedStorageChunkStorageProvider.IndexedStorageChunkLoader(store, this.flushOnWrite); } @Nonnull @Override public IChunkSaver getSaver(@Nonnull Store store) { - return new IndexedStorageChunkStorageProvider.IndexedStorageChunkSaver(store); + return new IndexedStorageChunkStorageProvider.IndexedStorageChunkSaver(store, this.flushOnWrite); } @Nonnull @@ -111,9 +116,6 @@ public class IndexedStorageChunkStorageProvider implements IChunkStorageProvider private final Long2ObjectConcurrentHashMap cache = new Long2ObjectConcurrentHashMap<>(true, ChunkUtil.NOT_FOUND); private Path path; - public IndexedStorageCache() { - } - public static ResourceType getResourceType() { return Universe.get().getIndexedStorageCacheResourceType(); } @@ -147,38 +149,42 @@ public class IndexedStorageChunkStorageProvider implements IChunkStorageProvider } @Nullable - public IndexedStorageFile getOrTryOpen(int regionX, int regionZ) { + public IndexedStorageFile getOrTryOpen(int regionX, int regionZ, boolean flushOnWrite) { return this.cache.computeIfAbsent(ChunkUtil.indexChunk(regionX, regionZ), k -> { Path regionFile = this.path.resolve(IndexedStorageChunkStorageProvider.toFileName(regionX, regionZ)); if (!Files.exists(regionFile)) { return null; } else { try { - return IndexedStorageFile.open(regionFile, StandardOpenOption.READ, StandardOpenOption.WRITE); - } catch (FileNotFoundException var7) { + IndexedStorageFile open = IndexedStorageFile.open(regionFile, StandardOpenOption.READ, StandardOpenOption.WRITE); + open.setFlushOnWrite(flushOnWrite); + return open; + } catch (FileNotFoundException var8) { return null; - } catch (IOException var8) { - throw SneakyThrow.sneakyThrow(var8); + } catch (IOException var9) { + throw SneakyThrow.sneakyThrow(var9); } } }); } @Nonnull - public IndexedStorageFile getOrCreate(int regionX, int regionZ) { + public IndexedStorageFile getOrCreate(int regionX, int regionZ, boolean flushOnWrite) { return this.cache.computeIfAbsent(ChunkUtil.indexChunk(regionX, regionZ), k -> { try { if (!Files.exists(this.path)) { try { Files.createDirectory(this.path); - } catch (FileAlreadyExistsException var6) { + } catch (FileAlreadyExistsException var8) { } } Path regionFile = this.path.resolve(IndexedStorageChunkStorageProvider.toFileName(regionX, regionZ)); - return IndexedStorageFile.open(regionFile, StandardOpenOption.CREATE, StandardOpenOption.READ, StandardOpenOption.WRITE); - } catch (IOException var7) { - throw SneakyThrow.sneakyThrow(var7); + IndexedStorageFile open = IndexedStorageFile.open(regionFile, StandardOpenOption.CREATE, StandardOpenOption.READ, StandardOpenOption.WRITE); + open.setFlushOnWrite(flushOnWrite); + return open; + } catch (IOException var9) { + throw SneakyThrow.sneakyThrow(var9); } }); } @@ -202,7 +208,7 @@ public class IndexedStorageChunkStorageProvider implements IChunkStorageProvider int regionX = ChunkUtil.xOfChunkIndex(regionIndex); int regionZ = ChunkUtil.zOfChunkIndex(regionIndex); - IndexedStorageFile regionFile = this.getOrTryOpen(regionX, regionZ); + IndexedStorageFile regionFile = this.getOrTryOpen(regionX, regionZ, true); if (regionFile != null) { IntList blobIndexes = regionFile.keys(); IntListIterator iterator = blobIndexes.iterator(); @@ -281,9 +287,6 @@ public class IndexedStorageChunkStorageProvider implements IChunkStorageProvider } public static class IndexedStorageCacheSetupSystem extends StoreSystem { - public IndexedStorageCacheSetupSystem() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -302,8 +305,11 @@ public class IndexedStorageChunkStorageProvider implements IChunkStorageProvider } public static class IndexedStorageChunkLoader extends BufferChunkLoader implements MetricProvider { - public IndexedStorageChunkLoader(@Nonnull Store store) { + private final boolean flushOnWrite; + + public IndexedStorageChunkLoader(@Nonnull Store store, boolean flushOnWrite) { super(store); + this.flushOnWrite = flushOnWrite; } @Override @@ -322,7 +328,7 @@ public class IndexedStorageChunkStorageProvider implements IChunkStorageProvider IndexedStorageChunkStorageProvider.IndexedStorageCache indexedStorageCache = this.getStore() .getResource(IndexedStorageChunkStorageProvider.IndexedStorageCache.getResourceType()); return CompletableFuture.supplyAsync(SneakyThrow.sneakySupplier(() -> { - IndexedStorageFile chunks = indexedStorageCache.getOrTryOpen(regionX, regionZ); + IndexedStorageFile chunks = indexedStorageCache.getOrTryOpen(regionX, regionZ, this.flushOnWrite); return chunks == null ? null : chunks.readBlob(index); })); } @@ -343,8 +349,11 @@ public class IndexedStorageChunkStorageProvider implements IChunkStorageProvider } public static class IndexedStorageChunkSaver extends BufferChunkSaver implements MetricProvider { - protected IndexedStorageChunkSaver(@Nonnull Store store) { + private final boolean flushOnWrite; + + protected IndexedStorageChunkSaver(@Nonnull Store store, boolean flushOnWrite) { super(store); + this.flushOnWrite = flushOnWrite; } @Override @@ -365,7 +374,7 @@ public class IndexedStorageChunkStorageProvider implements IChunkStorageProvider IndexedStorageChunkStorageProvider.IndexedStorageCache indexedStorageCache = this.getStore() .getResource(IndexedStorageChunkStorageProvider.IndexedStorageCache.getResourceType()); return CompletableFuture.runAsync(SneakyThrow.sneakyRunnable(() -> { - IndexedStorageFile chunks = indexedStorageCache.getOrCreate(regionX, regionZ); + IndexedStorageFile chunks = indexedStorageCache.getOrCreate(regionX, regionZ, this.flushOnWrite); chunks.writeBlob(index, buffer); })); } @@ -381,7 +390,7 @@ public class IndexedStorageChunkStorageProvider implements IChunkStorageProvider IndexedStorageChunkStorageProvider.IndexedStorageCache indexedStorageCache = this.getStore() .getResource(IndexedStorageChunkStorageProvider.IndexedStorageCache.getResourceType()); return CompletableFuture.runAsync(SneakyThrow.sneakyRunnable(() -> { - IndexedStorageFile chunks = indexedStorageCache.getOrTryOpen(regionX, regionZ); + IndexedStorageFile chunks = indexedStorageCache.getOrTryOpen(regionX, regionZ, this.flushOnWrite); if (chunks != null) { chunks.removeBlob(index); } diff --git a/src/com/hypixel/hytale/server/core/universe/world/storage/provider/MigrationChunkStorageProvider.java b/src/com/hypixel/hytale/server/core/universe/world/storage/provider/MigrationChunkStorageProvider.java index 919cea8..124cccb 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/storage/provider/MigrationChunkStorageProvider.java +++ b/src/com/hypixel/hytale/server/core/universe/world/storage/provider/MigrationChunkStorageProvider.java @@ -16,7 +16,6 @@ import java.util.Arrays; import java.util.concurrent.CompletableFuture; import java.util.function.Function; import javax.annotation.Nonnull; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class MigrationChunkStorageProvider implements IChunkStorageProvider { public static final String ID = "Migration"; @@ -53,7 +52,7 @@ public class MigrationChunkStorageProvider implements IChunkStorageProvider { @Nonnull @Override - public IChunkLoader getLoader(@NonNullDecl Store store) throws IOException { + public IChunkLoader getLoader(@Nonnull Store store) throws IOException { IChunkLoader[] loaders = new IChunkLoader[this.from.length]; for (int i = 0; i < this.from.length; i++) { @@ -65,7 +64,7 @@ public class MigrationChunkStorageProvider implements IChunkStorageProvider { @Nonnull @Override - public IChunkSaver getSaver(@NonNullDecl Store store) throws IOException { + public IChunkSaver getSaver(@Nonnull Store store) throws IOException { return this.to.getSaver(store); } diff --git a/src/com/hypixel/hytale/server/core/universe/world/storage/resources/DefaultResourceStorageProvider.java b/src/com/hypixel/hytale/server/core/universe/world/storage/resources/DefaultResourceStorageProvider.java index 78935c1..a739471 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/storage/resources/DefaultResourceStorageProvider.java +++ b/src/com/hypixel/hytale/server/core/universe/world/storage/resources/DefaultResourceStorageProvider.java @@ -12,9 +12,6 @@ public class DefaultResourceStorageProvider implements IResourceStorageProvider public static final BuilderCodec CODEC = BuilderCodec.builder(DefaultResourceStorageProvider.class, () -> INSTANCE).build(); public static final DiskResourceStorageProvider DEFAULT = new DiskResourceStorageProvider(); - public DefaultResourceStorageProvider() { - } - @Nonnull @Override public IResourceStorage getResourceStorage(@Nonnull World world) { diff --git a/src/com/hypixel/hytale/server/core/universe/world/storage/resources/DiskResourceStorageProvider.java b/src/com/hypixel/hytale/server/core/universe/world/storage/resources/DiskResourceStorageProvider.java index 0184ba0..27f48a9 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/storage/resources/DiskResourceStorageProvider.java +++ b/src/com/hypixel/hytale/server/core/universe/world/storage/resources/DiskResourceStorageProvider.java @@ -38,9 +38,6 @@ public class DiskResourceStorageProvider implements IResourceStorageProvider { @Nonnull private String path = "resources"; - public DiskResourceStorageProvider() { - } - @Nonnull public String getPath() { return this.path; diff --git a/src/com/hypixel/hytale/server/core/universe/world/storage/resources/EmptyResourceStorageProvider.java b/src/com/hypixel/hytale/server/core/universe/world/storage/resources/EmptyResourceStorageProvider.java index 99b9254..48e0cef 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/storage/resources/EmptyResourceStorageProvider.java +++ b/src/com/hypixel/hytale/server/core/universe/world/storage/resources/EmptyResourceStorageProvider.java @@ -12,9 +12,6 @@ public class EmptyResourceStorageProvider implements IResourceStorageProvider { public static final String ID = "Empty"; public static final BuilderCodec CODEC = BuilderCodec.builder(EmptyResourceStorageProvider.class, () -> INSTANCE).build(); - public EmptyResourceStorageProvider() { - } - @Nonnull @Override public IResourceStorage getResourceStorage(@Nonnull World world) { diff --git a/src/com/hypixel/hytale/server/core/universe/world/system/WorldPregenerateSystem.java b/src/com/hypixel/hytale/server/core/universe/world/system/WorldPregenerateSystem.java index 584d944..9e7f782 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/system/WorldPregenerateSystem.java +++ b/src/com/hypixel/hytale/server/core/universe/world/system/WorldPregenerateSystem.java @@ -23,9 +23,6 @@ import javax.annotation.Nonnull; public class WorldPregenerateSystem extends StoreSystem { private static final Set> DEPENDENCIES = Set.of(new SystemGroupDependency<>(Order.AFTER, ChunkStore.INIT_GROUP)); - public WorldPregenerateSystem() { - } - @Nonnull @Override public Set> getDependencies() { diff --git a/src/com/hypixel/hytale/server/core/universe/world/worldgen/GeneratedBlockStateChunk.java b/src/com/hypixel/hytale/server/core/universe/world/worldgen/GeneratedBlockStateChunk.java index 24e82ce..73e50f3 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/worldgen/GeneratedBlockStateChunk.java +++ b/src/com/hypixel/hytale/server/core/universe/world/worldgen/GeneratedBlockStateChunk.java @@ -14,9 +14,6 @@ import javax.annotation.Nullable; public class GeneratedBlockStateChunk { private final Int2ObjectMap> mapping = new Int2ObjectOpenHashMap<>(); - public GeneratedBlockStateChunk() { - } - public Holder getState(int x, int y, int z) { return this.mapping.get(ChunkUtil.indexBlockInColumn(x, y, z)); } diff --git a/src/com/hypixel/hytale/server/core/universe/world/worldgen/GeneratedChunkSection.java b/src/com/hypixel/hytale/server/core/universe/world/worldgen/GeneratedChunkSection.java index 4662c10..ba4244a 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/worldgen/GeneratedChunkSection.java +++ b/src/com/hypixel/hytale/server/core/universe/world/worldgen/GeneratedChunkSection.java @@ -17,9 +17,6 @@ public class GeneratedChunkSection { private ISectionPalette fillers = EmptySectionPalette.INSTANCE; private ISectionPalette rotations = EmptySectionPalette.INSTANCE; - public GeneratedChunkSection() { - } - public int getRotationIndex(int x, int y, int z) { return this.getRotationIndex(ChunkUtil.indexBlock(x, y, z)); } diff --git a/src/com/hypixel/hytale/server/core/universe/world/worldgen/provider/DummyWorldGenProvider.java b/src/com/hypixel/hytale/server/core/universe/world/worldgen/provider/DummyWorldGenProvider.java index a4c0e85..e650c6d 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/worldgen/provider/DummyWorldGenProvider.java +++ b/src/com/hypixel/hytale/server/core/universe/world/worldgen/provider/DummyWorldGenProvider.java @@ -19,9 +19,6 @@ public class DummyWorldGenProvider implements IWorldGenProvider { .documentation("A dummy world generation provider that places a single layer of unknown blocks in each chunk.") .build(); - public DummyWorldGenProvider() { - } - @Nonnull @Override public IWorldGen getGenerator() { diff --git a/src/com/hypixel/hytale/server/core/universe/world/worldlocationcondition/WorldLocationCondition.java b/src/com/hypixel/hytale/server/core/universe/world/worldlocationcondition/WorldLocationCondition.java index d2d5215..404f37e 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/worldlocationcondition/WorldLocationCondition.java +++ b/src/com/hypixel/hytale/server/core/universe/world/worldlocationcondition/WorldLocationCondition.java @@ -9,9 +9,6 @@ public abstract class WorldLocationCondition { public static final CodecMapCodec CODEC = new CodecMapCodec<>("Type"); public static final BuilderCodec BASE_CODEC = BuilderCodec.abstractBuilder(WorldLocationCondition.class).build(); - public WorldLocationCondition() { - } - public abstract boolean test(World var1, int var2, int var3, int var4); @Override diff --git a/src/com/hypixel/hytale/server/core/universe/world/worldmap/WorldMapManager.java b/src/com/hypixel/hytale/server/core/universe/world/worldmap/WorldMapManager.java index 85f8067..562c3a5 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/worldmap/WorldMapManager.java +++ b/src/com/hypixel/hytale/server/core/universe/world/worldmap/WorldMapManager.java @@ -15,7 +15,6 @@ import com.hypixel.hytale.math.util.ChunkUtil; import com.hypixel.hytale.math.util.MathUtil; import com.hypixel.hytale.protocol.packets.worldmap.MapImage; import com.hypixel.hytale.protocol.packets.worldmap.MapMarker; -import com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig; import com.hypixel.hytale.server.core.entity.UUIDComponent; import com.hypixel.hytale.server.core.entity.entities.Player; import com.hypixel.hytale.server.core.entity.entities.player.data.PlayerConfigData; @@ -23,14 +22,14 @@ import com.hypixel.hytale.server.core.entity.entities.player.data.PlayerWorldDat import com.hypixel.hytale.server.core.universe.PlayerRef; import com.hypixel.hytale.server.core.universe.Universe; import com.hypixel.hytale.server.core.universe.world.World; -import com.hypixel.hytale.server.core.universe.world.WorldMapTracker; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; -import com.hypixel.hytale.server.core.universe.world.worldmap.markers.DeathMarkerProvider; -import com.hypixel.hytale.server.core.universe.world.worldmap.markers.POIMarkerProvider; -import com.hypixel.hytale.server.core.universe.world.worldmap.markers.PlayerIconMarkerProvider; -import com.hypixel.hytale.server.core.universe.world.worldmap.markers.PlayerMarkersProvider; -import com.hypixel.hytale.server.core.universe.world.worldmap.markers.RespawnMarkerProvider; -import com.hypixel.hytale.server.core.universe.world.worldmap.markers.SpawnMarkerProvider; +import com.hypixel.hytale.server.core.universe.world.worldmap.markers.MapMarkerTracker; +import com.hypixel.hytale.server.core.universe.world.worldmap.markers.providers.DeathMarkerProvider; +import com.hypixel.hytale.server.core.universe.world.worldmap.markers.providers.POIMarkerProvider; +import com.hypixel.hytale.server.core.universe.world.worldmap.markers.providers.PerWorldDataMarkerProvider; +import com.hypixel.hytale.server.core.universe.world.worldmap.markers.providers.PlayerIconMarkerProvider; +import com.hypixel.hytale.server.core.universe.world.worldmap.markers.providers.RespawnMarkerProvider; +import com.hypixel.hytale.server.core.universe.world.worldmap.markers.providers.SpawnMarkerProvider; import com.hypixel.hytale.server.core.util.thread.TickingThread; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import it.unimi.dsi.fastutil.longs.LongSet; @@ -75,7 +74,7 @@ public class WorldMapManager extends TickingThread { this.addMarkerProvider("playerIcons", PlayerIconMarkerProvider.INSTANCE); this.addMarkerProvider("death", DeathMarkerProvider.INSTANCE); this.addMarkerProvider("respawn", RespawnMarkerProvider.INSTANCE); - this.addMarkerProvider("playerMarkers", PlayerMarkersProvider.INSTANCE); + this.addMarkerProvider("playerMarkers", PerWorldDataMarkerProvider.INSTANCE); this.addMarkerProvider("poi", POIMarkerProvider.INSTANCE); } @@ -321,7 +320,7 @@ public class WorldMapManager extends TickingThread { } public interface MarkerProvider { - void update(World var1, GameplayConfig var2, WorldMapTracker var3, int var4, int var5, int var6); + void update(World var1, MapMarkerTracker var2, int var3, int var4, int var5); } public interface MarkerReference { diff --git a/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/MapMarkerTracker.java b/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/MapMarkerTracker.java new file mode 100644 index 0000000..f6e8e24 --- /dev/null +++ b/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/MapMarkerTracker.java @@ -0,0 +1,179 @@ +package com.hypixel.hytale.server.core.universe.world.worldmap.markers; + +import com.hypixel.hytale.function.function.TriFunction; +import com.hypixel.hytale.math.util.MathUtil; +import com.hypixel.hytale.math.vector.Vector2d; +import com.hypixel.hytale.math.vector.Vector3d; +import com.hypixel.hytale.protocol.Position; +import com.hypixel.hytale.protocol.packets.worldmap.MapMarker; +import com.hypixel.hytale.protocol.packets.worldmap.UpdateWorldMap; +import com.hypixel.hytale.server.core.entity.entities.Player; +import com.hypixel.hytale.server.core.universe.PlayerRef; +import com.hypixel.hytale.server.core.universe.world.World; +import com.hypixel.hytale.server.core.universe.world.WorldMapTracker; +import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Predicate; +import javax.annotation.Nonnull; + +public class MapMarkerTracker { + private final WorldMapTracker worldMapTracker; + private final Player player; + private final Map sentToClientById = new ConcurrentHashMap<>(); + public static final float SMALL_MOVEMENTS_UPDATE_INTERVAL = 10.0F; + private float smallMovementsTimer; + private Predicate playerMapFilter; + @Nonnull + private final Set tempToRemove = new HashSet<>(); + @Nonnull + private final Set tempToAdd = new HashSet<>(); + @Nonnull + private final Set tempTestedMarkers = new HashSet<>(); + + public MapMarkerTracker(WorldMapTracker worldMapTracker) { + this.worldMapTracker = worldMapTracker; + this.player = worldMapTracker.getPlayer(); + } + + public Player getPlayer() { + return this.player; + } + + public Map getSentMarkers() { + return this.sentToClientById; + } + + public Predicate getPlayerMapFilter() { + return this.playerMapFilter; + } + + public void setPlayerMapFilter(Predicate playerMapFilter) { + this.playerMapFilter = playerMapFilter; + } + + private boolean isSendingSmallMovements() { + return this.smallMovementsTimer <= 0.0F; + } + + private void resetSmallMovementTimer() { + this.smallMovementsTimer = 10.0F; + } + + public void updatePointsOfInterest(float dt, @Nonnull World world, int chunkViewRadius, int playerChunkX, int playerChunkZ) { + if (this.worldMapTracker.getTransformComponent() != null) { + this.smallMovementsTimer -= dt; + WorldMapManager worldMapManager = world.getWorldMapManager(); + Map markerProviders = worldMapManager.getMarkerProviders(); + this.tempToAdd.clear(); + this.tempTestedMarkers.clear(); + + for (WorldMapManager.MarkerProvider provider : markerProviders.values()) { + provider.update(world, this, chunkViewRadius, playerChunkX, playerChunkZ); + } + + if (this.isSendingSmallMovements()) { + this.resetSmallMovementTimer(); + } + + this.tempToRemove.clear(); + this.tempToRemove.addAll(this.sentToClientById.keySet()); + if (!this.tempTestedMarkers.isEmpty()) { + this.tempToRemove.removeAll(this.tempTestedMarkers); + } + + for (String removedMarkerId : this.tempToRemove) { + this.sentToClientById.remove(removedMarkerId); + } + + if (!this.tempToAdd.isEmpty() || !this.tempToRemove.isEmpty()) { + MapMarker[] addedMarkers = !this.tempToAdd.isEmpty() ? this.tempToAdd.toArray(MapMarker[]::new) : null; + String[] removedMarkers = !this.tempToRemove.isEmpty() ? this.tempToRemove.toArray(String[]::new) : null; + this.player.getPlayerConnection().writeNoCache(new UpdateWorldMap(null, addedMarkers, removedMarkers)); + } + } + } + + public void trySendMarker(int chunkViewRadius, int playerChunkX, int playerChunkZ, @Nonnull MapMarker marker) { + this.trySendMarker( + chunkViewRadius, + playerChunkX, + playerChunkZ, + marker.transform.position.x, + marker.transform.position.z, + marker.transform.orientation.yaw, + marker.id, + marker.name, + marker, + (id, name, m) -> m + ); + } + + public void trySendMarker( + int chunkViewRadius, + int playerChunkX, + int playerChunkZ, + @Nonnull Vector3d markerPos, + float markerYaw, + @Nonnull String markerId, + @Nonnull String markerDisplayName, + @Nonnull T param, + @Nonnull TriFunction markerSupplier + ) { + this.trySendMarker(chunkViewRadius, playerChunkX, playerChunkZ, markerPos.x, markerPos.z, markerYaw, markerId, markerDisplayName, param, markerSupplier); + } + + private void trySendMarker( + int chunkViewRadius, + int playerChunkX, + int playerChunkZ, + double markerX, + double markerZ, + float markerYaw, + @Nonnull String markerId, + @Nonnull String markerName, + @Nonnull T param, + @Nonnull TriFunction markerSupplier + ) { + boolean shouldBeVisible = chunkViewRadius == -1 + || WorldMapTracker.shouldBeVisible(chunkViewRadius, MathUtil.floor(markerX) >> 5, MathUtil.floor(markerZ) >> 5, playerChunkX, playerChunkZ); + if (shouldBeVisible) { + this.tempTestedMarkers.add(markerId); + boolean needsUpdate = false; + MapMarker oldMarker = this.sentToClientById.get(markerId); + if (oldMarker != null) { + if (!markerName.equals(oldMarker.name)) { + needsUpdate = true; + } + + if (!needsUpdate) { + double distance = Math.abs(oldMarker.transform.orientation.yaw - markerYaw); + needsUpdate = distance > 0.05 || this.isSendingSmallMovements() && distance > 0.001; + } + + if (!needsUpdate) { + Position oldPosition = oldMarker.transform.position; + double distance = Vector2d.distance(oldPosition.x, oldPosition.z, markerX, markerZ); + needsUpdate = distance > 5.0 || this.isSendingSmallMovements() && distance > 0.1; + } + } else { + needsUpdate = true; + } + + if (needsUpdate) { + MapMarker marker = markerSupplier.apply(markerId, markerName, param); + this.sentToClientById.put(markerId, marker); + this.tempToAdd.add(marker); + } + } + } + + public void copyFrom(@Nonnull MapMarkerTracker other) { + for (Entry entry : other.sentToClientById.entrySet()) { + this.sentToClientById.put(entry.getKey(), new MapMarker(entry.getValue())); + } + } +} diff --git a/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/PlayerIconMarkerProvider.java b/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/PlayerIconMarkerProvider.java deleted file mode 100644 index fa22d50..0000000 --- a/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/PlayerIconMarkerProvider.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.hypixel.hytale.server.core.universe.world.worldmap.markers; - -import com.hypixel.hytale.math.vector.Transform; -import com.hypixel.hytale.math.vector.Vector3d; -import com.hypixel.hytale.protocol.packets.worldmap.MapMarker; -import com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig; -import com.hypixel.hytale.server.core.asset.type.gameplay.WorldMapConfig; -import com.hypixel.hytale.server.core.entity.entities.Player; -import com.hypixel.hytale.server.core.universe.PlayerRef; -import com.hypixel.hytale.server.core.universe.world.World; -import com.hypixel.hytale.server.core.universe.world.WorldMapTracker; -import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager; -import com.hypixel.hytale.server.core.util.PositionUtil; -import java.util.function.Predicate; -import javax.annotation.Nonnull; - -public class PlayerIconMarkerProvider implements WorldMapManager.MarkerProvider { - public static final PlayerIconMarkerProvider INSTANCE = new PlayerIconMarkerProvider(); - - private PlayerIconMarkerProvider() { - } - - @Override - public void update( - @Nonnull World world, @Nonnull GameplayConfig gameplayConfig, @Nonnull WorldMapTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ - ) { - WorldMapConfig worldMapConfig = gameplayConfig.getWorldMapConfig(); - if (worldMapConfig.isDisplayPlayers()) { - if (tracker.shouldUpdatePlayerMarkers()) { - Player player = tracker.getPlayer(); - int chunkViewRadiusSq = chunkViewRadius * chunkViewRadius; - Predicate playerMapFilter = tracker.getPlayerMapFilter(); - - for (PlayerRef otherPlayer : world.getPlayerRefs()) { - if (!otherPlayer.getUuid().equals(player.getUuid())) { - Transform otherPlayerTransform = otherPlayer.getTransform(); - Vector3d otherPos = otherPlayerTransform.getPosition(); - int otherChunkX = (int)otherPos.x >> 5; - int otherChunkZ = (int)otherPos.z >> 5; - int chunkDiffX = otherChunkX - playerChunkX; - int chunkDiffZ = otherChunkZ - playerChunkZ; - int chunkDistSq = chunkDiffX * chunkDiffX + chunkDiffZ * chunkDiffZ; - if (chunkDistSq <= chunkViewRadiusSq && (playerMapFilter == null || !playerMapFilter.test(otherPlayer))) { - tracker.trySendMarker( - chunkViewRadius, - playerChunkX, - playerChunkZ, - otherPos, - otherPlayer.getHeadRotation().getYaw(), - "Player-" + otherPlayer.getUuid(), - "Player: " + otherPlayer.getUsername(), - otherPlayer, - (id, name, op) -> new MapMarker(id, name, "Player.png", PositionUtil.toTransformPacket(op.getTransform()), null) - ); - } - } - } - - tracker.resetPlayerMarkersUpdateTimer(); - } - } - } -} diff --git a/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/DeathMarkerProvider.java b/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/providers/DeathMarkerProvider.java similarity index 76% rename from src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/DeathMarkerProvider.java rename to src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/providers/DeathMarkerProvider.java index cf38a27..ae96628 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/DeathMarkerProvider.java +++ b/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/providers/DeathMarkerProvider.java @@ -1,15 +1,14 @@ -package com.hypixel.hytale.server.core.universe.world.worldmap.markers; +package com.hypixel.hytale.server.core.universe.world.worldmap.markers.providers; import com.hypixel.hytale.math.vector.Transform; import com.hypixel.hytale.protocol.packets.worldmap.MapMarker; -import com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig; import com.hypixel.hytale.server.core.asset.type.gameplay.WorldMapConfig; import com.hypixel.hytale.server.core.entity.entities.Player; import com.hypixel.hytale.server.core.entity.entities.player.data.PlayerDeathPositionData; import com.hypixel.hytale.server.core.entity.entities.player.data.PlayerWorldData; import com.hypixel.hytale.server.core.universe.world.World; -import com.hypixel.hytale.server.core.universe.world.WorldMapTracker; import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager; +import com.hypixel.hytale.server.core.universe.world.worldmap.markers.MapMarkerTracker; import com.hypixel.hytale.server.core.util.PositionUtil; import javax.annotation.Nonnull; @@ -20,10 +19,8 @@ public class DeathMarkerProvider implements WorldMapManager.MarkerProvider { } @Override - public void update( - @Nonnull World world, @Nonnull GameplayConfig gameplayConfig, @Nonnull WorldMapTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ - ) { - WorldMapConfig worldMapConfig = gameplayConfig.getWorldMapConfig(); + public void update(@Nonnull World world, @Nonnull MapMarkerTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ) { + WorldMapConfig worldMapConfig = world.getGameplayConfig().getWorldMapConfig(); if (worldMapConfig.isDisplayDeathMarker()) { Player player = tracker.getPlayer(); PlayerWorldData perWorldData = player.getPlayerConfigData().getPerWorldData(world.getName()); @@ -34,7 +31,7 @@ public class DeathMarkerProvider implements WorldMapManager.MarkerProvider { } } - private static void addDeathMarker(@Nonnull WorldMapTracker tracker, int playerChunkX, int playerChunkZ, @Nonnull PlayerDeathPositionData deathPosition) { + private static void addDeathMarker(@Nonnull MapMarkerTracker tracker, int playerChunkX, int playerChunkZ, @Nonnull PlayerDeathPositionData deathPosition) { String markerId = deathPosition.getMarkerId(); Transform transform = deathPosition.getTransform(); int deathDay = deathPosition.getDay(); diff --git a/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/POIMarkerProvider.java b/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/providers/POIMarkerProvider.java similarity index 71% rename from src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/POIMarkerProvider.java rename to src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/providers/POIMarkerProvider.java index f6281ad..f9f91d4 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/POIMarkerProvider.java +++ b/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/providers/POIMarkerProvider.java @@ -1,10 +1,9 @@ -package com.hypixel.hytale.server.core.universe.world.worldmap.markers; +package com.hypixel.hytale.server.core.universe.world.worldmap.markers.providers; import com.hypixel.hytale.protocol.packets.worldmap.MapMarker; -import com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig; import com.hypixel.hytale.server.core.universe.world.World; -import com.hypixel.hytale.server.core.universe.world.WorldMapTracker; import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager; +import com.hypixel.hytale.server.core.universe.world.worldmap.markers.MapMarkerTracker; import java.util.Map; import javax.annotation.Nonnull; @@ -15,9 +14,7 @@ public class POIMarkerProvider implements WorldMapManager.MarkerProvider { } @Override - public void update( - @Nonnull World world, @Nonnull GameplayConfig gameplayConfig, @Nonnull WorldMapTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ - ) { + public void update(@Nonnull World world, @Nonnull MapMarkerTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ) { Map globalMarkers = world.getWorldMapManager().getPointsOfInterest(); if (!globalMarkers.isEmpty()) { for (MapMarker marker : globalMarkers.values()) { diff --git a/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/PlayerMarkersProvider.java b/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/providers/PerWorldDataMarkerProvider.java similarity index 62% rename from src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/PlayerMarkersProvider.java rename to src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/providers/PerWorldDataMarkerProvider.java index 31c5157..d696f8a 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/PlayerMarkersProvider.java +++ b/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/providers/PerWorldDataMarkerProvider.java @@ -1,24 +1,21 @@ -package com.hypixel.hytale.server.core.universe.world.worldmap.markers; +package com.hypixel.hytale.server.core.universe.world.worldmap.markers.providers; import com.hypixel.hytale.protocol.packets.worldmap.MapMarker; -import com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig; import com.hypixel.hytale.server.core.entity.entities.Player; import com.hypixel.hytale.server.core.entity.entities.player.data.PlayerWorldData; import com.hypixel.hytale.server.core.universe.world.World; -import com.hypixel.hytale.server.core.universe.world.WorldMapTracker; import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager; +import com.hypixel.hytale.server.core.universe.world.worldmap.markers.MapMarkerTracker; import javax.annotation.Nonnull; -public class PlayerMarkersProvider implements WorldMapManager.MarkerProvider { - public static final PlayerMarkersProvider INSTANCE = new PlayerMarkersProvider(); +public class PerWorldDataMarkerProvider implements WorldMapManager.MarkerProvider { + public static final PerWorldDataMarkerProvider INSTANCE = new PerWorldDataMarkerProvider(); - private PlayerMarkersProvider() { + private PerWorldDataMarkerProvider() { } @Override - public void update( - @Nonnull World world, @Nonnull GameplayConfig gameplayConfig, @Nonnull WorldMapTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ - ) { + public void update(@Nonnull World world, @Nonnull MapMarkerTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ) { Player player = tracker.getPlayer(); PlayerWorldData perWorldData = player.getPlayerConfigData().getPerWorldData(world.getName()); MapMarker[] worldMapMarkers = perWorldData.getWorldMapMarkers(); diff --git a/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/providers/PlayerIconMarkerProvider.java b/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/providers/PlayerIconMarkerProvider.java new file mode 100644 index 0000000..b580daa --- /dev/null +++ b/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/providers/PlayerIconMarkerProvider.java @@ -0,0 +1,56 @@ +package com.hypixel.hytale.server.core.universe.world.worldmap.markers.providers; + +import com.hypixel.hytale.math.vector.Transform; +import com.hypixel.hytale.math.vector.Vector3d; +import com.hypixel.hytale.protocol.packets.worldmap.MapMarker; +import com.hypixel.hytale.server.core.asset.type.gameplay.WorldMapConfig; +import com.hypixel.hytale.server.core.entity.entities.Player; +import com.hypixel.hytale.server.core.universe.PlayerRef; +import com.hypixel.hytale.server.core.universe.world.World; +import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager; +import com.hypixel.hytale.server.core.universe.world.worldmap.markers.MapMarkerTracker; +import com.hypixel.hytale.server.core.util.PositionUtil; +import java.util.function.Predicate; +import javax.annotation.Nonnull; + +public class PlayerIconMarkerProvider implements WorldMapManager.MarkerProvider { + public static final PlayerIconMarkerProvider INSTANCE = new PlayerIconMarkerProvider(); + + private PlayerIconMarkerProvider() { + } + + @Override + public void update(@Nonnull World world, @Nonnull MapMarkerTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ) { + WorldMapConfig worldMapConfig = world.getGameplayConfig().getWorldMapConfig(); + if (worldMapConfig.isDisplayPlayers()) { + Player player = tracker.getPlayer(); + int chunkViewRadiusSq = chunkViewRadius * chunkViewRadius; + Predicate playerMapFilter = tracker.getPlayerMapFilter(); + + for (PlayerRef otherPlayer : world.getPlayerRefs()) { + if (!otherPlayer.getUuid().equals(player.getUuid())) { + Transform otherPlayerTransform = otherPlayer.getTransform(); + Vector3d otherPos = otherPlayerTransform.getPosition(); + int otherChunkX = (int)otherPos.x >> 5; + int otherChunkZ = (int)otherPos.z >> 5; + int chunkDiffX = otherChunkX - playerChunkX; + int chunkDiffZ = otherChunkZ - playerChunkZ; + int chunkDistSq = chunkDiffX * chunkDiffX + chunkDiffZ * chunkDiffZ; + if (chunkDistSq <= chunkViewRadiusSq && (playerMapFilter == null || !playerMapFilter.test(otherPlayer))) { + tracker.trySendMarker( + chunkViewRadius, + playerChunkX, + playerChunkZ, + otherPos, + otherPlayer.getHeadRotation().getYaw(), + "Player-" + otherPlayer.getUuid(), + otherPlayer.getUsername(), + otherPlayer, + (id, name, op) -> new MapMarker(id, name, "Player.png", PositionUtil.toTransformPacket(op.getTransform()), null) + ); + } + } + } + } + } +} diff --git a/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/RespawnMarkerProvider.java b/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/providers/RespawnMarkerProvider.java similarity index 76% rename from src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/RespawnMarkerProvider.java rename to src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/providers/RespawnMarkerProvider.java index 892ef0c..10d376f 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/RespawnMarkerProvider.java +++ b/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/providers/RespawnMarkerProvider.java @@ -1,14 +1,13 @@ -package com.hypixel.hytale.server.core.universe.world.worldmap.markers; +package com.hypixel.hytale.server.core.universe.world.worldmap.markers.providers; import com.hypixel.hytale.math.vector.Transform; import com.hypixel.hytale.math.vector.Vector3i; import com.hypixel.hytale.protocol.packets.worldmap.MapMarker; -import com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig; import com.hypixel.hytale.server.core.asset.type.gameplay.WorldMapConfig; import com.hypixel.hytale.server.core.entity.entities.player.data.PlayerRespawnPointData; import com.hypixel.hytale.server.core.universe.world.World; -import com.hypixel.hytale.server.core.universe.world.WorldMapTracker; import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager; +import com.hypixel.hytale.server.core.universe.world.worldmap.markers.MapMarkerTracker; import com.hypixel.hytale.server.core.util.PositionUtil; import javax.annotation.Nonnull; @@ -19,10 +18,8 @@ public class RespawnMarkerProvider implements WorldMapManager.MarkerProvider { } @Override - public void update( - @Nonnull World world, @Nonnull GameplayConfig gameplayConfig, @Nonnull WorldMapTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ - ) { - WorldMapConfig worldMapConfig = gameplayConfig.getWorldMapConfig(); + public void update(@Nonnull World world, @Nonnull MapMarkerTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ) { + WorldMapConfig worldMapConfig = world.getGameplayConfig().getWorldMapConfig(); if (worldMapConfig.isDisplayHome()) { PlayerRespawnPointData[] respawnPoints = tracker.getPlayer().getPlayerConfigData().getPerWorldData(world.getName()).getRespawnPoints(); if (respawnPoints != null) { @@ -34,7 +31,7 @@ public class RespawnMarkerProvider implements WorldMapManager.MarkerProvider { } private static void addRespawnMarker( - @Nonnull WorldMapTracker tracker, int playerChunkX, int playerChunkZ, @Nonnull PlayerRespawnPointData respawnPoint, int index + @Nonnull MapMarkerTracker tracker, int playerChunkX, int playerChunkZ, @Nonnull PlayerRespawnPointData respawnPoint, int index ) { String respawnPointName = respawnPoint.getName(); Vector3i respawnPointPosition = respawnPoint.getBlockPosition(); diff --git a/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/SpawnMarkerProvider.java b/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/providers/SpawnMarkerProvider.java similarity index 78% rename from src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/SpawnMarkerProvider.java rename to src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/providers/SpawnMarkerProvider.java index 63b6a9d..e4aa57c 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/SpawnMarkerProvider.java +++ b/src/com/hypixel/hytale/server/core/universe/world/worldmap/markers/providers/SpawnMarkerProvider.java @@ -1,14 +1,13 @@ -package com.hypixel.hytale.server.core.universe.world.worldmap.markers; +package com.hypixel.hytale.server.core.universe.world.worldmap.markers.providers; import com.hypixel.hytale.math.vector.Transform; import com.hypixel.hytale.math.vector.Vector3d; import com.hypixel.hytale.protocol.packets.worldmap.MapMarker; -import com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig; import com.hypixel.hytale.server.core.asset.type.gameplay.WorldMapConfig; import com.hypixel.hytale.server.core.entity.entities.Player; import com.hypixel.hytale.server.core.universe.world.World; -import com.hypixel.hytale.server.core.universe.world.WorldMapTracker; import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager; +import com.hypixel.hytale.server.core.universe.world.worldmap.markers.MapMarkerTracker; import com.hypixel.hytale.server.core.util.PositionUtil; import javax.annotation.Nonnull; @@ -19,10 +18,8 @@ public class SpawnMarkerProvider implements WorldMapManager.MarkerProvider { } @Override - public void update( - @Nonnull World world, @Nonnull GameplayConfig gameplayConfig, @Nonnull WorldMapTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ - ) { - WorldMapConfig worldMapConfig = gameplayConfig.getWorldMapConfig(); + public void update(@Nonnull World world, @Nonnull MapMarkerTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ) { + WorldMapConfig worldMapConfig = world.getGameplayConfig().getWorldMapConfig(); if (worldMapConfig.isDisplaySpawn()) { Player player = tracker.getPlayer(); Transform spawnPoint = world.getWorldConfig().getSpawnProvider().getSpawnPoint(player); diff --git a/src/com/hypixel/hytale/server/core/universe/world/worldmap/provider/DisabledWorldMapProvider.java b/src/com/hypixel/hytale/server/core/universe/world/worldmap/provider/DisabledWorldMapProvider.java index 3af04e9..7ff8f1a 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/worldmap/provider/DisabledWorldMapProvider.java +++ b/src/com/hypixel/hytale/server/core/universe/world/worldmap/provider/DisabledWorldMapProvider.java @@ -18,9 +18,6 @@ public class DisabledWorldMapProvider implements IWorldMapProvider { public static final BuilderCodec CODEC = BuilderCodec.builder(DisabledWorldMapProvider.class, DisabledWorldMapProvider::new) .build(); - public DisabledWorldMapProvider() { - } - @Nonnull @Override public IWorldMap getGenerator(World world) throws WorldMapLoadException { @@ -36,9 +33,6 @@ public class DisabledWorldMapProvider implements IWorldMapProvider { static class DisabledWorldMap implements IWorldMap { public static final IWorldMap INSTANCE = new DisabledWorldMapProvider.DisabledWorldMap(); - DisabledWorldMap() { - } - @Nonnull @Override public WorldMapSettings getWorldMapSettings() { diff --git a/src/com/hypixel/hytale/server/core/universe/world/worldmap/provider/chunk/ChunkWorldMap.java b/src/com/hypixel/hytale/server/core/universe/world/worldmap/provider/chunk/ChunkWorldMap.java index a1769b4..0a42631 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/worldmap/provider/chunk/ChunkWorldMap.java +++ b/src/com/hypixel/hytale/server/core/universe/world/worldmap/provider/chunk/ChunkWorldMap.java @@ -16,9 +16,6 @@ import javax.annotation.Nonnull; public class ChunkWorldMap implements IWorldMap { public static final ChunkWorldMap INSTANCE = new ChunkWorldMap(); - public ChunkWorldMap() { - } - @Nonnull @Override public WorldMapSettings getWorldMapSettings() { diff --git a/src/com/hypixel/hytale/server/core/universe/world/worldmap/provider/chunk/ImageBuilder.java b/src/com/hypixel/hytale/server/core/universe/world/worldmap/provider/chunk/ImageBuilder.java index ad328c1..c00c60f 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/worldmap/provider/chunk/ImageBuilder.java +++ b/src/com/hypixel/hytale/server/core/universe/world/worldmap/provider/chunk/ImageBuilder.java @@ -2,6 +2,7 @@ package com.hypixel.hytale.server.core.universe.world.worldmap.provider.chunk; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.math.util.ChunkUtil; +import com.hypixel.hytale.protocol.ShaderType; import com.hypixel.hytale.protocol.packets.worldmap.MapImage; import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType; import com.hypixel.hytale.server.core.asset.type.environment.config.Environment; @@ -400,26 +401,30 @@ class ImageBuilder { int tintColorR = 255; int tintColorG = 255; int tintColorB = 255; - Environment environment = Environment.getAssetMap().getAsset(environmentId); - com.hypixel.hytale.protocol.Color waterTint = environment.getWaterTint(); - if (waterTint != null) { - tintColorR = tintColorR * (waterTint.red & 255) / 255; - tintColorG = tintColorG * (waterTint.green & 255) / 255; - tintColorB = tintColorB * (waterTint.blue & 255) / 255; - } - Fluid fluid = Fluid.getAssetMap().getAsset(fluidId); - com.hypixel.hytale.protocol.Color partcileColor = fluid.getParticleColor(); - if (partcileColor != null) { - tintColorR = tintColorR * (partcileColor.red & 255) / 255; - tintColorG = tintColorG * (partcileColor.green & 255) / 255; - tintColorB = tintColorB * (partcileColor.blue & 255) / 255; - } + if (fluid != null) { + if (fluid.hasEffect(ShaderType.Water)) { + Environment environment = Environment.getAssetMap().getAsset(environmentId); + com.hypixel.hytale.protocol.Color waterTint = environment.getWaterTint(); + if (waterTint != null) { + tintColorR = tintColorR * (waterTint.red & 255) / 255; + tintColorG = tintColorG * (waterTint.green & 255) / 255; + tintColorB = tintColorB * (waterTint.blue & 255) / 255; + } + } - float depthMultiplier = Math.min(1.0F, 1.0F / fluidDepth); - outColor.r = (int)(tintColorR + ((outColor.r & 0xFF) - tintColorR) * depthMultiplier) & 0xFF; - outColor.g = (int)(tintColorG + ((outColor.g & 0xFF) - tintColorG) * depthMultiplier) & 0xFF; - outColor.b = (int)(tintColorB + ((outColor.b & 0xFF) - tintColorB) * depthMultiplier) & 0xFF; + com.hypixel.hytale.protocol.Color partcileColor = fluid.getParticleColor(); + if (partcileColor != null) { + tintColorR = tintColorR * (partcileColor.red & 255) / 255; + tintColorG = tintColorG * (partcileColor.green & 255) / 255; + tintColorB = tintColorB * (partcileColor.blue & 255) / 255; + } + + float depthMultiplier = Math.min(1.0F, 1.0F / fluidDepth); + outColor.r = (int)(tintColorR + ((outColor.r & 0xFF) - tintColorR) * depthMultiplier) & 0xFF; + outColor.g = (int)(tintColorG + ((outColor.g & 0xFF) - tintColorG) * depthMultiplier) & 0xFF; + outColor.b = (int)(tintColorB + ((outColor.b & 0xFF) - tintColorB) * depthMultiplier) & 0xFF; + } } @Nonnull @@ -436,9 +441,6 @@ class ImageBuilder { public int b; public int a; - private Color() { - } - public int pack() { return (this.r & 0xFF) << 24 | (this.g & 0xFF) << 16 | (this.b & 0xFF) << 8 | this.a & 0xFF; } diff --git a/src/com/hypixel/hytale/server/core/universe/world/worldmap/provider/chunk/WorldGenWorldMapProvider.java b/src/com/hypixel/hytale/server/core/universe/world/worldmap/provider/chunk/WorldGenWorldMapProvider.java index 9152723..2c3f778 100644 --- a/src/com/hypixel/hytale/server/core/universe/world/worldmap/provider/chunk/WorldGenWorldMapProvider.java +++ b/src/com/hypixel/hytale/server/core/universe/world/worldmap/provider/chunk/WorldGenWorldMapProvider.java @@ -13,9 +13,6 @@ public class WorldGenWorldMapProvider implements IWorldMapProvider { public static final BuilderCodec CODEC = BuilderCodec.builder(WorldGenWorldMapProvider.class, WorldGenWorldMapProvider::new) .build(); - public WorldGenWorldMapProvider() { - } - @Override public IWorldMap getGenerator(@Nonnull World world) throws WorldMapLoadException { IWorldGen generator = world.getChunkStore().getGenerator(); diff --git a/src/com/hypixel/hytale/server/core/update/UpdateModule.java b/src/com/hypixel/hytale/server/core/update/UpdateModule.java new file mode 100644 index 0000000..a0c4d58 --- /dev/null +++ b/src/com/hypixel/hytale/server/core/update/UpdateModule.java @@ -0,0 +1,415 @@ +package com.hypixel.hytale.server.core.update; + +import com.hypixel.hytale.common.plugin.PluginManifest; +import com.hypixel.hytale.common.util.SystemUtil; +import com.hypixel.hytale.common.util.java.ManifestUtil; +import com.hypixel.hytale.logger.HytaleLogger; +import com.hypixel.hytale.server.core.Constants; +import com.hypixel.hytale.server.core.HytaleServer; +import com.hypixel.hytale.server.core.HytaleServerConfig; +import com.hypixel.hytale.server.core.Message; +import com.hypixel.hytale.server.core.ShutdownReason; +import com.hypixel.hytale.server.core.auth.ServerAuthManager; +import com.hypixel.hytale.server.core.permissions.PermissionsModule; +import com.hypixel.hytale.server.core.plugin.JavaPlugin; +import com.hypixel.hytale.server.core.plugin.JavaPluginInit; +import com.hypixel.hytale.server.core.universe.PlayerRef; +import com.hypixel.hytale.server.core.universe.Universe; +import com.hypixel.hytale.server.core.update.command.UpdateCommand; +import java.awt.Color; +import java.util.concurrent.CancellationException; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; +import java.util.logging.Level; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class UpdateModule extends JavaPlugin { + public static final PluginManifest MANIFEST = PluginManifest.corePlugin(UpdateModule.class).build(); + private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); + public static final boolean KILL_SWITCH_ENABLED = SystemUtil.getEnvBoolean("HYTALE_DISABLE_UPDATES"); + private static UpdateModule instance; + private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(r -> { + Thread t = new Thread(r, "UpdateChecker"); + t.setDaemon(true); + return t; + }); + @Nullable + private ScheduledFuture updateCheckTask; + @Nullable + private ScheduledFuture autoApplyTask; + private final AtomicReference latestKnownVersion = new AtomicReference<>(); + private final AtomicReference> activeDownload = new AtomicReference<>(); + private final AtomicReference activeDownloadThread = new AtomicReference<>(); + private final AtomicBoolean downloadLock = new AtomicBoolean(false); + private final AtomicLong downloadStartTime = new AtomicLong(0L); + private final AtomicLong downloadedBytes = new AtomicLong(0L); + private final AtomicLong totalBytes = new AtomicLong(0L); + private final AtomicLong autoApplyScheduledTime = new AtomicLong(0L); + private final AtomicLong lastWarningTime = new AtomicLong(0L); + + public UpdateModule(@Nonnull JavaPluginInit init) { + super(init); + instance = this; + } + + @Nullable + public static UpdateModule get() { + return instance; + } + + @Override + protected void setup() { + if (KILL_SWITCH_ENABLED) { + LOGGER.at(Level.INFO).log("Update commands disabled via HYTALE_DISABLE_UPDATES environment variable"); + } + + this.getCommandRegistry().registerCommand(new UpdateCommand()); + } + + @Override + protected void start() { + if (!KILL_SWITCH_ENABLED) { + String stagedVersion = UpdateService.getStagedVersion(); + if (stagedVersion != null) { + this.logStagedUpdateWarning(stagedVersion, true); + this.startAutoApplyTaskIfNeeded(); + } + + if (this.shouldEnableUpdateChecker()) { + HytaleServerConfig.UpdateConfig config = HytaleServer.get().getConfig().getUpdateConfig(); + int intervalSeconds = config.getCheckIntervalSeconds(); + LOGGER.at(Level.INFO).log("Update checker enabled (interval: %ds)", intervalSeconds); + this.updateCheckTask = this.scheduler.scheduleAtFixedRate(this::performUpdateCheck, 60L, intervalSeconds, TimeUnit.SECONDS); + } + } + } + + private synchronized void startAutoApplyTaskIfNeeded() { + if (this.autoApplyTask == null) { + HytaleServerConfig.UpdateConfig config = HytaleServer.get().getConfig().getUpdateConfig(); + HytaleServerConfig.UpdateConfig.AutoApplyMode autoApplyMode = config.getAutoApplyMode(); + if (autoApplyMode != HytaleServerConfig.UpdateConfig.AutoApplyMode.DISABLED) { + LOGGER.at(Level.INFO).log("Starting auto-apply task (mode: %s, delay: %d min)", autoApplyMode, config.getAutoApplyDelayMinutes()); + this.autoApplyTask = this.scheduler.scheduleAtFixedRate(this::performAutoApplyCheck, 0L, 60L, TimeUnit.SECONDS); + } + } + } + + @Override + protected void shutdown() { + if (this.updateCheckTask != null) { + this.updateCheckTask.cancel(false); + } + + if (this.autoApplyTask != null) { + this.autoApplyTask.cancel(false); + } + + this.scheduler.shutdown(); + } + + public void onServerReady() { + if (!KILL_SWITCH_ENABLED) { + String stagedVersion = UpdateService.getStagedVersion(); + if (stagedVersion != null) { + this.logStagedUpdateWarning(stagedVersion, false); + } + } + } + + @Nullable + public UpdateService.VersionManifest getLatestKnownVersion() { + return this.latestKnownVersion.get(); + } + + public void setLatestKnownVersion(@Nullable UpdateService.VersionManifest version) { + this.latestKnownVersion.set(version); + } + + public boolean isDownloadInProgress() { + return this.downloadLock.get(); + } + + public boolean tryAcquireDownloadLock() { + return this.downloadLock.compareAndSet(false, true); + } + + public void setActiveDownload(@Nullable CompletableFuture download, @Nullable Thread thread) { + this.activeDownload.set(download); + this.activeDownloadThread.set(thread); + } + + public void releaseDownloadLock() { + this.activeDownload.set(null); + this.activeDownloadThread.set(null); + this.downloadLock.set(false); + this.downloadStartTime.set(0L); + this.downloadedBytes.set(0L); + this.totalBytes.set(0L); + } + + public void updateDownloadProgress(long downloaded, long total) { + if (this.downloadStartTime.get() == 0L) { + this.downloadStartTime.set(System.currentTimeMillis()); + } + + this.downloadedBytes.set(downloaded); + this.totalBytes.set(total); + } + + @Nullable + public UpdateModule.DownloadProgress getDownloadProgress() { + if (!this.downloadLock.get()) { + return null; + } else { + long start = this.downloadStartTime.get(); + long downloaded = this.downloadedBytes.get(); + long total = this.totalBytes.get(); + if (start != 0L && total > 0L) { + int percent = (int)(downloaded * 100L / total); + long elapsed = System.currentTimeMillis() - start; + long etaSeconds = -1L; + if (elapsed > 0L && downloaded > 0L) { + double bytesPerMs = (double)downloaded / elapsed; + long remaining = total - downloaded; + etaSeconds = (long)(remaining / bytesPerMs / 1000.0); + } + + return new UpdateModule.DownloadProgress(percent, downloaded, total, etaSeconds); + } else { + return new UpdateModule.DownloadProgress(0, 0L, total, -1L); + } + } + } + + public boolean cancelDownload() { + CompletableFuture download = this.activeDownload.getAndSet(null); + Thread thread = this.activeDownloadThread.getAndSet(null); + if (thread != null) { + thread.interrupt(); + } + + if (download == null && thread == null) { + return false; + } else { + if (download != null) { + download.cancel(true); + } + + this.releaseDownloadLock(); + return true; + } + } + + private boolean shouldEnableUpdateChecker() { + if (!ManifestUtil.isJar()) { + LOGGER.at(Level.INFO).log("Update checker disabled: not running from JAR"); + return false; + } else if (Constants.SINGLEPLAYER) { + LOGGER.at(Level.INFO).log("Update checker disabled: singleplayer mode"); + return false; + } else { + HytaleServerConfig.UpdateConfig config = HytaleServer.get().getConfig().getUpdateConfig(); + if (!config.isEnabled()) { + LOGGER.at(Level.INFO).log("Update checker disabled: disabled in config"); + return false; + } else { + String manifestPatchline = ManifestUtil.getPatchline(); + String configPatchline = config.getPatchline(); + if (!"dev".equals(manifestPatchline) || configPatchline != null && !configPatchline.isEmpty()) { + if (!UpdateService.isValidUpdateLayout()) { + LOGGER.at(Level.WARNING) + .log("Update checker disabled: invalid folder layout. Expected to run from Server/ with Assets.zip and start.sh/bat in parent directory."); + return false; + } else { + return true; + } + } else { + LOGGER.at(Level.INFO).log("Update checker disabled: dev patchline (set Patchline in config to override)"); + return false; + } + } + } + } + + private void performUpdateCheck() { + ServerAuthManager authManager = ServerAuthManager.getInstance(); + if (!authManager.hasSessionToken()) { + LOGGER.at(Level.FINE).log("Not authenticated - skipping update check"); + } else { + String stagedVersion = UpdateService.getStagedVersion(); + if (stagedVersion != null) { + LOGGER.at(Level.FINE).log("Staged update already exists (%s) - skipping update check", stagedVersion); + this.startAutoApplyTaskIfNeeded(); + } else if (this.isDownloadInProgress()) { + LOGGER.at(Level.FINE).log("Download in progress - skipping update check"); + } else { + UpdateService updateService = new UpdateService(); + String patchline = UpdateService.getEffectivePatchline(); + updateService.checkForUpdate(patchline).thenAccept(manifest -> { + if (manifest == null) { + LOGGER.at(Level.FINE).log("Update check returned no result"); + } else { + this.setLatestKnownVersion(manifest); + String currentVersion = ManifestUtil.getImplementationVersion(); + if (currentVersion != null && currentVersion.equals(manifest.version)) { + LOGGER.at(Level.FINE).log("Already running latest version: %s", currentVersion); + } else { + this.logUpdateAvailable(currentVersion, manifest.version); + HytaleServerConfig.UpdateConfig config = HytaleServer.get().getConfig().getUpdateConfig(); + if (config.isNotifyPlayersOnAvailable()) { + this.notifyPlayers(manifest.version); + } + + if (config.getAutoApplyMode() != HytaleServerConfig.UpdateConfig.AutoApplyMode.DISABLED) { + LOGGER.at(Level.INFO).log("Auto-downloading update %s...", manifest.version); + this.autoDownloadUpdate(updateService, manifest); + } + } + } + }); + } + } + } + + private void autoDownloadUpdate(@Nonnull UpdateService updateService, @Nonnull UpdateService.VersionManifest manifest) { + if (UpdateService.getStagedVersion() == null && this.tryAcquireDownloadLock()) { + UpdateService.DownloadTask downloadTask = updateService.downloadUpdate( + manifest, UpdateService.getStagingDir(), (percent, downloaded, total) -> this.updateDownloadProgress(downloaded, total) + ); + CompletableFuture downloadFuture = downloadTask.future().whenComplete((success, error) -> { + this.releaseDownloadLock(); + if (Boolean.TRUE.equals(success)) { + LOGGER.at(Level.INFO).log("Update %s downloaded and staged", manifest.version); + this.startAutoApplyTaskIfNeeded(); + } else if (error instanceof CancellationException) { + LOGGER.at(Level.INFO).log("Download of update %s was cancelled", manifest.version); + UpdateService.deleteStagedUpdate(); + } else { + LOGGER.at(Level.WARNING).log("Failed to download update %s: %s", manifest.version, error != null ? error.getMessage() : "unknown error"); + UpdateService.deleteStagedUpdate(); + } + }); + this.setActiveDownload(downloadFuture, downloadTask.thread()); + } + } + + private void performAutoApplyCheck() { + String stagedVersion = UpdateService.getStagedVersion(); + if (stagedVersion == null) { + if (this.autoApplyScheduledTime.getAndSet(0L) != 0L) { + LOGGER.at(Level.FINE).log("No staged update - clearing auto-apply schedule"); + } + + this.lastWarningTime.set(0L); + } else { + LOGGER.at(Level.FINE).log("Auto-apply check: staged version %s", stagedVersion); + this.checkAutoApply(stagedVersion); + } + } + + private void logUpdateAvailable(@Nullable String currentVersion, @Nonnull String latestVersion) { + LOGGER.at(Level.INFO).log("Update available: %s (current: %s)", latestVersion, currentVersion); + HytaleServerConfig.UpdateConfig config = HytaleServer.get().getConfig().getUpdateConfig(); + if (config.getAutoApplyMode() == HytaleServerConfig.UpdateConfig.AutoApplyMode.DISABLED) { + LOGGER.at(Level.INFO).log("Run '/update download' to stage the update"); + } + } + + private void logStagedUpdateWarning(@Nullable String version, boolean isStartup) { + String border = "\u001b[0;33m==============================================================================================="; + LOGGER.at(Level.INFO).log(border); + if (isStartup) { + LOGGER.at(Level.INFO).log("%s WARNING: Staged update %s not applied!", "\u001b[0;33m", version != null ? version : "unknown"); + LOGGER.at(Level.INFO).log("%s Use launcher script (start.sh/bat) or manually move files from updater/staging/", "\u001b[0;33m"); + } else { + LOGGER.at(Level.INFO).log("%s REMINDER: Staged update %s waiting to be applied", "\u001b[0;33m", version != null ? version : "unknown"); + LOGGER.at(Level.INFO).log("%s Run '/update status' for details or '/update cancel' to abort", "\u001b[0;33m"); + } + + LOGGER.at(Level.INFO).log(border); + } + + private void checkAutoApply(@Nonnull String stagedVersion) { + HytaleServerConfig.UpdateConfig config = HytaleServer.get().getConfig().getUpdateConfig(); + HytaleServerConfig.UpdateConfig.AutoApplyMode mode = config.getAutoApplyMode(); + if (mode != HytaleServerConfig.UpdateConfig.AutoApplyMode.DISABLED) { + Universe universe = Universe.get(); + if (universe != null) { + int playerCount = universe.getPlayers().size(); + if (playerCount == 0) { + LOGGER.at(Level.INFO).log("No players online - auto-applying update %s", stagedVersion); + this.triggerAutoApply(); + } else if (mode != HytaleServerConfig.UpdateConfig.AutoApplyMode.WHEN_EMPTY) { + int delayMinutes = config.getAutoApplyDelayMinutes(); + long now = System.currentTimeMillis(); + long applyTime = now + delayMinutes * 60 * 1000L; + if (this.autoApplyScheduledTime.compareAndSet(0L, applyTime)) { + LOGGER.at(Level.INFO).log("Update %s will be auto-applied in %d minutes (players online: %d)", stagedVersion, delayMinutes, playerCount); + this.broadcastToPlayers( + Message.translation("server.update.auto_apply_warning").param("version", stagedVersion).param("minutes", delayMinutes).color(Color.YELLOW) + ); + } else { + long scheduledTime = this.autoApplyScheduledTime.get(); + if (now >= scheduledTime - 2000L) { + LOGGER.at(Level.INFO).log("Auto-apply delay expired - applying update %s", stagedVersion); + this.broadcastToPlayers(Message.translation("server.update.auto_apply_now").param("version", stagedVersion).color(Color.RED)); + this.triggerAutoApply(); + } else { + long remainingMinutes = (scheduledTime - now) / 60000L; + long warnInterval = remainingMinutes <= 1L ? 30000L : 300000L; + long lastWarn = this.lastWarningTime.get(); + if (now - lastWarn >= warnInterval && this.lastWarningTime.compareAndSet(lastWarn, now)) { + LOGGER.at(Level.INFO).log("Update %s will be auto-applied in %d minute(s)", stagedVersion, Math.max(1L, remainingMinutes)); + this.broadcastToPlayers( + Message.translation("server.update.auto_apply_warning") + .param("version", stagedVersion) + .param("minutes", Math.max(1L, remainingMinutes)) + .color(Color.YELLOW) + ); + } + } + } + } + } + } + } + + private void triggerAutoApply() { + this.autoApplyScheduledTime.set(0L); + HytaleServer.get().shutdownServer(ShutdownReason.UPDATE); + } + + private void broadcastToPlayers(@Nonnull Message message) { + Universe universe = Universe.get(); + if (universe != null) { + for (PlayerRef player : universe.getPlayers()) { + player.sendMessage(message); + } + } + } + + private void notifyPlayers(@Nonnull String version) { + Universe universe = Universe.get(); + if (universe != null) { + Message message = Message.translation("server.update.notify_players").param("version", version); + PermissionsModule permissionsModule = PermissionsModule.get(); + + for (PlayerRef player : universe.getPlayers()) { + if (permissionsModule.hasPermission(player.getUuid(), "hytale.system.update.notify")) { + player.sendMessage(message); + } + } + } + } + + public record DownloadProgress(int percent, long downloadedBytes, long totalBytes, long etaSeconds) { + } +} diff --git a/src/com/hypixel/hytale/server/core/update/UpdateService.java b/src/com/hypixel/hytale/server/core/update/UpdateService.java new file mode 100644 index 0000000..fd66b04 --- /dev/null +++ b/src/com/hypixel/hytale/server/core/update/UpdateService.java @@ -0,0 +1,382 @@ +package com.hypixel.hytale.server.core.update; + +import com.hypixel.hytale.codec.Codec; +import com.hypixel.hytale.codec.EmptyExtraInfo; +import com.hypixel.hytale.codec.KeyedCodec; +import com.hypixel.hytale.codec.builder.BuilderCodec; +import com.hypixel.hytale.codec.util.RawJsonReader; +import com.hypixel.hytale.common.util.java.ManifestUtil; +import com.hypixel.hytale.logger.HytaleLogger; +import com.hypixel.hytale.server.core.HytaleServer; +import com.hypixel.hytale.server.core.HytaleServerConfig; +import com.hypixel.hytale.server.core.auth.AuthConfig; +import com.hypixel.hytale.server.core.auth.ServerAuthManager; +import com.hypixel.hytale.server.core.util.io.FileUtil; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.http.HttpClient.Redirect; +import java.net.http.HttpResponse.BodyHandlers; +import java.nio.file.Files; +import java.nio.file.Path; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.time.Duration; +import java.util.HexFormat; +import java.util.concurrent.CancellationException; +import java.util.concurrent.CompletableFuture; +import java.util.jar.Attributes; +import java.util.jar.JarFile; +import java.util.jar.Manifest; +import java.util.logging.Level; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class UpdateService { + private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); + private static final Duration REQUEST_TIMEOUT = Duration.ofSeconds(30L); + private static final Duration DOWNLOAD_TIMEOUT = Duration.ofMinutes(30L); + private static final Path STAGING_DIR = Path.of("..").resolve("updater").resolve("staging"); + private static final Path BACKUP_DIR = Path.of("..").resolve("updater").resolve("backup"); + private final HttpClient httpClient; + private final String accountDataUrl = "https://account-data.hytale.com"; + + public UpdateService() { + this.httpClient = HttpClient.newBuilder().connectTimeout(REQUEST_TIMEOUT).followRedirects(Redirect.NORMAL).build(); + } + + @Nullable + public CompletableFuture checkForUpdate(@Nonnull String patchline) { + return CompletableFuture.supplyAsync( + () -> { + try { + ServerAuthManager authManager = ServerAuthManager.getInstance(); + String accessToken = authManager.getOAuthAccessToken(); + if (accessToken == null) { + LOGGER.at(Level.WARNING).log("Cannot check for updates - not authenticated"); + return null; + } else { + String manifestPath = String.format("version/%s.json", patchline); + String signedUrl = this.getSignedUrl(accessToken, manifestPath); + if (signedUrl == null) { + LOGGER.at(Level.WARNING).log("Failed to get signed URL for version manifest"); + return null; + } else { + HttpRequest manifestRequest = HttpRequest.newBuilder() + .uri(URI.create(signedUrl)) + .header("Accept", "application/json") + .timeout(REQUEST_TIMEOUT) + .GET() + .build(); + HttpResponse response = this.httpClient.send(manifestRequest, BodyHandlers.ofString()); + if (response.statusCode() != 200) { + LOGGER.at(Level.WARNING).log("Failed to fetch version manifest: HTTP %d", response.statusCode()); + return null; + } else { + UpdateService.VersionManifest manifest = UpdateService.VersionManifest.CODEC + .decodeJson(new RawJsonReader(response.body().toCharArray()), EmptyExtraInfo.EMPTY); + if (manifest != null && manifest.version != null) { + LOGGER.at(Level.INFO).log("Found version: %s", manifest.version); + return manifest; + } else { + LOGGER.at(Level.WARNING).log("Invalid version manifest response"); + return null; + } + } + } + } + } catch (IOException var9) { + LOGGER.at(Level.WARNING).log("IO error checking for updates: %s", var9.getMessage()); + return null; + } catch (InterruptedException var10) { + Thread.currentThread().interrupt(); + LOGGER.at(Level.WARNING).log("Update check interrupted"); + return null; + } catch (Exception var11) { + LOGGER.at(Level.WARNING).withCause(var11).log("Error checking for updates"); + return null; + } + } + ); + } + + public UpdateService.DownloadTask downloadUpdate( + @Nonnull UpdateService.VersionManifest manifest, @Nonnull Path stagingDir, @Nullable UpdateService.ProgressCallback progressCallback + ) { + CompletableFuture future = new CompletableFuture<>(); + Thread thread = new Thread(() -> { + try { + boolean result = this.performDownload(manifest, stagingDir, progressCallback); + future.complete(result); + } catch (CancellationException var6) { + future.completeExceptionally(var6); + } catch (InterruptedException var7) { + Thread.currentThread().interrupt(); + future.completeExceptionally(new CancellationException("Update download interrupted")); + } catch (Exception var8) { + LOGGER.at(Level.WARNING).withCause(var8).log("Error downloading update"); + future.complete(false); + } + }, "UpdateDownload"); + thread.setDaemon(true); + thread.start(); + return new UpdateService.DownloadTask(future, thread); + } + + private boolean performDownload( + @Nonnull UpdateService.VersionManifest manifest, @Nonnull Path stagingDir, @Nullable UpdateService.ProgressCallback progressCallback + ) throws IOException, InterruptedException { + ServerAuthManager authManager = ServerAuthManager.getInstance(); + String accessToken = authManager.getOAuthAccessToken(); + if (accessToken == null) { + LOGGER.at(Level.WARNING).log("Cannot download update - not authenticated"); + return false; + } else { + String signedUrl = this.getSignedUrl(accessToken, manifest.downloadUrl); + if (signedUrl == null) { + LOGGER.at(Level.WARNING).log("Failed to get signed URL for download"); + return false; + } else { + HttpRequest downloadRequest = HttpRequest.newBuilder().uri(URI.create(signedUrl)).timeout(DOWNLOAD_TIMEOUT).GET().build(); + Path tempFile = Files.createTempFile("hytale-update-", ".zip"); + + boolean var36; + try { + HttpResponse response = this.httpClient.send(downloadRequest, BodyHandlers.ofInputStream()); + if (response.statusCode() != 200) { + LOGGER.at(Level.WARNING).log("Failed to download update: HTTP %d", response.statusCode()); + return false; + } + + long contentLength = response.headers().firstValueAsLong("Content-Length").orElse(-1L); + + MessageDigest digest; + try { + digest = MessageDigest.getInstance("SHA-256"); + } catch (NoSuchAlgorithmException var31) { + LOGGER.at(Level.SEVERE).log("SHA-256 not available - this should never happen"); + return false; + } + + try ( + InputStream inputStream = response.body(); + OutputStream outputStream = Files.newOutputStream(tempFile); + ) { + byte[] buffer = new byte[8192]; + long downloaded = 0L; + + int read; + while ((read = inputStream.read(buffer)) != -1) { + if (Thread.currentThread().isInterrupted()) { + throw new CancellationException("Update download cancelled"); + } + + outputStream.write(buffer, 0, read); + digest.update(buffer, 0, read); + downloaded += read; + if (progressCallback != null && contentLength > 0L) { + int percent = (int)(downloaded * 100L / contentLength); + progressCallback.onProgress(percent, downloaded, contentLength); + } + } + } + + String actualHash = HexFormat.of().formatHex(digest.digest()); + if (manifest.sha256 == null || manifest.sha256.equalsIgnoreCase(actualHash)) { + if (clearStagingDir(stagingDir)) { + Files.createDirectories(stagingDir); + if (Thread.currentThread().isInterrupted()) { + throw new CancellationException("Update download cancelled"); + } + + FileUtil.extractZip(tempFile, stagingDir); + LOGGER.at(Level.INFO).log("Update %s downloaded and extracted to staging", manifest.version); + return true; + } + + LOGGER.at(Level.WARNING).log("Failed to clear staging directory before extraction"); + return false; + } + + LOGGER.at(Level.WARNING).log("Checksum mismatch! Expected: %s, Got: %s", manifest.sha256, actualHash); + var36 = false; + } finally { + Files.deleteIfExists(tempFile); + } + + return var36; + } + } + } + + @Nullable + private String getSignedUrl(String accessToken, String path) throws IOException, InterruptedException { + String url = this.accountDataUrl + "/game-assets/" + path; + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create(url)) + .header("Accept", "application/json") + .header("Authorization", "Bearer " + accessToken) + .header("User-Agent", AuthConfig.USER_AGENT) + .timeout(REQUEST_TIMEOUT) + .GET() + .build(); + HttpResponse response = this.httpClient.send(request, BodyHandlers.ofString()); + if (response.statusCode() != 200) { + LOGGER.at(Level.WARNING).log("Failed to get signed URL: HTTP %d - %s", response.statusCode(), response.body()); + return null; + } else { + UpdateService.SignedUrlResponse signedResponse = UpdateService.SignedUrlResponse.CODEC + .decodeJson(new RawJsonReader(response.body().toCharArray()), EmptyExtraInfo.EMPTY); + return signedResponse != null ? signedResponse.url : null; + } + } + + @Nonnull + public static String getEffectivePatchline() { + HytaleServerConfig.UpdateConfig config = HytaleServer.get().getConfig().getUpdateConfig(); + String patchline = config.getPatchline(); + if (patchline != null && !patchline.isEmpty()) { + return patchline; + } else { + patchline = ManifestUtil.getPatchline(); + return patchline != null ? patchline : "release"; + } + } + + public static boolean isValidUpdateLayout() { + Path parent = Path.of("..").toAbsolutePath(); + return Files.exists(parent.resolve("Assets.zip")) && (Files.exists(parent.resolve("start.sh")) || Files.exists(parent.resolve("start.bat"))); + } + + @Nonnull + public static Path getStagingDir() { + return STAGING_DIR; + } + + @Nonnull + public static Path getBackupDir() { + return BACKUP_DIR; + } + + @Nullable + public static String getStagedVersion() { + Path stagedJar = STAGING_DIR.resolve("Server").resolve("HytaleServer.jar"); + return !Files.exists(stagedJar) ? null : readVersionFromJar(stagedJar); + } + + public static boolean deleteStagedUpdate() { + return safeDeleteUpdaterDir(STAGING_DIR, "staging"); + } + + public static boolean deleteBackupDir() { + return safeDeleteUpdaterDir(BACKUP_DIR, "backup"); + } + + private static boolean clearStagingDir(@Nonnull Path stagingDir) { + if (!Files.exists(stagingDir)) { + return true; + } else if (stagingDir.toAbsolutePath().normalize().equals(STAGING_DIR.toAbsolutePath().normalize())) { + return deleteStagedUpdate(); + } else { + try { + FileUtil.deleteDirectory(stagingDir); + return true; + } catch (IOException var2) { + LOGGER.at(Level.WARNING).log("Failed to delete staging dir %s: %s", stagingDir, var2.getMessage()); + return false; + } + } + } + + private static boolean safeDeleteUpdaterDir(Path dir, String expectedName) { + try { + if (!Files.exists(dir)) { + return true; + } else { + Path absolute = dir.toAbsolutePath().normalize(); + Path parent = absolute.getParent(); + if (parent == null || !parent.getFileName().toString().equals("updater")) { + LOGGER.at(Level.SEVERE).log("Refusing to delete %s - not within updater/ directory", absolute); + return false; + } else if (!absolute.getFileName().toString().equals(expectedName)) { + LOGGER.at(Level.SEVERE).log("Refusing to delete %s - unexpected directory name", absolute); + return false; + } else { + FileUtil.deleteDirectory(dir); + return true; + } + } + } catch (IOException var4) { + LOGGER.at(Level.WARNING).log("Failed to delete %s: %s", dir, var4.getMessage()); + return false; + } + } + + @Nullable + public static String readVersionFromJar(@Nonnull Path jarPath) { + try { + String var5; + try (JarFile jarFile = new JarFile(jarPath.toFile())) { + Manifest manifest = jarFile.getManifest(); + if (manifest == null) { + return null; + } + + Attributes attrs = manifest.getMainAttributes(); + String vendorId = attrs.getValue("Implementation-Vendor-Id"); + if (!"com.hypixel.hytale".equals(vendorId)) { + return null; + } + + var5 = attrs.getValue("Implementation-Version"); + } + + return var5; + } catch (IOException var8) { + LOGGER.at(Level.WARNING).log("Failed to read version from JAR: %s", var8.getMessage()); + return null; + } + } + + private static KeyedCodec externalKey(String key, Codec codec) { + return new KeyedCodec<>(key, codec, false, true); + } + + public record DownloadTask(CompletableFuture future, Thread thread) { + } + + @FunctionalInterface + public interface ProgressCallback { + void onProgress(int var1, long var2, long var4); + } + + private static class SignedUrlResponse { + public String url; + public static final BuilderCodec CODEC = BuilderCodec.builder( + UpdateService.SignedUrlResponse.class, UpdateService.SignedUrlResponse::new + ) + .append(UpdateService.externalKey("url", Codec.STRING), (r, v) -> r.url = v, r -> r.url) + .add() + .build(); + } + + public static class VersionManifest { + public String version; + public String downloadUrl; + public String sha256; + public static final BuilderCodec CODEC = BuilderCodec.builder( + UpdateService.VersionManifest.class, UpdateService.VersionManifest::new + ) + .append(UpdateService.externalKey("version", Codec.STRING), (m, v) -> m.version = v, m -> m.version) + .add() + .append(UpdateService.externalKey("download_url", Codec.STRING), (m, v) -> m.downloadUrl = v, m -> m.downloadUrl) + .add() + .append(UpdateService.externalKey("sha256", Codec.STRING), (m, v) -> m.sha256 = v, m -> m.sha256) + .add() + .build(); + } +} diff --git a/src/com/hypixel/hytale/server/core/update/command/UpdateApplyCommand.java b/src/com/hypixel/hytale/server/core/update/command/UpdateApplyCommand.java new file mode 100644 index 0000000..ea66748 --- /dev/null +++ b/src/com/hypixel/hytale/server/core/update/command/UpdateApplyCommand.java @@ -0,0 +1,122 @@ +package com.hypixel.hytale.server.core.update.command; + +import com.hypixel.hytale.logger.HytaleLogger; +import com.hypixel.hytale.server.core.HytaleServer; +import com.hypixel.hytale.server.core.HytaleServerConfig; +import com.hypixel.hytale.server.core.Message; +import com.hypixel.hytale.server.core.Options; +import com.hypixel.hytale.server.core.ShutdownReason; +import com.hypixel.hytale.server.core.command.system.CommandContext; +import com.hypixel.hytale.server.core.command.system.arguments.system.FlagArg; +import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase; +import com.hypixel.hytale.server.core.universe.Universe; +import com.hypixel.hytale.server.core.update.UpdateService; +import com.hypixel.hytale.server.core.util.io.FileUtil; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.util.logging.Level; +import javax.annotation.Nonnull; + +public class UpdateApplyCommand extends CommandBase { + private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); + private static final Message MSG_NO_STAGED = Message.translation("server.commands.update.no_staged"); + private static final Message MSG_BACKUP_FAILED = Message.translation("server.commands.update.backup_failed"); + private final FlagArg confirmFlag = this.withFlagArg("confirm", "server.commands.update.apply.confirm.desc"); + private static final String[] CONFIG_FILES = new String[]{"config.json", "permissions.json", "bans.json", "whitelist.json"}; + + public UpdateApplyCommand() { + super("apply", "server.commands.update.apply.desc"); + } + + @Override + protected void executeSync(@Nonnull CommandContext context) { + String stagedVersion = UpdateService.getStagedVersion(); + if (stagedVersion == null) { + context.sendMessage(MSG_NO_STAGED); + } else if (!this.confirmFlag.get(context)) { + context.sendMessage(Message.translation("server.commands.update.apply_confirm_required").param("version", stagedVersion)); + } else { + if (!UpdateService.isValidUpdateLayout()) { + context.sendMessage(Message.translation("server.commands.update.applying_no_launcher").param("version", stagedVersion)); + LOGGER.at(Level.WARNING).log("No launcher script detected - update must be applied manually after shutdown"); + } else { + context.sendMessage(Message.translation("server.commands.update.applying").param("version", stagedVersion)); + } + + HytaleServerConfig.UpdateConfig config = HytaleServer.get().getConfig().getUpdateConfig(); + + try { + this.backupCurrentFiles(); + if (config.isRunBackupBeforeUpdate() && Options.getOptionSet().has(Options.BACKUP_DIRECTORY)) { + Universe universe = Universe.get(); + if (universe != null) { + LOGGER.at(Level.INFO).log("Running server backup before update..."); + universe.runBackup().join(); + LOGGER.at(Level.INFO).log("Server backup completed"); + } + } else if (config.isRunBackupBeforeUpdate()) { + LOGGER.at(Level.WARNING).log("RunBackupBeforeUpdate is enabled but backups are not configured (no --backup-dir)"); + } + + if (config.isBackupConfigBeforeUpdate()) { + this.backupConfigFiles(); + } + } catch (IOException var5) { + LOGGER.at(Level.SEVERE).withCause(var5).log("Failed to create backups before update"); + context.sendMessage(MSG_BACKUP_FAILED); + return; + } + + HytaleServer.get().shutdownServer(ShutdownReason.UPDATE); + } + } + + private void backupCurrentFiles() throws IOException { + Path backupDir = UpdateService.getBackupDir(); + Path backupServerDir = backupDir.resolve("Server"); + if (!UpdateService.deleteBackupDir()) { + throw new IOException("Failed to clear existing backup directory"); + } else { + Files.createDirectories(backupServerDir); + Path currentJar = Path.of("HytaleServer.jar"); + if (Files.exists(currentJar)) { + Files.copy(currentJar, backupServerDir.resolve("HytaleServer.jar"), StandardCopyOption.REPLACE_EXISTING); + } + + Path currentAot = Path.of("HytaleServer.aot"); + if (Files.exists(currentAot)) { + Files.copy(currentAot, backupServerDir.resolve("HytaleServer.aot"), StandardCopyOption.REPLACE_EXISTING); + } + + Path licensesDir = Path.of("Licenses"); + if (Files.exists(licensesDir)) { + FileUtil.copyDirectory(licensesDir, backupServerDir.resolve("Licenses")); + } + + Path assetsZip = Path.of("..").resolve("Assets.zip"); + if (Files.exists(assetsZip)) { + Files.copy(assetsZip, backupDir.resolve("Assets.zip"), StandardCopyOption.REPLACE_EXISTING); + } + + LOGGER.at(Level.INFO).log("Backed up current server files to %s", backupDir); + } + } + + private void backupConfigFiles() throws IOException { + Path backupServerDir = UpdateService.getBackupDir().resolve("Server"); + Files.createDirectories(backupServerDir); + int count = 0; + + for (String fileName : CONFIG_FILES) { + Path file = Path.of(fileName); + if (Files.exists(file)) { + Files.copy(file, backupServerDir.resolve(fileName), StandardCopyOption.REPLACE_EXISTING); + count++; + } + } + + LOGGER.at(Level.INFO).log("Backed up %d config files to %s", count, backupServerDir); + } +} diff --git a/src/com/hypixel/hytale/server/core/update/command/UpdateCancelCommand.java b/src/com/hypixel/hytale/server/core/update/command/UpdateCancelCommand.java new file mode 100644 index 0000000..f020619 --- /dev/null +++ b/src/com/hypixel/hytale/server/core/update/command/UpdateCancelCommand.java @@ -0,0 +1,41 @@ +package com.hypixel.hytale.server.core.update.command; + +import com.hypixel.hytale.server.core.Message; +import com.hypixel.hytale.server.core.command.system.CommandContext; +import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase; +import com.hypixel.hytale.server.core.update.UpdateModule; +import com.hypixel.hytale.server.core.update.UpdateService; +import javax.annotation.Nonnull; + +public class UpdateCancelCommand extends CommandBase { + private static final Message MSG_NOTHING_TO_CANCEL = Message.translation("server.commands.update.nothing_to_cancel"); + private static final Message MSG_DOWNLOAD_CANCELLED = Message.translation("server.commands.update.download_cancelled"); + private static final Message MSG_CANCEL_FAILED = Message.translation("server.commands.update.cancel_failed"); + + public UpdateCancelCommand() { + super("cancel", "server.commands.update.cancel.desc"); + } + + @Override + protected void executeSync(@Nonnull CommandContext context) { + UpdateModule updateModule = UpdateModule.get(); + boolean didSomething = false; + if (updateModule != null && updateModule.cancelDownload()) { + context.sendMessage(MSG_DOWNLOAD_CANCELLED); + didSomething = true; + } + + String stagedVersion = UpdateService.getStagedVersion(); + if (stagedVersion == null && !didSomething) { + context.sendMessage(MSG_NOTHING_TO_CANCEL); + } else { + if (UpdateService.deleteStagedUpdate()) { + if (stagedVersion != null) { + context.sendMessage(Message.translation("server.commands.update.cancelled").param("version", stagedVersion)); + } + } else if (stagedVersion != null) { + context.sendMessage(MSG_CANCEL_FAILED); + } + } + } +} diff --git a/src/com/hypixel/hytale/server/core/update/command/UpdateCheckCommand.java b/src/com/hypixel/hytale/server/core/update/command/UpdateCheckCommand.java new file mode 100644 index 0000000..13f1a1b --- /dev/null +++ b/src/com/hypixel/hytale/server/core/update/command/UpdateCheckCommand.java @@ -0,0 +1,58 @@ +package com.hypixel.hytale.server.core.update.command; + +import com.hypixel.hytale.common.util.java.ManifestUtil; +import com.hypixel.hytale.server.core.Message; +import com.hypixel.hytale.server.core.auth.ServerAuthManager; +import com.hypixel.hytale.server.core.command.system.CommandContext; +import com.hypixel.hytale.server.core.command.system.basecommands.AbstractAsyncCommand; +import com.hypixel.hytale.server.core.update.UpdateModule; +import com.hypixel.hytale.server.core.update.UpdateService; +import java.util.concurrent.CompletableFuture; +import javax.annotation.Nonnull; + +public class UpdateCheckCommand extends AbstractAsyncCommand { + private static final Message MSG_CHECKING = Message.translation("server.commands.update.checking"); + private static final Message MSG_NOT_AUTHENTICATED = Message.translation("server.commands.update.not_authenticated"); + private static final Message MSG_CHECK_FAILED = Message.translation("server.commands.update.check_failed"); + + public UpdateCheckCommand() { + super("check", "server.commands.update.check.desc"); + } + + @Nonnull + @Override + protected CompletableFuture executeAsync(@Nonnull CommandContext context) { + ServerAuthManager authManager = ServerAuthManager.getInstance(); + if (!authManager.hasSessionToken()) { + context.sendMessage(MSG_NOT_AUTHENTICATED); + return CompletableFuture.completedFuture(null); + } else { + context.sendMessage(MSG_CHECKING); + UpdateService updateService = new UpdateService(); + return updateService.checkForUpdate(UpdateService.getEffectivePatchline()) + .thenAccept( + manifest -> { + if (manifest == null) { + context.sendMessage(MSG_CHECK_FAILED); + } else { + UpdateModule updateModule = UpdateModule.get(); + if (updateModule != null) { + updateModule.setLatestKnownVersion(manifest); + } + + String currentVersion = ManifestUtil.getImplementationVersion(); + if (currentVersion != null && currentVersion.equals(manifest.version)) { + context.sendMessage(Message.translation("server.commands.update.already_latest").param("version", currentVersion)); + } else { + context.sendMessage( + Message.translation("server.commands.update.update_available") + .param("current", currentVersion != null ? currentVersion : "unknown") + .param("latest", manifest.version) + ); + } + } + } + ); + } + } +} diff --git a/src/com/hypixel/hytale/server/core/update/command/UpdateCommand.java b/src/com/hypixel/hytale/server/core/update/command/UpdateCommand.java new file mode 100644 index 0000000..f86d147 --- /dev/null +++ b/src/com/hypixel/hytale/server/core/update/command/UpdateCommand.java @@ -0,0 +1,36 @@ +package com.hypixel.hytale.server.core.update.command; + +import com.hypixel.hytale.server.core.Message; +import com.hypixel.hytale.server.core.command.system.CommandSender; +import com.hypixel.hytale.server.core.command.system.ParseResult; +import com.hypixel.hytale.server.core.command.system.ParserContext; +import com.hypixel.hytale.server.core.command.system.basecommands.AbstractCommandCollection; +import com.hypixel.hytale.server.core.update.UpdateModule; +import java.util.concurrent.CompletableFuture; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class UpdateCommand extends AbstractCommandCollection { + private static final Message MSG_DISABLED = Message.translation("server.commands.update.disabled"); + + public UpdateCommand() { + super("update", "server.commands.update.desc"); + this.addSubCommand(new UpdateCheckCommand()); + this.addSubCommand(new UpdateDownloadCommand()); + this.addSubCommand(new UpdateApplyCommand()); + this.addSubCommand(new UpdateCancelCommand()); + this.addSubCommand(new UpdateStatusCommand()); + this.addSubCommand(new UpdatePatchlineCommand()); + } + + @Nullable + @Override + public CompletableFuture acceptCall(@Nonnull CommandSender sender, @Nonnull ParserContext parserContext, @Nonnull ParseResult parseResult) { + if (UpdateModule.KILL_SWITCH_ENABLED) { + sender.sendMessage(MSG_DISABLED); + return CompletableFuture.completedFuture(null); + } else { + return super.acceptCall(sender, parserContext, parseResult); + } + } +} diff --git a/src/com/hypixel/hytale/server/core/update/command/UpdateDownloadCommand.java b/src/com/hypixel/hytale/server/core/update/command/UpdateDownloadCommand.java new file mode 100644 index 0000000..3dacc2c --- /dev/null +++ b/src/com/hypixel/hytale/server/core/update/command/UpdateDownloadCommand.java @@ -0,0 +1,115 @@ +package com.hypixel.hytale.server.core.update.command; + +import com.hypixel.hytale.common.util.FormatUtil; +import com.hypixel.hytale.common.util.java.ManifestUtil; +import com.hypixel.hytale.server.core.Message; +import com.hypixel.hytale.server.core.auth.ServerAuthManager; +import com.hypixel.hytale.server.core.command.system.CommandContext; +import com.hypixel.hytale.server.core.command.system.arguments.system.FlagArg; +import com.hypixel.hytale.server.core.command.system.basecommands.AbstractAsyncCommand; +import com.hypixel.hytale.server.core.update.UpdateModule; +import com.hypixel.hytale.server.core.update.UpdateService; +import java.util.concurrent.CancellationException; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.atomic.AtomicInteger; +import javax.annotation.Nonnull; + +public class UpdateDownloadCommand extends AbstractAsyncCommand { + private static final Message MSG_NOT_AUTHENTICATED = Message.translation("server.commands.update.not_authenticated"); + private static final Message MSG_CHECK_FAILED = Message.translation("server.commands.update.check_failed"); + private static final Message MSG_NO_UPDATE = Message.translation("server.commands.update.no_update"); + private static final Message MSG_DOWNLOAD_FAILED = Message.translation("server.commands.update.download_failed"); + private static final Message MSG_DOWNLOAD_COMPLETE = Message.translation("server.commands.update.download_complete"); + private static final Message MSG_DOWNLOAD_IN_PROGRESS = Message.translation("server.commands.update.download_in_progress"); + private static final Message MSG_INVALID_LAYOUT = Message.translation("server.commands.update.invalid_layout_download"); + private final FlagArg forceFlag = this.withFlagArg("force", "server.commands.update.download.force.desc"); + + public UpdateDownloadCommand() { + super("download", "server.commands.update.download.desc"); + } + + @Nonnull + @Override + protected CompletableFuture executeAsync(@Nonnull CommandContext context) { + UpdateModule updateModule = UpdateModule.get(); + if (updateModule != null && updateModule.isDownloadInProgress()) { + context.sendMessage(MSG_DOWNLOAD_IN_PROGRESS); + return CompletableFuture.completedFuture(null); + } else if (!UpdateService.isValidUpdateLayout() && !this.forceFlag.get(context)) { + context.sendMessage(MSG_INVALID_LAYOUT); + return CompletableFuture.completedFuture(null); + } else { + ServerAuthManager authManager = ServerAuthManager.getInstance(); + if (!authManager.hasSessionToken()) { + context.sendMessage(MSG_NOT_AUTHENTICATED); + return CompletableFuture.completedFuture(null); + } else { + UpdateService updateService = new UpdateService(); + return updateService.checkForUpdate(UpdateService.getEffectivePatchline()) + .thenCompose( + manifest -> { + if (manifest == null) { + context.sendMessage(MSG_CHECK_FAILED); + return CompletableFuture.completedFuture(null); + } else { + if (updateModule != null) { + updateModule.setLatestKnownVersion(manifest); + } + + String currentVersion = ManifestUtil.getImplementationVersion(); + if (currentVersion != null && currentVersion.equals(manifest.version)) { + context.sendMessage(MSG_NO_UPDATE); + return CompletableFuture.completedFuture(null); + } else if (updateModule != null && !updateModule.tryAcquireDownloadLock()) { + context.sendMessage(MSG_DOWNLOAD_IN_PROGRESS); + return CompletableFuture.completedFuture(null); + } else { + context.sendMessage(Message.translation("server.commands.update.downloading").param("version", manifest.version)); + AtomicInteger lastPercent = new AtomicInteger(-1); + UpdateService.DownloadTask downloadTask = updateService.downloadUpdate( + manifest, + UpdateService.getStagingDir(), + (percent, downloaded, total) -> { + if (updateModule != null) { + updateModule.updateDownloadProgress(downloaded, total); + } + + int rounded = percent / 10 * 10; + if (rounded > lastPercent.get()) { + lastPercent.set(rounded); + context.sendMessage( + Message.translation("server.commands.update.download_progress") + .param("percent", String.valueOf(percent)) + .param("downloaded", FormatUtil.bytesToString(downloaded)) + .param("total", FormatUtil.bytesToString(total)) + ); + } + } + ); + CompletableFuture downloadFuture = downloadTask.future().whenComplete((success, error) -> { + if (updateModule != null) { + updateModule.releaseDownloadLock(); + } + + if (error instanceof CancellationException) { + UpdateService.deleteStagedUpdate(); + } else if (error == null && Boolean.TRUE.equals(success)) { + context.sendMessage(MSG_DOWNLOAD_COMPLETE); + } else { + context.sendMessage(MSG_DOWNLOAD_FAILED); + UpdateService.deleteStagedUpdate(); + } + }); + if (updateModule != null) { + updateModule.setActiveDownload(downloadFuture, downloadTask.thread()); + } + + return downloadFuture.thenApply(v -> null); + } + } + } + ); + } + } + } +} diff --git a/src/com/hypixel/hytale/server/core/update/command/UpdatePatchlineCommand.java b/src/com/hypixel/hytale/server/core/update/command/UpdatePatchlineCommand.java new file mode 100644 index 0000000..fe993d3 --- /dev/null +++ b/src/com/hypixel/hytale/server/core/update/command/UpdatePatchlineCommand.java @@ -0,0 +1,41 @@ +package com.hypixel.hytale.server.core.update.command; + +import com.hypixel.hytale.server.core.HytaleServer; +import com.hypixel.hytale.server.core.HytaleServerConfig; +import com.hypixel.hytale.server.core.Message; +import com.hypixel.hytale.server.core.command.system.CommandContext; +import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg; +import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes; +import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase; +import com.hypixel.hytale.server.core.update.UpdateService; +import javax.annotation.Nonnull; + +public class UpdatePatchlineCommand extends CommandBase { + public UpdatePatchlineCommand() { + super("patchline", "server.commands.update.patchline.desc"); + this.addUsageVariant(new UpdatePatchlineCommand.SetPatchlineVariant()); + } + + @Override + protected void executeSync(@Nonnull CommandContext context) { + String current = UpdateService.getEffectivePatchline(); + context.sendMessage(Message.translation("server.commands.update.patchline.current").param("patchline", current)); + } + + private static class SetPatchlineVariant extends CommandBase { + @Nonnull + private final RequiredArg patchlineArg = this.withRequiredArg("patchline", "server.commands.update.patchline.arg.desc", ArgTypes.STRING); + + SetPatchlineVariant() { + super("server.commands.update.patchline.set.desc"); + } + + @Override + protected void executeSync(@Nonnull CommandContext context) { + String newPatchline = this.patchlineArg.get(context); + HytaleServerConfig.UpdateConfig config = HytaleServer.get().getConfig().getUpdateConfig(); + config.setPatchline(newPatchline); + context.sendMessage(Message.translation("server.commands.update.patchline.changed").param("patchline", newPatchline)); + } + } +} diff --git a/src/com/hypixel/hytale/server/core/update/command/UpdateStatusCommand.java b/src/com/hypixel/hytale/server/core/update/command/UpdateStatusCommand.java new file mode 100644 index 0000000..f58f47b --- /dev/null +++ b/src/com/hypixel/hytale/server/core/update/command/UpdateStatusCommand.java @@ -0,0 +1,68 @@ +package com.hypixel.hytale.server.core.update.command; + +import com.hypixel.hytale.common.util.FormatUtil; +import com.hypixel.hytale.common.util.java.ManifestUtil; +import com.hypixel.hytale.server.core.Message; +import com.hypixel.hytale.server.core.command.system.CommandContext; +import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase; +import com.hypixel.hytale.server.core.update.UpdateModule; +import com.hypixel.hytale.server.core.update.UpdateService; +import java.util.concurrent.TimeUnit; +import javax.annotation.Nonnull; + +public class UpdateStatusCommand extends CommandBase { + public UpdateStatusCommand() { + super("status", "server.commands.update.status.desc"); + } + + @Override + protected void executeSync(@Nonnull CommandContext context) { + String currentVersion = ManifestUtil.getImplementationVersion(); + String patchline = UpdateService.getEffectivePatchline(); + String stagedVersion = UpdateService.getStagedVersion(); + UpdateModule updateModule = UpdateModule.get(); + Message msg = Message.translation("server.commands.update.status") + .param("version", currentVersion != null ? currentVersion : "unknown") + .param("patchline", patchline) + .param("staged", stagedVersion != null ? stagedVersion : "none") + .param("latest", this.getLatestStatus(currentVersion, updateModule)) + .param("downloading", this.getDownloadStatus(updateModule)); + context.sendMessage(msg); + } + + private String getLatestStatus(String currentVersion, UpdateModule updateModule) { + if (updateModule == null) { + return "unknown"; + } else { + UpdateService.VersionManifest latestKnown = updateModule.getLatestKnownVersion(); + if (latestKnown == null) { + return "not checked"; + } else { + return currentVersion != null && currentVersion.equals(latestKnown.version) ? "up to date" : latestKnown.version + " available"; + } + } + } + + private String getDownloadStatus(UpdateModule updateModule) { + if (updateModule != null && updateModule.isDownloadInProgress()) { + UpdateModule.DownloadProgress progress = updateModule.getDownloadProgress(); + if (progress == null) { + return "starting..."; + } else { + StringBuilder sb = new StringBuilder(); + sb.append(progress.percent()).append("% ("); + sb.append(FormatUtil.bytesToString(progress.downloadedBytes())); + sb.append("/"); + sb.append(FormatUtil.bytesToString(progress.totalBytes())); + sb.append(")"); + if (progress.etaSeconds() >= 0L) { + sb.append(" ETA: ").append(FormatUtil.timeUnitToString(progress.etaSeconds(), TimeUnit.SECONDS)); + } + + return sb.toString(); + } + } else { + return "no"; + } + } +} diff --git a/src/com/hypixel/hytale/server/core/util/AssetUtil.java b/src/com/hypixel/hytale/server/core/util/AssetUtil.java index 059696d..2b7813a 100644 --- a/src/com/hypixel/hytale/server/core/util/AssetUtil.java +++ b/src/com/hypixel/hytale/server/core/util/AssetUtil.java @@ -4,9 +4,6 @@ import com.hypixel.hytale.server.core.asset.AssetModule; import java.nio.file.Path; public class AssetUtil { - public AssetUtil() { - } - @Deprecated(forRemoval = true) public static Path getHytaleAssetsPath() { return AssetModule.get().getBaseAssetPack().getRoot(); diff --git a/src/com/hypixel/hytale/server/core/util/AuthUtil.java b/src/com/hypixel/hytale/server/core/util/AuthUtil.java deleted file mode 100644 index 47c9ccc..0000000 --- a/src/com/hypixel/hytale/server/core/util/AuthUtil.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.hypixel.hytale.server.core.util; - -import com.hypixel.hytale.server.core.NameMatching; -import com.hypixel.hytale.server.core.universe.PlayerRef; -import com.hypixel.hytale.server.core.universe.Universe; -import java.nio.charset.StandardCharsets; -import java.util.UUID; -import java.util.concurrent.CompletableFuture; -import javax.annotation.Nonnull; - -public class AuthUtil { - public AuthUtil() { - } - - @Nonnull - @Deprecated - public static CompletableFuture lookupUuid(String username) { - PlayerRef player = Universe.get().getPlayerByUsername(username, NameMatching.EXACT); - return player != null - ? CompletableFuture.completedFuture(player.getUuid()) - : CompletableFuture.completedFuture(UUID.nameUUIDFromBytes(("NO_AUTH|" + username).getBytes(StandardCharsets.UTF_8))); - } -} diff --git a/src/com/hypixel/hytale/server/core/util/BsonUtil.java b/src/com/hypixel/hytale/server/core/util/BsonUtil.java index 08104d1..fa19958 100644 --- a/src/com/hypixel/hytale/server/core/util/BsonUtil.java +++ b/src/com/hypixel/hytale/server/core/util/BsonUtil.java @@ -50,9 +50,6 @@ public class BsonUtil { private static final EncoderContext encoderContext = EncoderContext.builder().build(); public static final BsonDocumentCodec BSON_DOCUMENT_CODEC = new BsonDocumentCodec(); - public BsonUtil() { - } - public static byte[] writeToBytes(@Nullable BsonDocument document) { if (document == null) { return ArrayUtil.EMPTY_BYTE_ARRAY; diff --git a/src/com/hypixel/hytale/server/core/util/ConsoleColorUtil.java b/src/com/hypixel/hytale/server/core/util/ConsoleColorUtil.java index b939ba1..7600445 100644 --- a/src/com/hypixel/hytale/server/core/util/ConsoleColorUtil.java +++ b/src/com/hypixel/hytale/server/core/util/ConsoleColorUtil.java @@ -9,7 +9,4 @@ public class ConsoleColorUtil { public static final String PURPLE = "\u001b[0;35m"; public static final String CYAN = "\u001b[0;36m"; public static final String WHITE = "\u001b[0;37m"; - - public ConsoleColorUtil() { - } } diff --git a/src/com/hypixel/hytale/server/core/util/DumpUtil.java b/src/com/hypixel/hytale/server/core/util/DumpUtil.java index d41e616..eace33d 100644 --- a/src/com/hypixel/hytale/server/core/util/DumpUtil.java +++ b/src/com/hypixel/hytale/server/core/util/DumpUtil.java @@ -82,9 +82,6 @@ import org.bson.BsonString; import org.bson.BsonValue; public class DumpUtil { - public DumpUtil() { - } - @Nonnull public static Path dumpToJson() throws IOException { Map playerComponents = collectPlayerComponentMetrics(); diff --git a/src/com/hypixel/hytale/server/core/util/EventTitleUtil.java b/src/com/hypixel/hytale/server/core/util/EventTitleUtil.java index 1267678..8b31a15 100644 --- a/src/com/hypixel/hytale/server/core/util/EventTitleUtil.java +++ b/src/com/hypixel/hytale/server/core/util/EventTitleUtil.java @@ -16,9 +16,6 @@ public class EventTitleUtil { public static final float DEFAULT_DURATION = 4.0F; public static final float DEFAULT_FADE_DURATION = 1.5F; - public EventTitleUtil() { - } - public static void showEventTitleToUniverse( @Nonnull Message primaryTitle, @Nonnull Message secondaryTitle, boolean isMajor, String icon, float duration, float fadeInDuration, float fadeOutDuration ) { diff --git a/src/com/hypixel/hytale/server/core/util/FillerBlockUtil.java b/src/com/hypixel/hytale/server/core/util/FillerBlockUtil.java index 5215b6c..6c4da8e 100644 --- a/src/com/hypixel/hytale/server/core/util/FillerBlockUtil.java +++ b/src/com/hypixel/hytale/server/core/util/FillerBlockUtil.java @@ -16,9 +16,6 @@ public class FillerBlockUtil { private static final int MASK = 31; private static final int INVERT = -32; - public FillerBlockUtil() { - } - public static void forEachFillerBlock(@Nonnull BlockBoundingBoxes.RotatedVariantBoxes blockBoundingBoxes, @Nonnull TriIntConsumer consumer) { forEachFillerBlock(0.0F, blockBoundingBoxes, consumer); } @@ -245,8 +242,5 @@ public class FillerBlockUtil { OK, INVALID_BLOCK, INVALID_FILLER; - - private ValidationResult() { - } } } diff --git a/src/com/hypixel/hytale/server/core/util/HashUtil.java b/src/com/hypixel/hytale/server/core/util/HashUtil.java index fa5575d..8b41106 100644 --- a/src/com/hypixel/hytale/server/core/util/HashUtil.java +++ b/src/com/hypixel/hytale/server/core/util/HashUtil.java @@ -6,9 +6,6 @@ import javax.annotation.Nonnull; import org.bouncycastle.util.encoders.Hex; public class HashUtil { - public HashUtil() { - } - @Nonnull public static String sha256(byte[] bytes) { try { diff --git a/src/com/hypixel/hytale/server/core/util/MessageUtil.java b/src/com/hypixel/hytale/server/core/util/MessageUtil.java index 6403802..b635f27 100644 --- a/src/com/hypixel/hytale/server/core/util/MessageUtil.java +++ b/src/com/hypixel/hytale/server/core/util/MessageUtil.java @@ -14,6 +14,7 @@ import com.hypixel.hytale.server.core.Message; import com.hypixel.hytale.server.core.asset.util.ColorParseUtil; import com.hypixel.hytale.server.core.modules.i18n.I18nModule; import com.hypixel.hytale.server.core.universe.PlayerRef; +import java.util.HashMap; import java.util.Map; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -23,8 +24,7 @@ import org.jline.utils.AttributedStyle; import org.jline.utils.Colors; public class MessageUtil { - public MessageUtil() { - } + private static final String[] ICU_PLURAL_KEYWORDS = new String[]{"zero", "one", "two", "few", "many", "other"}; public static AttributedString toAnsiString(@Nonnull Message message) { AttributedStyle style = AttributedStyle.DEFAULT; @@ -139,12 +139,10 @@ public class MessageUtil { sb.append(replacementMessage.messageId); } } - } else if (replacement == null) { - sb.append(text, i, end); - } else { + } else if (replacement != null) { String formattedReplacement; formattedReplacement = ""; - label185: + label147: switch (format) { case "upper": if (replacement instanceof StringParamValue s) { @@ -167,7 +165,7 @@ public class MessageUtil { case LongParamValue l -> Long.toString(l.value); default -> ""; }; - break label185; + break label147; case "decimal": case null: default: @@ -179,40 +177,20 @@ public class MessageUtil { case LongParamValue l -> Long.toString(l.value); default -> ""; }; - break label185; + break label147; } case "plural": if (options != null) { - String oneText = null; - String otherText = null; - int oneIdx = options.indexOf("one {"); - int otherIdx = options.indexOf("other {"); - if (oneIdx >= 0) { - int oneStart = oneIdx + "one {".length(); - int oneEnd = findMatchingBrace(options, oneStart - 1); - if (oneEnd > oneStart) { - oneText = options.substring(oneStart, oneEnd); - } - } - - if (otherIdx >= 0) { - int otherStart = otherIdx + "other {".length(); - int otherEnd = findMatchingBrace(options, otherStart - 1); - if (otherEnd > otherStart) { - otherText = options.substring(otherStart, otherEnd); - } - } - + Map pluralTexts = parsePluralOptions(options); int value = Integer.parseInt(replacement.toString()); + String category = getPluralCategory(value, "en-US"); String selected; - if (value == 1 && oneText != null) { - selected = oneText; - } else if (otherText != null) { - selected = otherText; - } else if (oneText != null) { - selected = oneText; + if (pluralTexts.containsKey(category)) { + selected = pluralTexts.get(category); + } else if (pluralTexts.containsKey("other")) { + selected = pluralTexts.get("other"); } else { - selected = ""; + selected = pluralTexts.isEmpty() ? "" : pluralTexts.values().iterator().next(); } formattedReplacement = formatText(selected, params, messageParams); @@ -232,6 +210,8 @@ public class MessageUtil { } sb.append(formattedReplacement); + } else { + sb.append(text, i, end); } i = end; @@ -292,4 +272,166 @@ public class MessageUtil { return end >= i ? end - i + 1 : 0; } + + @Nonnull + private static Map parsePluralOptions(@Nonnull String options) { + HashMap result = new HashMap<>(); + + for (String keyword : ICU_PLURAL_KEYWORDS) { + String searchPattern = keyword + " {"; + int idx = options.indexOf(searchPattern); + if (idx >= 0) { + int braceStart = idx + keyword.length() + 1; + int end = findMatchingBrace(options, braceStart); + if (end > braceStart + 1) { + result.put(keyword, options.substring(braceStart + 1, end)); + } + } + } + + return result; + } + + @Nonnull + private static String getPluralCategory(int n, @Nonnull String locale) { + String lang = locale.contains("-") ? locale.substring(0, locale.indexOf(45)) : locale; + + return switch (lang) { + case "en" -> getEnglishPluralCategory(n); + case "fr" -> getFrenchPluralCategory(n); + case "de" -> getGermanPluralCategory(n); + case "pt" -> !locale.equals("pt-BR") && !locale.equals("pt_BR") ? getPortuguesePluralCategory(n) : getPortugueseBrazilianPluralCategory(n); + case "ru" -> getRussianPluralCategory(n); + case "es" -> getSpanishPluralCategory(n); + case "pl" -> getPolishPluralCategory(n); + case "tr" -> getTurkishPluralCategory(n); + case "uk" -> getUkrainianPluralCategory(n); + case "it" -> getItalianPluralCategory(n); + case "nl" -> getDutchPluralCategory(n); + case "da" -> getDanishPluralCategory(n); + case "fi" -> getFinnishPluralCategory(n); + case "no", "nb", "nn" -> getNorwegianPluralCategory(n); + case "zh" -> getChinesePluralCategory(n); + case "ja" -> getJapanesePluralCategory(n); + case "ko" -> getKoreanPluralCategory(n); + default -> getEnglishPluralCategory(n); + }; + } + + @Nonnull + private static String getEnglishPluralCategory(int n) { + return n == 1 ? "one" : "other"; + } + + @Nonnull + private static String getFrenchPluralCategory(int n) { + return n != 0 && n != 1 ? "other" : "one"; + } + + @Nonnull + private static String getGermanPluralCategory(int n) { + return n == 1 ? "one" : "other"; + } + + @Nonnull + private static String getPortuguesePluralCategory(int n) { + return n == 1 ? "one" : "other"; + } + + @Nonnull + private static String getPortugueseBrazilianPluralCategory(int n) { + return n != 0 && n != 1 ? "other" : "one"; + } + + @Nonnull + private static String getRussianPluralCategory(int n) { + int absN = Math.abs(n); + int mod10 = absN % 10; + int mod100 = absN % 100; + if (mod10 == 1 && mod100 != 11) { + return "one"; + } else if (mod10 < 2 || mod10 > 4 || mod100 >= 12 && mod100 <= 14) { + return mod10 != 0 && (mod10 < 5 || mod10 > 9) && (mod100 < 11 || mod100 > 14) ? "other" : "many"; + } else { + return "few"; + } + } + + @Nonnull + private static String getSpanishPluralCategory(int n) { + return n == 1 ? "one" : "other"; + } + + @Nonnull + private static String getPolishPluralCategory(int n) { + int absN = Math.abs(n); + int mod10 = absN % 10; + int mod100 = absN % 100; + if (n == 1) { + return "one"; + } else if (mod10 < 2 || mod10 > 4 || mod100 >= 12 && mod100 <= 14) { + return mod10 != 0 && mod10 != 1 && (mod10 < 5 || mod10 > 9) && (mod100 < 12 || mod100 > 14) ? "other" : "many"; + } else { + return "few"; + } + } + + @Nonnull + private static String getTurkishPluralCategory(int n) { + return n == 1 ? "one" : "other"; + } + + @Nonnull + private static String getUkrainianPluralCategory(int n) { + int absN = Math.abs(n); + int mod10 = absN % 10; + int mod100 = absN % 100; + if (mod10 == 1 && mod100 != 11) { + return "one"; + } else if (mod10 < 2 || mod10 > 4 || mod100 >= 12 && mod100 <= 14) { + return mod10 != 0 && (mod10 < 5 || mod10 > 9) && (mod100 < 11 || mod100 > 14) ? "other" : "many"; + } else { + return "few"; + } + } + + @Nonnull + private static String getItalianPluralCategory(int n) { + return n == 1 ? "one" : "other"; + } + + @Nonnull + private static String getDutchPluralCategory(int n) { + return n == 1 ? "one" : "other"; + } + + @Nonnull + private static String getDanishPluralCategory(int n) { + return n == 1 ? "one" : "other"; + } + + @Nonnull + private static String getFinnishPluralCategory(int n) { + return n == 1 ? "one" : "other"; + } + + @Nonnull + private static String getNorwegianPluralCategory(int n) { + return n == 1 ? "one" : "other"; + } + + @Nonnull + private static String getChinesePluralCategory(int n) { + return "other"; + } + + @Nonnull + private static String getJapanesePluralCategory(int n) { + return "other"; + } + + @Nonnull + private static String getKoreanPluralCategory(int n) { + return "other"; + } } diff --git a/src/com/hypixel/hytale/server/core/util/NotificationUtil.java b/src/com/hypixel/hytale/server/core/util/NotificationUtil.java index 16c8739..2f68098 100644 --- a/src/com/hypixel/hytale/server/core/util/NotificationUtil.java +++ b/src/com/hypixel/hytale/server/core/util/NotificationUtil.java @@ -15,9 +15,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class NotificationUtil { - public NotificationUtil() { - } - public static void sendNotificationToUniverse( @Nonnull Message message, @Nullable Message secondaryMessage, @Nullable String icon, @Nullable ItemWithAllMetadata item, @Nonnull NotificationStyle style ) { diff --git a/src/com/hypixel/hytale/server/core/util/PositionUtil.java b/src/com/hypixel/hytale/server/core/util/PositionUtil.java index 8136fa4..241b562 100644 --- a/src/com/hypixel/hytale/server/core/util/PositionUtil.java +++ b/src/com/hypixel/hytale/server/core/util/PositionUtil.java @@ -9,9 +9,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class PositionUtil { - public PositionUtil() { - } - @Nonnull public static Transform toTransformPacket(@Nonnull com.hypixel.hytale.math.vector.Transform transform) { Vector3d position = transform.getPosition(); diff --git a/src/com/hypixel/hytale/server/core/util/PrefabUtil.java b/src/com/hypixel/hytale/server/core/util/PrefabUtil.java index f5d520a..aabcfc7 100644 --- a/src/com/hypixel/hytale/server/core/util/PrefabUtil.java +++ b/src/com/hypixel/hytale/server/core/util/PrefabUtil.java @@ -17,6 +17,7 @@ import com.hypixel.hytale.server.core.asset.type.blocktype.config.RotationTuple; import com.hypixel.hytale.server.core.blocktype.component.BlockPhysics; import com.hypixel.hytale.server.core.modules.entity.component.FromPrefab; import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent; +import com.hypixel.hytale.server.core.prefab.PrefabCopyableComponent; import com.hypixel.hytale.server.core.prefab.PrefabRotation; import com.hypixel.hytale.server.core.prefab.event.PrefabPasteEvent; import com.hypixel.hytale.server.core.prefab.event.PrefabPlaceEntityEvent; @@ -42,9 +43,6 @@ public class PrefabUtil { protected static final String EDITOR_BLOCK_PREFAB_ANCHOR = "Editor_Anchor"; private static final AtomicInteger PREFAB_ID_SOURCE = new AtomicInteger(0); - public PrefabUtil() { - } - public static boolean prefabMatchesAtPosition( @Nonnull IPrefabBuffer prefabBuffer, World world, @Nonnull Vector3i position, @Nonnull Rotation yaw, Random random ) { @@ -176,7 +174,11 @@ public class PrefabUtil { } String blockKey = block.getId(); - if (filler == 0) { + if (filler != 0) { + if (holder != null) { + chunk.setState(bx, by, bz, holder.clone()); + } + } else { if (pasteAnchorAsBlock && technicalPaste && x == buffer.getAnchorX() && y == buffer.getAnchorY() && z == buffer.getAnchorZ()) { int index = blockTypeMap.getIndex("Editor_Anchor"); BlockType type = blockTypeMap.getAsset(index); @@ -228,7 +230,11 @@ public class PrefabUtil { entityPosition.z = entityWorldPosition.z; PrefabPlaceEntityEvent prefabPlaceEntityEvent = new PrefabPlaceEntityEvent(prefabId, entityToAdd); componentAccessor.invoke(prefabPlaceEntityEvent); - entityToAdd.addComponent(FromPrefab.getComponentType(), FromPrefab.INSTANCE); + entityToAdd.ensureComponent(FromPrefab.getComponentType()); + if (technicalPaste) { + entityToAdd.ensureComponent(PrefabCopyableComponent.getComponentType()); + } + componentAccessor.addEntity(entityToAdd, AddReason.LOAD); } } diff --git a/src/com/hypixel/hytale/server/core/util/ProcessUtil.java b/src/com/hypixel/hytale/server/core/util/ProcessUtil.java index c5f1752..1c4dc7f 100644 --- a/src/com/hypixel/hytale/server/core/util/ProcessUtil.java +++ b/src/com/hypixel/hytale/server/core/util/ProcessUtil.java @@ -1,9 +1,6 @@ package com.hypixel.hytale.server.core.util; public class ProcessUtil { - public ProcessUtil() { - } - public static boolean isProcessRunning(int pid) { return ProcessHandle.of(pid).isPresent(); } diff --git a/src/com/hypixel/hytale/server/core/util/TargetUtil.java b/src/com/hypixel/hytale/server/core/util/TargetUtil.java index 5dbf46b..c3af9f3 100644 --- a/src/com/hypixel/hytale/server/core/util/TargetUtil.java +++ b/src/com/hypixel/hytale/server/core/util/TargetUtil.java @@ -37,9 +37,6 @@ import javax.annotation.Nullable; public final class TargetUtil { private static final float ENTITY_TARGET_RADIUS = 8.0F; - public TargetUtil() { - } - @Nullable public static Vector3i getTargetBlock( @Nonnull World world, diff --git a/src/com/hypixel/hytale/server/core/util/TempAssetIdUtil.java b/src/com/hypixel/hytale/server/core/util/TempAssetIdUtil.java index b3d8db6..ee0c6c2 100644 --- a/src/com/hypixel/hytale/server/core/util/TempAssetIdUtil.java +++ b/src/com/hypixel/hytale/server/core/util/TempAssetIdUtil.java @@ -16,9 +16,6 @@ public class TempAssetIdUtil { public static final String PARTICLE_SPLASH = "Splash"; public static final String DEFAULT_PLAYER_MODEL_NAME = "Player"; - public TempAssetIdUtil() { - } - public static int getSoundEventIndex(String soundEventId) { int soundEventIndex = SoundEvent.getAssetMap().getIndex(soundEventId); if (soundEventIndex == Integer.MIN_VALUE) { diff --git a/src/com/hypixel/hytale/server/core/util/UUIDUtil.java b/src/com/hypixel/hytale/server/core/util/UUIDUtil.java index d73e6f2..eb116b5 100644 --- a/src/com/hypixel/hytale/server/core/util/UUIDUtil.java +++ b/src/com/hypixel/hytale/server/core/util/UUIDUtil.java @@ -6,9 +6,6 @@ import javax.annotation.Nonnull; public class UUIDUtil { public static final UUID EMPTY_UUID = new UUID(0L, 0L); - public UUIDUtil() { - } - @Nonnull public static UUID generateVersion3UUID() { UUID out = UUID.randomUUID(); diff --git a/src/com/hypixel/hytale/server/core/util/ValidateUtil.java b/src/com/hypixel/hytale/server/core/util/ValidateUtil.java index 736bd2a..4c6b74f 100644 --- a/src/com/hypixel/hytale/server/core/util/ValidateUtil.java +++ b/src/com/hypixel/hytale/server/core/util/ValidateUtil.java @@ -5,9 +5,6 @@ import com.hypixel.hytale.protocol.Position; import javax.annotation.Nonnull; public class ValidateUtil { - public ValidateUtil() { - } - public static boolean isSafeDouble(double x) { return !Double.isNaN(x) && Double.isFinite(x); } diff --git a/src/com/hypixel/hytale/server/core/util/backup/BackupUtil.java b/src/com/hypixel/hytale/server/core/util/backup/BackupUtil.java index 751c5fc..16d8453 100644 --- a/src/com/hypixel/hytale/server/core/util/backup/BackupUtil.java +++ b/src/com/hypixel/hytale/server/core/util/backup/BackupUtil.java @@ -21,9 +21,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; class BackupUtil { - BackupUtil() { - } - static void walkFileTreeAndZip(@Nonnull Path sourceDir, @Nonnull Path zipPath) throws IOException { try (ZipOutputStream zipOutputStream = new ZipOutputStream(Files.newOutputStream(zipPath))) { zipOutputStream.setMethod(0); diff --git a/src/com/hypixel/hytale/server/core/util/concurrent/ThreadUtil.java b/src/com/hypixel/hytale/server/core/util/concurrent/ThreadUtil.java index f6288ec..ebf3959 100644 --- a/src/com/hypixel/hytale/server/core/util/concurrent/ThreadUtil.java +++ b/src/com/hypixel/hytale/server/core/util/concurrent/ThreadUtil.java @@ -13,9 +13,6 @@ import java.util.function.Predicate; import javax.annotation.Nonnull; public class ThreadUtil { - public ThreadUtil() { - } - public static void forceTimeHighResolution() { Thread t = new Thread(() -> { try { diff --git a/src/com/hypixel/hytale/server/core/util/io/ByteBufUtil.java b/src/com/hypixel/hytale/server/core/util/io/ByteBufUtil.java index eb59e03..f8fc63c 100644 --- a/src/com/hypixel/hytale/server/core/util/io/ByteBufUtil.java +++ b/src/com/hypixel/hytale/server/core/util/io/ByteBufUtil.java @@ -10,9 +10,6 @@ import javax.annotation.Nonnull; public class ByteBufUtil { private static int MAX_UNSIGNED_SHORT_VALUE = 65535; - public ByteBufUtil() { - } - public static void writeUTF(@Nonnull ByteBuf buf, @Nonnull String string) { if (io.netty.buffer.ByteBufUtil.utf8MaxBytes(string) >= MAX_UNSIGNED_SHORT_VALUE) { throw new IllegalArgumentException("String is too large"); diff --git a/src/com/hypixel/hytale/server/core/util/io/FileUtil.java b/src/com/hypixel/hytale/server/core/util/io/FileUtil.java index 3716b00..7c24b18 100644 --- a/src/com/hypixel/hytale/server/core/util/io/FileUtil.java +++ b/src/com/hypixel/hytale/server/core/util/io/FileUtil.java @@ -2,12 +2,14 @@ package com.hypixel.hytale.server.core.util.io; import com.hypixel.hytale.sneakythrow.SneakyThrow; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; import java.nio.file.CopyOption; import java.nio.file.FileVisitOption; import java.nio.file.Files; import java.nio.file.OpenOption; import java.nio.file.Path; +import java.nio.file.StandardCopyOption; import java.nio.file.StandardOpenOption; import java.util.Comparator; import java.util.Set; @@ -24,9 +26,6 @@ public class FileUtil { public static final FileVisitOption[] DEFAULT_WALK_TREE_OPTIONS_ARRAY = new FileVisitOption[0]; public static final Pattern INVALID_FILENAME_CHARACTERS = Pattern.compile("[<>:\"|?*/\\\\]"); - public FileUtil() { - } - public static void unzipFile(@Nonnull Path path, @Nonnull byte[] buffer, @Nonnull ZipInputStream zipStream, @Nonnull ZipEntry zipEntry, @Nonnull String name) throws IOException { Path filePath = path.resolve(name); if (!filePath.toAbsolutePath().startsWith(path)) { @@ -82,4 +81,27 @@ public class FileUtil { stream.sorted(Comparator.reverseOrder()).forEach(SneakyThrow.sneakyConsumer(Files::delete)); } } + + public static void extractZip(@Nonnull Path zipFile, @Nonnull Path destDir) throws IOException { + extractZip(Files.newInputStream(zipFile), destDir); + } + + public static void extractZip(@Nonnull InputStream inputStream, @Nonnull Path destDir) throws IOException { + ZipEntry entry; + try (ZipInputStream zis = new ZipInputStream(inputStream)) { + for (; (entry = zis.getNextEntry()) != null; zis.closeEntry()) { + Path destPath = destDir.resolve(entry.getName()).normalize(); + if (!destPath.startsWith(destDir)) { + throw new ZipException("Zip entry outside target directory: " + entry.getName()); + } + + if (entry.isDirectory()) { + Files.createDirectories(destPath); + } else { + Files.createDirectories(destPath.getParent()); + Files.copy(zis, destPath, StandardCopyOption.REPLACE_EXISTING); + } + } + } + } } diff --git a/src/com/hypixel/hytale/server/core/util/message/MessageFormat.java b/src/com/hypixel/hytale/server/core/util/message/MessageFormat.java index c1c1a75..52abde6 100644 --- a/src/com/hypixel/hytale/server/core/util/message/MessageFormat.java +++ b/src/com/hypixel/hytale/server/core/util/message/MessageFormat.java @@ -11,9 +11,6 @@ public final class MessageFormat { private static final Message DISABLED = Message.translation("server.general.disabled").color(Color.RED); private static final int LIST_MAX_INLINE_VALUES = 4; - public MessageFormat() { - } - @Nonnull public static Message enabled(boolean b) { return b ? ENABLED : DISABLED; diff --git a/src/com/hypixel/hytale/server/flock/Flock.java b/src/com/hypixel/hytale/server/flock/Flock.java index 68f1054..fe7fda6 100644 --- a/src/com/hypixel/hytale/server/flock/Flock.java +++ b/src/com/hypixel/hytale/server/flock/Flock.java @@ -127,8 +127,5 @@ public class Flock implements Component { NOT_REMOVED, DISSOLVED, UNLOADED; - - private FlockRemovedStatus() { - } } } diff --git a/src/com/hypixel/hytale/server/flock/FlockDeathSystems.java b/src/com/hypixel/hytale/server/flock/FlockDeathSystems.java index b24e35e..81d2104 100644 --- a/src/com/hypixel/hytale/server/flock/FlockDeathSystems.java +++ b/src/com/hypixel/hytale/server/flock/FlockDeathSystems.java @@ -15,16 +15,10 @@ import com.hypixel.hytale.server.npc.role.Role; import javax.annotation.Nonnull; public class FlockDeathSystems { - public FlockDeathSystems() { - } - public static class EntityDeath extends DeathSystems.OnDeathSystem { @Nonnull private final Query query = Query.and(AllLegacyLivingEntityTypesQuery.INSTANCE, Query.not(Player.getComponentType())); - public EntityDeath() { - } - @Nonnull @Override public Query getQuery() { @@ -43,13 +37,13 @@ public class FlockDeathSystems { } Damage damageInfo = component.getDeathInfo(); - Ref attackerRef = null; + Ref sourceRef = null; if (damageInfo != null && damageInfo.getSource() instanceof Damage.EntitySource entitySource) { - attackerRef = entitySource.getRef(); + sourceRef = entitySource.getRef(); } - if (attackerRef != null) { - Flock attackerFlock = FlockPlugin.getFlock(commandBuffer, attackerRef); + if (sourceRef != null) { + Flock attackerFlock = FlockPlugin.getFlock(commandBuffer, sourceRef); if (attackerFlock != null) { attackerFlock.onTargetKilled(commandBuffer, ref); } @@ -58,9 +52,6 @@ public class FlockDeathSystems { } public static class PlayerDeath extends DeathSystems.OnDeathSystem { - public PlayerDeath() { - } - @Nonnull @Override public Query getQuery() { diff --git a/src/com/hypixel/hytale/server/flock/FlockMembership.java b/src/com/hypixel/hytale/server/flock/FlockMembership.java index 00e1698..83c394b 100644 --- a/src/com/hypixel/hytale/server/flock/FlockMembership.java +++ b/src/com/hypixel/hytale/server/flock/FlockMembership.java @@ -32,9 +32,6 @@ public class FlockMembership implements Component { @Nullable private Ref flockRef; - public FlockMembership() { - } - public static ComponentType getComponentType() { return FlockPlugin.get().getFlockMembershipComponentType(); } diff --git a/src/com/hypixel/hytale/server/flock/FlockMembershipSystems.java b/src/com/hypixel/hytale/server/flock/FlockMembershipSystems.java index a307393..78989a9 100644 --- a/src/com/hypixel/hytale/server/flock/FlockMembershipSystems.java +++ b/src/com/hypixel/hytale/server/flock/FlockMembershipSystems.java @@ -36,9 +36,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class FlockMembershipSystems { - public FlockMembershipSystems() { - } - public static boolean canJoinFlock(@Nonnull Ref reference, @Nonnull Ref flockReference, @Nonnull Store store) { Flock flockComponent = store.getComponent(flockReference, Flock.getComponentType()); @@ -359,9 +356,6 @@ public class FlockMembershipSystems { @Nonnull private final Query query = Query.and(this.npcComponentType, this.fromWorldGenComponentType, this.flockMembershipComponentType); - public NPCAddedFromWorldGen() { - } - @Nonnull @Override public Query getQuery() { @@ -385,9 +379,6 @@ public class FlockMembershipSystems { } public static class OnDamageDealt extends DamageEventSystem { - public OnDamageDealt() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -434,9 +425,6 @@ public class FlockMembershipSystems { @Nonnull private final Query query = FlockMembership.getComponentType(); - public OnDamageReceived() { - } - @Nullable @Override public SystemGroup getGroup() { diff --git a/src/com/hypixel/hytale/server/flock/FlockSystems.java b/src/com/hypixel/hytale/server/flock/FlockSystems.java index 0bb0512..7b7fae7 100644 --- a/src/com/hypixel/hytale/server/flock/FlockSystems.java +++ b/src/com/hypixel/hytale/server/flock/FlockSystems.java @@ -24,9 +24,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class FlockSystems { - public FlockSystems() { - } - public static class EntityRemoved extends RefSystem { private final ComponentType flockIdComponentType = UUIDComponent.getComponentType(); private final ComponentType entityGroupComponentType = EntityGroup.getComponentType(); diff --git a/src/com/hypixel/hytale/server/flock/StoredFlock.java b/src/com/hypixel/hytale/server/flock/StoredFlock.java index e8a015d..bc05dfc 100644 --- a/src/com/hypixel/hytale/server/flock/StoredFlock.java +++ b/src/com/hypixel/hytale/server/flock/StoredFlock.java @@ -31,9 +31,6 @@ public class StoredFlock { @Nullable private Holder[] members; - public StoredFlock() { - } - public void storeNPCs(@Nonnull List> refs, @Nonnull Store store) { ComponentRegistry.Data data = EntityStore.REGISTRY.getData(); ObjectArrayList> members = new ObjectArrayList<>(); diff --git a/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderActionFlockBeacon.java b/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderActionFlockBeacon.java index 21db366..a0feaf1 100644 --- a/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderActionFlockBeacon.java +++ b/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderActionFlockBeacon.java @@ -19,9 +19,6 @@ public class BuilderActionFlockBeacon extends BuilderActionBase { protected boolean sendToSelf; protected boolean sendToLeaderOnly; - public BuilderActionFlockBeacon() { - } - @Nonnull public ActionFlockBeacon build(@Nonnull BuilderSupport builderSupport) { return new ActionFlockBeacon(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderActionFlockJoin.java b/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderActionFlockJoin.java index 2493d26..0ef05d3 100644 --- a/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderActionFlockJoin.java +++ b/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderActionFlockJoin.java @@ -11,9 +11,6 @@ import javax.annotation.Nonnull; public class BuilderActionFlockJoin extends BuilderActionBase { protected boolean forceJoin; - public BuilderActionFlockJoin() { - } - @Nonnull public ActionFlockJoin build(BuilderSupport builderSupport) { return new ActionFlockJoin(this); diff --git a/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderActionFlockLeave.java b/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderActionFlockLeave.java index 2359531..5aa3001 100644 --- a/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderActionFlockLeave.java +++ b/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderActionFlockLeave.java @@ -8,9 +8,6 @@ import com.hypixel.hytale.server.npc.corecomponents.builders.BuilderActionBase; import javax.annotation.Nonnull; public class BuilderActionFlockLeave extends BuilderActionBase { - public BuilderActionFlockLeave() { - } - @Nonnull public ActionFlockLeave build(BuilderSupport builderSupport) { return new ActionFlockLeave(this); diff --git a/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderActionFlockSetTarget.java b/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderActionFlockSetTarget.java index 2b94b22..02ee6fa 100644 --- a/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderActionFlockSetTarget.java +++ b/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderActionFlockSetTarget.java @@ -14,9 +14,6 @@ public class BuilderActionFlockSetTarget extends BuilderActionBase { protected boolean clear; protected final StringHolder targetSlot = new StringHolder(); - public BuilderActionFlockSetTarget() { - } - @Nonnull public ActionFlockSetTarget build(@Nonnull BuilderSupport builderSupport) { return new ActionFlockSetTarget(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderActionFlockState.java b/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderActionFlockState.java index 1969b19..0cda40a 100644 --- a/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderActionFlockState.java +++ b/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderActionFlockState.java @@ -13,9 +13,6 @@ import javax.annotation.Nonnull; public class BuilderActionFlockState extends BuilderActionBase { protected final StringHolder state = new StringHolder(); - public BuilderActionFlockState() { - } - @Nonnull public ActionFlockState build(@Nonnull BuilderSupport builderSupport) { return new ActionFlockState(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderBodyMotionFlock.java b/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderBodyMotionFlock.java index 45f80f5..f2cd180 100644 --- a/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderBodyMotionFlock.java +++ b/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderBodyMotionFlock.java @@ -10,9 +10,6 @@ import com.hypixel.hytale.server.npc.instructions.BodyMotion; import javax.annotation.Nonnull; public class BuilderBodyMotionFlock extends BuilderBodyMotionBase { - public BuilderBodyMotionFlock() { - } - @Nonnull public BodyMotionFlock build(BuilderSupport builderSupport) { return new BodyMotionFlock(this); diff --git a/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderEntityFilterFlock.java b/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderEntityFilterFlock.java index b631e53..061ec15 100644 --- a/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderEntityFilterFlock.java +++ b/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderEntityFilterFlock.java @@ -17,9 +17,6 @@ public class BuilderEntityFilterFlock extends BuilderEntityFilterBase { protected int[] size; protected boolean checkCanJoin; - public BuilderEntityFilterFlock() { - } - @Nonnull public IEntityFilter build(BuilderSupport builderSupport) { return new EntityFilterFlock(this); diff --git a/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderSensorFlockCombatDamage.java b/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderSensorFlockCombatDamage.java index 6cacda2..20f1608 100644 --- a/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderSensorFlockCombatDamage.java +++ b/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderSensorFlockCombatDamage.java @@ -13,9 +13,6 @@ import javax.annotation.Nonnull; public class BuilderSensorFlockCombatDamage extends BuilderSensorBase { protected boolean leaderOnly; - public BuilderSensorFlockCombatDamage() { - } - @Nonnull public SensorFlockCombatDamage build(BuilderSupport builderSupport) { return new SensorFlockCombatDamage(this); diff --git a/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderSensorFlockLeader.java b/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderSensorFlockLeader.java index 1aa0285..0cf022d 100644 --- a/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderSensorFlockLeader.java +++ b/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderSensorFlockLeader.java @@ -11,9 +11,6 @@ import com.hypixel.hytale.server.npc.instructions.Sensor; import javax.annotation.Nonnull; public class BuilderSensorFlockLeader extends BuilderSensorBase { - public BuilderSensorFlockLeader() { - } - @Nonnull public SensorFlockLeader build(BuilderSupport builderSupport) { return new SensorFlockLeader(this); diff --git a/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderSensorInflictedDamage.java b/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderSensorInflictedDamage.java index 463634e..9f6f97a 100644 --- a/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderSensorInflictedDamage.java +++ b/src/com/hypixel/hytale/server/flock/corecomponents/builders/BuilderSensorInflictedDamage.java @@ -14,9 +14,6 @@ public class BuilderSensorInflictedDamage extends BuilderSensorBase { protected SensorInflictedDamage.Target target; protected boolean friendlyFire; - public BuilderSensorInflictedDamage() { - } - @Nonnull public SensorInflictedDamage build(BuilderSupport builderSupport) { return new SensorInflictedDamage(this); diff --git a/src/com/hypixel/hytale/server/npc/NPCPlugin.java b/src/com/hypixel/hytale/server/npc/NPCPlugin.java index a118c5d..76dbeb2 100644 --- a/src/com/hypixel/hytale/server/npc/NPCPlugin.java +++ b/src/com/hypixel/hytale/server/npc/NPCPlugin.java @@ -1089,9 +1089,9 @@ public class NPCPlugin extends JavaPlugin { @Nonnull Store store, int roleIndex, @Nonnull Vector3d position, - Vector3f rotation, - Model spawnModel, - TriConsumer, Store> postSpawn + @Nullable Vector3f rotation, + @Nullable Model spawnModel, + @Nullable TriConsumer, Store> postSpawn ) { return this.spawnEntity(store, roleIndex, position, rotation, spawnModel, null, postSpawn); } @@ -1611,9 +1611,6 @@ public class NPCPlugin extends JavaPlugin { "Test_Bird_Land" }; - public NPCConfig() { - } - public boolean isGenerateDescriptors() { return this.generateDescriptors; } diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/BuilderAttributeDescriptor.java b/src/com/hypixel/hytale/server/npc/asset/builder/BuilderAttributeDescriptor.java index a02818f..41274de 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/BuilderAttributeDescriptor.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/BuilderAttributeDescriptor.java @@ -186,8 +186,5 @@ public class BuilderAttributeDescriptor { REQUIRED, OPTIONAL, REQUIRED_IF_NOT_OVERRIDDEN; - - private RequirementType() { - } } } diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/BuilderBase.java b/src/com/hypixel/hytale/server/npc/asset/builder/BuilderBase.java index 73d75eb..edb3fa2 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/BuilderBase.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/BuilderBase.java @@ -141,9 +141,6 @@ public abstract class BuilderBase implements Builder { @Nullable protected SchemaContext builderSchemaContext; - public BuilderBase() { - } - @Override public void setTypeName(String name) { this.typeName = name; diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/BuilderBaseWithType.java b/src/com/hypixel/hytale/server/npc/asset/builder/BuilderBaseWithType.java index ff4a08a..ba40f3a 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/BuilderBaseWithType.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/BuilderBaseWithType.java @@ -8,9 +8,6 @@ import javax.annotation.Nonnull; public abstract class BuilderBaseWithType extends BuilderBase implements ISpawnable { private String type; - public BuilderBaseWithType() { - } - @Override public Builder readCommonConfig(JsonElement data) { return super.readCommonConfig(data); diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/BuilderDescriptorState.java b/src/com/hypixel/hytale/server/npc/asset/builder/BuilderDescriptorState.java index 14c16e8..00af60d 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/BuilderDescriptorState.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/BuilderDescriptorState.java @@ -6,7 +6,4 @@ public enum BuilderDescriptorState { Experimental, Stable, Deprecated; - - private BuilderDescriptorState() { - } } diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/BuilderInfo.java b/src/com/hypixel/hytale/server/npc/asset/builder/BuilderInfo.java index 3661323..9214395 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/BuilderInfo.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/BuilderInfo.java @@ -84,8 +84,5 @@ public class BuilderInfo { VALID, INVALID, REMOVED; - - private State() { - } } } diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/BuilderManager.java b/src/com/hypixel/hytale/server/npc/asset/builder/BuilderManager.java index 1c6bc99..4644488 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/BuilderManager.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/BuilderManager.java @@ -6,6 +6,8 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializer; import com.google.gson.stream.JsonReader; import com.hypixel.fastutil.ints.Int2ObjectConcurrentHashMap; import com.hypixel.hytale.assetstore.AssetExtraInfo; @@ -60,6 +62,8 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; +import java.time.Duration; +import java.time.Period; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -779,6 +783,8 @@ public class BuilderManager { public static void saveDescriptors(List builderDescriptors, @Nonnull Path fileName) { try (BufferedWriter fileWriter = Files.newBufferedWriter(fileName)) { GsonBuilder gsonBuilder = new GsonBuilder().setPrettyPrinting().serializeNulls().setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE); + gsonBuilder.registerTypeAdapter(Duration.class, (JsonSerializer)(src, typeOfSrc, context) -> new JsonPrimitive(src.toString())); + gsonBuilder.registerTypeAdapter(Period.class, (JsonSerializer)(src, typeOfSrc, context) -> new JsonPrimitive(src.toString())); ValidatorTypeRegistry.registerTypes(gsonBuilder); ProviderEvaluatorTypeRegistry.registerTypes(gsonBuilder); Gson gson = gsonBuilder.create(); @@ -1232,8 +1238,5 @@ public class BuilderManager { private static enum TestType { NORMAL, FAILING; - - private TestType() { - } } } diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/BuilderModifier.java b/src/com/hypixel/hytale/server/npc/asset/builder/BuilderModifier.java index b7bbdf6..e85735c 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/BuilderModifier.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/BuilderModifier.java @@ -3,6 +3,7 @@ package com.hypixel.hytale.server.npc.asset.builder; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import com.hypixel.hytale.codec.Codec; import com.hypixel.hytale.codec.ExtraInfo; import com.hypixel.hytale.codec.schema.NamedSchema; import com.hypixel.hytale.codec.schema.SchemaContext; @@ -200,7 +201,9 @@ public class BuilderModifier { String combatConfig = null; JsonElement combatConfigValue = modify.get("_CombatConfig"); if (combatConfigValue != null) { - combatConfig = combatConfigValue.getAsString(); + combatConfig = BalanceAsset.CHILD_ASSET_CODEC.decode(BsonUtil.translateJsonToBson(combatConfigValue), extraInfo); + extraInfo.getValidationResults()._processValidationResults(); + extraInfo.getValidationResults().logOrThrowValidatorExceptions(HytaleLogger.getLogger()); } Map interactionVars = null; @@ -272,9 +275,6 @@ public class BuilderModifier { @Nonnull public static BuilderModifier.SchemaGenerator INSTANCE = new BuilderModifier.SchemaGenerator(); - private SchemaGenerator() { - } - @Nonnull @Override public String getSchemaName() { @@ -290,9 +290,11 @@ public class BuilderModifier { s.setProperties(props); props.put("_ExportStates", new ArraySchema(new StringSchema())); props.put("_InterfaceParameters", new ObjectSchema()); - StringSchema combatConfig = new StringSchema(); - combatConfig.setHytaleAssetRef(BalanceAsset.class.getSimpleName()); - props.put("_CombatConfig", combatConfig); + Schema combatConfigKeySchema = context.refDefinition(Codec.STRING); + combatConfigKeySchema.setTitle("Reference to " + BalanceAsset.class.getSimpleName()); + Schema combatConfigNestedSchema = context.refDefinition(BalanceAsset.CHILD_ASSET_CODEC); + Schema combatConfigSchema = Schema.anyOf(combatConfigKeySchema, combatConfigNestedSchema); + props.put("_CombatConfig", combatConfigSchema); ObjectSchema interactionVars = new ObjectSchema(); interactionVars.setTitle("Map"); Schema childSchema = context.refDefinition(RootInteraction.CHILD_ASSET_CODEC); diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/SpawnableWithModelBuilder.java b/src/com/hypixel/hytale/server/npc/asset/builder/SpawnableWithModelBuilder.java index 0e1f140..215eb42 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/SpawnableWithModelBuilder.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/SpawnableWithModelBuilder.java @@ -7,9 +7,6 @@ import it.unimi.dsi.fastutil.ints.IntSet; public abstract class SpawnableWithModelBuilder extends BuilderBase implements ISpawnableWithModel { private IntSet dynamicDependencies; - public SpawnableWithModelBuilder() { - } - @Override public boolean hasDynamicDependencies() { return this.dynamicDependencies != null; diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/StateMappingHelper.java b/src/com/hypixel/hytale/server/npc/asset/builder/StateMappingHelper.java index c4afd9b..93a9fdf 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/StateMappingHelper.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/StateMappingHelper.java @@ -42,9 +42,6 @@ public class StateMappingHelper { private Object2IntOpenHashMap componentImportStateMappings; private StateMappingHelper.SingletonStateMap singletonDefaultStateMap; - public StateMappingHelper() { - } - public int[] getAllMainStates() { return this.allMainStates; } diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/expression/BuilderExpression.java b/src/com/hypixel/hytale/server/npc/asset/builder/expression/BuilderExpression.java index a894c54..eaebf52 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/expression/BuilderExpression.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/expression/BuilderExpression.java @@ -21,9 +21,6 @@ import javax.annotation.Nullable; public abstract class BuilderExpression { public static final String STATIC = ""; - public BuilderExpression() { - } - public abstract ValueType getType(); public abstract boolean isStatic(); @@ -173,9 +170,6 @@ public abstract class BuilderExpression { @Nonnull public static BuilderExpression.SchemaGenerator INSTANCE = new BuilderExpression.SchemaGenerator(); - private SchemaGenerator() { - } - @Nonnull @Override public String getSchemaName() { diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/expression/BuilderExpressionStaticEmptyArray.java b/src/com/hypixel/hytale/server/npc/asset/builder/expression/BuilderExpressionStaticEmptyArray.java index 2d8838c..d8aedb4 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/expression/BuilderExpressionStaticEmptyArray.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/expression/BuilderExpressionStaticEmptyArray.java @@ -9,9 +9,6 @@ import javax.annotation.Nonnull; public class BuilderExpressionStaticEmptyArray extends BuilderExpression { public static final BuilderExpressionStaticEmptyArray INSTANCE = new BuilderExpressionStaticEmptyArray(); - public BuilderExpressionStaticEmptyArray() { - } - @Nonnull @Override public ValueType getType() { diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/holder/AssetArrayHolder.java b/src/com/hypixel/hytale/server/npc/asset/builder/holder/AssetArrayHolder.java index 0176fd8..4810381 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/holder/AssetArrayHolder.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/holder/AssetArrayHolder.java @@ -11,9 +11,6 @@ import javax.annotation.Nullable; public class AssetArrayHolder extends StringArrayHolder { protected AssetValidator assetValidator; - public AssetArrayHolder() { - } - public void readJSON( @Nonnull JsonElement requiredJsonElement, int minLength, diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/holder/AssetHolder.java b/src/com/hypixel/hytale/server/npc/asset/builder/holder/AssetHolder.java index 9d680b7..2e8ae16 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/holder/AssetHolder.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/holder/AssetHolder.java @@ -11,9 +11,6 @@ import javax.annotation.Nonnull; public class AssetHolder extends StringHolderBase { protected AssetValidator assetValidator; - public AssetHolder() { - } - @Override public void validate(ExecutionContext context) { this.get(context); diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/holder/DeferEvaluateAssetHolder.java b/src/com/hypixel/hytale/server/npc/asset/builder/holder/DeferEvaluateAssetHolder.java index 34c2bb8..273bf3e 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/holder/DeferEvaluateAssetHolder.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/holder/DeferEvaluateAssetHolder.java @@ -1,9 +1,6 @@ package com.hypixel.hytale.server.npc.asset.builder.holder; public class DeferEvaluateAssetHolder extends AssetHolder { - public DeferEvaluateAssetHolder() { - } - @Override public boolean isStatic() { return false; diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/holder/DoubleHolder.java b/src/com/hypixel/hytale/server/npc/asset/builder/holder/DoubleHolder.java index 9c75fe9..669e385 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/holder/DoubleHolder.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/holder/DoubleHolder.java @@ -3,9 +3,6 @@ package com.hypixel.hytale.server.npc.asset.builder.holder; import com.hypixel.hytale.server.npc.util.expression.ExecutionContext; public class DoubleHolder extends DoubleHolderBase { - public DoubleHolder() { - } - @Override public void validate(ExecutionContext context) { this.get(context); diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/holder/EnumHolder.java b/src/com/hypixel/hytale/server/npc/asset/builder/holder/EnumHolder.java index 8e8f8ef..0bdd475 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/holder/EnumHolder.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/holder/EnumHolder.java @@ -15,9 +15,6 @@ public class EnumHolder> extends StringHolderBase { private E[] enumConstants; private E value; - public EnumHolder() { - } - @Override public void validate(ExecutionContext context) { this.get(context); diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/holder/FloatHolder.java b/src/com/hypixel/hytale/server/npc/asset/builder/holder/FloatHolder.java index 5a637ac..1bce64c 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/holder/FloatHolder.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/holder/FloatHolder.java @@ -7,9 +7,6 @@ import com.hypixel.hytale.server.npc.util.expression.ExecutionContext; import javax.annotation.Nonnull; public class FloatHolder extends DoubleHolderBase { - public FloatHolder() { - } - @Override public void validate(ExecutionContext context) { this.get(context); diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/holder/StringHolder.java b/src/com/hypixel/hytale/server/npc/asset/builder/holder/StringHolder.java index db9d801..b56a56c 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/holder/StringHolder.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/holder/StringHolder.java @@ -10,9 +10,6 @@ import javax.annotation.Nonnull; public class StringHolder extends StringHolderBase { protected StringValidator stringValidator; - public StringHolder() { - } - @Override public void validate(ExecutionContext context) { this.get(context); diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/holder/TemporalArrayHolder.java b/src/com/hypixel/hytale/server/npc/asset/builder/holder/TemporalArrayHolder.java index 5110db2..e5956a2 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/holder/TemporalArrayHolder.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/holder/TemporalArrayHolder.java @@ -15,9 +15,6 @@ public class TemporalArrayHolder extends StringArrayHolder { protected TemporalArrayValidator validator; private TemporalAmount[] cachedTemporalArray; - public TemporalArrayHolder() { - } - public static TemporalAmount[] convertStringToTemporalArray(@Nullable String[] source) { if (source == null) { return null; diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/providerevaluators/ProviderEvaluatorTypeRegistry.java b/src/com/hypixel/hytale/server/npc/asset/builder/providerevaluators/ProviderEvaluatorTypeRegistry.java index de13a4a..b6ee1b7 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/providerevaluators/ProviderEvaluatorTypeRegistry.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/providerevaluators/ProviderEvaluatorTypeRegistry.java @@ -5,9 +5,6 @@ import com.hypixel.hytale.server.npc.asset.builder.validators.SubTypeTypeAdapter import javax.annotation.Nonnull; public class ProviderEvaluatorTypeRegistry { - public ProviderEvaluatorTypeRegistry() { - } - @Nonnull public static GsonBuilder registerTypes(@Nonnull GsonBuilder gsonBuilder) { SubTypeTypeAdapterFactory factory = SubTypeTypeAdapterFactory.of(ProviderEvaluator.class, "Type"); diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/validators/ArrayValidator.java b/src/com/hypixel/hytale/server/npc/asset/builder/validators/ArrayValidator.java index dc442d5..5961f7b 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/validators/ArrayValidator.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/validators/ArrayValidator.java @@ -3,9 +3,6 @@ package com.hypixel.hytale.server.npc.asset.builder.validators; import com.hypixel.hytale.server.npc.asset.builder.BuilderObjectArrayHelper; public abstract class ArrayValidator extends Validator { - public ArrayValidator() { - } - public abstract boolean test(BuilderObjectArrayHelper var1); public abstract String errorMessage(String var1, BuilderObjectArrayHelper var2); diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/validators/AssetValidator.java b/src/com/hypixel/hytale/server/npc/asset/builder/validators/AssetValidator.java index 4e6cd13..0cfbe18 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/validators/AssetValidator.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/validators/AssetValidator.java @@ -57,8 +57,5 @@ public abstract class AssetValidator { LIST_NULLABLE, LIST_CAN_BE_EMPTY, MATCHER; - - private Config() { - } } } diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/validators/BooleanArrayValidator.java b/src/com/hypixel/hytale/server/npc/asset/builder/validators/BooleanArrayValidator.java index fb53603..15d23c6 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/validators/BooleanArrayValidator.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/validators/BooleanArrayValidator.java @@ -1,9 +1,6 @@ package com.hypixel.hytale.server.npc.asset.builder.validators; public abstract class BooleanArrayValidator extends Validator { - public BooleanArrayValidator() { - } - public abstract boolean test(boolean[] var1); public abstract String errorMessage(String var1, boolean[] var2); diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/validators/DoubleArrayValidator.java b/src/com/hypixel/hytale/server/npc/asset/builder/validators/DoubleArrayValidator.java index 89ec154..ea4fd58 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/validators/DoubleArrayValidator.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/validators/DoubleArrayValidator.java @@ -1,9 +1,6 @@ package com.hypixel.hytale.server.npc.asset.builder.validators; public abstract class DoubleArrayValidator extends Validator { - public DoubleArrayValidator() { - } - public abstract boolean test(double[] var1); public abstract String errorMessage(double[] var1, String var2); diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/validators/DoubleValidator.java b/src/com/hypixel/hytale/server/npc/asset/builder/validators/DoubleValidator.java index ace725e..6562f53 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/validators/DoubleValidator.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/validators/DoubleValidator.java @@ -3,9 +3,6 @@ package com.hypixel.hytale.server.npc.asset.builder.validators; import javax.annotation.Nonnull; public abstract class DoubleValidator extends Validator { - public DoubleValidator() { - } - public abstract boolean test(double var1); public static boolean compare(double value, @Nonnull RelationalOperator predicate, double c) { diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/validators/EnumArrayValidator.java b/src/com/hypixel/hytale/server/npc/asset/builder/validators/EnumArrayValidator.java index 3097d94..a45a95c 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/validators/EnumArrayValidator.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/validators/EnumArrayValidator.java @@ -1,9 +1,6 @@ package com.hypixel.hytale.server.npc.asset.builder.validators; public abstract class EnumArrayValidator extends Validator { - public EnumArrayValidator() { - } - public abstract > boolean test(T[] var1, Class var2); public abstract > String errorMessage(String var1, T[] var2); diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/validators/IntArrayValidator.java b/src/com/hypixel/hytale/server/npc/asset/builder/validators/IntArrayValidator.java index df699a3..deade44 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/validators/IntArrayValidator.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/validators/IntArrayValidator.java @@ -1,9 +1,6 @@ package com.hypixel.hytale.server.npc.asset.builder.validators; public abstract class IntArrayValidator extends Validator { - public IntArrayValidator() { - } - public abstract boolean test(int[] var1); public abstract String errorMessage(int[] var1, String var2); diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/validators/IntValidator.java b/src/com/hypixel/hytale/server/npc/asset/builder/validators/IntValidator.java index 3163cca..4dd7d54 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/validators/IntValidator.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/validators/IntValidator.java @@ -3,9 +3,6 @@ package com.hypixel.hytale.server.npc.asset.builder.validators; import javax.annotation.Nonnull; public abstract class IntValidator extends Validator { - public IntValidator() { - } - public abstract boolean test(int var1); public static boolean compare(int value, @Nonnull RelationalOperator op, int c) { diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/validators/RequiredFeatureValidator.java b/src/com/hypixel/hytale/server/npc/asset/builder/validators/RequiredFeatureValidator.java index 2933d42..ccb686c 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/validators/RequiredFeatureValidator.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/validators/RequiredFeatureValidator.java @@ -4,9 +4,6 @@ import com.hypixel.hytale.server.npc.asset.builder.FeatureEvaluatorHelper; import javax.annotation.Nullable; public abstract class RequiredFeatureValidator extends Validator { - public RequiredFeatureValidator() { - } - public abstract boolean validate(FeatureEvaluatorHelper var1); @Nullable diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/validators/StringArrayValidator.java b/src/com/hypixel/hytale/server/npc/asset/builder/validators/StringArrayValidator.java index a88780a..b8366de 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/validators/StringArrayValidator.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/validators/StringArrayValidator.java @@ -1,9 +1,6 @@ package com.hypixel.hytale.server.npc.asset.builder.validators; public abstract class StringArrayValidator extends Validator { - public StringArrayValidator() { - } - public abstract boolean test(String[] var1); public abstract String errorMessage(String var1, String[] var2); diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/validators/StringValidator.java b/src/com/hypixel/hytale/server/npc/asset/builder/validators/StringValidator.java index 787d4a8..913e345 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/validators/StringValidator.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/validators/StringValidator.java @@ -1,9 +1,6 @@ package com.hypixel.hytale.server.npc.asset.builder.validators; public abstract class StringValidator extends Validator { - public StringValidator() { - } - public abstract boolean test(String var1); public abstract String errorMessage(String var1); diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/validators/TemporalArrayValidator.java b/src/com/hypixel/hytale/server/npc/asset/builder/validators/TemporalArrayValidator.java index 5cd3802..c19b0c8 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/validators/TemporalArrayValidator.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/validators/TemporalArrayValidator.java @@ -3,9 +3,6 @@ package com.hypixel.hytale.server.npc.asset.builder.validators; import java.time.temporal.TemporalAmount; public abstract class TemporalArrayValidator extends Validator { - public TemporalArrayValidator() { - } - public abstract boolean test(TemporalAmount[] var1); public abstract String errorMessage(String var1, TemporalAmount[] var2); diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/validators/Validator.java b/src/com/hypixel/hytale/server/npc/asset/builder/validators/Validator.java index f6ea86a..00233be 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/validators/Validator.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/validators/Validator.java @@ -1,6 +1,4 @@ package com.hypixel.hytale.server.npc.asset.builder.validators; public abstract class Validator { - public Validator() { - } } diff --git a/src/com/hypixel/hytale/server/npc/asset/builder/validators/ValidatorTypeRegistry.java b/src/com/hypixel/hytale/server/npc/asset/builder/validators/ValidatorTypeRegistry.java index c257849..a2c8ed6 100644 --- a/src/com/hypixel/hytale/server/npc/asset/builder/validators/ValidatorTypeRegistry.java +++ b/src/com/hypixel/hytale/server/npc/asset/builder/validators/ValidatorTypeRegistry.java @@ -4,9 +4,6 @@ import com.google.gson.GsonBuilder; import javax.annotation.Nonnull; public class ValidatorTypeRegistry { - public ValidatorTypeRegistry() { - } - @Nonnull public static GsonBuilder registerTypes(@Nonnull GsonBuilder gsonBuilder) { SubTypeTypeAdapterFactory factory = SubTypeTypeAdapterFactory.of(Validator.class, "Type"); diff --git a/src/com/hypixel/hytale/server/npc/blackboard/Blackboard.java b/src/com/hypixel/hytale/server/npc/blackboard/Blackboard.java index f645b96..e747a0e 100644 --- a/src/com/hypixel/hytale/server/npc/blackboard/Blackboard.java +++ b/src/com/hypixel/hytale/server/npc/blackboard/Blackboard.java @@ -30,9 +30,6 @@ public class Blackboard implements Resource { public static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); private final ConcurrentHashMap>, IBlackboardViewManager> views = new ConcurrentHashMap<>(); - public Blackboard() { - } - public static ResourceType getResourceType() { return NPCPlugin.get().getBlackboardResourceType(); } diff --git a/src/com/hypixel/hytale/server/npc/blackboard/view/BlockRegionView.java b/src/com/hypixel/hytale/server/npc/blackboard/view/BlockRegionView.java index 2c5f59e..07dd084 100644 --- a/src/com/hypixel/hytale/server/npc/blackboard/view/BlockRegionView.java +++ b/src/com/hypixel/hytale/server/npc/blackboard/view/BlockRegionView.java @@ -11,9 +11,6 @@ public abstract class BlockRegionView public static final int SIZE_MASK = 127; public static final int BITS2 = 14; - public BlockRegionView() { - } - public static int toRegionalBlackboardCoordinate(int pos) { return pos >> 7; } diff --git a/src/com/hypixel/hytale/server/npc/blackboard/view/BlockRegionViewManager.java b/src/com/hypixel/hytale/server/npc/blackboard/view/BlockRegionViewManager.java index 2f152a0..68809a6 100644 --- a/src/com/hypixel/hytale/server/npc/blackboard/view/BlockRegionViewManager.java +++ b/src/com/hypixel/hytale/server/npc/blackboard/view/BlockRegionViewManager.java @@ -18,9 +18,6 @@ public abstract class BlockRegionViewManager> @Nonnull protected LongArrayFIFOQueue removalQueue = new LongArrayFIFOQueue(); - public BlockRegionViewManager() { - } - public Type get(@Nonnull Ref ref, Blackboard blackboard, @Nonnull ComponentAccessor componentAccessor) { TransformComponent transformComponent = componentAccessor.getComponent(ref, TransformComponent.getComponentType()); diff --git a/src/com/hypixel/hytale/server/npc/blackboard/view/PrioritisedProviderView.java b/src/com/hypixel/hytale/server/npc/blackboard/view/PrioritisedProviderView.java index 6a38703..ef9041f 100644 --- a/src/com/hypixel/hytale/server/npc/blackboard/view/PrioritisedProviderView.java +++ b/src/com/hypixel/hytale/server/npc/blackboard/view/PrioritisedProviderView.java @@ -10,9 +10,6 @@ public abstract class PrioritisedProviderView> providers = new ObjectArrayList<>(); - public PrioritisedProviderView() { - } - public void registerProvider(int priority, T provider) { this.providers.add(new PrioritisedProviderView.PrioritisedProvider<>(priority, provider)); Collections.sort(this.providers); diff --git a/src/com/hypixel/hytale/server/npc/blackboard/view/attitude/AttitudeMap.java b/src/com/hypixel/hytale/server/npc/blackboard/view/attitude/AttitudeMap.java index 8d3e107..cbe8b97 100644 --- a/src/com/hypixel/hytale/server/npc/blackboard/view/attitude/AttitudeMap.java +++ b/src/com/hypixel/hytale/server/npc/blackboard/view/attitude/AttitudeMap.java @@ -70,9 +70,6 @@ public class AttitudeMap { public static class Builder { private final Int2ObjectMap[] map = new Int2ObjectMap[AttitudeGroup.getAssetMap().getNextIndex()]; - public Builder() { - } - public void addAttitudeGroups(@Nonnull Map groups) { groups.forEach((id, group) -> this.addAttitudeGroup(group)); } diff --git a/src/com/hypixel/hytale/server/npc/blackboard/view/attitude/ItemAttitudeMap.java b/src/com/hypixel/hytale/server/npc/blackboard/view/attitude/ItemAttitudeMap.java index 2290b0d..03fbc10 100644 --- a/src/com/hypixel/hytale/server/npc/blackboard/view/attitude/ItemAttitudeMap.java +++ b/src/com/hypixel/hytale/server/npc/blackboard/view/attitude/ItemAttitudeMap.java @@ -51,9 +51,6 @@ public class ItemAttitudeMap { public static class Builder { private final Map[] map = new HashMap[ItemAttitudeGroup.getAssetMap().getNextIndex()]; - public Builder() { - } - public void addAttitudeGroups(@Nonnull Map groups) { groups.forEach((id, group) -> this.addAttitudeGroup(group)); } diff --git a/src/com/hypixel/hytale/server/npc/blackboard/view/blocktype/BlockPositionEntryGenerator.java b/src/com/hypixel/hytale/server/npc/blackboard/view/blocktype/BlockPositionEntryGenerator.java index efcd5e5..930a145 100644 --- a/src/com/hypixel/hytale/server/npc/blackboard/view/blocktype/BlockPositionEntryGenerator.java +++ b/src/com/hypixel/hytale/server/npc/blackboard/view/blocktype/BlockPositionEntryGenerator.java @@ -26,9 +26,6 @@ public class BlockPositionEntryGenerator { private final BlockPositionEntryGenerator.FoundBlockConsumer foundBlockConsumer = new BlockPositionEntryGenerator.FoundBlockConsumer(); private final IntSet internalIdHolder = new IntOpenHashSet(); - public BlockPositionEntryGenerator() { - } - @Nonnull public BlockPositionProvider generate( short changeCounter, int sectionIndex, @Nonnull BlockChunk chunk, IntList unifiedBlocksOfInterest, @Nonnull BitSet searchedBlockSets @@ -59,9 +56,6 @@ public class BlockPositionEntryGenerator { @Nullable private Int2ObjectOpenHashMap> blockData; - private FoundBlockConsumer() { - } - public void init(ChunkSectionReference sectionPointer, BitSet searchedBlockSets) { this.sectionPointer = sectionPointer; this.searchedBlockSets = searchedBlockSets; diff --git a/src/com/hypixel/hytale/server/npc/blackboard/view/blocktype/BlockTypeViewManager.java b/src/com/hypixel/hytale/server/npc/blackboard/view/blocktype/BlockTypeViewManager.java index 38c9c33..cf62809 100644 --- a/src/com/hypixel/hytale/server/npc/blackboard/view/blocktype/BlockTypeViewManager.java +++ b/src/com/hypixel/hytale/server/npc/blackboard/view/blocktype/BlockTypeViewManager.java @@ -7,9 +7,6 @@ import javax.annotation.Nonnull; public class BlockTypeViewManager extends BlockRegionViewManager { private final BlockPositionEntryGenerator generator = new BlockPositionEntryGenerator(); - public BlockTypeViewManager() { - } - @Nonnull protected BlockTypeView createView(long index, Blackboard blackboard) { return new BlockTypeView(index, blackboard, this.generator); diff --git a/src/com/hypixel/hytale/server/npc/blackboard/view/combat/CombatViewSystems.java b/src/com/hypixel/hytale/server/npc/blackboard/view/combat/CombatViewSystems.java index 7b12469..3fe7075 100644 --- a/src/com/hypixel/hytale/server/npc/blackboard/view/combat/CombatViewSystems.java +++ b/src/com/hypixel/hytale/server/npc/blackboard/view/combat/CombatViewSystems.java @@ -15,9 +15,7 @@ import com.hypixel.hytale.component.Store; import com.hypixel.hytale.component.query.Query; import com.hypixel.hytale.component.system.HolderSystem; import com.hypixel.hytale.component.system.tick.EntityTickingSystem; -import com.hypixel.hytale.server.core.entity.EntityUtils; import com.hypixel.hytale.server.core.entity.InteractionManager; -import com.hypixel.hytale.server.core.entity.LivingEntity; import com.hypixel.hytale.server.core.modules.entity.AllLegacyEntityTypesQuery; import com.hypixel.hytale.server.core.modules.interaction.InteractionModule; import com.hypixel.hytale.server.core.modules.interaction.interaction.config.RootInteraction; @@ -33,9 +31,6 @@ import java.util.Set; import javax.annotation.Nonnull; public class CombatViewSystems { - public CombatViewSystems() { - } - private static void clearCombatData(@Nonnull CombatViewSystems.CombatData combatData, @Nonnull CombatViewSystems.CombatDataPool dataPool) { if (combatData.interpreted) { List dataList = combatData.combatData; @@ -50,20 +45,19 @@ public class CombatViewSystems { } @Nonnull - public static List getCombatData(@Nonnull Ref reference) { - CombatViewSystems.CombatData combatData = reference.getStore().getComponent(reference, CombatViewSystems.CombatData.getComponentType()); - if (combatData.interpreted) { - return combatData.unmodifiableCombatData; + public static List getCombatData(@Nonnull Ref ref, @Nonnull Store store) { + CombatViewSystems.CombatData combatDataComponent = store.getComponent(ref, CombatViewSystems.CombatData.getComponentType()); + if (combatDataComponent.interpreted) { + return combatDataComponent.unmodifiableCombatData; } else { - InteractionManager interactionManager = reference.getStore().getComponent(reference, InteractionModule.get().getInteractionManagerComponent()); - CombatViewSystems.CombatDataPool combatDataPool = reference.getStore().getResource(CombatViewSystems.CombatDataPool.getResourceType()); - List dataList = combatData.combatData; + InteractionManager interactionManager = store.getComponent(ref, InteractionModule.get().getInteractionManagerComponent()); + CombatViewSystems.CombatDataPool combatDataPool = store.getResource(CombatViewSystems.CombatDataPool.getResourceType()); + List dataList = combatDataComponent.combatData; IndexedLookupTableAssetMap interactionAssetMap = RootInteraction.getAssetMap(); Set attackInteractions = interactionAssetMap.getKeysForTag(CombatSupport.ATTACK_TAG_INDEX); Set meleeInteractions = interactionAssetMap.getKeysForTag(CombatSupport.MELEE_TAG_INDEX); Set rangedInteractions = interactionAssetMap.getKeysForTag(CombatSupport.RANGED_TAG_INDEX); Set blockInteractions = interactionAssetMap.getKeysForTag(CombatSupport.BLOCK_TAG_INDEX); - LivingEntity entity = (LivingEntity)EntityUtils.getEntity(reference, reference.getStore()); interactionManager.forEachInteraction((chain, interaction, list) -> { String rootId = chain.getRootInteraction().getId(); if (!attackInteractions.contains(rootId)) { @@ -80,8 +74,8 @@ public class CombatViewSystems { return list; } }, dataList); - combatData.interpreted = true; - return combatData.unmodifiableCombatData; + combatDataComponent.interpreted = true; + return combatDataComponent.unmodifiableCombatData; } } @@ -90,9 +84,6 @@ public class CombatViewSystems { private final List unmodifiableCombatData = Collections.unmodifiableList(this.combatData); private boolean interpreted; - public CombatData() { - } - public static ComponentType getComponentType() { return NPCPlugin.get().getCombatDataComponentType(); } @@ -114,9 +105,6 @@ public class CombatViewSystems { public static class CombatDataPool implements Resource { private final ArrayDeque combatDataPool = new ArrayDeque<>(); - public CombatDataPool() { - } - public static ResourceType getResourceType() { return NPCPlugin.get().getCombatDataPoolResourceType(); } diff --git a/src/com/hypixel/hytale/server/npc/blackboard/view/combat/InterpretedCombatData.java b/src/com/hypixel/hytale/server/npc/blackboard/view/combat/InterpretedCombatData.java index ffb7e19..08e5893 100644 --- a/src/com/hypixel/hytale/server/npc/blackboard/view/combat/InterpretedCombatData.java +++ b/src/com/hypixel/hytale/server/npc/blackboard/view/combat/InterpretedCombatData.java @@ -10,9 +10,6 @@ public class InterpretedCombatData { private boolean performingRangedAttack; private boolean performingBlock; - public InterpretedCombatData() { - } - public String getAttack() { return this.attack; } diff --git a/src/com/hypixel/hytale/server/npc/blackboard/view/event/EntityEventNotification.java b/src/com/hypixel/hytale/server/npc/blackboard/view/event/EntityEventNotification.java index e9670cf..02f781c 100644 --- a/src/com/hypixel/hytale/server/npc/blackboard/view/event/EntityEventNotification.java +++ b/src/com/hypixel/hytale/server/npc/blackboard/view/event/EntityEventNotification.java @@ -6,9 +6,6 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; public class EntityEventNotification extends EventNotification { private Ref flockReference; - public EntityEventNotification() { - } - public Ref getFlockReference() { return this.flockReference; } diff --git a/src/com/hypixel/hytale/server/npc/blackboard/view/event/EventNotification.java b/src/com/hypixel/hytale/server/npc/blackboard/view/event/EventNotification.java index d485c0b..062ae15 100644 --- a/src/com/hypixel/hytale/server/npc/blackboard/view/event/EventNotification.java +++ b/src/com/hypixel/hytale/server/npc/blackboard/view/event/EventNotification.java @@ -10,9 +10,6 @@ public class EventNotification { private Ref initiator; private int set; - public EventNotification() { - } - @Nonnull public Vector3d getPosition() { return this.position; diff --git a/src/com/hypixel/hytale/server/npc/blackboard/view/interaction/ReservationStatus.java b/src/com/hypixel/hytale/server/npc/blackboard/view/interaction/ReservationStatus.java index 541295f..e555e11 100644 --- a/src/com/hypixel/hytale/server/npc/blackboard/view/interaction/ReservationStatus.java +++ b/src/com/hypixel/hytale/server/npc/blackboard/view/interaction/ReservationStatus.java @@ -4,7 +4,4 @@ public enum ReservationStatus { NOT_RESERVED, RESERVED_OTHER, RESERVED_THIS; - - private ReservationStatus() { - } } diff --git a/src/com/hypixel/hytale/server/npc/blackboard/view/resource/ResourceViewManager.java b/src/com/hypixel/hytale/server/npc/blackboard/view/resource/ResourceViewManager.java index c16f74a..32feeb9 100644 --- a/src/com/hypixel/hytale/server/npc/blackboard/view/resource/ResourceViewManager.java +++ b/src/com/hypixel/hytale/server/npc/blackboard/view/resource/ResourceViewManager.java @@ -5,9 +5,6 @@ import com.hypixel.hytale.server.npc.blackboard.view.BlockRegionViewManager; import javax.annotation.Nonnull; public class ResourceViewManager extends BlockRegionViewManager { - public ResourceViewManager() { - } - @Nonnull protected ResourceView createView(long index, Blackboard blackboard) { return new ResourceView(index); diff --git a/src/com/hypixel/hytale/server/npc/commands/NPCCommandUtils.java b/src/com/hypixel/hytale/server/npc/commands/NPCCommandUtils.java index 95c6fdc..1782369 100644 --- a/src/com/hypixel/hytale/server/npc/commands/NPCCommandUtils.java +++ b/src/com/hypixel/hytale/server/npc/commands/NPCCommandUtils.java @@ -15,9 +15,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class NPCCommandUtils { - public NPCCommandUtils() { - } - @Nullable public static Pair, NPCEntity> getTargetNpc( @Nonnull CommandContext context, @Nonnull EntityWrappedArg arg, @Nonnull Store store diff --git a/src/com/hypixel/hytale/server/npc/commands/NPCRunTestsCommand.java b/src/com/hypixel/hytale/server/npc/commands/NPCRunTestsCommand.java index 895d63f..e18204d 100644 --- a/src/com/hypixel/hytale/server/npc/commands/NPCRunTestsCommand.java +++ b/src/com/hypixel/hytale/server/npc/commands/NPCRunTestsCommand.java @@ -256,9 +256,6 @@ public class NPCRunTestsCommand extends AbstractPlayerCommand { private int index; private UUID targetUUID; - public NPCTestData() { - } - public static ComponentType getComponentType() { return NPCPlugin.get().getNpcTestDataComponentType(); } diff --git a/src/com/hypixel/hytale/server/npc/components/FailedSpawnComponent.java b/src/com/hypixel/hytale/server/npc/components/FailedSpawnComponent.java index b962c6f..0859646 100644 --- a/src/com/hypixel/hytale/server/npc/components/FailedSpawnComponent.java +++ b/src/com/hypixel/hytale/server/npc/components/FailedSpawnComponent.java @@ -11,9 +11,6 @@ public class FailedSpawnComponent implements Component { return NPCPlugin.get().getFailedSpawnComponentType(); } - public FailedSpawnComponent() { - } - @Nonnull @Override public Component clone() { diff --git a/src/com/hypixel/hytale/server/npc/components/SortBufferProviderResource.java b/src/com/hypixel/hytale/server/npc/components/SortBufferProviderResource.java index 41e0646..67bf5d2 100644 --- a/src/com/hypixel/hytale/server/npc/components/SortBufferProviderResource.java +++ b/src/com/hypixel/hytale/server/npc/components/SortBufferProviderResource.java @@ -10,9 +10,6 @@ import javax.annotation.Nonnull; public class SortBufferProviderResource implements Resource { private final BucketList.SortBufferProvider sortBufferProvider = new BucketList.SortBufferProvider(); - public SortBufferProviderResource() { - } - public static ResourceType getResourceType() { return NPCPlugin.get().getSortBufferProviderResourceResourceType(); } diff --git a/src/com/hypixel/hytale/server/npc/components/SpawnBeaconReference.java b/src/com/hypixel/hytale/server/npc/components/SpawnBeaconReference.java index 15e38ed..7d5c3de 100644 --- a/src/com/hypixel/hytale/server/npc/components/SpawnBeaconReference.java +++ b/src/com/hypixel/hytale/server/npc/components/SpawnBeaconReference.java @@ -11,9 +11,6 @@ public class SpawnBeaconReference extends SpawnReference { public static final BuilderCodec CODEC = BuilderCodec.builder(SpawnBeaconReference.class, SpawnBeaconReference::new, BASE_CODEC) .build(); - public SpawnBeaconReference() { - } - public static ComponentType getComponentType() { return SpawningPlugin.get().getSpawnBeaconReferenceComponentType(); } diff --git a/src/com/hypixel/hytale/server/npc/components/SpawnMarkerReference.java b/src/com/hypixel/hytale/server/npc/components/SpawnMarkerReference.java index 32b2dfc..8ff5b90 100644 --- a/src/com/hypixel/hytale/server/npc/components/SpawnMarkerReference.java +++ b/src/com/hypixel/hytale/server/npc/components/SpawnMarkerReference.java @@ -11,9 +11,6 @@ public class SpawnMarkerReference extends SpawnReference { public static final BuilderCodec CODEC = BuilderCodec.builder(SpawnMarkerReference.class, SpawnMarkerReference::new, BASE_CODEC) .build(); - public SpawnMarkerReference() { - } - public static ComponentType getComponentType() { return SpawningPlugin.get().getSpawnMarkerReferenceComponentType(); } diff --git a/src/com/hypixel/hytale/server/npc/components/SpawnReference.java b/src/com/hypixel/hytale/server/npc/components/SpawnReference.java index 4506417..7bc66c5 100644 --- a/src/com/hypixel/hytale/server/npc/components/SpawnReference.java +++ b/src/com/hypixel/hytale/server/npc/components/SpawnReference.java @@ -19,9 +19,6 @@ public abstract class SpawnReference implements Component { protected InvalidatablePersistentRef reference = new InvalidatablePersistentRef(); private float markerLostTimeoutCounter; - public SpawnReference() { - } - public InvalidatablePersistentRef getReference() { return this.reference; } diff --git a/src/com/hypixel/hytale/server/npc/components/messaging/BeaconSupport.java b/src/com/hypixel/hytale/server/npc/components/messaging/BeaconSupport.java index 8caed37..9dd7d75 100644 --- a/src/com/hypixel/hytale/server/npc/components/messaging/BeaconSupport.java +++ b/src/com/hypixel/hytale/server/npc/components/messaging/BeaconSupport.java @@ -16,9 +16,6 @@ public class BeaconSupport extends MessageSupport implements Component messageIndices; private Int2ObjectMap indicesToMessages; - public BeaconSupport() { - } - public static ComponentType getComponentType() { return NPCPlugin.get().getBeaconSupportComponentType(); } diff --git a/src/com/hypixel/hytale/server/npc/components/messaging/EntityEventSupport.java b/src/com/hypixel/hytale/server/npc/components/messaging/EntityEventSupport.java index d8f8d59..07648b0 100644 --- a/src/com/hypixel/hytale/server/npc/components/messaging/EntityEventSupport.java +++ b/src/com/hypixel/hytale/server/npc/components/messaging/EntityEventSupport.java @@ -11,9 +11,6 @@ import com.hypixel.hytale.server.npc.blackboard.view.event.entity.EntityEventTyp import javax.annotation.Nonnull; public abstract class EntityEventSupport extends EventSupport { - public EntityEventSupport() { - } - public void postMessage( EntityEventType type, @Nonnull EntityEventNotification notification, @Nonnull Ref parent, @Nonnull Store store ) { diff --git a/src/com/hypixel/hytale/server/npc/components/messaging/EventSupport.java b/src/com/hypixel/hytale/server/npc/components/messaging/EventSupport.java index 3719184..4253db6 100644 --- a/src/com/hypixel/hytale/server/npc/components/messaging/EventSupport.java +++ b/src/com/hypixel/hytale/server/npc/components/messaging/EventSupport.java @@ -17,9 +17,6 @@ public abstract class EventSupport, Notificati protected EventMessage[] messageSlots; protected Map messageIndices; - public EventSupport() { - } - public void postMessage(EventType type, @Nonnull NotificationType notification, @Nonnull Ref parent, @Nonnull Store store) { EventMessage slot = this.getMessageSlot(type, notification); if (slot != null && slot.isEnabled()) { diff --git a/src/com/hypixel/hytale/server/npc/components/messaging/MessageSupport.java b/src/com/hypixel/hytale/server/npc/components/messaging/MessageSupport.java index 8db9684..166297a 100644 --- a/src/com/hypixel/hytale/server/npc/components/messaging/MessageSupport.java +++ b/src/com/hypixel/hytale/server/npc/components/messaging/MessageSupport.java @@ -4,9 +4,6 @@ import com.hypixel.hytale.component.Component; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; public abstract class MessageSupport implements Component { - public MessageSupport() { - } - public abstract NPCMessage[] getMessageSlots(); public boolean isMessageQueued(int messageIndex) { diff --git a/src/com/hypixel/hytale/server/npc/components/messaging/NPCBlockEventSupport.java b/src/com/hypixel/hytale/server/npc/components/messaging/NPCBlockEventSupport.java index d9447b6..b385a1c 100644 --- a/src/com/hypixel/hytale/server/npc/components/messaging/NPCBlockEventSupport.java +++ b/src/com/hypixel/hytale/server/npc/components/messaging/NPCBlockEventSupport.java @@ -9,9 +9,6 @@ import com.hypixel.hytale.server.npc.blackboard.view.event.block.BlockEventType; import javax.annotation.Nonnull; public class NPCBlockEventSupport extends EventSupport implements Component { - public NPCBlockEventSupport() { - } - public static ComponentType getComponentType() { return NPCPlugin.get().getNpcBlockEventSupportComponentType(); } diff --git a/src/com/hypixel/hytale/server/npc/components/messaging/NPCEntityEventSupport.java b/src/com/hypixel/hytale/server/npc/components/messaging/NPCEntityEventSupport.java index 262610d..7260471 100644 --- a/src/com/hypixel/hytale/server/npc/components/messaging/NPCEntityEventSupport.java +++ b/src/com/hypixel/hytale/server/npc/components/messaging/NPCEntityEventSupport.java @@ -7,9 +7,6 @@ import com.hypixel.hytale.server.npc.NPCPlugin; import javax.annotation.Nonnull; public class NPCEntityEventSupport extends EntityEventSupport implements Component { - public NPCEntityEventSupport() { - } - public static ComponentType getComponentType() { return NPCPlugin.get().getNpcEntityEventSupportComponentType(); } diff --git a/src/com/hypixel/hytale/server/npc/components/messaging/NPCMessage.java b/src/com/hypixel/hytale/server/npc/components/messaging/NPCMessage.java index d2cb013..a8c6172 100644 --- a/src/com/hypixel/hytale/server/npc/components/messaging/NPCMessage.java +++ b/src/com/hypixel/hytale/server/npc/components/messaging/NPCMessage.java @@ -12,9 +12,6 @@ public class NPCMessage { private double age; private Ref target; - public NPCMessage() { - } - public boolean tickAge(float dt) { return (this.age -= dt) <= 0.0; } diff --git a/src/com/hypixel/hytale/server/npc/components/messaging/PlayerBlockEventSupport.java b/src/com/hypixel/hytale/server/npc/components/messaging/PlayerBlockEventSupport.java index f7a97fe..58c1507 100644 --- a/src/com/hypixel/hytale/server/npc/components/messaging/PlayerBlockEventSupport.java +++ b/src/com/hypixel/hytale/server/npc/components/messaging/PlayerBlockEventSupport.java @@ -9,9 +9,6 @@ import com.hypixel.hytale.server.npc.blackboard.view.event.block.BlockEventType; import javax.annotation.Nonnull; public class PlayerBlockEventSupport extends EventSupport implements Component { - public PlayerBlockEventSupport() { - } - public static ComponentType getComponentType() { return NPCPlugin.get().getPlayerBlockEventSupportComponentType(); } diff --git a/src/com/hypixel/hytale/server/npc/components/messaging/PlayerEntityEventSupport.java b/src/com/hypixel/hytale/server/npc/components/messaging/PlayerEntityEventSupport.java index b1f6ccd..de97b87 100644 --- a/src/com/hypixel/hytale/server/npc/components/messaging/PlayerEntityEventSupport.java +++ b/src/com/hypixel/hytale/server/npc/components/messaging/PlayerEntityEventSupport.java @@ -7,9 +7,6 @@ import com.hypixel.hytale.server.npc.NPCPlugin; import javax.annotation.Nonnull; public class PlayerEntityEventSupport extends EntityEventSupport implements Component { - public PlayerEntityEventSupport() { - } - public static ComponentType getComponentType() { return NPCPlugin.get().getPlayerEntityEventSupportComponentType(); } diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/AnnotatedComponentBase.java b/src/com/hypixel/hytale/server/npc/corecomponents/AnnotatedComponentBase.java index 82a105c..ae47830 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/AnnotatedComponentBase.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/AnnotatedComponentBase.java @@ -8,9 +8,6 @@ public abstract class AnnotatedComponentBase implements IAnnotatedComponent { protected IAnnotatedComponent parent; protected int index; - public AnnotatedComponentBase() { - } - @Override public void getInfo(Role role, ComponentInfo holder) { } diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/BlockTarget.java b/src/com/hypixel/hytale/server/npc/corecomponents/BlockTarget.java index 288393e..1f6f9d9 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/BlockTarget.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/BlockTarget.java @@ -15,9 +15,6 @@ public class BlockTarget { @Nullable private ResourceView reservationHolder; - public BlockTarget() { - } - @Nonnull public Vector3d getPosition() { return this.position; diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/EntityFilterBase.java b/src/com/hypixel/hytale/server/npc/corecomponents/EntityFilterBase.java index 18e6f0d..e23b38e 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/EntityFilterBase.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/EntityFilterBase.java @@ -1,6 +1,4 @@ package com.hypixel.hytale.server.npc.corecomponents; public abstract class EntityFilterBase extends AnnotatedComponentBase implements IEntityFilter { - public EntityFilterBase() { - } } diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/MotionBase.java b/src/com/hypixel/hytale/server/npc/corecomponents/MotionBase.java index 4c5fcb2..dfa7e51 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/MotionBase.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/MotionBase.java @@ -3,6 +3,4 @@ package com.hypixel.hytale.server.npc.corecomponents; import com.hypixel.hytale.server.npc.instructions.Motion; public abstract class MotionBase extends AnnotatedComponentBase implements Motion { - public MotionBase() { - } } diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/ActionSpawnParticles.java b/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/ActionSpawnParticles.java index 454c670..4468058 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/ActionSpawnParticles.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/ActionSpawnParticles.java @@ -24,8 +24,8 @@ public class ActionSpawnParticles extends ActionBase { public ActionSpawnParticles(@Nonnull BuilderActionSpawnParticles builder, @Nonnull BuilderSupport support) { super(builder); this.particleSystem = builder.getParticleSystem(support); - this.offset = builder.getOffset(); - this.range = builder.getRange(); + this.offset = builder.getOffset(support); + this.range = builder.getRange(support); } @Override diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderActionAppearance.java b/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderActionAppearance.java index 78e6286..a8eee01 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderActionAppearance.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderActionAppearance.java @@ -11,9 +11,6 @@ import javax.annotation.Nonnull; public class BuilderActionAppearance extends BuilderActionBase { protected String appearance; - public BuilderActionAppearance() { - } - @Nonnull public ActionAppearance build(BuilderSupport builderSupport) { return new ActionAppearance(this); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderActionDisplayName.java b/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderActionDisplayName.java index 70aa2cb..d1bafda 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderActionDisplayName.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderActionDisplayName.java @@ -11,9 +11,6 @@ import javax.annotation.Nonnull; public class BuilderActionDisplayName extends BuilderActionBase { protected final StringHolder displayName = new StringHolder(); - public BuilderActionDisplayName() { - } - @Nonnull public ActionDisplayName build(@Nonnull BuilderSupport builderSupport) { return new ActionDisplayName(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderActionModelAttachment.java b/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderActionModelAttachment.java index c8551cc..b4e608c 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderActionModelAttachment.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderActionModelAttachment.java @@ -13,9 +13,6 @@ public class BuilderActionModelAttachment extends BuilderActionBase { protected final StringHolder slot = new StringHolder(); protected final StringHolder attachment = new StringHolder(); - public BuilderActionModelAttachment() { - } - @Nonnull public ActionModelAttachment build(@Nonnull BuilderSupport builderSupport) { return new ActionModelAttachment(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderActionPlayAnimation.java b/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderActionPlayAnimation.java index 977395a..596e3b5 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderActionPlayAnimation.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderActionPlayAnimation.java @@ -17,9 +17,6 @@ public class BuilderActionPlayAnimation extends BuilderActionBase { protected NPCAnimationSlot slot; protected final StringHolder animationId = new StringHolder(); - public BuilderActionPlayAnimation() { - } - public ActionPlayAnimation build(@Nonnull BuilderSupport builderSupport) { return new ActionPlayAnimation(this, builderSupport); } diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderActionPlaySound.java b/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderActionPlaySound.java index 1b893a0..acfe7bc 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderActionPlaySound.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderActionPlaySound.java @@ -13,9 +13,6 @@ import javax.annotation.Nonnull; public class BuilderActionPlaySound extends BuilderActionBase { protected final AssetHolder soundEventId = new AssetHolder(); - public BuilderActionPlaySound() { - } - @Nonnull public ActionPlaySound build(@Nonnull BuilderSupport builderSupport) { return new ActionPlaySound(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderActionSpawnParticles.java b/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderActionSpawnParticles.java index 3953ade..43f3500 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderActionSpawnParticles.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderActionSpawnParticles.java @@ -5,6 +5,8 @@ import com.hypixel.hytale.math.vector.Vector3d; import com.hypixel.hytale.server.npc.asset.builder.BuilderDescriptorState; import com.hypixel.hytale.server.npc.asset.builder.BuilderSupport; import com.hypixel.hytale.server.npc.asset.builder.holder.AssetHolder; +import com.hypixel.hytale.server.npc.asset.builder.holder.DoubleHolder; +import com.hypixel.hytale.server.npc.asset.builder.holder.NumberArrayHolder; import com.hypixel.hytale.server.npc.asset.builder.validators.DoubleSingleValidator; import com.hypixel.hytale.server.npc.asset.builder.validators.asset.ParticleSystemExistsValidator; import com.hypixel.hytale.server.npc.corecomponents.audiovisual.ActionSpawnParticles; @@ -13,11 +15,8 @@ import javax.annotation.Nonnull; public class BuilderActionSpawnParticles extends BuilderActionBase { protected final AssetHolder particleSystem = new AssetHolder(); - protected double range; - protected double[] offset; - - public BuilderActionSpawnParticles() { - } + protected final DoubleHolder range = new DoubleHolder(); + protected final NumberArrayHolder offset = new NumberArrayHolder(); @Nonnull public ActionSpawnParticles build(@Nonnull BuilderSupport builderSupport) { @@ -47,12 +46,8 @@ public class BuilderActionSpawnParticles extends BuilderActionBase { this.requireAsset( data, "ParticleSystem", this.particleSystem, ParticleSystemExistsValidator.required(), BuilderDescriptorState.Stable, "Particle system to spawn", null ); - this.getDouble( - data, "Range", v -> this.range = v, 75.0, DoubleSingleValidator.greater0(), BuilderDescriptorState.Stable, "Maximum visibility range", null - ); - this.getVector3d( - data, "Offset", v -> this.offset = v, null, null, BuilderDescriptorState.Stable, "Offset relative to footpoint in view direction of NPC", null - ); + this.getDouble(data, "Range", this.range, 75.0, DoubleSingleValidator.greater0(), BuilderDescriptorState.Stable, "Maximum visibility range", null); + this.getVector3d(data, "Offset", this.offset, null, null, BuilderDescriptorState.Stable, "Offset relative to footpoint in view direction of NPC", null); return this; } @@ -60,11 +55,11 @@ public class BuilderActionSpawnParticles extends BuilderActionBase { return this.particleSystem.get(support.getExecutionContext()); } - public double getRange() { - return this.range; + public double getRange(BuilderSupport support) { + return this.range.get(support.getExecutionContext()); } - public Vector3d getOffset() { - return createVector3d(this.offset, Vector3d.ZERO::clone); + public Vector3d getOffset(BuilderSupport support) { + return createVector3d(this.offset.get(support.getExecutionContext()), Vector3d.ZERO::clone); } } diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderSensorAnimation.java b/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderSensorAnimation.java index 7778f91..67cf1c5 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderSensorAnimation.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/audiovisual/builders/BuilderSensorAnimation.java @@ -17,9 +17,6 @@ public class BuilderSensorAnimation extends BuilderSensorBase { protected final EnumHolder animationSlot = new EnumHolder<>(); protected final StringHolder animationId = new StringHolder(); - public BuilderSensorAnimation() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderActionBase.java b/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderActionBase.java index 4b99b32..0389eea 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderActionBase.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderActionBase.java @@ -11,9 +11,6 @@ import javax.annotation.Nonnull; public abstract class BuilderActionBase extends BuilderBase { protected boolean once; - public BuilderActionBase() { - } - @Override public boolean canRequireFeature() { return true; diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderActionWithDelay.java b/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderActionWithDelay.java index d449cca..04bb5bb 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderActionWithDelay.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderActionWithDelay.java @@ -13,9 +13,6 @@ public abstract class BuilderActionWithDelay extends BuilderActionBase { public static final double[] DEFAULT_TIMEOUT_RANGE = new double[]{1.0, 1.0}; protected final NumberArrayHolder delayRange = new NumberArrayHolder(); - public BuilderActionWithDelay() { - } - @Nonnull @Override public Builder readCommonConfig(@Nonnull JsonElement data) { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderBodyMotionBase.java b/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderBodyMotionBase.java index 6731ed1..5aafd49 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderBodyMotionBase.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderBodyMotionBase.java @@ -4,9 +4,6 @@ import com.hypixel.hytale.server.npc.instructions.BodyMotion; import javax.annotation.Nonnull; public abstract class BuilderBodyMotionBase extends BuilderMotionBase { - public BuilderBodyMotionBase() { - } - @Nonnull @Override public final Class category() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderEntityFilterBase.java b/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderEntityFilterBase.java index 54599b1..e2f4a63 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderEntityFilterBase.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderEntityFilterBase.java @@ -7,9 +7,6 @@ import java.util.List; import javax.annotation.Nonnull; public abstract class BuilderEntityFilterBase extends BuilderEntityFilterWithToggle { - public BuilderEntityFilterBase() { - } - @Override public boolean validate( String configName, @Nonnull NPCLoadTimeValidationHelper validationHelper, ExecutionContext context, Scope globalScope, @Nonnull List errors diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderEntityFilterWithToggle.java b/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderEntityFilterWithToggle.java index 28942aa..01910a7 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderEntityFilterWithToggle.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderEntityFilterWithToggle.java @@ -12,9 +12,6 @@ import javax.annotation.Nonnull; public abstract class BuilderEntityFilterWithToggle extends BuilderBase { protected final BooleanHolder enabled = new BooleanHolder(); - public BuilderEntityFilterWithToggle() { - } - @Nonnull @Override public Builder readCommonConfig(@Nonnull JsonElement data) { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderHeadMotionBase.java b/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderHeadMotionBase.java index 75364e8..a9f718d 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderHeadMotionBase.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderHeadMotionBase.java @@ -4,9 +4,6 @@ import com.hypixel.hytale.server.npc.instructions.HeadMotion; import javax.annotation.Nonnull; public abstract class BuilderHeadMotionBase extends BuilderMotionBase { - public BuilderHeadMotionBase() { - } - @Nonnull @Override public final Class category() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderMotionBase.java b/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderMotionBase.java index 526b4c2..689d795 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderMotionBase.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderMotionBase.java @@ -12,9 +12,6 @@ import java.util.List; import javax.annotation.Nonnull; public abstract class BuilderMotionBase extends BuilderBase { - public BuilderMotionBase() { - } - @Override public boolean canRequireFeature() { return true; diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderSensorBase.java b/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderSensorBase.java index cfa3727..4f5f4b0 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderSensorBase.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderSensorBase.java @@ -16,9 +16,6 @@ public abstract class BuilderSensorBase extends BuilderBase { protected boolean once; protected final BooleanHolder enabled = new BooleanHolder(); - public BuilderSensorBase() { - } - @Nonnull @Override public Builder readCommonConfig(@Nonnull JsonElement data) { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderSensorWithEntityFilters.java b/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderSensorWithEntityFilters.java index 1d5ca8b..08e37c1 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderSensorWithEntityFilters.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderSensorWithEntityFilters.java @@ -18,9 +18,6 @@ import javax.annotation.Nullable; public abstract class BuilderSensorWithEntityFilters extends BuilderSensorBase { protected final BuilderObjectListHelper filters = new BuilderObjectListHelper<>(IEntityFilter.class, this); - public BuilderSensorWithEntityFilters() { - } - @Override public boolean validate( String configName, diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderWeightedAction.java b/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderWeightedAction.java index 61d9cf7..41cf01d 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderWeightedAction.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/builders/BuilderWeightedAction.java @@ -21,9 +21,6 @@ public class BuilderWeightedAction extends BuilderBase { private final BuilderObjectReferenceHelper action = new BuilderObjectReferenceHelper<>(Action.class, this); private final DoubleHolder weight = new DoubleHolder(); - public BuilderWeightedAction() { - } - @Nonnull public WeightedAction build(@Nonnull BuilderSupport builderSupport) { return new WeightedAction(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/combat/HeadMotionAim.java b/src/com/hypixel/hytale/server/npc/corecomponents/combat/HeadMotionAim.java index aed2296..09c7068 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/combat/HeadMotionAim.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/combat/HeadMotionAim.java @@ -44,9 +44,9 @@ public class HeadMotionAim extends HeadMotionBase { public HeadMotionAim(@Nonnull BuilderHeadMotionAim builder, @Nonnull BuilderSupport support) { super(builder); - this.spread = builder.getSpread(); - this.hitProbability = builder.getHitProbability(); - this.deflection = builder.isDeflection(); + this.spread = builder.getSpread(support); + this.hitProbability = builder.getHitProbability(support); + this.deflection = builder.isDeflection(support); this.relativeTurnSpeed = builder.getRelativeTurnSpeed(support); } diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/combat/builders/BuilderActionApplyEntityEffect.java b/src/com/hypixel/hytale/server/npc/corecomponents/combat/builders/BuilderActionApplyEntityEffect.java index 3812935..fd2d42c 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/combat/builders/BuilderActionApplyEntityEffect.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/combat/builders/BuilderActionApplyEntityEffect.java @@ -16,9 +16,6 @@ public class BuilderActionApplyEntityEffect extends BuilderActionBase { protected final AssetHolder entityEffect = new AssetHolder(); protected final BooleanHolder useTarget = new BooleanHolder(); - public BuilderActionApplyEntityEffect() { - } - @Nonnull public ActionApplyEntityEffect build(@Nonnull BuilderSupport builderSupport) { return new ActionApplyEntityEffect(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/combat/builders/BuilderActionAttack.java b/src/com/hypixel/hytale/server/npc/corecomponents/combat/builders/BuilderActionAttack.java index 57136f9..8acfd46 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/combat/builders/BuilderActionAttack.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/combat/builders/BuilderActionAttack.java @@ -44,9 +44,6 @@ public class BuilderActionAttack extends BuilderActionBase { ); protected boolean attackProvided; - public BuilderActionAttack() { - } - @Nonnull public ActionAttack build(@Nonnull BuilderSupport builderSupport) { return new ActionAttack(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/combat/builders/BuilderBodyMotionAimCharge.java b/src/com/hypixel/hytale/server/npc/corecomponents/combat/builders/BuilderBodyMotionAimCharge.java index da43167..306aed2 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/combat/builders/BuilderBodyMotionAimCharge.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/combat/builders/BuilderBodyMotionAimCharge.java @@ -14,9 +14,6 @@ import javax.annotation.Nonnull; public class BuilderBodyMotionAimCharge extends BuilderBodyMotionBase { protected final DoubleHolder relativeTurnSpeed = new DoubleHolder(); - public BuilderBodyMotionAimCharge() { - } - @Nonnull public BodyMotion build(@Nonnull BuilderSupport builderSupport) { return new BodyMotionAimCharge(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/combat/builders/BuilderHeadMotionAim.java b/src/com/hypixel/hytale/server/npc/corecomponents/combat/builders/BuilderHeadMotionAim.java index bdd8bf6..6638335 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/combat/builders/BuilderHeadMotionAim.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/combat/builders/BuilderHeadMotionAim.java @@ -4,6 +4,7 @@ import com.google.gson.JsonElement; import com.hypixel.hytale.server.npc.asset.builder.BuilderDescriptorState; import com.hypixel.hytale.server.npc.asset.builder.BuilderSupport; import com.hypixel.hytale.server.npc.asset.builder.Feature; +import com.hypixel.hytale.server.npc.asset.builder.holder.BooleanHolder; import com.hypixel.hytale.server.npc.asset.builder.holder.DoubleHolder; import com.hypixel.hytale.server.npc.asset.builder.validators.DoubleRangeValidator; import com.hypixel.hytale.server.npc.corecomponents.builders.BuilderHeadMotionBase; @@ -11,14 +12,11 @@ import com.hypixel.hytale.server.npc.corecomponents.combat.HeadMotionAim; import javax.annotation.Nonnull; public class BuilderHeadMotionAim extends BuilderHeadMotionBase { - protected double spread; - protected boolean deflection; - protected double hitProbability; + protected final DoubleHolder spread = new DoubleHolder(); + protected final BooleanHolder deflection = new BooleanHolder(); + protected final DoubleHolder hitProbability = new DoubleHolder(); protected final DoubleHolder relativeTurnSpeed = new DoubleHolder(); - public BuilderHeadMotionAim() { - } - @Nonnull public HeadMotionAim build(@Nonnull BuilderSupport builderSupport) { return new HeadMotionAim(this, builderSupport); @@ -45,19 +43,19 @@ public class BuilderHeadMotionAim extends BuilderHeadMotionBase { @Nonnull public BuilderHeadMotionAim readConfig(@Nonnull JsonElement data) { this.getDouble( - data, "Spread", d -> this.spread = d, 1.0, DoubleRangeValidator.between(0.0, 5.0), BuilderDescriptorState.Experimental, "Random targeting error", null + data, "Spread", this.spread, 1.0, DoubleRangeValidator.between(0.0, 5.0), BuilderDescriptorState.Experimental, "Random targeting error", null ); this.getDouble( data, "HitProbability", - d -> this.hitProbability = d, + this.hitProbability, 0.33, DoubleRangeValidator.between01(), BuilderDescriptorState.Experimental, "Probability of shot being straight on target", null ); - this.getBoolean(data, "Deflection", b -> this.deflection = b, true, BuilderDescriptorState.Experimental, "Compute deflection for moving targets", null); + this.getBoolean(data, "Deflection", this.deflection, true, BuilderDescriptorState.Experimental, "Compute deflection for moving targets", null); this.getDouble( data, "RelativeTurnSpeed", @@ -72,16 +70,16 @@ public class BuilderHeadMotionAim extends BuilderHeadMotionBase { return this; } - public double getSpread() { - return this.spread; + public double getSpread(BuilderSupport support) { + return this.spread.get(support.getExecutionContext()); } - public boolean isDeflection() { - return this.deflection; + public boolean isDeflection(BuilderSupport support) { + return this.deflection.get(support.getExecutionContext()); } - public double getHitProbability() { - return this.hitProbability; + public double getHitProbability(BuilderSupport support) { + return this.hitProbability.get(support.getExecutionContext()); } public double getRelativeTurnSpeed(@Nonnull BuilderSupport support) { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/combat/builders/BuilderSensorDamage.java b/src/com/hypixel/hytale/server/npc/corecomponents/combat/builders/BuilderSensorDamage.java index cbb54c2..31a69b0 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/combat/builders/BuilderSensorDamage.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/combat/builders/BuilderSensorDamage.java @@ -22,9 +22,6 @@ public class BuilderSensorDamage extends BuilderSensorBase { protected boolean otherDamage; protected String targetSlot; - public BuilderSensorDamage() { - } - @Nonnull public SensorDamage build(@Nonnull BuilderSupport builderSupport) { return new SensorDamage(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/combat/builders/BuilderSensorIsBackingAway.java b/src/com/hypixel/hytale/server/npc/corecomponents/combat/builders/BuilderSensorIsBackingAway.java index 0d3885e..593671b 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/combat/builders/BuilderSensorIsBackingAway.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/combat/builders/BuilderSensorIsBackingAway.java @@ -7,9 +7,6 @@ import com.hypixel.hytale.server.npc.corecomponents.combat.SensorIsBackingAway; import javax.annotation.Nonnull; public class BuilderSensorIsBackingAway extends BuilderSensorBase { - public BuilderSensorIsBackingAway() { - } - @Nonnull public SensorIsBackingAway build(@Nonnull BuilderSupport builderSupport) { return new SensorIsBackingAway(this); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/debug/builders/BuilderActionLog.java b/src/com/hypixel/hytale/server/npc/corecomponents/debug/builders/BuilderActionLog.java index 6c2769c..982dcd9 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/debug/builders/BuilderActionLog.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/debug/builders/BuilderActionLog.java @@ -11,9 +11,6 @@ import javax.annotation.Nonnull; public class BuilderActionLog extends BuilderActionBase { protected final StringHolder text = new StringHolder(); - public BuilderActionLog() { - } - @Nonnull public ActionLog build(@Nonnull BuilderSupport builderSupport) { return new ActionLog(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/debug/builders/BuilderActionTest.java b/src/com/hypixel/hytale/server/npc/corecomponents/debug/builders/BuilderActionTest.java index 2eae6f8..e079d34 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/debug/builders/BuilderActionTest.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/debug/builders/BuilderActionTest.java @@ -34,9 +34,6 @@ public class BuilderActionTest extends BuilderActionBase { protected final NumberArrayHolder numberArrayHolder = new NumberArrayHolder(); protected final StringArrayHolder stringArrayHolder = new StringArrayHolder(); - public BuilderActionTest() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/debug/builders/BuilderBodyMotionTestProbe.java b/src/com/hypixel/hytale/server/npc/corecomponents/debug/builders/BuilderBodyMotionTestProbe.java index 4e13152..814df15 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/debug/builders/BuilderBodyMotionTestProbe.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/debug/builders/BuilderBodyMotionTestProbe.java @@ -15,9 +15,6 @@ public class BuilderBodyMotionTestProbe extends BuilderBodyMotionBase { protected boolean isAvoidingBlockDamage; protected boolean isRelaxedMoveConstraints; - public BuilderBodyMotionTestProbe() { - } - @Nonnull public BodyMotionTestProbe build(BuilderSupport builderSupport) { return new BodyMotionTestProbe(this); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionBeacon.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionBeacon.java index 8000a88..fa4a289 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionBeacon.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionBeacon.java @@ -26,9 +26,6 @@ public class BuilderActionBeacon extends BuilderActionBase { protected double expirationTime; protected int sendCount; - public BuilderActionBeacon() { - } - @Nonnull public ActionBeacon build(@Nonnull BuilderSupport builderSupport) { return new ActionBeacon(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionIgnoreForAvoidance.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionIgnoreForAvoidance.java index 85445cd..4840324 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionIgnoreForAvoidance.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionIgnoreForAvoidance.java @@ -13,9 +13,6 @@ import javax.annotation.Nonnull; public class BuilderActionIgnoreForAvoidance extends BuilderActionBase { protected final StringHolder targetSlot = new StringHolder(); - public BuilderActionIgnoreForAvoidance() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionNotify.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionNotify.java index e5dac32..f2c2121 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionNotify.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionNotify.java @@ -20,9 +20,6 @@ public class BuilderActionNotify extends BuilderActionBase { protected double expirationTime; protected String usedTargetSlot; - public BuilderActionNotify() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionOverrideAttitude.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionOverrideAttitude.java index cfb1456..c22dbee 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionOverrideAttitude.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionOverrideAttitude.java @@ -17,9 +17,6 @@ public class BuilderActionOverrideAttitude extends BuilderActionBase { protected final EnumHolder attitude = new EnumHolder<>(); protected final DoubleHolder duration = new DoubleHolder(); - public BuilderActionOverrideAttitude() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionReleaseTarget.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionReleaseTarget.java index 076837b..39da28f 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionReleaseTarget.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionReleaseTarget.java @@ -12,9 +12,6 @@ import javax.annotation.Nonnull; public class BuilderActionReleaseTarget extends BuilderActionBase { protected final StringHolder targetSlot = new StringHolder(); - public BuilderActionReleaseTarget() { - } - @Nonnull public ActionReleaseTarget build(@Nonnull BuilderSupport builderSupport) { return new ActionReleaseTarget(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionSetMarkedTarget.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionSetMarkedTarget.java index 532d9ec..0501c5f 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionSetMarkedTarget.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionSetMarkedTarget.java @@ -14,9 +14,6 @@ import javax.annotation.Nonnull; public class BuilderActionSetMarkedTarget extends BuilderActionBase { protected final StringHolder targetSlot = new StringHolder(); - public BuilderActionSetMarkedTarget() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionSetStat.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionSetStat.java index 3710138..f78f2f9 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionSetStat.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderActionSetStat.java @@ -17,9 +17,6 @@ public class BuilderActionSetStat extends BuilderActionBase { protected final FloatHolder value = new FloatHolder(); protected final BooleanHolder add = new BooleanHolder(); - public BuilderActionSetStat() { - } - @Nonnull public ActionSetStat build(@Nonnull BuilderSupport builderSupport) { return new ActionSetStat(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderHeadMotionWatch.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderHeadMotionWatch.java index df01aa8..93fc977 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderHeadMotionWatch.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderHeadMotionWatch.java @@ -13,9 +13,6 @@ import javax.annotation.Nonnull; public class BuilderHeadMotionWatch extends BuilderHeadMotionBase { protected final DoubleHolder relativeTurnSpeed = new DoubleHolder(); - public BuilderHeadMotionWatch() { - } - @Nonnull public HeadMotionWatch build(@Nonnull BuilderSupport builderSupport) { return new HeadMotionWatch(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorBeacon.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorBeacon.java index 03561f6..7dc2246 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorBeacon.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorBeacon.java @@ -21,9 +21,6 @@ public class BuilderSensorBeacon extends BuilderSensorBase { protected String targetSlot; protected boolean consume; - public BuilderSensorBeacon() { - } - @Nonnull public SensorBeacon build(@Nonnull BuilderSupport builderSupport) { return new SensorBeacon(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorCount.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorCount.java index 22296b6..b073881 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorCount.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorCount.java @@ -21,9 +21,6 @@ public class BuilderSensorCount extends BuilderSensorBase { protected String[] includeGroups; protected String[] excludeGroups; - public BuilderSensorCount() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorEntity.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorEntity.java index a643e70..9672c98 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorEntity.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorEntity.java @@ -14,9 +14,6 @@ public class BuilderSensorEntity extends BuilderSensorEntityBase { protected final BooleanHolder getNPCs = new BooleanHolder(); protected final BooleanHolder excludeOwnType = new BooleanHolder(); - public BuilderSensorEntity() { - } - @Nonnull public SensorEntity build(@Nonnull BuilderSupport builderSupport) { return new SensorEntity(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorEntityBase.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorEntityBase.java index 5d2860e..57d658d 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorEntityBase.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorEntityBase.java @@ -38,9 +38,6 @@ public abstract class BuilderSensorEntityBase extends BuilderSensorWithEntityFil protected final BuilderObjectReferenceHelper prioritiser = new BuilderObjectReferenceHelper<>(ISensorEntityPrioritiser.class, this); protected final BuilderObjectReferenceHelper collector = new BuilderObjectReferenceHelper<>(ISensorEntityCollector.class, this); - public BuilderSensorEntityBase() { - } - @Nonnull @Override public Builder readConfig(@Nonnull JsonElement data) { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorKill.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorKill.java index a4c0878..25abb3a 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorKill.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorKill.java @@ -15,9 +15,6 @@ import javax.annotation.Nonnull; public class BuilderSensorKill extends BuilderSensorBase { protected final StringHolder targetSlot = new StringHolder(); - public BuilderSensorKill() { - } - @Nonnull public SensorKill build(@Nonnull BuilderSupport builderSupport) { return new SensorKill(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorPlayer.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorPlayer.java index 9b5e451..7efae62 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorPlayer.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorPlayer.java @@ -9,9 +9,6 @@ import com.hypixel.hytale.server.npc.instructions.Sensor; import javax.annotation.Nonnull; public class BuilderSensorPlayer extends BuilderSensorEntityBase { - public BuilderSensorPlayer() { - } - @Nonnull public SensorPlayer build(@Nonnull BuilderSupport builderSupport) { return new SensorPlayer(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorSelf.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorSelf.java index bf828c7..01c5f8a 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorSelf.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorSelf.java @@ -13,9 +13,6 @@ import com.hypixel.hytale.server.npc.instructions.Sensor; import javax.annotation.Nonnull; public class BuilderSensorSelf extends BuilderSensorWithEntityFilters { - public BuilderSensorSelf() { - } - @Nonnull public SensorSelf build(@Nonnull BuilderSupport builderSupport) { return new SensorSelf(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorTarget.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorTarget.java index 54c4fd9..5401539 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorTarget.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/builders/BuilderSensorTarget.java @@ -22,9 +22,6 @@ public class BuilderSensorTarget extends BuilderSensorWithEntityFilters { protected final BooleanHolder autoUnlockTarget = new BooleanHolder(); protected final StringHolder targetSlot = new StringHolder(); - public BuilderSensorTarget() { - } - @Nonnull public SensorTarget build(@Nonnull BuilderSupport builderSupport) { return new SensorTarget(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/EntityFilterCombat.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/EntityFilterCombat.java index 12a80b7..b9ccc70 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/EntityFilterCombat.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/EntityFilterCombat.java @@ -32,7 +32,7 @@ public class EntityFilterCombat extends EntityFilterBase { @Override public boolean matchesEntity(@Nonnull Ref ref, @Nonnull Ref targetRef, @Nonnull Role role, @Nonnull Store store) { - List combatData = CombatViewSystems.getCombatData(targetRef); + List combatData = CombatViewSystems.getCombatData(targetRef, store); for (int i = 0; i < combatData.size(); i++) { InterpretedCombatData data = combatData.get(i); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/EntityFilterLineOfSight.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/EntityFilterLineOfSight.java index 0ece21c..a6cce02 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/EntityFilterLineOfSight.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/EntityFilterLineOfSight.java @@ -10,9 +10,6 @@ import javax.annotation.Nonnull; public class EntityFilterLineOfSight extends EntityFilterBase { public static final int COST = 400; - public EntityFilterLineOfSight() { - } - @Override public boolean matchesEntity(@Nonnull Ref ref, @Nonnull Ref targetRef, @Nonnull Role role, @Nonnull Store store) { return role.getPositionCache().hasLineOfSight(ref, targetRef, store); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterAltitude.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterAltitude.java index a3d5bb6..57e1307 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterAltitude.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterAltitude.java @@ -14,9 +14,6 @@ import javax.annotation.Nonnull; public class BuilderEntityFilterAltitude extends BuilderEntityFilterBase { protected final NumberArrayHolder altitudeRange = new NumberArrayHolder(); - public BuilderEntityFilterAltitude() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterAnd.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterAnd.java index e041d93..0471d08 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterAnd.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterAnd.java @@ -9,9 +9,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class BuilderEntityFilterAnd extends BuilderEntityFilterMany { - public BuilderEntityFilterAnd() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterAttitude.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterAttitude.java index dfc3dc9..98da9d3 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterAttitude.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterAttitude.java @@ -17,9 +17,6 @@ import javax.annotation.Nonnull; public class BuilderEntityFilterAttitude extends BuilderEntityFilterBase { protected final EnumSetHolder attitudes = new EnumSetHolder<>(); - public BuilderEntityFilterAttitude() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterCombat.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterCombat.java index d67eecd..8df2be0 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterCombat.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterCombat.java @@ -22,9 +22,6 @@ public class BuilderEntityFilterCombat extends BuilderEntityFilterBase { protected final NumberArrayHolder elapsedTimeRange = new NumberArrayHolder(); protected final EnumHolder mode = new EnumHolder<>(); - public BuilderEntityFilterCombat() { - } - @Nonnull public EntityFilterCombat build(@Nonnull BuilderSupport builderSupport) { return new EntityFilterCombat(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterHeightDifference.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterHeightDifference.java index f68acb8..82677e5 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterHeightDifference.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterHeightDifference.java @@ -19,9 +19,6 @@ public class BuilderEntityFilterHeightDifference extends BuilderEntityFilterBase protected final BooleanHolder useEyePosition = new BooleanHolder(); protected final NumberArrayHolder heightDifference = new NumberArrayHolder(); - public BuilderEntityFilterHeightDifference() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterInsideBlock.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterInsideBlock.java index be5503f..2f99081 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterInsideBlock.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterInsideBlock.java @@ -15,9 +15,6 @@ import javax.annotation.Nonnull; public class BuilderEntityFilterInsideBlock extends BuilderEntityFilterBase { protected final AssetHolder blockSet = new AssetHolder(); - public BuilderEntityFilterInsideBlock() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterInventory.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterInventory.java index 95e1087..bc75312 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterInventory.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterInventory.java @@ -24,9 +24,6 @@ public class BuilderEntityFilterInventory extends BuilderEntityFilterBase { protected final NumberArrayHolder count = new NumberArrayHolder(); protected final NumberArrayHolder freeSlots = new NumberArrayHolder(); - public BuilderEntityFilterInventory() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterItemInHand.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterItemInHand.java index 8294cfa..ecb219e 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterItemInHand.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterItemInHand.java @@ -19,9 +19,6 @@ public class BuilderEntityFilterItemInHand extends BuilderEntityFilterBase { protected final AssetArrayHolder items = new AssetArrayHolder(); protected final EnumHolder hand = new EnumHolder<>(); - public BuilderEntityFilterItemInHand() { - } - @Nonnull public EntityFilterItemInHand build(@Nonnull BuilderSupport builderSupport) { return new EntityFilterItemInHand(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterLineOfSight.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterLineOfSight.java index 33ddf97..af5a481 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterLineOfSight.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterLineOfSight.java @@ -12,9 +12,6 @@ import com.hypixel.hytale.server.npc.corecomponents.entity.filters.EntityFilterL import javax.annotation.Nonnull; public class BuilderEntityFilterLineOfSight extends BuilderEntityFilterBase { - public BuilderEntityFilterLineOfSight() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterMany.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterMany.java index 407943b..a3a8cd4 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterMany.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterMany.java @@ -18,9 +18,6 @@ public abstract class BuilderEntityFilterMany extends BuilderEntityFilterWithTog @Nonnull protected BuilderObjectListHelper objectListHelper = new BuilderObjectListHelper<>(IEntityFilter.class, this); - public BuilderEntityFilterMany() { - } - @Override public void registerTags(@Nonnull Set tags) { super.registerTags(tags); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterMovementState.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterMovementState.java index fa79dba..84d2d34 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterMovementState.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterMovementState.java @@ -13,9 +13,6 @@ import javax.annotation.Nonnull; public class BuilderEntityFilterMovementState extends BuilderEntityFilterBase { protected MovementState movementState; - public BuilderEntityFilterMovementState() { - } - @Nonnull public EntityFilterMovementState build(BuilderSupport builderSupport) { return new EntityFilterMovementState(this); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterNPCGroup.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterNPCGroup.java index 5cf8a1f..ae7ea10 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterNPCGroup.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterNPCGroup.java @@ -17,9 +17,6 @@ public class BuilderEntityFilterNPCGroup extends BuilderEntityFilterBase { protected final AssetArrayHolder includeGroups = new AssetArrayHolder(); protected final AssetArrayHolder excludeGroups = new AssetArrayHolder(); - public BuilderEntityFilterNPCGroup() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterNot.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterNot.java index 3a493fb..6f8d36a 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterNot.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterNot.java @@ -19,9 +19,6 @@ import javax.annotation.Nullable; public class BuilderEntityFilterNot extends BuilderEntityFilterWithToggle { protected final BuilderObjectReferenceHelper filter = new BuilderObjectReferenceHelper<>(IEntityFilter.class, this); - public BuilderEntityFilterNot() { - } - @Nullable public IEntityFilter build(@Nonnull BuilderSupport builderSupport) { IEntityFilter filter = this.getFilter(builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterOr.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterOr.java index 5313bf2..c52482c 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterOr.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterOr.java @@ -9,9 +9,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class BuilderEntityFilterOr extends BuilderEntityFilterMany { - public BuilderEntityFilterOr() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterSpotsMe.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterSpotsMe.java index bc871a8..687ab07 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterSpotsMe.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterSpotsMe.java @@ -18,9 +18,6 @@ public class BuilderEntityFilterSpotsMe extends BuilderEntityFilterBase { protected boolean testLineOfSight; protected ViewTest viewTest; - public BuilderEntityFilterSpotsMe() { - } - @Nonnull public EntityFilterSpotsMe build(BuilderSupport builderSupport) { return new EntityFilterSpotsMe(this); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterStandingOnBlock.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterStandingOnBlock.java index f02a4d1..20f3bea 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterStandingOnBlock.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterStandingOnBlock.java @@ -15,9 +15,6 @@ import javax.annotation.Nonnull; public class BuilderEntityFilterStandingOnBlock extends BuilderEntityFilterBase { protected final AssetHolder blockSet = new AssetHolder(); - public BuilderEntityFilterStandingOnBlock() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterStat.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterStat.java index 8770317..3dbca17 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterStat.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterStat.java @@ -22,9 +22,6 @@ public class BuilderEntityFilterStat extends BuilderEntityFilterBase { protected final EnumHolder relativeToTarget = new EnumHolder<>(); protected final NumberArrayHolder valueRange = new NumberArrayHolder(); - public BuilderEntityFilterStat() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterViewSector.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterViewSector.java index f654b7c..fbfb1d7 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterViewSector.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/filters/builders/BuilderEntityFilterViewSector.java @@ -16,9 +16,6 @@ import javax.annotation.Nonnull; public class BuilderEntityFilterViewSector extends BuilderEntityFilterBase { protected final FloatHolder viewSector = new FloatHolder(); - public BuilderEntityFilterViewSector() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/entity/prioritisers/SensorEntityPrioritiserDefault.java b/src/com/hypixel/hytale/server/npc/corecomponents/entity/prioritisers/SensorEntityPrioritiserDefault.java index 93f9b9d..2f8e60b 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/entity/prioritisers/SensorEntityPrioritiserDefault.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/entity/prioritisers/SensorEntityPrioritiserDefault.java @@ -21,9 +21,6 @@ public class SensorEntityPrioritiserDefault implements ISensorEntityPrioritiser private final SensorEntityPrioritiserDefault.DefaultPrioritiser playerPrioritiser = new SensorEntityPrioritiserDefault.DefaultPrioritiser(); private final SensorEntityPrioritiserDefault.DefaultPrioritiser npcPrioritiser = new SensorEntityPrioritiserDefault.DefaultPrioritiser(); - public SensorEntityPrioritiserDefault() { - } - @Nonnull @Override public IEntityByPriorityFilter getNPCPrioritiser() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/interaction/builders/BuilderActionLockOnInteractionTarget.java b/src/com/hypixel/hytale/server/npc/corecomponents/interaction/builders/BuilderActionLockOnInteractionTarget.java index b1cf065..b7cbd91 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/interaction/builders/BuilderActionLockOnInteractionTarget.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/interaction/builders/BuilderActionLockOnInteractionTarget.java @@ -15,9 +15,6 @@ import javax.annotation.Nonnull; public class BuilderActionLockOnInteractionTarget extends BuilderActionBase { protected final StringHolder targetSlot = new StringHolder(); - public BuilderActionLockOnInteractionTarget() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/interaction/builders/BuilderActionSetInteractable.java b/src/com/hypixel/hytale/server/npc/corecomponents/interaction/builders/BuilderActionSetInteractable.java index b2b222d..3c07ae4 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/interaction/builders/BuilderActionSetInteractable.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/interaction/builders/BuilderActionSetInteractable.java @@ -17,9 +17,6 @@ public class BuilderActionSetInteractable extends BuilderActionBase { protected String hint; protected boolean showPrompt = true; - public BuilderActionSetInteractable() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/interaction/builders/BuilderSensorCanInteract.java b/src/com/hypixel/hytale/server/npc/corecomponents/interaction/builders/BuilderSensorCanInteract.java index 36863c3..17b7245 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/interaction/builders/BuilderSensorCanInteract.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/interaction/builders/BuilderSensorCanInteract.java @@ -19,9 +19,6 @@ public class BuilderSensorCanInteract extends BuilderSensorBase { protected final FloatHolder viewSector = new FloatHolder(); protected final EnumSetHolder attitudes = new EnumSetHolder<>(); - public BuilderSensorCanInteract() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/interaction/builders/BuilderSensorHasInteracted.java b/src/com/hypixel/hytale/server/npc/corecomponents/interaction/builders/BuilderSensorHasInteracted.java index 5e251d5..0ae7fa2 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/interaction/builders/BuilderSensorHasInteracted.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/interaction/builders/BuilderSensorHasInteracted.java @@ -12,9 +12,6 @@ import java.util.EnumSet; import javax.annotation.Nonnull; public class BuilderSensorHasInteracted extends BuilderSensorBase { - public BuilderSensorHasInteracted() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/interaction/builders/BuilderSensorInteractionContext.java b/src/com/hypixel/hytale/server/npc/corecomponents/interaction/builders/BuilderSensorInteractionContext.java index 4db6a2b..c277aab 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/interaction/builders/BuilderSensorInteractionContext.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/interaction/builders/BuilderSensorInteractionContext.java @@ -16,9 +16,6 @@ import javax.annotation.Nonnull; public class BuilderSensorInteractionContext extends BuilderSensorBase { protected final StringHolder interactionContext = new StringHolder(); - public BuilderSensorInteractionContext() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/items/ActionInventory.java b/src/com/hypixel/hytale/server/npc/corecomponents/items/ActionInventory.java index 91cd268..f5a59fc 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/items/ActionInventory.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/items/ActionInventory.java @@ -66,7 +66,7 @@ public class ActionInventory extends ActionBase { InventoryHelper.clearItemInHand(inventory, (byte)-1); return true; } else if (this.operation == ActionInventory.Operation.RemoveHeldItem) { - InventoryHelper.removeItemInHand(inventory); + InventoryHelper.removeItemInHand(inventory, this.count); return true; } else if (this.operation != ActionInventory.Operation.EquipHotbar || this.item != null && !this.item.isEmpty()) { if (this.operation != ActionInventory.Operation.EquipOffHand || this.item != null && !this.item.isEmpty()) { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/items/builders/BuilderActionDropItem.java b/src/com/hypixel/hytale/server/npc/corecomponents/items/builders/BuilderActionDropItem.java index 75648a3..ef02f60 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/items/builders/BuilderActionDropItem.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/items/builders/BuilderActionDropItem.java @@ -30,9 +30,6 @@ public class BuilderActionDropItem extends BuilderActionWithDelay { protected double[] dropSector; protected boolean highPitch; - public BuilderActionDropItem() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/items/builders/BuilderActionInventory.java b/src/com/hypixel/hytale/server/npc/corecomponents/items/builders/BuilderActionInventory.java index b1962be..245d919 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/items/builders/BuilderActionInventory.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/items/builders/BuilderActionInventory.java @@ -28,9 +28,6 @@ public class BuilderActionInventory extends BuilderActionBase { protected final BooleanHolder useTarget = new BooleanHolder(); protected final IntHolder slot = new IntHolder(); - public BuilderActionInventory() { - } - @Nonnull public Action build(@Nonnull BuilderSupport builderSupport) { return new ActionInventory(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/items/builders/BuilderActionPickUpItem.java b/src/com/hypixel/hytale/server/npc/corecomponents/items/builders/BuilderActionPickUpItem.java index 392fdc5..ed51b2c 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/items/builders/BuilderActionPickUpItem.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/items/builders/BuilderActionPickUpItem.java @@ -22,9 +22,6 @@ public class BuilderActionPickUpItem extends BuilderActionWithDelay { protected AssetArrayHolder items = new AssetArrayHolder(); protected boolean hoover; - public BuilderActionPickUpItem() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/items/builders/BuilderSensorDroppedItem.java b/src/com/hypixel/hytale/server/npc/corecomponents/items/builders/BuilderSensorDroppedItem.java index 5cd03b6..293c35b 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/items/builders/BuilderSensorDroppedItem.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/items/builders/BuilderSensorDroppedItem.java @@ -30,9 +30,6 @@ public class BuilderSensorDroppedItem extends BuilderSensorBase { protected final AssetArrayHolder items = new AssetArrayHolder(); protected final EnumSetHolder attitudes = new EnumSetHolder<>(); - public BuilderSensorDroppedItem() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderActionDelayDespawn.java b/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderActionDelayDespawn.java index 8b89793..04e7b17 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderActionDelayDespawn.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderActionDelayDespawn.java @@ -12,9 +12,6 @@ public class BuilderActionDelayDespawn extends BuilderActionBase { protected float time; protected boolean shorten; - public BuilderActionDelayDespawn() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderActionDespawn.java b/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderActionDespawn.java index c828911..c074976 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderActionDespawn.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderActionDespawn.java @@ -10,9 +10,6 @@ import javax.annotation.Nonnull; public class BuilderActionDespawn extends BuilderActionBase { protected boolean force; - public BuilderActionDespawn() { - } - @Nonnull public ActionDespawn build(BuilderSupport builderSupport) { return new ActionDespawn(this); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderActionDie.java b/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderActionDie.java index 8a2de80..340a26f 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderActionDie.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderActionDie.java @@ -7,9 +7,6 @@ import com.hypixel.hytale.server.npc.corecomponents.lifecycle.ActionDie; import javax.annotation.Nonnull; public class BuilderActionDie extends BuilderActionBase { - public BuilderActionDie() { - } - @Nonnull public ActionDie build(BuilderSupport builderSupport) { return new ActionDie(this); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderActionRemove.java b/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderActionRemove.java index d5b372b..ccf09f8 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderActionRemove.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderActionRemove.java @@ -14,9 +14,6 @@ import javax.annotation.Nonnull; public class BuilderActionRemove extends BuilderActionBase { protected final BooleanHolder useTarget = new BooleanHolder(); - public BuilderActionRemove() { - } - @Nonnull public Action build(@Nonnull BuilderSupport builderSupport) { return new ActionRemove(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderActionRole.java b/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderActionRole.java index 08afb44..6091e7d 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderActionRole.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderActionRole.java @@ -19,9 +19,6 @@ public class BuilderActionRole extends BuilderActionBase { protected final BooleanHolder changeAppearance = new BooleanHolder(); protected final StringHolder state = new StringHolder(); - public BuilderActionRole() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderActionSpawn.java b/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderActionSpawn.java index ba38f73..059d629 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderActionSpawn.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderActionSpawn.java @@ -41,9 +41,6 @@ public class BuilderActionSpawn extends BuilderActionBase { protected final StringHolder spawnState = new StringHolder(); protected final StringHolder spawnSubState = new StringHolder(); - public BuilderActionSpawn() { - } - @Nonnull public ActionSpawn build(@Nonnull BuilderSupport builderSupport) { return new ActionSpawn(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderSensorAge.java b/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderSensorAge.java index eb89d23..817d21c 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderSensorAge.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/lifecycle/builders/BuilderSensorAge.java @@ -22,9 +22,6 @@ public class BuilderSensorAge extends BuilderSensorBase { public static final TemporalAmount MAX_TIME = Period.ofDays(Integer.MAX_VALUE); protected final TemporalArrayHolder ageRange = new TemporalArrayHolder(); - public BuilderSensorAge() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/movement/BodyMotionTeleport.java b/src/com/hypixel/hytale/server/npc/corecomponents/movement/BodyMotionTeleport.java index f2517c7..d8f24d6 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/movement/BodyMotionTeleport.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/movement/BodyMotionTeleport.java @@ -97,7 +97,7 @@ public class BodyMotionTeleport extends BodyMotionBase { switch (this.orientation) { case Unchanged: { Vector3f bodyRotation = transformComponent.getRotation(); - componentAccessor.addComponent(ref, Teleport.getComponentType(), new Teleport(this.target, bodyRotation)); + componentAccessor.addComponent(ref, Teleport.getComponentType(), Teleport.createExact(this.target, bodyRotation)); break; } case TowardsTarget: { @@ -116,7 +116,7 @@ public class BodyMotionTeleport extends BodyMotionBase { } componentAccessor.addComponent( - ref, Teleport.getComponentType(), new Teleport(this.target, new Vector3f(yaw, pitch, bodyRotation.getRoll())) + ref, Teleport.getComponentType(), Teleport.createExact(this.target, new Vector3f(yaw, pitch, bodyRotation.getRoll())) ); break; } @@ -131,7 +131,7 @@ public class BodyMotionTeleport extends BodyMotionBase { assert targetTransformComponent != null; Vector3f bodyRotation = targetTransformComponent.getRotation(); - componentAccessor.addComponent(ref, Teleport.getComponentType(), new Teleport(this.target, bodyRotation)); + componentAccessor.addComponent(ref, Teleport.getComponentType(), Teleport.createExact(this.target, bodyRotation)); } } diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/movement/BodyMotionWanderBase.java b/src/com/hypixel/hytale/server/npc/corecomponents/movement/BodyMotionWanderBase.java index 9848f0a..b7bd9e5 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/movement/BodyMotionWanderBase.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/movement/BodyMotionWanderBase.java @@ -477,8 +477,5 @@ public abstract class BodyMotionWanderBase extends BodyMotionBase { TURNING, WALKING, STOPPED; - - private State() { - } } } diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderActionCrouch.java b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderActionCrouch.java index c91e67d..1fd1758 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderActionCrouch.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderActionCrouch.java @@ -13,9 +13,6 @@ import javax.annotation.Nonnull; public class BuilderActionCrouch extends BuilderActionBase { protected final BooleanHolder crouching = new BooleanHolder(); - public BuilderActionCrouch() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderActionOverrideAltitude.java b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderActionOverrideAltitude.java index 312fa89..35523f8 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderActionOverrideAltitude.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderActionOverrideAltitude.java @@ -14,9 +14,6 @@ import javax.annotation.Nonnull; public class BuilderActionOverrideAltitude extends BuilderActionBase { protected final NumberArrayHolder desiredAltitudeRange = new NumberArrayHolder(); - public BuilderActionOverrideAltitude() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderActionRecomputePath.java b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderActionRecomputePath.java index 81e11fd..0285edb 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderActionRecomputePath.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderActionRecomputePath.java @@ -10,9 +10,6 @@ import com.hypixel.hytale.server.npc.instructions.Action; import javax.annotation.Nonnull; public class BuilderActionRecomputePath extends BuilderActionBase implements Builder { - public BuilderActionRecomputePath() { - } - @Nonnull public ActionRecomputePath build(BuilderSupport builderSupport) { return new ActionRecomputePath(this); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionFind.java b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionFind.java index ee98db5..d6f5021 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionFind.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionFind.java @@ -23,9 +23,6 @@ public class BuilderBodyMotionFind extends BuilderBodyMotionFindWithTarget { private final DoubleHolder falloff = new DoubleHolder(); private final DoubleHolder switchToSteeringDistance = new DoubleHolder(); - public BuilderBodyMotionFind() { - } - public BodyMotionFind build(@Nonnull BuilderSupport builderSupport) { return new BodyMotionFind(this, builderSupport); } diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionLand.java b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionLand.java index 8ca33ad..9a61358 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionLand.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionLand.java @@ -17,9 +17,6 @@ import javax.annotation.Nonnull; public class BuilderBodyMotionLand extends BuilderBodyMotionFind { protected final DoubleHolder goalLenience = new DoubleHolder(); - public BuilderBodyMotionLand() { - } - @Nonnull public BodyMotionLand build(@Nonnull BuilderSupport builderSupport) { return new BodyMotionLand(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionMaintainDistance.java b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionMaintainDistance.java index d8b1037..57be3e2 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionMaintainDistance.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionMaintainDistance.java @@ -34,9 +34,6 @@ public class BuilderBodyMotionMaintainDistance extends BuilderBodyMotionBase { protected final NumberArrayHolder strafingDurationRange = new NumberArrayHolder(); protected final NumberArrayHolder strafingFrequencyRange = new NumberArrayHolder(); - public BuilderBodyMotionMaintainDistance() { - } - @Nonnull public BodyMotionMaintainDistance build(@Nonnull BuilderSupport builderSupport) { return new BodyMotionMaintainDistance(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionMatchLook.java b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionMatchLook.java index e533748..c0e9865 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionMatchLook.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionMatchLook.java @@ -8,9 +8,6 @@ import com.hypixel.hytale.server.npc.corecomponents.movement.BodyMotionMatchLook import javax.annotation.Nonnull; public class BuilderBodyMotionMatchLook extends BuilderBodyMotionBase { - public BuilderBodyMotionMatchLook() { - } - @Nonnull public BodyMotionMatchLook build(BuilderSupport builderSupport) { return new BodyMotionMatchLook(this); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionMoveAway.java b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionMoveAway.java index d0d6dc6..06806bb 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionMoveAway.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionMoveAway.java @@ -24,9 +24,6 @@ public class BuilderBodyMotionMoveAway extends BuilderBodyMotionFindWithTarget { protected final DoubleHolder erraticExtraJitter = new DoubleHolder(); protected final DoubleHolder erraticChangeDurationMultiplier = new DoubleHolder(); - public BuilderBodyMotionMoveAway() { - } - @Nonnull public BodyMotionMoveAway build(@Nonnull BuilderSupport builderSupport) { return new BodyMotionMoveAway(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionTakeOff.java b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionTakeOff.java index 97091ee..603ec99 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionTakeOff.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionTakeOff.java @@ -19,9 +19,6 @@ import javax.annotation.Nonnull; public class BuilderBodyMotionTakeOff extends BuilderBodyMotionBase { protected double jumpSpeed = 1.0; - public BuilderBodyMotionTakeOff() { - } - @Nonnull public BodyMotion build(BuilderSupport builderSupport) { return new BodyMotionTakeOff(this); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionTeleport.java b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionTeleport.java index 1c0fd25..190fd86 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionTeleport.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionTeleport.java @@ -19,9 +19,6 @@ public class BuilderBodyMotionTeleport extends BuilderBodyMotionBase { protected float sector; protected BodyMotionTeleport.Orientation orientation; - public BuilderBodyMotionTeleport() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionWander.java b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionWander.java index 938ef82..d9f5fbb 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionWander.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionWander.java @@ -7,9 +7,6 @@ import com.hypixel.hytale.server.npc.corecomponents.movement.BodyMotionWander; import javax.annotation.Nonnull; public class BuilderBodyMotionWander extends BuilderBodyMotionWanderBase { - public BuilderBodyMotionWander() { - } - @Nonnull public BodyMotionWander build(@Nonnull BuilderSupport builderSupport) { return new BodyMotionWander(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionWanderBase.java b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionWanderBase.java index 46a97df..0071e0f 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionWanderBase.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionWanderBase.java @@ -32,9 +32,6 @@ public abstract class BuilderBodyMotionWanderBase extends BuilderBodyMotionBase protected final IntHolder testsPerTick = new IntHolder(); protected final DoubleHolder desiredAltitudeWeight = new DoubleHolder(); - public BuilderBodyMotionWanderBase() { - } - @Nullable public BodyMotionWanderBase build(@Nonnull BuilderSupport builderSupport) { builderSupport.setRequireLeashPosition(); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionWanderInCircle.java b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionWanderInCircle.java index 69773ce..f8af92b 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionWanderInCircle.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionWanderInCircle.java @@ -13,9 +13,6 @@ public class BuilderBodyMotionWanderInCircle extends BuilderBodyMotionWanderBase protected boolean flock; protected boolean useSphere; - public BuilderBodyMotionWanderInCircle() { - } - @Nonnull public BodyMotionWanderInCircle build(@Nonnull BuilderSupport builderSupport) { super.build(builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionWanderInRect.java b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionWanderInRect.java index 3be9f6c..71cb43f 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionWanderInRect.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderBodyMotionWanderInRect.java @@ -11,9 +11,6 @@ public class BuilderBodyMotionWanderInRect extends BuilderBodyMotionWanderBase { protected double width; protected double depth; - public BuilderBodyMotionWanderInRect() { - } - @Nonnull public BodyMotionWanderInRect build(@Nonnull BuilderSupport builderSupport) { super.build(builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderSensorInAir.java b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderSensorInAir.java index 420e9d4..7cb212f 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderSensorInAir.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderSensorInAir.java @@ -10,9 +10,6 @@ import com.hypixel.hytale.server.npc.instructions.Sensor; import javax.annotation.Nonnull; public class BuilderSensorInAir extends BuilderSensorBase { - public BuilderSensorInAir() { - } - @Nonnull public SensorInAir build(BuilderSupport builderSupport) { return new SensorInAir(this); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderSensorMotionController.java b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderSensorMotionController.java index 95bf956..9291478 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderSensorMotionController.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderSensorMotionController.java @@ -13,9 +13,6 @@ import javax.annotation.Nonnull; public class BuilderSensorMotionController extends BuilderSensorBase { protected String motionControllerName; - public BuilderSensorMotionController() { - } - @Nonnull public Sensor build(BuilderSupport builderSupport) { return new SensorMotionController(this); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderSensorNav.java b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderSensorNav.java index 931181b..88114b3 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderSensorNav.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderSensorNav.java @@ -19,9 +19,6 @@ public class BuilderSensorNav extends BuilderSensorBase { protected final DoubleHolder throttleDuration = new DoubleHolder(); protected final DoubleHolder targetDelta = new DoubleHolder(); - public BuilderSensorNav() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderSensorOnGround.java b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderSensorOnGround.java index 4339932..1d0b9ab 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderSensorOnGround.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/movement/builders/BuilderSensorOnGround.java @@ -10,9 +10,6 @@ import com.hypixel.hytale.server.npc.instructions.Sensor; import javax.annotation.Nonnull; public class BuilderSensorOnGround extends BuilderSensorBase { - public BuilderSensorOnGround() { - } - @Nonnull public SensorOnGround build(BuilderSupport builderSupport) { return new SensorOnGround(this); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/statemachine/builders/BuilderActionParentState.java b/src/com/hypixel/hytale/server/npc/corecomponents/statemachine/builders/BuilderActionParentState.java index f90c6a3..304ed76 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/statemachine/builders/BuilderActionParentState.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/statemachine/builders/BuilderActionParentState.java @@ -13,9 +13,6 @@ import javax.annotation.Nonnull; public class BuilderActionParentState extends BuilderActionBase { protected String state; - public BuilderActionParentState() { - } - @Nonnull public ActionParentState build(@Nonnull BuilderSupport builderSupport) { return new ActionParentState(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/statemachine/builders/BuilderActionState.java b/src/com/hypixel/hytale/server/npc/corecomponents/statemachine/builders/BuilderActionState.java index d307916..ba1eaf4 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/statemachine/builders/BuilderActionState.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/statemachine/builders/BuilderActionState.java @@ -16,9 +16,6 @@ public class BuilderActionState extends BuilderActionBase { protected boolean clearState; protected boolean componentLocal; - public BuilderActionState() { - } - @Nonnull public ActionState build(@Nonnull BuilderSupport builderSupport) { return new ActionState(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/statemachine/builders/BuilderActionToggleStateEvaluator.java b/src/com/hypixel/hytale/server/npc/corecomponents/statemachine/builders/BuilderActionToggleStateEvaluator.java index a0fc3c9..baefaae 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/statemachine/builders/BuilderActionToggleStateEvaluator.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/statemachine/builders/BuilderActionToggleStateEvaluator.java @@ -10,9 +10,6 @@ import javax.annotation.Nonnull; public class BuilderActionToggleStateEvaluator extends BuilderActionBase { protected boolean enable; - public BuilderActionToggleStateEvaluator() { - } - @Nonnull public ActionToggleStateEvaluator build(BuilderSupport builderSupport) { return new ActionToggleStateEvaluator(this); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/statemachine/builders/BuilderSensorIsBusy.java b/src/com/hypixel/hytale/server/npc/corecomponents/statemachine/builders/BuilderSensorIsBusy.java index cc182d3..2852dc7 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/statemachine/builders/BuilderSensorIsBusy.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/statemachine/builders/BuilderSensorIsBusy.java @@ -8,9 +8,6 @@ import com.hypixel.hytale.server.npc.instructions.Sensor; import javax.annotation.Nonnull; public class BuilderSensorIsBusy extends BuilderSensorBase { - public BuilderSensorIsBusy() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/statemachine/builders/BuilderSensorState.java b/src/com/hypixel/hytale/server/npc/corecomponents/statemachine/builders/BuilderSensorState.java index 8479a70..ab366b7 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/statemachine/builders/BuilderSensorState.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/statemachine/builders/BuilderSensorState.java @@ -18,9 +18,6 @@ public class BuilderSensorState extends BuilderSensorBase { protected boolean ignoreMissingSetState; protected boolean componentLocal; - public BuilderSensorState() { - } - @Nonnull public SensorState build(@Nonnull BuilderSupport builderSupport) { return new SensorState(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionSetAlarm.java b/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionSetAlarm.java index dbf290c..4f29cc8 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionSetAlarm.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionSetAlarm.java @@ -22,9 +22,6 @@ public class BuilderActionSetAlarm extends BuilderActionBase { protected final StringHolder name = new StringHolder(); protected final TemporalArrayHolder durationRange = new TemporalArrayHolder(); - public BuilderActionSetAlarm() { - } - @Nonnull public ActionSetAlarm build(@Nonnull BuilderSupport builderSupport) { return new ActionSetAlarm(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimer.java b/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimer.java index 0e6aabf..843d6d7 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimer.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimer.java @@ -12,9 +12,6 @@ import javax.annotation.Nonnull; public abstract class BuilderActionTimer extends BuilderActionBase { protected final StringHolder name = new StringHolder(); - public BuilderActionTimer() { - } - @Nonnull @Override public BuilderDescriptorState getBuilderDescriptorState() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimerContinue.java b/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimerContinue.java index 40346cc..eda628c 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimerContinue.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimerContinue.java @@ -6,9 +6,6 @@ import com.hypixel.hytale.server.npc.util.Timer; import javax.annotation.Nonnull; public class BuilderActionTimerContinue extends BuilderActionTimer { - public BuilderActionTimerContinue() { - } - @Nonnull public ActionTimer build(@Nonnull BuilderSupport builderSupport) { return new ActionTimer(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimerModify.java b/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimerModify.java index 9bc6559..8f41695 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimerModify.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimerModify.java @@ -21,9 +21,6 @@ public class BuilderActionTimerModify extends BuilderActionTimer { protected final BooleanHolder repeating = new BooleanHolder(); protected boolean modifyRepeating; - public BuilderActionTimerModify() { - } - @Nonnull public ActionTimer build(@Nonnull BuilderSupport builderSupport) { return new ActionTimer(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimerPause.java b/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimerPause.java index dd74747..7f1d787 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimerPause.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimerPause.java @@ -6,9 +6,6 @@ import com.hypixel.hytale.server.npc.util.Timer; import javax.annotation.Nonnull; public class BuilderActionTimerPause extends BuilderActionTimer { - public BuilderActionTimerPause() { - } - @Nonnull public ActionTimer build(@Nonnull BuilderSupport builderSupport) { return new ActionTimer(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimerRestart.java b/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimerRestart.java index d8226db..3101875 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimerRestart.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimerRestart.java @@ -6,9 +6,6 @@ import com.hypixel.hytale.server.npc.util.Timer; import javax.annotation.Nonnull; public class BuilderActionTimerRestart extends BuilderActionTimer { - public BuilderActionTimerRestart() { - } - @Nonnull public ActionTimer build(@Nonnull BuilderSupport builderSupport) { return new ActionTimer(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimerStart.java b/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimerStart.java index 828d108..2e038de 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimerStart.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimerStart.java @@ -18,9 +18,6 @@ public class BuilderActionTimerStart extends BuilderActionTimer { protected final DoubleHolder rate = new DoubleHolder(); protected final BooleanHolder repeating = new BooleanHolder(); - public BuilderActionTimerStart() { - } - @Nonnull public ActionTimer build(@Nonnull BuilderSupport builderSupport) { return new ActionTimer(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimerStop.java b/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimerStop.java index 754d7de..e550f61 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimerStop.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderActionTimerStop.java @@ -6,9 +6,6 @@ import com.hypixel.hytale.server.npc.util.Timer; import javax.annotation.Nonnull; public class BuilderActionTimerStop extends BuilderActionTimer { - public BuilderActionTimerStop() { - } - @Nonnull public ActionTimer build(@Nonnull BuilderSupport builderSupport) { return new ActionTimer(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderMotionTimer.java b/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderMotionTimer.java index 4016b1c..7eabc69 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderMotionTimer.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderMotionTimer.java @@ -20,9 +20,6 @@ public abstract class BuilderMotionTimer extends BuilderMotion protected final NumberArrayHolder timerRange = new NumberArrayHolder(); protected BuilderObjectReferenceHelper motion; - public BuilderMotionTimer() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderSensorAlarm.java b/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderSensorAlarm.java index 00eb8a5..5482ec3 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderSensorAlarm.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderSensorAlarm.java @@ -19,9 +19,6 @@ public class BuilderSensorAlarm extends BuilderSensorBase { protected final EnumHolder state = new EnumHolder<>(); protected final BooleanHolder clear = new BooleanHolder(); - public BuilderSensorAlarm() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderSensorTimer.java b/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderSensorTimer.java index 1ebba59..f62400e 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderSensorTimer.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/timer/builders/BuilderSensorTimer.java @@ -20,9 +20,6 @@ public class BuilderSensorTimer extends BuilderSensorBase { protected final StringHolder name = new StringHolder(); protected Timer.TimerState timerState; - public BuilderSensorTimer() { - } - @Nonnull public SensorTimer build(@Nonnull BuilderSupport builderSupport) { return new SensorTimer(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderActionNothing.java b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderActionNothing.java index ea13ac0..8652c28 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderActionNothing.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderActionNothing.java @@ -8,9 +8,6 @@ import com.hypixel.hytale.server.npc.corecomponents.utility.ActionNothing; import javax.annotation.Nonnull; public class BuilderActionNothing extends BuilderActionBase { - public BuilderActionNothing() { - } - @Nonnull public ActionNothing build(BuilderSupport builderSupport) { return new ActionNothing(this); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderActionRandom.java b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderActionRandom.java index 148be3a..62dbc58 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderActionRandom.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderActionRandom.java @@ -17,9 +17,6 @@ import javax.annotation.Nullable; public class BuilderActionRandom extends BuilderActionBase { protected final BuilderObjectListHelper actions = new BuilderObjectListHelper<>(WeightedAction.class, this); - public BuilderActionRandom() { - } - @Nonnull public ActionRandom build(@Nonnull BuilderSupport builderSupport) { return new ActionRandom(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderActionResetInstructions.java b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderActionResetInstructions.java index 58237ec..a957c42 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderActionResetInstructions.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderActionResetInstructions.java @@ -14,9 +14,6 @@ import javax.annotation.Nonnull; public class BuilderActionResetInstructions extends BuilderActionBase { protected final StringArrayHolder instructions = new StringArrayHolder(); - public BuilderActionResetInstructions() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderActionSequence.java b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderActionSequence.java index e13f2d8..d50aaef 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderActionSequence.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderActionSequence.java @@ -18,9 +18,6 @@ public class BuilderActionSequence extends BuilderActionBase { protected boolean blocking; protected boolean atomic; - public BuilderActionSequence() { - } - @Nonnull public ActionSequence build(@Nonnull BuilderSupport builderSupport) { return new ActionSequence(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderActionSetFlag.java b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderActionSetFlag.java index 6e22e9a..4ec7796 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderActionSetFlag.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderActionSetFlag.java @@ -15,9 +15,6 @@ public class BuilderActionSetFlag extends BuilderActionBase { protected final StringHolder name = new StringHolder(); protected final BooleanHolder value = new BooleanHolder(); - public BuilderActionSetFlag() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderActionTimeout.java b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderActionTimeout.java index f00c742..c4a7e06 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderActionTimeout.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderActionTimeout.java @@ -18,9 +18,6 @@ public class BuilderActionTimeout extends BuilderActionWithDelay { protected boolean delayAfter; protected final BuilderObjectReferenceHelper action = new BuilderObjectReferenceHelper<>(Action.class, this); - public BuilderActionTimeout() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderBodyMotionNothing.java b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderBodyMotionNothing.java index 713a7d0..9c722af 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderBodyMotionNothing.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderBodyMotionNothing.java @@ -7,9 +7,6 @@ import com.hypixel.hytale.server.npc.corecomponents.utility.BodyMotionNothing; import javax.annotation.Nonnull; public class BuilderBodyMotionNothing extends BuilderBodyMotionBase { - public BuilderBodyMotionNothing() { - } - @Nonnull public BodyMotionNothing build(BuilderSupport builderSupport) { return new BodyMotionNothing(this); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderHeadMotionNothing.java b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderHeadMotionNothing.java index 9b70b51..9b273e4 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderHeadMotionNothing.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderHeadMotionNothing.java @@ -7,9 +7,6 @@ import com.hypixel.hytale.server.npc.corecomponents.utility.HeadMotionNothing; import javax.annotation.Nonnull; public class BuilderHeadMotionNothing extends BuilderHeadMotionBase { - public BuilderHeadMotionNothing() { - } - @Nonnull public HeadMotionNothing build(BuilderSupport builderSupport) { return new HeadMotionNothing(this); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderMotionSequence.java b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderMotionSequence.java index 183be4c..b670168 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderMotionSequence.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderMotionSequence.java @@ -17,9 +17,6 @@ public abstract class BuilderMotionSequence extends BuilderMot protected boolean looped; protected boolean restartOnActivate; - public BuilderMotionSequence() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorAdjustPosition.java b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorAdjustPosition.java index eac0a3e..6fc76a6 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorAdjustPosition.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorAdjustPosition.java @@ -22,9 +22,6 @@ public class BuilderSensorAdjustPosition extends BuilderSensorBase { protected final BuilderObjectReferenceHelper sensor = new BuilderObjectReferenceHelper<>(Sensor.class, this); protected final NumberArrayHolder offset = new NumberArrayHolder(); - public BuilderSensorAdjustPosition() { - } - @Nullable public SensorAdjustPosition build(@Nonnull BuilderSupport builderSupport) { Sensor sensor = this.getSensor(builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorAnd.java b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorAnd.java index 3458c67..8ec30e7 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorAnd.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorAnd.java @@ -9,9 +9,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class BuilderSensorAnd extends BuilderSensorMany { - public BuilderSensorAnd() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorAny.java b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorAny.java index d8741f9..9370bcb 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorAny.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorAny.java @@ -11,9 +11,6 @@ import java.util.Set; import javax.annotation.Nonnull; public class BuilderSensorAny extends BuilderSensorBase { - public BuilderSensorAny() { - } - @Nonnull public Sensor build(BuilderSupport builderSupport) { return (Sensor)(!this.once ? Sensor.NULL : new SensorAny(this)); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorEval.java b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorEval.java index 764af6c..add1094 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorEval.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorEval.java @@ -13,9 +13,6 @@ import javax.annotation.Nonnull; public class BuilderSensorEval extends BuilderSensorBase { protected String expression; - public BuilderSensorEval() { - } - @Nonnull public SensorEval build(@Nonnull BuilderSupport builderSupport) { return new SensorEval(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorFlag.java b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorFlag.java index 46609d4..1b0f5a3 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorFlag.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorFlag.java @@ -16,9 +16,6 @@ public class BuilderSensorFlag extends BuilderSensorBase { protected final StringHolder name = new StringHolder(); protected final BooleanHolder value = new BooleanHolder(); - public BuilderSensorFlag() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorMany.java b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorMany.java index d902dc9..54a69b4 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorMany.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorMany.java @@ -22,9 +22,6 @@ public abstract class BuilderSensorMany extends BuilderSensorBase { protected BuilderObjectListHelper objectListHelper = new BuilderObjectListHelper<>(Sensor.class, this); protected final StringHolder unlockTargetSlot = new StringHolder(); - public BuilderSensorMany() { - } - @Override public void registerTags(@Nonnull Set tags) { super.registerTags(tags); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorNot.java b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorNot.java index 4b88b21..5969936 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorNot.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorNot.java @@ -22,9 +22,6 @@ public class BuilderSensorNot extends BuilderSensorBase { protected final StringHolder targetSlot = new StringHolder(); protected final StringHolder autoUnlockTargetSlot = new StringHolder(); - public BuilderSensorNot() { - } - @Nullable public SensorNot build(@Nonnull BuilderSupport builderSupport) { Sensor sensor = this.getSensor(builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorOr.java b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorOr.java index 48f665c..1461f96 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorOr.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorOr.java @@ -9,9 +9,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class BuilderSensorOr extends BuilderSensorMany { - public BuilderSensorOr() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorRandom.java b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorRandom.java index b7a48a9..880eb86 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorRandom.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorRandom.java @@ -15,9 +15,6 @@ public class BuilderSensorRandom extends BuilderSensorBase { protected final NumberArrayHolder falseRange = new NumberArrayHolder(); protected final NumberArrayHolder trueRange = new NumberArrayHolder(); - public BuilderSensorRandom() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorSwitch.java b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorSwitch.java index fcbce40..45414fc 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorSwitch.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorSwitch.java @@ -14,9 +14,6 @@ import javax.annotation.Nonnull; public class BuilderSensorSwitch extends BuilderSensorBase { protected final BooleanHolder switchHolder = new BooleanHolder(); - public BuilderSensorSwitch() { - } - @Nonnull public SensorSwitch build(@Nonnull BuilderSupport builderSupport) { return new SensorSwitch(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorValueProviderWrapper.java b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorValueProviderWrapper.java index d5f543e..a643650 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorValueProviderWrapper.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderSensorValueProviderWrapper.java @@ -26,9 +26,6 @@ public class BuilderSensorValueProviderWrapper extends BuilderSensorBase { BuilderValueToParameterMapping.ValueToParameterMapping.class, this ); - public BuilderSensorValueProviderWrapper() { - } - @Nullable public SensorValueProviderWrapper build(@Nonnull BuilderSupport builderSupport) { Sensor sensor = this.getSensor(builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderValueToParameterMapping.java b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderValueToParameterMapping.java index 8ee4783..b2636ce 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderValueToParameterMapping.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/utility/builders/BuilderValueToParameterMapping.java @@ -19,9 +19,6 @@ public class BuilderValueToParameterMapping extends BuilderBase fromSlot; protected String toParameter; - public BuilderValueToParameterMapping() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/SensorPath.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/SensorPath.java index 8eeccfb..413f83e 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/SensorPath.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/SensorPath.java @@ -295,9 +295,6 @@ public class SensorPath extends SensorBase { WAITING, FAILED, SUCCESS; - - private LoadStatus() { - } } public static enum PathType implements Supplier { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionMakePath.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionMakePath.java index ab878d2..2d663b5 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionMakePath.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionMakePath.java @@ -20,9 +20,6 @@ import javax.annotation.Nullable; public class BuilderActionMakePath extends BuilderActionBase { protected final BuilderObjectReferenceHelper transientPath = new BuilderObjectReferenceHelper<>(TransientPathDefinition.class, this); - public BuilderActionMakePath() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionPlaceBlock.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionPlaceBlock.java index 02eb40e..f76a269 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionPlaceBlock.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionPlaceBlock.java @@ -17,9 +17,6 @@ public class BuilderActionPlaceBlock extends BuilderActionBase { protected final DoubleHolder range = new DoubleHolder(); protected final BooleanHolder allowEmptyMaterials = new BooleanHolder(); - public BuilderActionPlaceBlock() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionResetBlockSensors.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionResetBlockSensors.java index e7be948..8c7d84f 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionResetBlockSensors.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionResetBlockSensors.java @@ -16,9 +16,6 @@ import javax.annotation.Nonnull; public class BuilderActionResetBlockSensors extends BuilderActionBase { protected final AssetArrayHolder blockSets = new AssetArrayHolder(); - public BuilderActionResetBlockSensors() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionResetPath.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionResetPath.java index c701928..8294b60 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionResetPath.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionResetPath.java @@ -8,9 +8,6 @@ import com.hypixel.hytale.server.npc.instructions.Action; import javax.annotation.Nonnull; public class BuilderActionResetPath extends BuilderActionBase { - public BuilderActionResetPath() { - } - @Nonnull public Action build(BuilderSupport builderSupport) { return new ActionResetPath(this); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionResetSearchRays.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionResetSearchRays.java index 3474821..bd57386 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionResetSearchRays.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionResetSearchRays.java @@ -14,9 +14,6 @@ import javax.annotation.Nonnull; public class BuilderActionResetSearchRays extends BuilderActionBase { protected final AssetArrayHolder names = new AssetArrayHolder(); - public BuilderActionResetSearchRays() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionSetBlockToPlace.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionSetBlockToPlace.java index 5da2e73..35a8a68 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionSetBlockToPlace.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionSetBlockToPlace.java @@ -13,9 +13,6 @@ import javax.annotation.Nonnull; public class BuilderActionSetBlockToPlace extends BuilderActionBase { protected final AssetHolder block = new AssetHolder(); - public BuilderActionSetBlockToPlace() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionSetLeashPosition.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionSetLeashPosition.java index 934ff5e..4b6f4c9 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionSetLeashPosition.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionSetLeashPosition.java @@ -12,9 +12,6 @@ public class BuilderActionSetLeashPosition extends BuilderActionBase { protected boolean toTarget; protected boolean toCurrent; - public BuilderActionSetLeashPosition() { - } - @Nonnull public ActionSetLeashPosition build(@Nonnull BuilderSupport builderSupport) { builderSupport.setRequireLeashPosition(); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionStorePosition.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionStorePosition.java index 90ef21d..9e141a5 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionStorePosition.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionStorePosition.java @@ -13,9 +13,6 @@ import javax.annotation.Nonnull; public class BuilderActionStorePosition extends BuilderActionBase { protected final StringHolder slot = new StringHolder(); - public BuilderActionStorePosition() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionTriggerSpawners.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionTriggerSpawners.java index 0b8113d..b14186f 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionTriggerSpawners.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderActionTriggerSpawners.java @@ -21,9 +21,6 @@ public class BuilderActionTriggerSpawners extends BuilderActionBase { protected final DoubleHolder range = new DoubleHolder(); protected final IntHolder count = new IntHolder(); - public BuilderActionTriggerSpawners() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderBodyMotionPath.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderBodyMotionPath.java index e74dce3..35cfb47 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderBodyMotionPath.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderBodyMotionPath.java @@ -38,9 +38,6 @@ public class BuilderBodyMotionPath extends BuilderBodyMotionBase { protected boolean useNodeViewDirection; protected boolean pickRandomAngle; - public BuilderBodyMotionPath() { - } - @Nonnull public BodyMotionPath build(@Nonnull BuilderSupport builderSupport) { return new BodyMotionPath(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderHeadMotionObserve.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderHeadMotionObserve.java index 7bda5e1..b59bbdb 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderHeadMotionObserve.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderHeadMotionObserve.java @@ -22,9 +22,6 @@ public class BuilderHeadMotionObserve extends BuilderHeadMotionBase { protected final IntHolder viewSegments = new IntHolder(); protected final DoubleHolder relativeTurnSpeed = new DoubleHolder(); - public BuilderHeadMotionObserve() { - } - @Nonnull public HeadMotionObserve build(@Nonnull BuilderSupport builderSupport) { return new HeadMotionObserve(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorBlock.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorBlock.java index 9fcbb72..4a9af6d 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorBlock.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorBlock.java @@ -23,9 +23,6 @@ public class BuilderSensorBlock extends BuilderSensorBase { protected final BooleanHolder pickRandom = new BooleanHolder(); protected final BooleanHolder reserveBlock = new BooleanHolder(); - public BuilderSensorBlock() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorBlockChange.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorBlockChange.java index c508dab..5a04240 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorBlockChange.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorBlockChange.java @@ -17,9 +17,6 @@ public class BuilderSensorBlockChange extends BuilderSensorEvent { protected final AssetHolder blockSet = new AssetHolder(); protected final EnumHolder blockEventType = new EnumHolder<>(); - public BuilderSensorBlockChange() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorBlockType.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorBlockType.java index bd5b1b9..e6ffa1e 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorBlockType.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorBlockType.java @@ -18,9 +18,6 @@ public class BuilderSensorBlockType extends BuilderSensorBase { protected final BuilderObjectReferenceHelper sensor = new BuilderObjectReferenceHelper<>(Sensor.class, this); protected final AssetHolder blockSet = new AssetHolder(); - public BuilderSensorBlockType() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorCanPlace.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorCanPlace.java index 2d0244b..d06ffd9 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorCanPlace.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorCanPlace.java @@ -20,9 +20,6 @@ public class BuilderSensorCanPlace extends BuilderSensorBase { protected final DoubleHolder retryDelay = new DoubleHolder(); protected final BooleanHolder allowEmptyMaterials = new BooleanHolder(); - public BuilderSensorCanPlace() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorEntityEvent.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorEntityEvent.java index 06a9013..6bedf69 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorEntityEvent.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorEntityEvent.java @@ -19,9 +19,6 @@ public class BuilderSensorEntityEvent extends BuilderSensorEvent { protected final EnumHolder entityEventType = new EnumHolder<>(); protected final BooleanHolder flockOnly = new BooleanHolder(); - public BuilderSensorEntityEvent() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorEvent.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorEvent.java index 465dc54..a3e1cc0 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorEvent.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorEvent.java @@ -20,9 +20,6 @@ public abstract class BuilderSensorEvent extends BuilderSensorBase { protected final EnumHolder searchType = new EnumHolder<>(); protected final StringHolder lockOnTargetSlot = new StringHolder(); - public BuilderSensorEvent() { - } - @Nonnull @Override public Builder readConfig(@Nonnull JsonElement data) { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorInWater.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorInWater.java index e7b06df..6898705 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorInWater.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorInWater.java @@ -8,9 +8,6 @@ import com.hypixel.hytale.server.npc.instructions.Sensor; import javax.annotation.Nonnull; public class BuilderSensorInWater extends BuilderSensorBase { - public BuilderSensorInWater() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorLeash.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorLeash.java index 1e0102d..2769a27 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorLeash.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorLeash.java @@ -15,9 +15,6 @@ import javax.annotation.Nonnull; public class BuilderSensorLeash extends BuilderSensorBase { protected final DoubleHolder range = new DoubleHolder(); - public BuilderSensorLeash() { - } - @Nonnull public SensorLeash build(@Nonnull BuilderSupport builderSupport) { builderSupport.setRequireLeashPosition(); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorLight.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorLight.java index e4e4e76..2b89adb 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorLight.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorLight.java @@ -23,9 +23,6 @@ public class BuilderSensorLight extends BuilderSensorBase { protected final NumberArrayHolder greenLightRange = new NumberArrayHolder(); protected final NumberArrayHolder blueLightRange = new NumberArrayHolder(); - public BuilderSensorLight() { - } - @Nonnull public SensorLight build(@Nonnull BuilderSupport builderSupport) { return new SensorLight(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorPath.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorPath.java index 59ff79d..6eb28f6 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorPath.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorPath.java @@ -21,9 +21,6 @@ public class BuilderSensorPath extends BuilderSensorBase { protected final DoubleHolder range = new DoubleHolder(); protected final EnumHolder pathType = new EnumHolder<>(); - public BuilderSensorPath() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorReadPosition.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorReadPosition.java index 810f4e7..b0251d4 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorReadPosition.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorReadPosition.java @@ -21,9 +21,6 @@ public class BuilderSensorReadPosition extends BuilderSensorBase { protected final DoubleHolder range = new DoubleHolder(); protected final DoubleHolder minRange = new DoubleHolder(); - public BuilderSensorReadPosition() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorSearchRay.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorSearchRay.java index 5754ebe..7adb200 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorSearchRay.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorSearchRay.java @@ -28,9 +28,6 @@ public class BuilderSensorSearchRay extends BuilderSensorBase { protected final DoubleHolder minRetestMove = new DoubleHolder(); protected final DoubleHolder throttleTime = new DoubleHolder(); - public BuilderSensorSearchRay() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorTime.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorTime.java index 2106308..5148e13 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorTime.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorTime.java @@ -17,9 +17,6 @@ public class BuilderSensorTime extends BuilderSensorBase { protected boolean checkYear; protected boolean scaleDayTimeRange; - public BuilderSensorTime() { - } - @Nonnull public Sensor build(@Nonnull BuilderSupport builderSupport) { return new SensorTime(this, builderSupport); diff --git a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorWeather.java b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorWeather.java index 7e2a38e..c9233fb 100644 --- a/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorWeather.java +++ b/src/com/hypixel/hytale/server/npc/corecomponents/world/builders/BuilderSensorWeather.java @@ -17,9 +17,6 @@ import javax.annotation.Nullable; public class BuilderSensorWeather extends BuilderSensorBase { protected final AssetArrayHolder weathers = new AssetArrayHolder(); - public BuilderSensorWeather() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/decisionmaker/core/EvaluationContext.java b/src/com/hypixel/hytale/server/npc/decisionmaker/core/EvaluationContext.java index 1a2da04..769442a 100644 --- a/src/com/hypixel/hytale/server/npc/decisionmaker/core/EvaluationContext.java +++ b/src/com/hypixel/hytale/server/npc/decisionmaker/core/EvaluationContext.java @@ -6,9 +6,6 @@ public class EvaluationContext { private float predictability; private long lastUsedNanos; - public EvaluationContext() { - } - public double getMinimumUtility() { return this.minimumUtility; } diff --git a/src/com/hypixel/hytale/server/npc/decisionmaker/core/Evaluator.java b/src/com/hypixel/hytale/server/npc/decisionmaker/core/Evaluator.java index b890e7a..e4367d0 100644 --- a/src/com/hypixel/hytale/server/npc/decisionmaker/core/Evaluator.java +++ b/src/com/hypixel/hytale/server/npc/decisionmaker/core/Evaluator.java @@ -21,9 +21,6 @@ public abstract class Evaluator { public static long NOT_USED = 0L; protected List.OptionHolder> options; - public Evaluator() { - } - public void initialise() { this.options.sort(Comparator.comparingDouble(Evaluator.OptionHolder::getWeightCoefficient).reversed()); diff --git a/src/com/hypixel/hytale/server/npc/decisionmaker/core/conditions/LineOfSightCondition.java b/src/com/hypixel/hytale/server/npc/decisionmaker/core/conditions/LineOfSightCondition.java index 4506bbe..d89711e 100644 --- a/src/com/hypixel/hytale/server/npc/decisionmaker/core/conditions/LineOfSightCondition.java +++ b/src/com/hypixel/hytale/server/npc/decisionmaker/core/conditions/LineOfSightCondition.java @@ -20,9 +20,6 @@ public class LineOfSightCondition extends SimpleCondition { @Nullable protected static final ComponentType NPC_COMPONENT_TYPE = NPCEntity.getComponentType(); - public LineOfSightCondition() { - } - @Override public int getSimplicity() { return 40; diff --git a/src/com/hypixel/hytale/server/npc/decisionmaker/core/conditions/RandomiserCondition.java b/src/com/hypixel/hytale/server/npc/decisionmaker/core/conditions/RandomiserCondition.java index 099ba58..a3a80c9 100644 --- a/src/com/hypixel/hytale/server/npc/decisionmaker/core/conditions/RandomiserCondition.java +++ b/src/com/hypixel/hytale/server/npc/decisionmaker/core/conditions/RandomiserCondition.java @@ -37,9 +37,6 @@ public class RandomiserCondition extends Condition { protected double minValue; protected double maxValue; - public RandomiserCondition() { - } - @Override public double calculateUtility( int selfIndex, ArchetypeChunk archetypeChunk, Ref target, CommandBuffer commandBuffer, EvaluationContext context diff --git a/src/com/hypixel/hytale/server/npc/decisionmaker/core/conditions/TargetDistanceCondition.java b/src/com/hypixel/hytale/server/npc/decisionmaker/core/conditions/TargetDistanceCondition.java index 84c8b21..4318f3b 100644 --- a/src/com/hypixel/hytale/server/npc/decisionmaker/core/conditions/TargetDistanceCondition.java +++ b/src/com/hypixel/hytale/server/npc/decisionmaker/core/conditions/TargetDistanceCondition.java @@ -22,9 +22,6 @@ public class TargetDistanceCondition extends ScaledCurveCondition { @Nonnull private static final ComponentType TRANSFORM_COMPONENT_TYPE = TransformComponent.getComponentType(); - public TargetDistanceCondition() { - } - @Override protected double getInput( int selfIndex, diff --git a/src/com/hypixel/hytale/server/npc/decisionmaker/core/conditions/TargetMovementStateCondition.java b/src/com/hypixel/hytale/server/npc/decisionmaker/core/conditions/TargetMovementStateCondition.java index a44ac7d..8721f4a 100644 --- a/src/com/hypixel/hytale/server/npc/decisionmaker/core/conditions/TargetMovementStateCondition.java +++ b/src/com/hypixel/hytale/server/npc/decisionmaker/core/conditions/TargetMovementStateCondition.java @@ -32,9 +32,6 @@ public class TargetMovementStateCondition extends SimpleCondition { .build(); protected MovementState movementState; - public TargetMovementStateCondition() { - } - @Override protected boolean evaluate( int selfIndex, diff --git a/src/com/hypixel/hytale/server/npc/entities/PathManager.java b/src/com/hypixel/hytale/server/npc/entities/PathManager.java index 4b7697f..1cc2532 100644 --- a/src/com/hypixel/hytale/server/npc/entities/PathManager.java +++ b/src/com/hypixel/hytale/server/npc/entities/PathManager.java @@ -26,9 +26,6 @@ public class PathManager { @Nullable private IPath currentPath; - public PathManager() { - } - public void setPrefabPath(@Nonnull UUID currentPath, @Nonnull IPrefabPath path) { this.currentPathHint = currentPath; this.currentPath = path; diff --git a/src/com/hypixel/hytale/server/npc/instructions/NullSensor.java b/src/com/hypixel/hytale/server/npc/instructions/NullSensor.java index 0f0741d..746ad4f 100644 --- a/src/com/hypixel/hytale/server/npc/instructions/NullSensor.java +++ b/src/com/hypixel/hytale/server/npc/instructions/NullSensor.java @@ -11,9 +11,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class NullSensor implements Sensor { - public NullSensor() { - } - @Override public boolean matches(@Nonnull Ref ref, @Nonnull Role role, double dt, @Nonnull Store store) { return true; diff --git a/src/com/hypixel/hytale/server/npc/instructions/builders/BuilderActionList.java b/src/com/hypixel/hytale/server/npc/instructions/builders/BuilderActionList.java index 667c4e1..d92de1d 100644 --- a/src/com/hypixel/hytale/server/npc/instructions/builders/BuilderActionList.java +++ b/src/com/hypixel/hytale/server/npc/instructions/builders/BuilderActionList.java @@ -16,9 +16,6 @@ import javax.annotation.Nonnull; public class BuilderActionList extends BuilderBase { protected final BuilderObjectListHelper actions = new BuilderObjectListHelper<>(Action.class, this); - public BuilderActionList() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/instructions/builders/BuilderInstruction.java b/src/com/hypixel/hytale/server/npc/instructions/builders/BuilderInstruction.java index 61d8e34..8de498b 100644 --- a/src/com/hypixel/hytale/server/npc/instructions/builders/BuilderInstruction.java +++ b/src/com/hypixel/hytale/server/npc/instructions/builders/BuilderInstruction.java @@ -44,9 +44,6 @@ public class BuilderInstruction extends BuilderBase { protected final BooleanHolder invertTreeModeResult = new BooleanHolder(); protected String currentStateName; - public BuilderInstruction() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/instructions/builders/BuilderInstructionRandomized.java b/src/com/hypixel/hytale/server/npc/instructions/builders/BuilderInstructionRandomized.java index f57e43d..7ad3536 100644 --- a/src/com/hypixel/hytale/server/npc/instructions/builders/BuilderInstructionRandomized.java +++ b/src/com/hypixel/hytale/server/npc/instructions/builders/BuilderInstructionRandomized.java @@ -22,9 +22,6 @@ public class BuilderInstructionRandomized extends BuilderInstruction { protected final BooleanHolder resetOnStateChange = new BooleanHolder(); protected final NumberArrayHolder executeFor = new NumberArrayHolder(); - public BuilderInstructionRandomized() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/instructions/builders/BuilderInstructionReference.java b/src/com/hypixel/hytale/server/npc/instructions/builders/BuilderInstructionReference.java index 926e705..1722a36 100644 --- a/src/com/hypixel/hytale/server/npc/instructions/builders/BuilderInstructionReference.java +++ b/src/com/hypixel/hytale/server/npc/instructions/builders/BuilderInstructionReference.java @@ -14,9 +14,6 @@ public class BuilderInstructionReference extends BuilderInstruction { @Nullable protected IntSet internalDependencies; - public BuilderInstructionReference() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/interactions/NPCInteractionSimulationHandler.java b/src/com/hypixel/hytale/server/npc/interactions/NPCInteractionSimulationHandler.java index 20ddbfb..1ed7934 100644 --- a/src/com/hypixel/hytale/server/npc/interactions/NPCInteractionSimulationHandler.java +++ b/src/com/hypixel/hytale/server/npc/interactions/NPCInteractionSimulationHandler.java @@ -10,9 +10,6 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; public class NPCInteractionSimulationHandler implements IInteractionSimulationHandler { private float requestedChargeTime; - public NPCInteractionSimulationHandler() { - } - @Override public void setState(InteractionType type, boolean state) { } diff --git a/src/com/hypixel/hytale/server/npc/interactions/SpawnNPCInteraction.java b/src/com/hypixel/hytale/server/npc/interactions/SpawnNPCInteraction.java index b38bd99..04b6bb1 100644 --- a/src/com/hypixel/hytale/server/npc/interactions/SpawnNPCInteraction.java +++ b/src/com/hypixel/hytale/server/npc/interactions/SpawnNPCInteraction.java @@ -71,9 +71,6 @@ public class SpawnNPCInteraction extends SimpleBlockInteraction { protected float spawnYawOffset; protected float spawnChance = 1.0F; - public SpawnNPCInteraction() { - } - private void spawnNPC(@Nonnull Store store, @Nonnull Vector3i targetBlock) { World world = store.getExternalData().getWorld(); SpawnNPCInteraction.SpawnData spawnData = this.computeSpawnData(world, targetBlock); diff --git a/src/com/hypixel/hytale/server/npc/metadata/CapturedNPCMetadata.java b/src/com/hypixel/hytale/server/npc/metadata/CapturedNPCMetadata.java index 1168c38..5ebeb81 100644 --- a/src/com/hypixel/hytale/server/npc/metadata/CapturedNPCMetadata.java +++ b/src/com/hypixel/hytale/server/npc/metadata/CapturedNPCMetadata.java @@ -39,9 +39,6 @@ public class CapturedNPCMetadata { private String npcNameKey; private String fullItemIcon; - public CapturedNPCMetadata() { - } - public int getRoleIndex() { return this.roleIndex; } diff --git a/src/com/hypixel/hytale/server/npc/movement/GroupSteeringAccumulator.java b/src/com/hypixel/hytale/server/npc/movement/GroupSteeringAccumulator.java index c943dac..3917220 100644 --- a/src/com/hypixel/hytale/server/npc/movement/GroupSteeringAccumulator.java +++ b/src/com/hypixel/hytale/server/npc/movement/GroupSteeringAccumulator.java @@ -31,9 +31,6 @@ public class GroupSteeringAccumulator { private double maxDistance = Double.MAX_VALUE; private float collisionViewHalfAngleCosine = 1.0F; - public GroupSteeringAccumulator() { - } - public void begin(double x, double y, double z, double xViewDirection, double yViewDirection, double zViewDirection) { this.x = x; this.y = y; diff --git a/src/com/hypixel/hytale/server/npc/movement/MotionKind.java b/src/com/hypixel/hytale/server/npc/movement/MotionKind.java index 0e71cb1..2d3d48c 100644 --- a/src/com/hypixel/hytale/server/npc/movement/MotionKind.java +++ b/src/com/hypixel/hytale/server/npc/movement/MotionKind.java @@ -9,7 +9,4 @@ public enum MotionKind { FLYING, SWIMMING, SWIMMING_TURNING; - - private MotionKind() { - } } diff --git a/src/com/hypixel/hytale/server/npc/movement/Steering.java b/src/com/hypixel/hytale/server/npc/movement/Steering.java index 0e3820d..578c1b0 100644 --- a/src/com/hypixel/hytale/server/npc/movement/Steering.java +++ b/src/com/hypixel/hytale/server/npc/movement/Steering.java @@ -19,9 +19,6 @@ public class Steering { private double relativeTurnSpeed; private boolean hasRelativeTurnSpeed; - public Steering() { - } - @Nonnull public Steering clear() { this.clearTranslation(); diff --git a/src/com/hypixel/hytale/server/npc/movement/controllers/BuilderMotionControllerMapUtil.java b/src/com/hypixel/hytale/server/npc/movement/controllers/BuilderMotionControllerMapUtil.java index 03d3757..6db8022 100644 --- a/src/com/hypixel/hytale/server/npc/movement/controllers/BuilderMotionControllerMapUtil.java +++ b/src/com/hypixel/hytale/server/npc/movement/controllers/BuilderMotionControllerMapUtil.java @@ -6,7 +6,4 @@ import java.util.Map; public class BuilderMotionControllerMapUtil { private static final Map MAP_OBJECT_REFERENCE = new HashMap<>(); public static final Class> CLASS_REFERENCE = (Class>)MAP_OBJECT_REFERENCE.getClass(); - - public BuilderMotionControllerMapUtil() { - } } diff --git a/src/com/hypixel/hytale/server/npc/movement/controllers/MotionController.java b/src/com/hypixel/hytale/server/npc/movement/controllers/MotionController.java index bebb34e..2e97cec 100644 --- a/src/com/hypixel/hytale/server/npc/movement/controllers/MotionController.java +++ b/src/com/hypixel/hytale/server/npc/movement/controllers/MotionController.java @@ -32,6 +32,8 @@ public interface MotionController { double getGravity(); + void setHeadPitchAngleRange(@Nullable float[] var1); + void spawned(); void activate(); @@ -224,9 +226,6 @@ public interface MotionController { public double min; public double max; - public VerticalRange() { - } - public void assign(double current, double min, double max) { this.current = current; this.min = min; diff --git a/src/com/hypixel/hytale/server/npc/movement/controllers/MotionControllerBase.java b/src/com/hypixel/hytale/server/npc/movement/controllers/MotionControllerBase.java index 2f7b013..1cca3a8 100644 --- a/src/com/hypixel/hytale/server/npc/movement/controllers/MotionControllerBase.java +++ b/src/com/hypixel/hytale/server/npc/movement/controllers/MotionControllerBase.java @@ -78,6 +78,8 @@ public abstract class MotionControllerBase implements MotionController { protected double inertia; protected double knockbackScale; protected double gravity; + @Nullable + protected float[] headPitchAngleRange; protected boolean debugModeSteer; protected boolean debugModeMove; protected boolean debugModeCollisions; @@ -181,6 +183,17 @@ public abstract class MotionControllerBase implements MotionController { this.collisionBoundingBox.assign(boundingBox); } + @Override + public void setHeadPitchAngleRange(float[] headPitchAngleRange) { + if (headPitchAngleRange == null) { + this.headPitchAngleRange = null; + } else { + assert headPitchAngleRange.length == 2; + + this.headPitchAngleRange = (float[])headPitchAngleRange.clone(); + } + } + protected void readEntityPosition(@Nonnull Ref ref, @Nonnull ComponentAccessor componentAccessor) { TransformComponent transformComponent = componentAccessor.getComponent(ref, TransformComponent.getComponentType()); @@ -655,7 +668,12 @@ public abstract class MotionControllerBase implements MotionController { CameraSettings headRotationRestrictions = modelComponent.getModel().getCamera(); float pitchMin; float pitchMax; - if (headRotationRestrictions != null && headRotationRestrictions.getPitch() != null && headRotationRestrictions.getPitch().getAngleRange() != null) { + if (this.headPitchAngleRange != null) { + pitchMin = this.headPitchAngleRange[0]; + pitchMax = this.headPitchAngleRange[1]; + } else if (headRotationRestrictions != null + && headRotationRestrictions.getPitch() != null + && headRotationRestrictions.getPitch().getAngleRange() != null) { Rangef pitchRange = headRotationRestrictions.getPitch().getAngleRange(); pitchMin = pitchRange.min * (float) (Math.PI / 180.0); pitchMax = pitchRange.max * (float) (Math.PI / 180.0); diff --git a/src/com/hypixel/hytale/server/npc/movement/controllers/MotionControllerWalk.java b/src/com/hypixel/hytale/server/npc/movement/controllers/MotionControllerWalk.java index 7409c75..10c5aa9 100644 --- a/src/com/hypixel/hytale/server/npc/movement/controllers/MotionControllerWalk.java +++ b/src/com/hypixel/hytale/server/npc/movement/controllers/MotionControllerWalk.java @@ -156,10 +156,10 @@ public class MotionControllerWalk extends MotionControllerBase { this.jumpDescentSteepness = builder.getJumpDescentSteepness(builderSupport); this.jumpBlending = builder.getJumpBlending(builderSupport); this.jumpDescentBlending = builder.getJumpDescentBlending(builderSupport); - this.ascentAnimationType = builder.getAscentAnimationType(); - this.climbSpeedMult = builder.getClimbSpeedMult(); - this.climbSpeedPow = builder.getClimbSpeedPow(); - this.climbSpeedConst = builder.getClimbSpeedConst(); + this.ascentAnimationType = builder.getAscentAnimationType(builderSupport); + this.climbSpeedMult = builder.getClimbSpeedMult(builderSupport); + this.climbSpeedPow = builder.getClimbSpeedPow(builderSupport); + this.climbSpeedConst = builder.getClimbSpeedConst(builderSupport); this.minDescentAnimationHeight = builder.getMinDescentAnimationHeight(builderSupport); this.descendFlatness = builder.getDescendForwardAmount(builderSupport); this.descendSpeedCompensation = builder.getDescendSpeedCompensation(builderSupport); @@ -173,7 +173,7 @@ public class MotionControllerWalk extends MotionControllerBase { this.hoverFreq = builder.getHoverFreq(); this.hoverCycle = this.hoverFreq > 0.0 ? 1.0F / (float)this.hoverFreq : 0.0F; this.maxWalkSpeedAfterHitMultiplier = builder.getMaxWalkSpeedAfterHitMultiplier(); - this.descentAnimationType = builder.getDescentAnimationType(); + this.descentAnimationType = builder.getDescentAnimationType(builderSupport); this.descentSteepness = builder.getDescentSteepness(builderSupport); this.descentBlending = builder.getDescentBlending(builderSupport); } diff --git a/src/com/hypixel/hytale/server/npc/movement/controllers/ProbeMoveData.java b/src/com/hypixel/hytale/server/npc/movement/controllers/ProbeMoveData.java index dfda385..0ce5f76 100644 --- a/src/com/hypixel/hytale/server/npc/movement/controllers/ProbeMoveData.java +++ b/src/com/hypixel/hytale/server/npc/movement/controllers/ProbeMoveData.java @@ -238,9 +238,6 @@ public class ProbeMoveData { public boolean onGround; public int blockId; - public Segment() { - } - public void initAsStartSegment(@Nonnull Vector3d position, boolean onGround) { this.type = ProbeMoveData.Segment.Type.START; this.position.assign(position); diff --git a/src/com/hypixel/hytale/server/npc/movement/controllers/builders/BuilderMotionControllerBase.java b/src/com/hypixel/hytale/server/npc/movement/controllers/builders/BuilderMotionControllerBase.java index 8fe8d52..98afc8f 100644 --- a/src/com/hypixel/hytale/server/npc/movement/controllers/builders/BuilderMotionControllerBase.java +++ b/src/com/hypixel/hytale/server/npc/movement/controllers/builders/BuilderMotionControllerBase.java @@ -28,9 +28,6 @@ public abstract class BuilderMotionControllerBase extends BuilderBaseWithType readCommonConfig(@Nonnull JsonElement data) { diff --git a/src/com/hypixel/hytale/server/npc/movement/controllers/builders/BuilderMotionControllerDive.java b/src/com/hypixel/hytale/server/npc/movement/controllers/builders/BuilderMotionControllerDive.java index cbbeca8..018d4f8 100644 --- a/src/com/hypixel/hytale/server/npc/movement/controllers/builders/BuilderMotionControllerDive.java +++ b/src/com/hypixel/hytale/server/npc/movement/controllers/builders/BuilderMotionControllerDive.java @@ -33,9 +33,6 @@ public class BuilderMotionControllerDive extends BuilderMotionControllerBase { private double fastDiveThreshold; private double desiredDepthWeight; - public BuilderMotionControllerDive() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/movement/controllers/builders/BuilderMotionControllerFly.java b/src/com/hypixel/hytale/server/npc/movement/controllers/builders/BuilderMotionControllerFly.java index 0439954..8fb7d80 100644 --- a/src/com/hypixel/hytale/server/npc/movement/controllers/builders/BuilderMotionControllerFly.java +++ b/src/com/hypixel/hytale/server/npc/movement/controllers/builders/BuilderMotionControllerFly.java @@ -33,9 +33,6 @@ public class BuilderMotionControllerFly extends BuilderMotionControllerBase { private boolean autoLevel; private double desiredAltitudeWeight; - public BuilderMotionControllerFly() { - } - @Nonnull public MotionControllerFly build(@Nonnull BuilderSupport builderSupport) { return new MotionControllerFly(builderSupport, this); diff --git a/src/com/hypixel/hytale/server/npc/movement/controllers/builders/BuilderMotionControllerMap.java b/src/com/hypixel/hytale/server/npc/movement/controllers/builders/BuilderMotionControllerMap.java index 85098ed..eafd90f 100644 --- a/src/com/hypixel/hytale/server/npc/movement/controllers/builders/BuilderMotionControllerMap.java +++ b/src/com/hypixel/hytale/server/npc/movement/controllers/builders/BuilderMotionControllerMap.java @@ -29,9 +29,6 @@ public class BuilderMotionControllerMap extends BuilderBase build(@Nonnull BuilderSupport builderSupport) { return new HashMap<>(this.motionControllers.build(builderSupport)); diff --git a/src/com/hypixel/hytale/server/npc/movement/controllers/builders/BuilderMotionControllerWalk.java b/src/com/hypixel/hytale/server/npc/movement/controllers/builders/BuilderMotionControllerWalk.java index 4766295..765cc25 100644 --- a/src/com/hypixel/hytale/server/npc/movement/controllers/builders/BuilderMotionControllerWalk.java +++ b/src/com/hypixel/hytale/server/npc/movement/controllers/builders/BuilderMotionControllerWalk.java @@ -5,6 +5,7 @@ import com.hypixel.hytale.server.core.asset.type.blockset.config.BlockSet; import com.hypixel.hytale.server.npc.asset.builder.BuilderDescriptorState; import com.hypixel.hytale.server.npc.asset.builder.BuilderSupport; import com.hypixel.hytale.server.npc.asset.builder.holder.DoubleHolder; +import com.hypixel.hytale.server.npc.asset.builder.holder.EnumHolder; import com.hypixel.hytale.server.npc.asset.builder.holder.FloatHolder; import com.hypixel.hytale.server.npc.asset.builder.holder.NumberArrayHolder; import com.hypixel.hytale.server.npc.asset.builder.validators.AssetValidator; @@ -37,9 +38,9 @@ public class BuilderMotionControllerWalk extends BuilderMotionControllerBase { private final DoubleHolder minJumpDistance = new DoubleHolder(); private final DoubleHolder jumpBlending = new DoubleHolder(); private final DoubleHolder jumpDescentBlending = new DoubleHolder(); - private double climbSpeedMult; - private double climbSpeedPow; - private double climbSpeedConst; + private final DoubleHolder climbSpeedMult = new DoubleHolder(); + private final DoubleHolder climbSpeedPow = new DoubleHolder(); + private final DoubleHolder climbSpeedConst = new DoubleHolder(); private final DoubleHolder minDescentAnimationHeight = new DoubleHolder(); private final DoubleHolder descendFlatness = new DoubleHolder(); private final DoubleHolder descendSpeedCompensation = new DoubleHolder(); @@ -56,11 +57,8 @@ public class BuilderMotionControllerWalk extends BuilderMotionControllerBase { private float hoverFreq; private double maxWalkSpeedAfterHitMultiplier; private String fenceBlockSet; - private MotionControllerWalk.DescentAnimationType descentAnimationType; - private MotionControllerWalk.AscentAnimationType ascentAnimationType; - - public BuilderMotionControllerWalk() { - } + private final EnumHolder descentAnimationType = new EnumHolder<>(); + private final EnumHolder ascentAnimationType = new EnumHolder<>(); @Nonnull public MotionControllerWalk build(@Nonnull BuilderSupport builderSupport) { @@ -238,7 +236,7 @@ public class BuilderMotionControllerWalk extends BuilderMotionControllerBase { this.getEnum( data, "AscentAnimationType", - v -> this.ascentAnimationType = v, + this.ascentAnimationType, MotionControllerWalk.AscentAnimationType.class, MotionControllerWalk.AscentAnimationType.Walk, BuilderDescriptorState.Stable, @@ -248,7 +246,7 @@ public class BuilderMotionControllerWalk extends BuilderMotionControllerBase { this.getDouble( data, "ClimbSpeedMult", - v -> this.climbSpeedMult = v, + this.climbSpeedMult, 0.0, null, BuilderDescriptorState.WorkInProgress, @@ -258,7 +256,7 @@ public class BuilderMotionControllerWalk extends BuilderMotionControllerBase { this.getDouble( data, "ClimbSpeedPow", - v -> this.climbSpeedPow = v, + this.climbSpeedPow, 1.0, null, BuilderDescriptorState.WorkInProgress, @@ -268,7 +266,7 @@ public class BuilderMotionControllerWalk extends BuilderMotionControllerBase { this.getDouble( data, "ClimbSpeedConst", - v -> this.climbSpeedConst = v, + this.climbSpeedConst, 5.0, DoubleSingleValidator.greater0(), BuilderDescriptorState.WorkInProgress, @@ -308,7 +306,7 @@ public class BuilderMotionControllerWalk extends BuilderMotionControllerBase { this.getEnum( data, "DescentAnimationType", - v -> this.descentAnimationType = v, + this.descentAnimationType, MotionControllerWalk.DescentAnimationType.class, MotionControllerWalk.DescentAnimationType.Fall, BuilderDescriptorState.Experimental, @@ -487,16 +485,16 @@ public class BuilderMotionControllerWalk extends BuilderMotionControllerBase { return this.maxClimbHeight.get(support.getExecutionContext()); } - public double getClimbSpeedMult() { - return this.climbSpeedMult; + public double getClimbSpeedMult(BuilderSupport support) { + return this.climbSpeedMult.get(support.getExecutionContext()); } - public double getClimbSpeedPow() { - return this.climbSpeedPow; + public double getClimbSpeedPow(BuilderSupport support) { + return this.climbSpeedPow.get(support.getExecutionContext()); } - public double getClimbSpeedConst() { - return this.climbSpeedConst; + public double getClimbSpeedConst(BuilderSupport support) { + return this.climbSpeedConst.get(support.getExecutionContext()); } public double getDescendForwardAmount(@Nonnull BuilderSupport builderSupport) { @@ -576,12 +574,12 @@ public class BuilderMotionControllerWalk extends BuilderMotionControllerBase { return this.jumpDescentBlending.get(support.getExecutionContext()); } - public MotionControllerWalk.DescentAnimationType getDescentAnimationType() { - return this.descentAnimationType; + public MotionControllerWalk.DescentAnimationType getDescentAnimationType(BuilderSupport support) { + return this.descentAnimationType.get(support.getExecutionContext()); } - public MotionControllerWalk.AscentAnimationType getAscentAnimationType() { - return this.ascentAnimationType; + public MotionControllerWalk.AscentAnimationType getAscentAnimationType(BuilderSupport support) { + return this.ascentAnimationType.get(support.getExecutionContext()); } public double getDescentSteepness(@Nonnull BuilderSupport support) { diff --git a/src/com/hypixel/hytale/server/npc/movement/steeringforces/SteeringForceAvoidCollision.java b/src/com/hypixel/hytale/server/npc/movement/steeringforces/SteeringForceAvoidCollision.java index 2f64241..7a3d593 100644 --- a/src/com/hypixel/hytale/server/npc/movement/steeringforces/SteeringForceAvoidCollision.java +++ b/src/com/hypixel/hytale/server/npc/movement/steeringforces/SteeringForceAvoidCollision.java @@ -40,9 +40,6 @@ public class SteeringForceAvoidCollision extends SteeringForceWithGroup { protected final Vector3d lastSteeringDirection = new Vector3d(); private boolean debug; - public SteeringForceAvoidCollision() { - } - public void setDebug(boolean debug) { this.debug = debug; } diff --git a/src/com/hypixel/hytale/server/npc/movement/steeringforces/SteeringForceRotate.java b/src/com/hypixel/hytale/server/npc/movement/steeringforces/SteeringForceRotate.java index 76688f2..7e6609b 100644 --- a/src/com/hypixel/hytale/server/npc/movement/steeringforces/SteeringForceRotate.java +++ b/src/com/hypixel/hytale/server/npc/movement/steeringforces/SteeringForceRotate.java @@ -14,9 +14,6 @@ public class SteeringForceRotate implements SteeringForce { private float heading; private double tolerance = 0.05235988F; - public SteeringForceRotate() { - } - @Override public boolean compute(@Nonnull Steering output) { output.clear(); diff --git a/src/com/hypixel/hytale/server/npc/movement/steeringforces/SteeringForceWithGroup.java b/src/com/hypixel/hytale/server/npc/movement/steeringforces/SteeringForceWithGroup.java index c6fe396..ea3de00 100644 --- a/src/com/hypixel/hytale/server/npc/movement/steeringforces/SteeringForceWithGroup.java +++ b/src/com/hypixel/hytale/server/npc/movement/steeringforces/SteeringForceWithGroup.java @@ -13,9 +13,6 @@ public abstract class SteeringForceWithGroup implements SteeringForce { protected final Vector3d selfPosition = new Vector3d(); protected Vector3d componentSelector; - public SteeringForceWithGroup() { - } - public void setSelf(@Nonnull Ref ref, @Nonnull Vector3d position, @Nonnull ComponentAccessor componentAccessor) { this.selfPosition.assign(position.getX(), position.getY(), position.getZ()); } diff --git a/src/com/hypixel/hytale/server/npc/movement/steeringforces/SteeringForceWithTarget.java b/src/com/hypixel/hytale/server/npc/movement/steeringforces/SteeringForceWithTarget.java index c9ef3b8..3478ec8 100644 --- a/src/com/hypixel/hytale/server/npc/movement/steeringforces/SteeringForceWithTarget.java +++ b/src/com/hypixel/hytale/server/npc/movement/steeringforces/SteeringForceWithTarget.java @@ -9,9 +9,6 @@ public abstract class SteeringForceWithTarget implements SteeringForce { protected final Vector3d targetPosition = new Vector3d(); private Vector3d componentSelector; - public SteeringForceWithTarget() { - } - @Nonnull public Vector3d getSelfPosition() { return this.selfPosition; diff --git a/src/com/hypixel/hytale/server/npc/navigation/AStarBase.java b/src/com/hypixel/hytale/server/npc/navigation/AStarBase.java index 0e294fd..3d0e5d1 100644 --- a/src/com/hypixel/hytale/server/npc/navigation/AStarBase.java +++ b/src/com/hypixel/hytale/server/npc/navigation/AStarBase.java @@ -69,9 +69,6 @@ public class AStarBase { protected final Vector3d tempPositionVector = new Vector3d(); protected final Vector3d tempDirectionVector = new Vector3d(); - public AStarBase() { - } - public void setCanMoveDiagonal(boolean canMoveDiagonal) { this.canMoveDiagonal = canMoveDiagonal; } @@ -680,8 +677,5 @@ public class AStarBase { TERMINATED, TERMINATED_OPEN_NODE_LIMIT_EXCEEDED, TERMINATED_TOTAL_NODE_LIMIT_EXCEEDED; - - private Progress() { - } } } diff --git a/src/com/hypixel/hytale/server/npc/navigation/AStarDebugBase.java b/src/com/hypixel/hytale/server/npc/navigation/AStarDebugBase.java index 90fc817..df7217f 100644 --- a/src/com/hypixel/hytale/server/npc/navigation/AStarDebugBase.java +++ b/src/com/hypixel/hytale/server/npc/navigation/AStarDebugBase.java @@ -13,18 +13,18 @@ import javax.annotation.Nullable; public class AStarDebugBase { public static final char CENTER = ' '; - public static final char CROSS = '\u253c'; - public static final char HLINE = '\u2500'; - public static final char VLINE = '\u2502'; - public static final char OPEN_NODE = '\u25c6'; - public static final char CLOSED_NODE = '\u25c7'; - public static final char CLOSED_PATH_NODE = '\u25ef'; - public static final char OPEN_PATH_NODE = '\u25c9'; - public static final char BLOCKED_NODE = '\u00d7'; + public static final char CROSS = '┼'; + public static final char HLINE = '─'; + public static final char VLINE = '│'; + public static final char OPEN_NODE = '◆'; + public static final char CLOSED_NODE = '◇'; + public static final char CLOSED_PATH_NODE = '◯'; + public static final char OPEN_PATH_NODE = '◉'; + public static final char BLOCKED_NODE = '×'; public static final char START_POSITION = '@'; - public static final char END_POSITION = '\u03a9'; - public static final String BORDER_PATTERN = "\u2500\u253c".repeat(1025); - public static final String CENTER_PATTERN = " \u2502".repeat(1025); + public static final char END_POSITION = 'Ω'; + public static final String BORDER_PATTERN = "─┼".repeat(1025); + public static final String CENTER_PATTERN = " │".repeat(1025); protected AStarBase aStarBase; protected HytaleLogger logger; protected HytaleLogger.Api loggerInfo; @@ -160,7 +160,7 @@ public class AStarDebugBase { while (fastIterator.hasNext()) { AStarNode nodex = fastIterator.next().getValue(); - this.plot(nodex.getPositionIndex(), (char)(nodex.isInvalid() ? '\u00d7' : (nodex.isOpen() ? '\u25c6' : '\u25c7')), map, minX, minZ); + this.plot(nodex.getPositionIndex(), (char)(nodex.isInvalid() ? '×' : (nodex.isOpen() ? '◆' : '◇')), map, minX, minZ); } int openCount = this.aStarBase.getOpenCount(); @@ -169,7 +169,7 @@ public class AStarDebugBase { maxLength = pathNode.getLength(); while (pathNode != null) { - this.plot(pathNode.getPositionIndex(), (char)(pathNode.isOpen() ? '\u25c9' : '\u25ef'), map, minX, minZ); + this.plot(pathNode.getPositionIndex(), (char)(pathNode.isOpen() ? '◉' : '◯'), map, minX, minZ); pathNode = isFinalPath ? pathNode.getNextPathNode() : pathNode.getPredecessor(); } } else { diff --git a/src/com/hypixel/hytale/server/npc/navigation/AStarDebugWithTarget.java b/src/com/hypixel/hytale/server/npc/navigation/AStarDebugWithTarget.java index 6a4876b..c62bb2c 100644 --- a/src/com/hypixel/hytale/server/npc/navigation/AStarDebugWithTarget.java +++ b/src/com/hypixel/hytale/server/npc/navigation/AStarDebugWithTarget.java @@ -25,7 +25,7 @@ public class AStarDebugWithTarget extends AStarDebugBase { @Override protected void drawMapFinish(@Nonnull StringBuilder[] map, int minX, int minZ) { super.drawMapFinish(map, minX, minZ); - this.plot(this.aStarWithTarget.getTargetPositionIndex(), '\u03a9', map, minX, minZ); + this.plot(this.aStarWithTarget.getTargetPositionIndex(), 'Ω', map, minX, minZ); } @Nonnull diff --git a/src/com/hypixel/hytale/server/npc/navigation/AStarNodePoolProviderSimple.java b/src/com/hypixel/hytale/server/npc/navigation/AStarNodePoolProviderSimple.java index c02d0ba..89f3f5f 100644 --- a/src/com/hypixel/hytale/server/npc/navigation/AStarNodePoolProviderSimple.java +++ b/src/com/hypixel/hytale/server/npc/navigation/AStarNodePoolProviderSimple.java @@ -12,9 +12,6 @@ public class AStarNodePoolProviderSimple implements AStarNodePoolProvider, Resou @Nonnull protected Int2ObjectMap nodePools = new Int2ObjectOpenHashMap<>(); - public AStarNodePoolProviderSimple() { - } - public static ResourceType getResourceType() { return NPCPlugin.get().getAStarNodePoolProviderSimpleResourceType(); } diff --git a/src/com/hypixel/hytale/server/npc/navigation/AStarWithTarget.java b/src/com/hypixel/hytale/server/npc/navigation/AStarWithTarget.java index 1ca3358..5350765 100644 --- a/src/com/hypixel/hytale/server/npc/navigation/AStarWithTarget.java +++ b/src/com/hypixel/hytale/server/npc/navigation/AStarWithTarget.java @@ -14,9 +14,6 @@ public class AStarWithTarget extends AStarBase { protected Vector3d targetPosition = new Vector3d(); protected long targetPositionIndex; - public AStarWithTarget() { - } - @Nonnull public Vector3d getTargetPosition() { return this.targetPosition; diff --git a/src/com/hypixel/hytale/server/npc/navigation/PathFollower.java b/src/com/hypixel/hytale/server/npc/navigation/PathFollower.java index 8d4f14d..d31bf78 100644 --- a/src/com/hypixel/hytale/server/npc/navigation/PathFollower.java +++ b/src/com/hypixel/hytale/server/npc/navigation/PathFollower.java @@ -36,9 +36,6 @@ public class PathFollower { protected boolean debugNodes = false; protected boolean shouldSmoothPath = true; - public PathFollower() { - } - public void setPathSmoothing(int pathSmoothing) { this.pathSmoothing = pathSmoothing; } @@ -330,9 +327,6 @@ public class PathFollower { private static class FrozenWaypoint implements IWaypoint { protected final Vector3d position = new Vector3d(); - private FrozenWaypoint() { - } - @Override public int getLength() { return 1; diff --git a/src/com/hypixel/hytale/server/npc/pages/EntitySpawnPage.java b/src/com/hypixel/hytale/server/npc/pages/EntitySpawnPage.java index 647ffae..482a35b 100644 --- a/src/com/hypixel/hytale/server/npc/pages/EntitySpawnPage.java +++ b/src/com/hypixel/hytale/server/npc/pages/EntitySpawnPage.java @@ -843,8 +843,5 @@ public class EntitySpawnPage extends InteractiveCustomUIPage waypoints = new BuilderObjectListHelper<>(RelativeWaypointDefinition.class, this); protected final DoubleHolder scale = new DoubleHolder(); - public BuilderTransientPathDefinition() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/role/Role.java b/src/com/hypixel/hytale/server/npc/role/Role.java index 4953f31..2f98444 100644 --- a/src/com/hypixel/hytale/server/npc/role/Role.java +++ b/src/com/hypixel/hytale/server/npc/role/Role.java @@ -98,6 +98,8 @@ public class Role implements IAnnotatedComponentCollection { protected final double separationFarRadiusTarget; protected final boolean applySeparation; protected final Vector3d lastSeparationSteering = new Vector3d(); + @Nullable + protected final float[] headPitchAngleRange; protected final boolean stayInEnvironment; protected final String allowedEnvironments; @Nullable @@ -192,7 +194,7 @@ public class Role implements IAnnotatedComponentCollection { motionController.setInertia(this.inertia); } - this.knockbackScale = builder.getKnockbackScale(); + this.knockbackScale = builder.getKnockbackScale(builderSupport); for (MotionController motionController : this.motionControllers.values()) { motionController.setKnockbackScale(this.knockbackScale); @@ -213,6 +215,12 @@ public class Role implements IAnnotatedComponentCollection { this.separationNearRadiusTarget = builder.getSeparationNearRadiusTarget(); this.separationFarRadiusTarget = builder.getSeparationFarRadiusTarget(); this.applySeparation = builder.isApplySeparation(builderSupport); + if (builder.isOverridingHeadPitchAngle(builderSupport)) { + this.headPitchAngleRange = builder.getHeadPitchAngleRange(builderSupport); + } else { + this.headPitchAngleRange = null; + } + this.stayInEnvironment = builder.isStayingInEnvironment(); this.allowedEnvironments = builder.getAllowedEnvironments(); this.entityAvoidanceStrength = builder.getEntityAvoidanceStrength(); @@ -571,6 +579,7 @@ public class Role implements IAnnotatedComponentCollection { motionController.setRole(this); motionController.setInertia(this.inertia); motionController.setKnockbackScale(this.knockbackScale); + motionController.setHeadPitchAngleRange(this.headPitchAngleRange); if (boundingBox != null && model != null) { motionController.updateModelParameters(ref, model, boundingBox, componentAccessor); motionController.updatePhysicsValues(model.getPhysicsValues()); diff --git a/src/com/hypixel/hytale/server/npc/role/RoleUtils.java b/src/com/hypixel/hytale/server/npc/role/RoleUtils.java index c8f035f..4af2b3d 100644 --- a/src/com/hypixel/hytale/server/npc/role/RoleUtils.java +++ b/src/com/hypixel/hytale/server/npc/role/RoleUtils.java @@ -9,9 +9,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class RoleUtils { - public RoleUtils() { - } - public static void setHotbarItems(@Nonnull NPCEntity npcComponent, @Nonnull String[] hotbarItems) { Inventory inventory = npcComponent.getInventory(); diff --git a/src/com/hypixel/hytale/server/npc/role/builders/BuilderRole.java b/src/com/hypixel/hytale/server/npc/role/builders/BuilderRole.java index 124c167..c41c1d1 100644 --- a/src/com/hypixel/hytale/server/npc/role/builders/BuilderRole.java +++ b/src/com/hypixel/hytale/server/npc/role/builders/BuilderRole.java @@ -23,13 +23,16 @@ import com.hypixel.hytale.server.npc.asset.builder.SpawnableWithModelBuilder; import com.hypixel.hytale.server.npc.asset.builder.holder.AssetArrayHolder; import com.hypixel.hytale.server.npc.asset.builder.holder.AssetHolder; import com.hypixel.hytale.server.npc.asset.builder.holder.BooleanHolder; +import com.hypixel.hytale.server.npc.asset.builder.holder.DoubleHolder; import com.hypixel.hytale.server.npc.asset.builder.holder.EnumHolder; import com.hypixel.hytale.server.npc.asset.builder.holder.FloatHolder; import com.hypixel.hytale.server.npc.asset.builder.holder.IntHolder; +import com.hypixel.hytale.server.npc.asset.builder.holder.NumberArrayHolder; import com.hypixel.hytale.server.npc.asset.builder.holder.StringArrayHolder; import com.hypixel.hytale.server.npc.asset.builder.holder.StringHolder; import com.hypixel.hytale.server.npc.asset.builder.validators.AssetValidator; import com.hypixel.hytale.server.npc.asset.builder.validators.DoubleRangeValidator; +import com.hypixel.hytale.server.npc.asset.builder.validators.DoubleSequenceValidator; import com.hypixel.hytale.server.npc.asset.builder.validators.DoubleSingleValidator; import com.hypixel.hytale.server.npc.asset.builder.validators.IntRangeValidator; import com.hypixel.hytale.server.npc.asset.builder.validators.IntSingleValidator; @@ -71,9 +74,9 @@ import java.util.Map; import java.util.Objects; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; public class BuilderRole extends SpawnableWithModelBuilder implements SpawnEffect { + protected static final double[] DEFAULT_HEAD_PITCH_RANGE = new double[]{-89.0, 89.0}; protected String[] displayNames; protected final AssetHolder appearance = new AssetHolder(); protected final AssetHolder dropListId = new AssetHolder(); @@ -85,7 +88,7 @@ public class BuilderRole extends SpawnableWithModelBuilder implements Spaw protected final EnumSet parsedDebugFlags = EnumSet.noneOf(RoleDebugFlags.class); protected String debugFlags; protected double inertia; - protected double knockbackScale; + protected final DoubleHolder knockbackScale = new DoubleHolder(); protected String opaqueBlockSet; protected boolean applyAvoidance; protected double entityAvoidanceStrength; @@ -155,9 +158,8 @@ public class BuilderRole extends SpawnableWithModelBuilder implements Spaw protected final StringHolder memoriesCategory = new StringHolder(); protected final StringHolder memoriesNameOverride = new StringHolder(); protected final StringHolder nameTranslationKey = new StringHolder(); - - public BuilderRole() { - } + protected final NumberArrayHolder headPitchAngleRange = new NumberArrayHolder(); + protected final BooleanHolder overrideHeadPitchAngle = new BooleanHolder(); @Nonnull @Override @@ -278,7 +280,7 @@ public class BuilderRole extends SpawnableWithModelBuilder implements Spaw this.getDouble( data, "KnockbackScale", - v -> this.knockbackScale = v, + this.knockbackScale, 1.0, DoubleSingleValidator.greaterEqual0(), BuilderDescriptorState.Stable, @@ -719,6 +721,25 @@ public class BuilderRole extends SpawnableWithModelBuilder implements Spaw "Whether the NPC should stay in the flock until corpse removal or be removed at the moment of death", null ); + this.getBoolean( + data, + "OverrideHeadPitchAngle", + this.overrideHeadPitchAngle, + true, + BuilderDescriptorState.Experimental, + "Whether to override the head pitch angle range", + null + ); + this.getDoubleRange( + data, + "HeadPitchAngleRange", + this.headPitchAngleRange, + DEFAULT_HEAD_PITCH_RANGE, + DoubleSequenceValidator.betweenWeaklyMonotonic(-90.0, 90.0), + BuilderDescriptorState.Experimental, + "Head rotation pitch range to be used instead of model camera settings", + null + ); this.validateAny(this.breathesInAir, this.breathesInWater); this.registerStateSetter(this.startState, this.defaultSubState, (m, s) -> { this.startStateIndex = m; @@ -968,8 +989,8 @@ public class BuilderRole extends SpawnableWithModelBuilder implements Spaw return this.inertia; } - public double getKnockbackScale() { - return this.knockbackScale; + public double getKnockbackScale(@Nonnull BuilderSupport support) { + return this.knockbackScale.get(support.getExecutionContext()); } @Nullable @@ -1066,6 +1087,15 @@ public class BuilderRole extends SpawnableWithModelBuilder implements Spaw return this.entityAvoidanceStrength; } + public boolean isOverridingHeadPitchAngle(@Nonnull BuilderSupport support) { + return this.overrideHeadPitchAngle.get(support.getExecutionContext()); + } + + public float[] getHeadPitchAngleRange(@Nonnull BuilderSupport support) { + double[] range = this.headPitchAngleRange.get(support.getExecutionContext()); + return new float[]{(float)(range[0] * (float) (Math.PI / 180.0)), (float)(range[1] * (float) (Math.PI / 180.0))}; + } + @Nullable public String[] getFlockSpawnTypes(@Nonnull BuilderSupport support) { return this.flockSpawnTypes.get(support.getExecutionContext()); @@ -1243,13 +1273,13 @@ public class BuilderRole extends SpawnableWithModelBuilder implements Spaw } @Override - public String getMemoriesNameOverride(ExecutionContext context, @NullableDecl Scope modifierScope) { + public String getMemoriesNameOverride(ExecutionContext context, @Nullable Scope modifierScope) { return this.memoriesNameOverride.get(context); } @Nonnull @Override - public String getNameTranslationKey(ExecutionContext context, @NullableDecl Scope modifierScope) { + public String getNameTranslationKey(ExecutionContext context, @Nullable Scope modifierScope) { return this.nameTranslationKey.get(context); } diff --git a/src/com/hypixel/hytale/server/npc/role/builders/BuilderRoleAbstract.java b/src/com/hypixel/hytale/server/npc/role/builders/BuilderRoleAbstract.java index 2677b67..cc01850 100644 --- a/src/com/hypixel/hytale/server/npc/role/builders/BuilderRoleAbstract.java +++ b/src/com/hypixel/hytale/server/npc/role/builders/BuilderRoleAbstract.java @@ -1,9 +1,6 @@ package com.hypixel.hytale.server.npc.role.builders; public class BuilderRoleAbstract extends BuilderRole { - public BuilderRoleAbstract() { - } - @Override public boolean isSpawnable() { return false; diff --git a/src/com/hypixel/hytale/server/npc/role/builders/BuilderRoleVariant.java b/src/com/hypixel/hytale/server/npc/role/builders/BuilderRoleVariant.java index 4cf5da7..5ece860 100644 --- a/src/com/hypixel/hytale/server/npc/role/builders/BuilderRoleVariant.java +++ b/src/com/hypixel/hytale/server/npc/role/builders/BuilderRoleVariant.java @@ -37,9 +37,6 @@ public class BuilderRoleVariant extends SpawnableWithModelBuilder { protected int referenceIndex; protected BuilderModifier modifier; - public BuilderRoleVariant() { - } - @Nullable public Role build(@Nonnull BuilderSupport builderSupport) { return this.executeOnSuperRole(builderSupport, Builder::build, () -> null); diff --git a/src/com/hypixel/hytale/server/npc/role/support/PositionCache.java b/src/com/hypixel/hytale/server/npc/role/support/PositionCache.java index 0b02070..50cfbd0 100644 --- a/src/com/hypixel/hytale/server/npc/role/support/PositionCache.java +++ b/src/com/hypixel/hytale/server/npc/role/support/PositionCache.java @@ -800,9 +800,6 @@ public class PositionCache { public BlockTypeAssetMap assetMap; public boolean result; - private LineOfSightBuffer() { - } - public void clearRefs() { this.world = null; this.chunk = null; @@ -815,9 +812,6 @@ public class PositionCache { public final Vector3d pos = new Vector3d(); public final Vector3d dir = new Vector3d(); public final Vector2d minMax = new Vector2d(); - - private LineOfSightEntityBuffer() { - } } @FunctionalInterface diff --git a/src/com/hypixel/hytale/server/npc/role/support/RoleStats.java b/src/com/hypixel/hytale/server/npc/role/support/RoleStats.java index 8a431e8..e4433e7 100644 --- a/src/com/hypixel/hytale/server/npc/role/support/RoleStats.java +++ b/src/com/hypixel/hytale/server/npc/role/support/RoleStats.java @@ -15,9 +15,6 @@ public class RoleStats { @Nullable protected IntArrayList npcBucketRanges; - public RoleStats() { - } - public void clear() { this.playerRanges.clear(); this.npcRanges.clear(); @@ -63,8 +60,5 @@ public class RoleStats { SORTED, UNSORTED, AVOIDANCE; - - private RangeType() { - } } } diff --git a/src/com/hypixel/hytale/server/npc/role/support/StateSupport.java b/src/com/hypixel/hytale/server/npc/role/support/StateSupport.java index c960d22..28b486d 100644 --- a/src/com/hypixel/hytale/server/npc/role/support/StateSupport.java +++ b/src/com/hypixel/hytale/server/npc/role/support/StateSupport.java @@ -337,7 +337,7 @@ public class StateSupport { @Nonnull Ref entityRef, @Nonnull Ref playerReference, @Nonnull String hint, @Nonnull Store store ) { EntityTrackerSystems.EntityViewer viewerComponent = store.getComponent(playerReference, EntityTrackerSystems.EntityViewer.getComponentType()); - if (viewerComponent != null) { + if (viewerComponent != null && viewerComponent.visible.contains(entityRef)) { ComponentUpdate update = new ComponentUpdate(); update.type = ComponentUpdateType.Interactable; update.interactionHint = hint; diff --git a/src/com/hypixel/hytale/server/npc/sensorinfo/CachedPositionProvider.java b/src/com/hypixel/hytale/server/npc/sensorinfo/CachedPositionProvider.java index a5ecc2c..57883b3 100644 --- a/src/com/hypixel/hytale/server/npc/sensorinfo/CachedPositionProvider.java +++ b/src/com/hypixel/hytale/server/npc/sensorinfo/CachedPositionProvider.java @@ -3,9 +3,6 @@ package com.hypixel.hytale.server.npc.sensorinfo; public class CachedPositionProvider extends PositionProvider { private boolean fromCache; - public CachedPositionProvider() { - } - public void setIsFromCache(boolean status) { this.fromCache = status; } diff --git a/src/com/hypixel/hytale/server/npc/sensorinfo/PathProvider.java b/src/com/hypixel/hytale/server/npc/sensorinfo/PathProvider.java index a18de5d..58703df 100644 --- a/src/com/hypixel/hytale/server/npc/sensorinfo/PathProvider.java +++ b/src/com/hypixel/hytale/server/npc/sensorinfo/PathProvider.java @@ -9,9 +9,6 @@ public class PathProvider implements IPathProvider { private IPath path; private boolean isValid; - public PathProvider() { - } - public void setPath(IPath path) { this.path = path; this.isValid = true; diff --git a/src/com/hypixel/hytale/server/npc/sensorinfo/parameterproviders/MultipleParameterProvider.java b/src/com/hypixel/hytale/server/npc/sensorinfo/parameterproviders/MultipleParameterProvider.java index 67543a6..163e702 100644 --- a/src/com/hypixel/hytale/server/npc/sensorinfo/parameterproviders/MultipleParameterProvider.java +++ b/src/com/hypixel/hytale/server/npc/sensorinfo/parameterproviders/MultipleParameterProvider.java @@ -6,9 +6,6 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; public class MultipleParameterProvider implements ParameterProvider { private final Int2ObjectMap providers = new Int2ObjectOpenHashMap<>(); - public MultipleParameterProvider() { - } - @Override public ParameterProvider getParameterProvider(int parameter) { return this.providers.get(parameter); diff --git a/src/com/hypixel/hytale/server/npc/statetransition/builders/BuilderStateTransition.java b/src/com/hypixel/hytale/server/npc/statetransition/builders/BuilderStateTransition.java index e4aef96..52ca4c7 100644 --- a/src/com/hypixel/hytale/server/npc/statetransition/builders/BuilderStateTransition.java +++ b/src/com/hypixel/hytale/server/npc/statetransition/builders/BuilderStateTransition.java @@ -25,9 +25,6 @@ public class BuilderStateTransition extends BuilderBase actions = new BuilderObjectReferenceHelper<>(ActionList.class, this); protected final BooleanHolder enabled = new BooleanHolder(); - public BuilderStateTransition() { - } - @Nonnull @Override public String getShortDescription() { diff --git a/src/com/hypixel/hytale/server/npc/statetransition/builders/BuilderStateTransitionController.java b/src/com/hypixel/hytale/server/npc/statetransition/builders/BuilderStateTransitionController.java index a233ec5..9a18fcb 100644 --- a/src/com/hypixel/hytale/server/npc/statetransition/builders/BuilderStateTransitionController.java +++ b/src/com/hypixel/hytale/server/npc/statetransition/builders/BuilderStateTransitionController.java @@ -19,9 +19,6 @@ public class BuilderStateTransitionController extends BuilderBase { .add() .build(); - public AlarmStore() { - } - @Nonnull protected Alarm createParameter() { return new Alarm(); diff --git a/src/com/hypixel/hytale/server/npc/systems/BalancingInitialisationSystem.java b/src/com/hypixel/hytale/server/npc/systems/BalancingInitialisationSystem.java index 87d5570..6fe81bf 100644 --- a/src/com/hypixel/hytale/server/npc/systems/BalancingInitialisationSystem.java +++ b/src/com/hypixel/hytale/server/npc/systems/BalancingInitialisationSystem.java @@ -38,9 +38,6 @@ public class BalancingInitialisationSystem extends HolderSystem { @Nonnull private final Query query = Archetype.of(this.npcComponentType, this.entityStatMapComponentType); - public BalancingInitialisationSystem() { - } - @Nonnull @Override public Set> getDependencies() { diff --git a/src/com/hypixel/hytale/server/npc/systems/BlackboardSystems.java b/src/com/hypixel/hytale/server/npc/systems/BlackboardSystems.java index 9893826..d2a85cd 100644 --- a/src/com/hypixel/hytale/server/npc/systems/BlackboardSystems.java +++ b/src/com/hypixel/hytale/server/npc/systems/BlackboardSystems.java @@ -18,9 +18,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class BlackboardSystems { - public BlackboardSystems() { - } - public static class BreakBlockEventSystem extends EntityEventSystem { public BreakBlockEventSystem() { super(BreakBlockEvent.class); diff --git a/src/com/hypixel/hytale/server/npc/systems/FailedSpawnSystem.java b/src/com/hypixel/hytale/server/npc/systems/FailedSpawnSystem.java index 0857988..28b4e06 100644 --- a/src/com/hypixel/hytale/server/npc/systems/FailedSpawnSystem.java +++ b/src/com/hypixel/hytale/server/npc/systems/FailedSpawnSystem.java @@ -12,9 +12,6 @@ import com.hypixel.hytale.server.npc.components.FailedSpawnComponent; import javax.annotation.Nonnull; public class FailedSpawnSystem extends RefSystem { - public FailedSpawnSystem() { - } - @Override public void onEntityAdded( @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer diff --git a/src/com/hypixel/hytale/server/npc/systems/NPCDamageSystems.java b/src/com/hypixel/hytale/server/npc/systems/NPCDamageSystems.java index ff2cca6..8d898fd 100644 --- a/src/com/hypixel/hytale/server/npc/systems/NPCDamageSystems.java +++ b/src/com/hypixel/hytale/server/npc/systems/NPCDamageSystems.java @@ -42,13 +42,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class NPCDamageSystems { - public NPCDamageSystems() { - } - public static class DamageDealtSystem extends DamageEventSystem { - public DamageDealtSystem() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -68,12 +62,12 @@ public class NPCDamageSystems { @Nonnull CommandBuffer commandBuffer, @Nonnull Damage damage ) { - if (damage.getSource() instanceof Damage.EntitySource) { - Ref attackerRef = ((Damage.EntitySource)damage.getSource()).getRef(); - if (attackerRef.isValid()) { - NPCEntity npcComponent = commandBuffer.getComponent(attackerRef, NPCEntity.getComponentType()); - if (npcComponent != null) { - npcComponent.getDamageData().onInflictedDamage(archetypeChunk.getReferenceTo(index), damage.getAmount()); + if (damage.getSource() instanceof Damage.EntitySource entitySource) { + Ref sourceRef = entitySource.getRef(); + if (sourceRef.isValid()) { + NPCEntity sourceNpcComponent = commandBuffer.getComponent(sourceRef, NPCEntity.getComponentType()); + if (sourceNpcComponent != null) { + sourceNpcComponent.getDamageData().onInflictedDamage(archetypeChunk.getReferenceTo(index), damage.getAmount()); } } } @@ -90,9 +84,6 @@ public class NPCDamageSystems { @Nonnull private final Query query = Query.and(Query.or(NPCEntity.getComponentType(), this.playerComponentType), this.transformComponentType); - public DamageReceivedEventViewSystem() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -120,18 +111,18 @@ public class NPCDamageSystems { EntityEventView view = blackboard.getView( EntityEventView.class, ChunkUtil.chunkCoordinate(transformComponent.getPosition().x), ChunkUtil.chunkCoordinate(transformComponent.getPosition().z) ); - if (damage.getSource() instanceof Damage.EntitySource) { - Ref attackerRef = ((Damage.EntitySource)damage.getSource()).getRef(); - if (attackerRef.isValid()) { - Player attackerPlayerComponent = commandBuffer.getComponent(attackerRef, Player.getComponentType()); - if (attackerPlayerComponent != null && attackerPlayerComponent.getGameMode() == GameMode.Creative) { - PlayerSettings playerSettingsComponent = commandBuffer.getComponent(attackerRef, PlayerSettings.getComponentType()); + if (damage.getSource() instanceof Damage.EntitySource entitySource) { + Ref sourceRef = entitySource.getRef(); + if (sourceRef.isValid()) { + Player sourcePlayerComponent = commandBuffer.getComponent(sourceRef, Player.getComponentType()); + if (sourcePlayerComponent != null && sourcePlayerComponent.getGameMode() == GameMode.Creative) { + PlayerSettings playerSettingsComponent = commandBuffer.getComponent(sourceRef, PlayerSettings.getComponentType()); if (playerSettingsComponent == null || !playerSettingsComponent.creativeSettings().allowNPCDetection()) { return; } } - view.processAttackedEvent(archetypeChunk.getReferenceTo(index), attackerRef, commandBuffer, EntityEventType.DAMAGE); + view.processAttackedEvent(archetypeChunk.getReferenceTo(index), sourceRef, commandBuffer, EntityEventType.DAMAGE); } } } @@ -141,9 +132,6 @@ public class NPCDamageSystems { @Nonnull private final Query query = NPCEntity.getComponentType(); - public DamageReceivedSystem() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -178,9 +166,6 @@ public class NPCDamageSystems { NPCEntity.getComponentType(), TransformComponent.getComponentType(), HeadRotation.getComponentType(), Query.not(Player.getComponentType()) ); - public DropDeathItems() { - } - @Nonnull @Override public Query getQuery() { @@ -196,38 +181,37 @@ public class NPCDamageSystems { assert npcComponent != null; Role role = npcComponent.getRole(); - - assert role != null; - - List itemsToDrop = new ObjectArrayList<>(); - if (role.isPickupDropOnDeath()) { - Inventory inventory = npcComponent.getInventory(); - itemsToDrop.addAll(inventory.getStorage().dropAllItemStacks()); - } - - String dropListId = role.getDropListId(); - if (dropListId != null) { - ItemModule itemModule = ItemModule.get(); - if (itemModule.isEnabled()) { - List randomItemsToDrop = itemModule.getRandomItemDrops(dropListId); - itemsToDrop.addAll(randomItemsToDrop); + if (role != null) { + List itemsToDrop = new ObjectArrayList<>(); + if (role.isPickupDropOnDeath()) { + Inventory inventory = npcComponent.getInventory(); + itemsToDrop.addAll(inventory.getStorage().dropAllItemStacks()); } - } - if (!itemsToDrop.isEmpty()) { - TransformComponent transformComponent = store.getComponent(ref, TransformComponent.getComponentType()); + String dropListId = role.getDropListId(); + if (dropListId != null) { + ItemModule itemModule = ItemModule.get(); + if (itemModule.isEnabled()) { + List randomItemsToDrop = itemModule.getRandomItemDrops(dropListId); + itemsToDrop.addAll(randomItemsToDrop); + } + } - assert transformComponent != null; + if (!itemsToDrop.isEmpty()) { + TransformComponent transformComponent = store.getComponent(ref, TransformComponent.getComponentType()); - Vector3d position = transformComponent.getPosition(); - HeadRotation headRotationComponent = store.getComponent(ref, HeadRotation.getComponentType()); + assert transformComponent != null; - assert headRotationComponent != null; + Vector3d position = transformComponent.getPosition(); + HeadRotation headRotationComponent = store.getComponent(ref, HeadRotation.getComponentType()); - Vector3f headRotation = headRotationComponent.getRotation(); - Vector3d dropPosition = position.clone().add(0.0, 1.0, 0.0); - Holder[] drops = ItemComponent.generateItemDrops(store, itemsToDrop, dropPosition, headRotation.clone()); - commandBuffer.addEntities(drops, AddReason.SPAWN); + assert headRotationComponent != null; + + Vector3f headRotation = headRotationComponent.getRotation(); + Vector3d dropPosition = position.clone().add(0.0, 1.0, 0.0); + Holder[] drops = ItemComponent.generateItemDrops(store, itemsToDrop, dropPosition, headRotation.clone()); + commandBuffer.addEntities(drops, AddReason.SPAWN); + } } } } @@ -237,9 +221,6 @@ public class NPCDamageSystems { @Nonnull private final Query query = NPCEntity.getComponentType(); - public FilterDamageSystem() { - } - @Nullable @Override public SystemGroup getGroup() { @@ -263,10 +244,10 @@ public class NPCDamageSystems { assert npcComponent != null; - if (damage.getSource() instanceof Damage.EntitySource) { - Ref attackerRef = ((Damage.EntitySource)damage.getSource()).getRef(); - if (attackerRef.isValid()) { - if (!npcComponent.getCanCauseDamage(attackerRef, commandBuffer)) { + if (damage.getSource() instanceof Damage.EntitySource entitySource) { + Ref sourceRef = entitySource.getRef(); + if (sourceRef.isValid()) { + if (!npcComponent.getCanCauseDamage(sourceRef, commandBuffer)) { damage.setCancelled(true); } } diff --git a/src/com/hypixel/hytale/server/npc/systems/NPCDeathSystems.java b/src/com/hypixel/hytale/server/npc/systems/NPCDeathSystems.java index 7dec65b..9ce0aa7 100644 --- a/src/com/hypixel/hytale/server/npc/systems/NPCDeathSystems.java +++ b/src/com/hypixel/hytale/server/npc/systems/NPCDeathSystems.java @@ -24,9 +24,6 @@ import com.hypixel.hytale.server.npc.entities.NPCEntity; import javax.annotation.Nonnull; public class NPCDeathSystems { - public NPCDeathSystems() { - } - public static class EntityViewSystem extends DeathSystems.OnDeathSystem { @Nonnull private final ComponentType playerComponentType = Player.getComponentType(); @@ -37,9 +34,6 @@ public class NPCDeathSystems { @Nonnull private final Query query = Query.and(Query.or(NPCEntity.getComponentType(), this.playerComponentType), this.transformComponentType); - public EntityViewSystem() { - } - @Nonnull @Override public Query getQuery() { @@ -51,11 +45,11 @@ public class NPCDeathSystems { ) { Damage deathInfo = component.getDeathInfo(); if (deathInfo != null && deathInfo.getSource() instanceof Damage.EntitySource entitySource) { - Ref attackerRef = entitySource.getRef(); - if (attackerRef.isValid()) { - Player attackerPlayerComponent = commandBuffer.getComponent(attackerRef, Player.getComponentType()); - if (attackerPlayerComponent != null && attackerPlayerComponent.getGameMode() == GameMode.Creative) { - PlayerSettings playerSettingsComponent = commandBuffer.getComponent(attackerRef, PlayerSettings.getComponentType()); + Ref sourceRef = entitySource.getRef(); + if (sourceRef.isValid()) { + Player sourcePlayerComponent = commandBuffer.getComponent(sourceRef, Player.getComponentType()); + if (sourcePlayerComponent != null && sourcePlayerComponent.getGameMode() == GameMode.Creative) { + PlayerSettings playerSettingsComponent = commandBuffer.getComponent(sourceRef, PlayerSettings.getComponentType()); if (playerSettingsComponent == null || !playerSettingsComponent.creativeSettings().allowNPCDetection()) { return; } @@ -70,35 +64,35 @@ public class NPCDeathSystems { EntityEventView entityEventView = blackboardResource.getView( EntityEventView.class, ChunkUtil.chunkCoordinate(position.x), ChunkUtil.chunkCoordinate(position.z) ); - entityEventView.processAttackedEvent(ref, attackerRef, commandBuffer, EntityEventType.DEATH); + entityEventView.processAttackedEvent(ref, sourceRef, commandBuffer, EntityEventType.DEATH); } } } } public static class NPCKillsEntitySystem extends DeathSystems.OnDeathSystem { - public NPCKillsEntitySystem() { - } - @Nonnull @Override public Query getQuery() { - return AllLegacyLivingEntityTypesQuery.INSTANCE; + return Query.and(AllLegacyLivingEntityTypesQuery.INSTANCE, TransformComponent.getComponentType()); } public void onComponentAdded( @Nonnull Ref ref, @Nonnull DeathComponent component, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { - Damage deathInfo = component.getDeathInfo(); - if (deathInfo != null && deathInfo.getSource() instanceof Damage.EntitySource) { - Ref attackerReference = ((Damage.EntitySource)deathInfo.getSource()).getRef(); - NPCEntity attackerNpcComponent = store.getComponent(attackerReference, NPCEntity.getComponentType()); - if (attackerNpcComponent != null) { - TransformComponent entityTransformComponent = store.getComponent(ref, TransformComponent.getComponentType()); + ComponentType npcComponentType = NPCEntity.getComponentType(); + if (npcComponentType != null) { + Damage deathInfo = component.getDeathInfo(); + if (deathInfo != null && deathInfo.getSource() instanceof Damage.EntitySource entitySource) { + Ref var11 = entitySource.getRef(); + NPCEntity sourceNpcComponent = store.getComponent(var11, npcComponentType); + if (sourceNpcComponent != null) { + TransformComponent transformComponent = store.getComponent(ref, TransformComponent.getComponentType()); - assert entityTransformComponent != null; + assert transformComponent != null; - attackerNpcComponent.getDamageData().onKill(ref, entityTransformComponent.getPosition().clone()); + sourceNpcComponent.getDamageData().onKill(ref, transformComponent.getPosition().clone()); + } } } } diff --git a/src/com/hypixel/hytale/server/npc/systems/NPCInteractionSystems.java b/src/com/hypixel/hytale/server/npc/systems/NPCInteractionSystems.java index 4ab3c54..508daf7 100644 --- a/src/com/hypixel/hytale/server/npc/systems/NPCInteractionSystems.java +++ b/src/com/hypixel/hytale/server/npc/systems/NPCInteractionSystems.java @@ -22,9 +22,6 @@ import com.hypixel.hytale.server.npc.interactions.NPCInteractionSimulationHandle import javax.annotation.Nonnull; public class NPCInteractionSystems { - public NPCInteractionSystems() { - } - public static class AddSimulationManagerSystem extends HolderSystem { @Nonnull private final ComponentType npcEntityComponentType; diff --git a/src/com/hypixel/hytale/server/npc/systems/NPCSystems.java b/src/com/hypixel/hytale/server/npc/systems/NPCSystems.java index 1564552..f8cd7f3 100644 --- a/src/com/hypixel/hytale/server/npc/systems/NPCSystems.java +++ b/src/com/hypixel/hytale/server/npc/systems/NPCSystems.java @@ -59,12 +59,8 @@ import java.util.Set; import java.util.UUID; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.checkerframework.checker.nullness.compatqual.NonNullDecl; public class NPCSystems { - public NPCSystems() { - } - public static class AddSpawnEntityEffectSystem extends RefSystem { @Nonnull private final ComponentType npcComponentType; @@ -129,7 +125,7 @@ public class NPCSystems { this.npcComponentType = npcComponentType; this.transformComponentType = TransformComponent.getComponentType(); this.dependencies = Set.of(new SystemDependency<>(Order.AFTER, NPCSystems.AddedSystem.class)); - this.query = Query.and(npcComponentType, Query.or(FromWorldGen.getComponentType(), FromPrefab.getComponentType())); + this.query = Query.and(npcComponentType, this.transformComponentType, Query.or(FromWorldGen.getComponentType(), FromPrefab.getComponentType())); } @Override @@ -193,9 +189,6 @@ public class NPCSystems { @Nonnull private final Query query = Query.and(this.npcComponentType, this.fromWorldGenComponentType); - public AddedFromWorldGenSystem() { - } - @Nonnull @Override public Query getQuery() { @@ -294,10 +287,10 @@ public class NPCSystems { public void handle( int index, - @NonNullDecl ArchetypeChunk archetypeChunk, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer, - @NonNullDecl KillFeedEvent.DecedentMessage event + @Nonnull ArchetypeChunk archetypeChunk, + @Nonnull Store store, + @Nonnull CommandBuffer commandBuffer, + @Nonnull KillFeedEvent.DecedentMessage event ) { event.setCancelled(true); } @@ -321,10 +314,10 @@ public class NPCSystems { public void handle( int index, - @NonNullDecl ArchetypeChunk archetypeChunk, - @NonNullDecl Store store, - @NonNullDecl CommandBuffer commandBuffer, - @NonNullDecl KillFeedEvent.KillerMessage event + @Nonnull ArchetypeChunk archetypeChunk, + @Nonnull Store store, + @Nonnull CommandBuffer commandBuffer, + @Nonnull KillFeedEvent.KillerMessage event ) { Ref targetRef = event.getTargetRef(); if (targetRef.isValid()) { @@ -367,9 +360,6 @@ public class NPCSystems { this.npcComponentType, Query.not(this.worldGenIdComponentType), Query.not(FromWorldGen.getComponentType()) ); - public LegacyWorldGenId() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { NPCEntity npcComponent = holder.getComponent(this.npcComponentType); @@ -401,9 +391,6 @@ public class NPCSystems { @Nonnull private final Set> dependencies = Set.of(new SystemDependency<>(Order.AFTER, ModelSystems.UpdateBoundingBox.class)); - public ModelChangeSystem() { - } - @Nullable @Override public Query getQuery() { @@ -465,9 +452,6 @@ public class NPCSystems { @Nonnull private final ComponentType deferredCorpseRemovalComponentType = DeferredCorpseRemoval.getComponentType(); - public OnDeathSystem() { - } - @Nonnull @Override public Query getQuery() { @@ -497,9 +481,6 @@ public class NPCSystems { @Nonnull private final Set> dependencies = Set.of(new SystemDependency<>(Order.AFTER, TeleportSystems.MoveSystem.class)); - public OnTeleportSystem() { - } - @Nonnull @Override public Set> getDependencies() { @@ -554,9 +535,7 @@ public class NPCSystems { super(PrefabPlaceEntityEvent.class); } - public void handle( - @NonNullDecl Store store, @NonNullDecl CommandBuffer commandBuffer, @NonNullDecl PrefabPlaceEntityEvent event - ) { + public void handle(@Nonnull Store store, @Nonnull CommandBuffer commandBuffer, @Nonnull PrefabPlaceEntityEvent event) { Holder holder = event.getHolder(); FlockMembership flockMembershipComponent = holder.getComponent(FlockMembership.getComponentType()); if (flockMembershipComponent != null) { diff --git a/src/com/hypixel/hytale/server/npc/systems/NPCVelocityInstructionSystem.java b/src/com/hypixel/hytale/server/npc/systems/NPCVelocityInstructionSystem.java index 8d8ec6a..cf59b27 100644 --- a/src/com/hypixel/hytale/server/npc/systems/NPCVelocityInstructionSystem.java +++ b/src/com/hypixel/hytale/server/npc/systems/NPCVelocityInstructionSystem.java @@ -32,9 +32,6 @@ public class NPCVelocityInstructionSystem extends EntityTickingSystem query = Query.and(NPCEntity.getComponentType(), Velocity.getComponentType()); - public NPCVelocityInstructionSystem() { - } - @Override public void tick( float dt, @@ -47,42 +44,42 @@ public class NPCVelocityInstructionSystem extends EntityTickingSystem { @Nonnull private final ObjectList> queue = new ObjectArrayList<>(); - public QueueResource() { - } - @Nonnull public static ResourceType getResourceType() { return NPCPlugin.get().getNewSpawnStartTickingQueueResourceType(); diff --git a/src/com/hypixel/hytale/server/npc/systems/PositionCacheSystems.java b/src/com/hypixel/hytale/server/npc/systems/PositionCacheSystems.java index 31e84bf..53b5963 100644 --- a/src/com/hypixel/hytale/server/npc/systems/PositionCacheSystems.java +++ b/src/com/hypixel/hytale/server/npc/systems/PositionCacheSystems.java @@ -45,9 +45,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class PositionCacheSystems { - public PositionCacheSystems() { - } - public static void initialisePositionCache(@Nonnull Role role, @Nullable StateEvaluator stateEvaluator, double flockInfluenceRange) { PositionCache positionCache = role.getPositionCache(); positionCache.reset(true); diff --git a/src/com/hypixel/hytale/server/npc/systems/RoleChangeSystem.java b/src/com/hypixel/hytale/server/npc/systems/RoleChangeSystem.java index ad58bcc..94327a1 100644 --- a/src/com/hypixel/hytale/server/npc/systems/RoleChangeSystem.java +++ b/src/com/hypixel/hytale/server/npc/systems/RoleChangeSystem.java @@ -172,9 +172,6 @@ public class RoleChangeSystem extends TickingSystem { @Nonnull private final Deque requests = new ArrayDeque<>(); - public RoleChangeQueue() { - } - @Nonnull public static ResourceType getResourceType() { return NPCPlugin.get().getRoleChangeQueueResourceType(); diff --git a/src/com/hypixel/hytale/server/npc/systems/RoleSystems.java b/src/com/hypixel/hytale/server/npc/systems/RoleSystems.java index a0fcad3..c25c6bd 100644 --- a/src/com/hypixel/hytale/server/npc/systems/RoleSystems.java +++ b/src/com/hypixel/hytale/server/npc/systems/RoleSystems.java @@ -46,9 +46,6 @@ import javax.annotation.Nonnull; public class RoleSystems { private static final ThreadLocal>> ENTITY_LIST = ThreadLocal.withInitial(ArrayList::new); - public RoleSystems() { - } - public static class BehaviourTickSystem extends TickingSystem { @Nonnull private final ComponentType npcComponentType; diff --git a/src/com/hypixel/hytale/server/npc/systems/SpawnReferenceSystems.java b/src/com/hypixel/hytale/server/npc/systems/SpawnReferenceSystems.java index 8524255..af30bc8 100644 --- a/src/com/hypixel/hytale/server/npc/systems/SpawnReferenceSystems.java +++ b/src/com/hypixel/hytale/server/npc/systems/SpawnReferenceSystems.java @@ -39,9 +39,6 @@ import java.util.logging.Level; import javax.annotation.Nonnull; public class SpawnReferenceSystems { - public SpawnReferenceSystems() { - } - public static class BeaconAddRemoveSystem extends RefSystem { @Nonnull private final ComponentType spawnReferenceComponentType; diff --git a/src/com/hypixel/hytale/server/npc/systems/StateEvaluatorSystem.java b/src/com/hypixel/hytale/server/npc/systems/StateEvaluatorSystem.java index 41be04f..d0e9be5 100644 --- a/src/com/hypixel/hytale/server/npc/systems/StateEvaluatorSystem.java +++ b/src/com/hypixel/hytale/server/npc/systems/StateEvaluatorSystem.java @@ -31,6 +31,8 @@ public class StateEvaluatorSystem extends EntityTickingSystem { @Nonnull private final ComponentType npcComponentType; @Nonnull + private final ComponentType uuidComponentType = UUIDComponent.getComponentType(); + @Nonnull private final Set> dependencies; @Nonnull private final Query query; @@ -44,7 +46,7 @@ public class StateEvaluatorSystem extends EntityTickingSystem { new SystemDependency<>(Order.BEFORE, RoleSystems.BehaviourTickSystem.class), new SystemDependency<>(Order.AFTER, RoleSystems.PreBehaviourSupportTickSystem.class) ); - this.query = Query.and(npcComponentType, stateEvaluatorComponent); + this.query = Query.and(npcComponentType, stateEvaluatorComponent, this.uuidComponentType); } @Nonnull @@ -76,44 +78,46 @@ public class StateEvaluatorSystem extends EntityTickingSystem { assert npcComponent != null; - UUIDComponent uuidComponent = archetypeChunk.getComponent(index, UUIDComponent.getComponentType()); + UUIDComponent uuidComponent = archetypeChunk.getComponent(index, this.uuidComponentType); assert uuidComponent != null; Role role = npcComponent.getRole(); - StateSupport stateSupport = role.getStateSupport(); - if (!stateSupport.isRunningTransitionActions()) { - StateEvaluator stateEvaluator = archetypeChunk.getComponent(index, this.stateEvaluatorComponent); + if (role != null) { + StateSupport stateSupport = role.getStateSupport(); + if (!stateSupport.isRunningTransitionActions()) { + StateEvaluator stateEvaluator = archetypeChunk.getComponent(index, this.stateEvaluatorComponent); - assert stateEvaluator != null; + assert stateEvaluator != null; - if (stateEvaluator.isActive() && stateEvaluator.shouldExecute(dt)) { - HytaleLogger.Api logContext = LOGGER.at(Level.FINE); - if (logContext.isEnabled()) { - logContext.log("%s with uuid %s: Beginning state evaluation", npcComponent.getRoleName(), uuidComponent.getUuid()); - } + if (stateEvaluator.isActive() && stateEvaluator.shouldExecute(dt)) { + HytaleLogger.Api logContext = LOGGER.at(Level.FINE); + if (logContext.isEnabled()) { + logContext.log("%s with uuid %s: Beginning state evaluation", npcComponent.getRoleName(), uuidComponent.getUuid()); + } - EvaluationContext evaluationContext = stateEvaluator.getEvaluationContext(); - stateEvaluator.prepareEvaluationContext(evaluationContext); - Evaluator.OptionHolder chosenOption = stateEvaluator.evaluate(index, archetypeChunk, commandBuffer, evaluationContext); - evaluationContext.reset(); - logContext = LOGGER.at(Level.FINE); - if (logContext.isEnabled()) { - logContext.log("%s with uuid %s: Chose state option %s", npcComponent.getRoleName(), uuidComponent.getUuid(), chosenOption); - } + EvaluationContext evaluationContext = stateEvaluator.getEvaluationContext(); + stateEvaluator.prepareEvaluationContext(evaluationContext); + Evaluator.OptionHolder chosenOption = stateEvaluator.evaluate(index, archetypeChunk, commandBuffer, evaluationContext); + evaluationContext.reset(); + logContext = LOGGER.at(Level.FINE); + if (logContext.isEnabled()) { + logContext.log("%s with uuid %s: Chose state option %s", npcComponent.getRoleName(), uuidComponent.getUuid(), chosenOption); + } - if (chosenOption != null) { - StateOption action = (StateOption)chosenOption.getOption(); - int targetState = action.getStateIndex(); - int targetSubState = action.getSubStateIndex(); - if (!stateSupport.inState(targetState) || !stateSupport.inSubState(targetSubState)) { - stateSupport.setState(action.getStateIndex(), action.getSubStateIndex(), true, false); - logContext = LOGGER.at(Level.FINE); - if (logContext.isEnabled()) { - logContext.log("%s with uuid %s: Setting state", npcComponent.getRoleName(), uuidComponent.getUuid()); + if (chosenOption != null) { + StateOption action = (StateOption)chosenOption.getOption(); + int targetState = action.getStateIndex(); + int targetSubState = action.getSubStateIndex(); + if (!stateSupport.inState(targetState) || !stateSupport.inSubState(targetSubState)) { + stateSupport.setState(action.getStateIndex(), action.getSubStateIndex(), true, false); + logContext = LOGGER.at(Level.FINE); + if (logContext.isEnabled()) { + logContext.log("%s with uuid %s: Setting state", npcComponent.getRoleName(), uuidComponent.getUuid()); + } + + stateEvaluator.onStateSwitched(); } - - stateEvaluator.onStateSwitched(); } } } diff --git a/src/com/hypixel/hytale/server/npc/systems/SteeringSystem.java b/src/com/hypixel/hytale/server/npc/systems/SteeringSystem.java index 35315ca..091b104 100644 --- a/src/com/hypixel/hytale/server/npc/systems/SteeringSystem.java +++ b/src/com/hypixel/hytale/server/npc/systems/SteeringSystem.java @@ -38,7 +38,7 @@ public class SteeringSystem extends SteppableTickingSystem { new SystemDependency<>(Order.AFTER, KnockbackSystems.ApplyKnockback.class), new SystemDependency<>(Order.BEFORE, TransformSystems.EntityTrackerUpdate.class) ); - this.query = Query.and(npcEntityComponent); + this.query = Query.and(npcEntityComponent, TransformComponent.getComponentType()); } @Nonnull @@ -66,50 +66,52 @@ public class SteeringSystem extends SteppableTickingSystem { @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { - NPCEntity npc = archetypeChunk.getComponent(index, this.npcEntityComponent); + NPCEntity npcComponent = archetypeChunk.getComponent(index, this.npcEntityComponent); - assert npc != null; + assert npcComponent != null; - TransformComponent npcTransformComponent = archetypeChunk.getComponent(index, TransformComponent.getComponentType()); + TransformComponent transformComponent = archetypeChunk.getComponent(index, TransformComponent.getComponentType()); - assert npcTransformComponent != null; + assert transformComponent != null; - Role role = npc.getRole(); - Ref ref = archetypeChunk.getReferenceTo(index); + Role role = npcComponent.getRole(); + if (role != null) { + Ref ref = archetypeChunk.getReferenceTo(index); - try { - if (role.getDebugSupport().isDebugMotionSteering()) { - Vector3d position = npcTransformComponent.getPosition(); - double x = position.getX(); - double z = position.getZ(); - float yaw = npcTransformComponent.getRotation().getYaw(); - role.getActiveMotionController().steer(ref, role, role.getBodySteering(), role.getHeadSteering(), dt, commandBuffer); - x = position.getX() - x; - z = position.getZ() - z; - double l = Math.sqrt(x * x + z * z); - double v = l / dt; - double vx = x / dt; - double vz = z / dt; - double vh = l > 0.0 ? PhysicsMath.normalizeTurnAngle(PhysicsMath.headingFromDirection(x, z)) : 0.0; - NPCPlugin.get() - .getLogger() - .at(Level.FINER) - .log( - "= Role = t =%.4f v =%.4f vx=%.4f vz=%.4f h =%.4f nh=%.4f vh=%.4f", - dt, - v, - vx, - vz, - (180.0F / (float)Math.PI) * yaw, - (180.0F / (float)Math.PI) * yaw, - 180.0F / (float)Math.PI * vh - ); - } else { - role.getActiveMotionController().steer(ref, role, role.getBodySteering(), role.getHeadSteering(), dt, commandBuffer); + try { + if (role.getDebugSupport().isDebugMotionSteering()) { + Vector3d position = transformComponent.getPosition(); + double x = position.getX(); + double z = position.getZ(); + float yaw = transformComponent.getRotation().getYaw(); + role.getActiveMotionController().steer(ref, role, role.getBodySteering(), role.getHeadSteering(), dt, commandBuffer); + x = position.getX() - x; + z = position.getZ() - z; + double l = Math.sqrt(x * x + z * z); + double v = l / dt; + double vx = x / dt; + double vz = z / dt; + double vh = l > 0.0 ? PhysicsMath.normalizeTurnAngle(PhysicsMath.headingFromDirection(x, z)) : 0.0; + NPCPlugin.get() + .getLogger() + .at(Level.FINER) + .log( + "= Role = t =%.4f v =%.4f vx=%.4f vz=%.4f h =%.4f nh=%.4f vh=%.4f", + dt, + v, + vx, + vz, + (180.0F / (float)Math.PI) * yaw, + (180.0F / (float)Math.PI) * yaw, + 180.0F / (float)Math.PI * vh + ); + } else { + role.getActiveMotionController().steer(ref, role, role.getBodySteering(), role.getHeadSteering(), dt, commandBuffer); + } + } catch (IllegalStateException | IllegalArgumentException var26) { + NPCPlugin.get().getLogger().at(Level.SEVERE).withCause(var26).log(); + commandBuffer.removeEntity(archetypeChunk.getReferenceTo(index), RemoveReason.REMOVE); } - } catch (IllegalStateException | IllegalArgumentException var26) { - NPCPlugin.get().getLogger().at(Level.SEVERE).withCause(var26).log(); - commandBuffer.removeEntity(archetypeChunk.getReferenceTo(index), RemoveReason.REMOVE); } } } diff --git a/src/com/hypixel/hytale/server/npc/systems/SteppableTickingSystem.java b/src/com/hypixel/hytale/server/npc/systems/SteppableTickingSystem.java index 8de0a0c..5f313a1 100644 --- a/src/com/hypixel/hytale/server/npc/systems/SteppableTickingSystem.java +++ b/src/com/hypixel/hytale/server/npc/systems/SteppableTickingSystem.java @@ -17,9 +17,6 @@ public abstract class SteppableTickingSystem extends EntityTickingSystem frozenComponentType = Frozen.getComponentType(); - public SteppableTickingSystem() { - } - @Override public void tick( float dt, diff --git a/src/com/hypixel/hytale/server/npc/util/AimingData.java b/src/com/hypixel/hytale/server/npc/util/AimingData.java index 4dc78e0..03ccb41 100644 --- a/src/com/hypixel/hytale/server/npc/util/AimingData.java +++ b/src/com/hypixel/hytale/server/npc/util/AimingData.java @@ -33,9 +33,6 @@ public class AimingData implements ExtraInfoProvider { private Ref target; private int owner = Integer.MIN_VALUE; - public AimingData() { - } - public boolean isHaveAttacked() { return this.haveAttacked; } diff --git a/src/com/hypixel/hytale/server/npc/util/AimingHelper.java b/src/com/hypixel/hytale/server/npc/util/AimingHelper.java index 46450b2..c39acaf 100644 --- a/src/com/hypixel/hytale/server/npc/util/AimingHelper.java +++ b/src/com/hypixel/hytale/server/npc/util/AimingHelper.java @@ -6,9 +6,6 @@ import javax.annotation.Nonnull; public class AimingHelper { public static final int MIN_GRAVITY_FOR_PARABOLA = 3; - public AimingHelper() { - } - public static double ensurePossibleThrowSpeed(double distance, double y, double gravity, double throwSpeed) { double x2 = distance * distance; if (x2 < 1.0000000000000002E-10) { diff --git a/src/com/hypixel/hytale/server/npc/util/Alarm.java b/src/com/hypixel/hytale/server/npc/util/Alarm.java index 9de8007..97f3960 100644 --- a/src/com/hypixel/hytale/server/npc/util/Alarm.java +++ b/src/com/hypixel/hytale/server/npc/util/Alarm.java @@ -14,9 +14,6 @@ public class Alarm extends PersistentParameter { .build(); protected Instant alarmInstant; - public Alarm() { - } - protected void set0(Instant value) { this.alarmInstant = value; } diff --git a/src/com/hypixel/hytale/server/npc/util/BlockPlacementHelper.java b/src/com/hypixel/hytale/server/npc/util/BlockPlacementHelper.java index 9c631d6..95f2e84 100644 --- a/src/com/hypixel/hytale/server/npc/util/BlockPlacementHelper.java +++ b/src/com/hypixel/hytale/server/npc/util/BlockPlacementHelper.java @@ -10,9 +10,6 @@ import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk; import javax.annotation.Nonnull; public class BlockPlacementHelper { - public BlockPlacementHelper() { - } - public static boolean canPlaceUnitBlock(@Nonnull World world, BlockType placedBlockType, boolean allowEmptyMaterials, int x, int y, int z) { WorldChunk chunk = world.getChunkIfInMemory(ChunkUtil.indexChunkFromBlock(x, z)); if (chunk == null) { diff --git a/src/com/hypixel/hytale/server/npc/util/InventoryHelper.java b/src/com/hypixel/hytale/server/npc/util/InventoryHelper.java index f1303f8..b94056e 100644 --- a/src/com/hypixel/hytale/server/npc/util/InventoryHelper.java +++ b/src/com/hypixel/hytale/server/npc/util/InventoryHelper.java @@ -197,11 +197,11 @@ public class InventoryHelper { } } - public static void removeItemInHand(@Nonnull Inventory inventory) { + public static void removeItemInHand(@Nonnull Inventory inventory, int count) { if (!ItemStack.isEmpty(inventory.getItemInHand())) { byte activeHotbarSlot = inventory.getActiveHotbarSlot(); if (activeHotbarSlot != -1) { - inventory.getHotbar().removeItemStackFromSlot(activeHotbarSlot); + inventory.getHotbar().removeItemStackFromSlot(activeHotbarSlot, count); } } } diff --git a/src/com/hypixel/hytale/server/npc/util/NPCPhysicsMath.java b/src/com/hypixel/hytale/server/npc/util/NPCPhysicsMath.java index 4e9c3e3..bb8e2f1 100644 --- a/src/com/hypixel/hytale/server/npc/util/NPCPhysicsMath.java +++ b/src/com/hypixel/hytale/server/npc/util/NPCPhysicsMath.java @@ -899,8 +899,5 @@ public class NPCPhysicsMath { NEG_Y, POS_Z, NEG_Z; - - private Direction() { - } } } diff --git a/src/com/hypixel/hytale/server/npc/util/PositionProbeAir.java b/src/com/hypixel/hytale/server/npc/util/PositionProbeAir.java index 32bac6c..2430d96 100644 --- a/src/com/hypixel/hytale/server/npc/util/PositionProbeAir.java +++ b/src/com/hypixel/hytale/server/npc/util/PositionProbeAir.java @@ -17,9 +17,6 @@ public class PositionProbeAir extends PositionProbeBase { protected boolean onSolid; protected boolean collideWithFluid; - public PositionProbeAir() { - } - public boolean probePosition( @Nonnull Ref ref, @Nonnull Box boundingBox, diff --git a/src/com/hypixel/hytale/server/npc/util/PositionProbeBase.java b/src/com/hypixel/hytale/server/npc/util/PositionProbeBase.java index 06d81e0..0ce62c1 100644 --- a/src/com/hypixel/hytale/server/npc/util/PositionProbeBase.java +++ b/src/com/hypixel/hytale/server/npc/util/PositionProbeBase.java @@ -36,9 +36,6 @@ public class PositionProbeBase { private int lastWaterCheckZ = Integer.MAX_VALUE; private int lastWaterCheckLevel = -2; - public PositionProbeBase() { - } - protected boolean probePosition( @Nonnull Ref ref, @Nonnull Box boundingBox, diff --git a/src/com/hypixel/hytale/server/npc/util/PositionProbeWater.java b/src/com/hypixel/hytale/server/npc/util/PositionProbeWater.java index a82ee77..7913147 100644 --- a/src/com/hypixel/hytale/server/npc/util/PositionProbeWater.java +++ b/src/com/hypixel/hytale/server/npc/util/PositionProbeWater.java @@ -14,9 +14,6 @@ import javax.annotation.Nonnull; public class PositionProbeWater extends PositionProbeBase { private double ySwim; - public PositionProbeWater() { - } - public boolean probePosition( @Nonnull Ref ref, @Nonnull Box boundingBox, diff --git a/src/com/hypixel/hytale/server/npc/util/RayBlockHitTest.java b/src/com/hypixel/hytale/server/npc/util/RayBlockHitTest.java index 01ce3a0..94349bd 100644 --- a/src/com/hypixel/hytale/server/npc/util/RayBlockHitTest.java +++ b/src/com/hypixel/hytale/server/npc/util/RayBlockHitTest.java @@ -27,9 +27,6 @@ public class RayBlockHitTest implements BlockIterator.BlockIteratorProcedure { private final Vector3d hitPosition = new Vector3d(Vector3d.MIN); private short lastBlockRevision; - public RayBlockHitTest() { - } - @Override public boolean accept(int x, int y, int z, double px, double py, double pz, double qx, double qy, double qz) { if (!ChunkUtil.isInsideChunk(this.chunk.getX(), this.chunk.getZ(), x, z)) { diff --git a/src/com/hypixel/hytale/server/npc/util/RootSolver.java b/src/com/hypixel/hytale/server/npc/util/RootSolver.java index 2d0496c..a704b64 100644 --- a/src/com/hypixel/hytale/server/npc/util/RootSolver.java +++ b/src/com/hypixel/hytale/server/npc/util/RootSolver.java @@ -4,9 +4,6 @@ public class RootSolver { public static final double M_PI = Math.PI; public static final double EQN_EPS = 1.0E-15; - public RootSolver() { - } - protected static boolean isZero(double x) { return x > -1.0E-15 && x < 1.0E-15; } diff --git a/src/com/hypixel/hytale/server/npc/util/SensorSupportBenchmark.java b/src/com/hypixel/hytale/server/npc/util/SensorSupportBenchmark.java index bf22c1f..0187da1 100644 --- a/src/com/hypixel/hytale/server/npc/util/SensorSupportBenchmark.java +++ b/src/com/hypixel/hytale/server/npc/util/SensorSupportBenchmark.java @@ -59,9 +59,6 @@ public class SensorSupportBenchmark { protected long friendlyBlockingTestTick; protected long friendlyBlockingCacheHitTick; - public SensorSupportBenchmark() { - } - public void collectPlayerList(long getNanos, double maxPlayerDistanceSorted, double maxPlayerDistance, double maxPlayerDistanceAvoidance, int numPlayers) { this.playerGetTime.recordNanos(getNanos); this.playerDistance.record(MathUtil.fastCeil(maxPlayerDistance)); diff --git a/src/com/hypixel/hytale/server/npc/util/Timer.java b/src/com/hypixel/hytale/server/npc/util/Timer.java index 08be987..5c378c0 100644 --- a/src/com/hypixel/hytale/server/npc/util/Timer.java +++ b/src/com/hypixel/hytale/server/npc/util/Timer.java @@ -13,9 +13,6 @@ public class Timer implements Tickable { private Timer.TimerState state = Timer.TimerState.STOPPED; private boolean initialised; - public Timer() { - } - public void setRate(double rate) { this.rate = rate; } diff --git a/src/com/hypixel/hytale/server/npc/util/expression/ExecutionContext.java b/src/com/hypixel/hytale/server/npc/util/expression/ExecutionContext.java index f17a0f4..5b63208 100644 --- a/src/com/hypixel/hytale/server/npc/util/expression/ExecutionContext.java +++ b/src/com/hypixel/hytale/server/npc/util/expression/ExecutionContext.java @@ -460,9 +460,6 @@ public class ExecutionContext { @Nullable public boolean[] boolArray; - public Operand() { - } - public ValueType set(String value) { this.reInit(ValueType.STRING); this.string = value; diff --git a/src/com/hypixel/hytale/server/npc/util/expression/ValueType.java b/src/com/hypixel/hytale/server/npc/util/expression/ValueType.java index 4e4a42a..aea9d42 100644 --- a/src/com/hypixel/hytale/server/npc/util/expression/ValueType.java +++ b/src/com/hypixel/hytale/server/npc/util/expression/ValueType.java @@ -12,9 +12,6 @@ public enum ValueType { STRING_ARRAY, BOOLEAN_ARRAY; - private ValueType() { - } - public static boolean isAssignableType(@Nullable ValueType from, @Nullable ValueType to) { return to != null && from != null && to != VOID && from != VOID ? to == from || from == EMPTY_ARRAY && isTypedArray(to) : false; } diff --git a/src/com/hypixel/hytale/server/npc/util/expression/compile/LexerContext.java b/src/com/hypixel/hytale/server/npc/util/expression/compile/LexerContext.java index 504b0d5..65bfad4 100644 --- a/src/com/hypixel/hytale/server/npc/util/expression/compile/LexerContext.java +++ b/src/com/hypixel/hytale/server/npc/util/expression/compile/LexerContext.java @@ -13,9 +13,6 @@ public class LexerContext { private StringBuilder tokenString = new StringBuilder(200); private double tokenNumber; - public LexerContext() { - } - public void init(@Nonnull String expression) { this.expression = expression; this.length = expression.length(); diff --git a/src/com/hypixel/hytale/server/npc/util/expression/compile/TokenFlags.java b/src/com/hypixel/hytale/server/npc/util/expression/compile/TokenFlags.java index 31556e6..1ab755b 100644 --- a/src/com/hypixel/hytale/server/npc/util/expression/compile/TokenFlags.java +++ b/src/com/hypixel/hytale/server/npc/util/expression/compile/TokenFlags.java @@ -10,7 +10,4 @@ public enum TokenFlags { CLOSING_BRACKET, LIST, OPENING_TUPLE; - - private TokenFlags() { - } } diff --git a/src/com/hypixel/hytale/server/npc/validators/NPCRoleValidator.java b/src/com/hypixel/hytale/server/npc/validators/NPCRoleValidator.java index 7ef238a..3c13fae 100644 --- a/src/com/hypixel/hytale/server/npc/validators/NPCRoleValidator.java +++ b/src/com/hypixel/hytale/server/npc/validators/NPCRoleValidator.java @@ -11,9 +11,6 @@ import javax.annotation.Nonnull; public class NPCRoleValidator implements LateValidator { public static final NPCRoleValidator INSTANCE = new NPCRoleValidator(); - public NPCRoleValidator() { - } - public void accept(String s, ValidationResults results) { } diff --git a/src/com/hypixel/hytale/server/npc/valuestore/ValueStore.java b/src/com/hypixel/hytale/server/npc/valuestore/ValueStore.java index 4be71ac..d57c71f 100644 --- a/src/com/hypixel/hytale/server/npc/valuestore/ValueStore.java +++ b/src/com/hypixel/hytale/server/npc/valuestore/ValueStore.java @@ -64,9 +64,6 @@ public class ValueStore implements Component { private final SlotMapper intSlots = new SlotMapper(); private final SlotMapper doubleSlots = new SlotMapper(); - public Builder() { - } - public int getStringSlot(String name) { return this.stringSlots.getSlot(name); } diff --git a/src/com/hypixel/hytale/server/npc/valuestore/ValueStoreValidator.java b/src/com/hypixel/hytale/server/npc/valuestore/ValueStoreValidator.java index a51ad1f..6eb297d 100644 --- a/src/com/hypixel/hytale/server/npc/valuestore/ValueStoreValidator.java +++ b/src/com/hypixel/hytale/server/npc/valuestore/ValueStoreValidator.java @@ -12,9 +12,6 @@ import javax.annotation.Nonnull; public class ValueStoreValidator { private final EnumMap>> usages = new EnumMap<>(ValueStore.Type.class); - public ValueStoreValidator() { - } - public void registerValueUsage(@Nonnull ValueStoreValidator.ValueUsage usage) { if (usage.useType != ValueStoreValidator.UseType.READ) { HashMap> usagesOfType = this.usages.computeIfAbsent(usage.valueType, k -> new HashMap<>()); diff --git a/src/com/hypixel/hytale/server/spawning/SpawnRejection.java b/src/com/hypixel/hytale/server/spawning/SpawnRejection.java index ace33fc..174dd2b 100644 --- a/src/com/hypixel/hytale/server/spawning/SpawnRejection.java +++ b/src/com/hypixel/hytale/server/spawning/SpawnRejection.java @@ -9,7 +9,4 @@ public enum SpawnRejection { OTHER; public static final SpawnRejection[] VALUES = values(); - - private SpawnRejection() { - } } diff --git a/src/com/hypixel/hytale/server/spawning/SpawnTestResult.java b/src/com/hypixel/hytale/server/spawning/SpawnTestResult.java index 9323c11..d3e8493 100644 --- a/src/com/hypixel/hytale/server/spawning/SpawnTestResult.java +++ b/src/com/hypixel/hytale/server/spawning/SpawnTestResult.java @@ -8,7 +8,4 @@ public enum SpawnTestResult { FAIL_NO_MOTION_CONTROLLERS, FAIL_NOT_SPAWNABLE, FAIL_NOT_BREATHABLE; - - private SpawnTestResult() { - } } diff --git a/src/com/hypixel/hytale/server/spawning/SpawningContext.java b/src/com/hypixel/hytale/server/spawning/SpawningContext.java index 2716169..cf75add 100644 --- a/src/com/hypixel/hytale/server/spawning/SpawningContext.java +++ b/src/com/hypixel/hytale/server/spawning/SpawningContext.java @@ -613,8 +613,5 @@ public class SpawningContext { int top; int waterLevel; int groundLevel; - - private SpawnSpan() { - } } } diff --git a/src/com/hypixel/hytale/server/spawning/SpawningPlugin.java b/src/com/hypixel/hytale/server/spawning/SpawningPlugin.java index ba2236b..d8154ad 100644 --- a/src/com/hypixel/hytale/server/spawning/SpawningPlugin.java +++ b/src/com/hypixel/hytale/server/spawning/SpawningPlugin.java @@ -906,9 +906,6 @@ public class SpawningPlugin extends JavaPlugin { private final ComponentType> unknownComponentsComponentType = EntityStore.REGISTRY.getUnknownComponentType(); private final Query query = Query.and(this.unknownComponentsComponentType, Query.not(AllLegacyEntityTypesQuery.INSTANCE)); - public LegacySpawnSuppressorEntityMigration() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { Map unknownComponents = holder.getComponent(this.unknownComponentsComponentType).getUnknownComponents(); @@ -970,8 +967,5 @@ public class SpawningPlugin extends JavaPlugin { private int maxActiveJobs = 20; private String defaultMarkerModel = "NPC_Spawn_Marker"; private double localSpawnControllerJoinDelay = 15.0; - - public NPCSpawningConfig() { - } } } diff --git a/src/com/hypixel/hytale/server/spawning/assets/spawns/LightType.java b/src/com/hypixel/hytale/server/spawning/assets/spawns/LightType.java index 2b6fb12..c9a514d 100644 --- a/src/com/hypixel/hytale/server/spawning/assets/spawns/LightType.java +++ b/src/com/hypixel/hytale/server/spawning/assets/spawns/LightType.java @@ -9,7 +9,4 @@ public enum LightType { BlueLight; public static final LightType[] VALUES = values(); - - private LightType() { - } } diff --git a/src/com/hypixel/hytale/server/spawning/beacons/InitialBeaconDelay.java b/src/com/hypixel/hytale/server/spawning/beacons/InitialBeaconDelay.java index 620681e..983dc32 100644 --- a/src/com/hypixel/hytale/server/spawning/beacons/InitialBeaconDelay.java +++ b/src/com/hypixel/hytale/server/spawning/beacons/InitialBeaconDelay.java @@ -10,9 +10,6 @@ import javax.annotation.Nonnull; public class InitialBeaconDelay implements Component { private double loadTimeSpawnDelay; - public InitialBeaconDelay() { - } - public static ComponentType getComponentType() { return SpawningPlugin.get().getInitialBeaconDelayComponentType(); } diff --git a/src/com/hypixel/hytale/server/spawning/beacons/SpawnBeacon.java b/src/com/hypixel/hytale/server/spawning/beacons/SpawnBeacon.java index 9024c79..fc7bdf8 100644 --- a/src/com/hypixel/hytale/server/spawning/beacons/SpawnBeacon.java +++ b/src/com/hypixel/hytale/server/spawning/beacons/SpawnBeacon.java @@ -109,53 +109,55 @@ public class SpawnBeacon extends Entity { for (int i = 0; i < concurrentSpawns; i++) { RoleSpawnParameters roleSpawnParameters = this.spawnWrapper.pickRole(ThreadLocalRandom.current()); - int roleIndex = NPCPlugin.get().getIndex(roleSpawnParameters.getId()); - if (!this.unspawnableRoles.contains(roleIndex)) { - ISpawnableWithModel spawnable = (ISpawnableWithModel)NPCPlugin.get().tryGetCachedValidRole(roleIndex); - this.spawningContext.setSpawnable(spawnable); - if (!positionSelector.hasPositionsForRole(roleIndex)) { - this.markUnspawnable(ref, roleIndex, store); - this.spawningContext.releaseFull(); - } else { - Vector3d targetPos = targetRef.getStore().getComponent(targetRef, TransformComponent.getComponentType()).getPosition(); - if (!positionSelector.prepareSpawnContext(targetPos, concurrentSpawns, roleIndex, this.spawningContext, this.spawnWrapper)) { + if (roleSpawnParameters != null) { + int roleIndex = NPCPlugin.get().getIndex(roleSpawnParameters.getId()); + if (!this.unspawnableRoles.contains(roleIndex)) { + ISpawnableWithModel spawnable = (ISpawnableWithModel)NPCPlugin.get().tryGetCachedValidRole(roleIndex); + this.spawningContext.setSpawnable(spawnable); + if (!positionSelector.hasPositionsForRole(roleIndex)) { + this.markUnspawnable(ref, roleIndex, store); this.spawningContext.releaseFull(); } else { - Vector3d position = this.spawningContext.newPosition(); - Vector3f rotation = this.spawningContext.newRotation(); - FlockAsset flockDefinition = roleSpawnParameters.getFlockDefinition(); - int flockSize = flockDefinition != null ? flockDefinition.pickFlockSize() : 1; + Vector3d targetPos = targetRef.getStore().getComponent(targetRef, TransformComponent.getComponentType()).getPosition(); + if (!positionSelector.prepareSpawnContext(targetPos, concurrentSpawns, roleIndex, this.spawningContext, this.spawnWrapper)) { + this.spawningContext.releaseFull(); + } else { + Vector3d position = this.spawningContext.newPosition(); + Vector3f rotation = this.spawningContext.newRotation(); + FlockAsset flockDefinition = roleSpawnParameters.getFlockDefinition(); + int flockSize = flockDefinition != null ? flockDefinition.pickFlockSize() : 1; - try { - Pair, NPCEntity> npcPair = NPCPlugin.get() - .spawnEntity( - store, + try { + Pair, NPCEntity> npcPair = NPCPlugin.get() + .spawnEntity( + store, + roleIndex, + position, + rotation, + this.spawningContext.getModel(), + (_npc, _ref, _store) -> postSpawn(_npc, _ref, this.spawnWrapper.getSpawn(), targetRef, _store) + ); + Ref npcRef = npcPair.first(); + NPCEntity npcComponent = npcPair.second(); + FlockPlugin.trySpawnFlock( + npcRef, + npcComponent, roleIndex, position, rotation, - this.spawningContext.getModel(), - (_npc, _ref, _store) -> postSpawn(_npc, _ref, this.spawnWrapper.getSpawn(), targetRef, _store) + flockSize, + flockDefinition, + null, + (_npc, _ref, _store) -> postSpawn(_npc, _ref, this.spawnWrapper.getSpawn(), targetRef, _store), + store ); - Ref npcRef = npcPair.first(); - NPCEntity npcComponent = npcPair.second(); - FlockPlugin.trySpawnFlock( - npcRef, - npcComponent, - roleIndex, - position, - rotation, - flockSize, - flockDefinition, - null, - (_npc, _ref, _store) -> postSpawn(_npc, _ref, this.spawnWrapper.getSpawn(), targetRef, _store), - store - ); - spawnedCount++; - } catch (RuntimeException var22) { - LOGGER.at(Level.WARNING).log("Failed to create %s: %s", NPCPlugin.get().getName(roleIndex), var22.getMessage()); - this.markUnspawnable(ref, roleIndex, store); - } finally { - this.spawningContext.releaseFull(); + spawnedCount++; + } catch (RuntimeException var22) { + LOGGER.at(Level.WARNING).log("Failed to create %s: %s", NPCPlugin.get().getName(roleIndex), var22.getMessage()); + this.markUnspawnable(ref, roleIndex, store); + } finally { + this.spawningContext.releaseFull(); + } } } } diff --git a/src/com/hypixel/hytale/server/spawning/beacons/SpawnBeaconSystems.java b/src/com/hypixel/hytale/server/spawning/beacons/SpawnBeaconSystems.java index 6041124..4a22599 100644 --- a/src/com/hypixel/hytale/server/spawning/beacons/SpawnBeaconSystems.java +++ b/src/com/hypixel/hytale/server/spawning/beacons/SpawnBeaconSystems.java @@ -68,9 +68,6 @@ public class SpawnBeaconSystems { public static final double[] POSITION_CALCULATION_DELAY_RANGE = new double[]{0.0, 1.0}; private static final double LOAD_TIME_SPAWN_DELAY = 15.0; - public SpawnBeaconSystems() { - } - public static class CheckDespawn extends EntityTickingSystem { private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); private final ComponentType componentType; @@ -84,7 +81,7 @@ public class SpawnBeaconSystems { ) { this.componentType = componentType; this.npcComponentType = NPCEntity.getComponentType(); - this.query = Query.and(componentType, Query.not(initialBeaconDelayComponentType)); + this.query = Query.and(componentType, UUIDComponent.getComponentType(), Query.not(initialBeaconDelayComponentType)); } @Nonnull diff --git a/src/com/hypixel/hytale/server/spawning/blockstates/SpawnMarkerBlockState.java b/src/com/hypixel/hytale/server/spawning/blockstates/SpawnMarkerBlockState.java index f954a0c..bceeec6 100644 --- a/src/com/hypixel/hytale/server/spawning/blockstates/SpawnMarkerBlockState.java +++ b/src/com/hypixel/hytale/server/spawning/blockstates/SpawnMarkerBlockState.java @@ -18,9 +18,6 @@ public class SpawnMarkerBlockState extends BlockState { private PersistentRef spawnMarkerReference; private float markerLostTimeout = 30.0F; - public SpawnMarkerBlockState() { - } - public PersistentRef getSpawnMarkerReference() { return this.spawnMarkerReference; } diff --git a/src/com/hypixel/hytale/server/spawning/blockstates/SpawnMarkerBlockStateSystems.java b/src/com/hypixel/hytale/server/spawning/blockstates/SpawnMarkerBlockStateSystems.java index 15bf189..d78eb6f 100644 --- a/src/com/hypixel/hytale/server/spawning/blockstates/SpawnMarkerBlockStateSystems.java +++ b/src/com/hypixel/hytale/server/spawning/blockstates/SpawnMarkerBlockStateSystems.java @@ -39,9 +39,6 @@ import javax.annotation.Nonnull; public class SpawnMarkerBlockStateSystems { private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); - public SpawnMarkerBlockStateSystems() { - } - private static void createMarker( @Nonnull Ref ref, @Nonnull SpawnMarkerBlockState state, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { diff --git a/src/com/hypixel/hytale/server/spawning/controllers/BeaconSpawnController.java b/src/com/hypixel/hytale/server/spawning/controllers/BeaconSpawnController.java index d41a9a7..2b8928f 100644 --- a/src/com/hypixel/hytale/server/spawning/controllers/BeaconSpawnController.java +++ b/src/com/hypixel/hytale/server/spawning/controllers/BeaconSpawnController.java @@ -74,25 +74,29 @@ public class BeaconSpawnController extends SpawnController { BeaconSpawnWrapper wrapper = legacySpawnBeaconComponent.getSpawnWrapper(); RoleSpawnParameters spawn = wrapper.pickRole(ThreadLocalRandom.current()); - String spawnId = spawn.getId(); - int roleIndex = NPCPlugin.get().getIndex(spawnId); - if (roleIndex >= 0 && !this.unspawnableRoles.contains(roleIndex)) { - NPCBeaconSpawnJob job = null; - int predictedTotal = this.spawnedEntities.size() + this.activeJobs.size(); - if (this.activeJobs.size() < this.getMaxActiveJobs() - && this.nextPlayerIndex < this.playersInRegion.size() - && predictedTotal < this.currentScaledMaxTotalSpawns) { - job = this.idleJobs.isEmpty() ? new NPCBeaconSpawnJob() : this.idleJobs.pop(); - job.beginProbing(this.playersInRegion.get(this.nextPlayerIndex++), this.currentScaledMaxConcurrentSpawns, roleIndex, spawn.getFlockDefinition()); - this.activeJobs.add(job); - if (this.nextPlayerIndex >= this.playersInRegion.size()) { - this.nextPlayerIndex = 0; - } - } - - return job; - } else { + if (spawn == null) { return null; + } else { + String spawnId = spawn.getId(); + int roleIndex = NPCPlugin.get().getIndex(spawnId); + if (roleIndex >= 0 && !this.unspawnableRoles.contains(roleIndex)) { + NPCBeaconSpawnJob job = null; + int predictedTotal = this.spawnedEntities.size() + this.activeJobs.size(); + if (this.activeJobs.size() < this.getMaxActiveJobs() + && this.nextPlayerIndex < this.playersInRegion.size() + && predictedTotal < this.currentScaledMaxTotalSpawns) { + job = this.idleJobs.isEmpty() ? new NPCBeaconSpawnJob() : this.idleJobs.pop(); + job.beginProbing(this.playersInRegion.get(this.nextPlayerIndex++), this.currentScaledMaxConcurrentSpawns, roleIndex, spawn.getFlockDefinition()); + this.activeJobs.add(job); + if (this.nextPlayerIndex >= this.playersInRegion.size()) { + this.nextPlayerIndex = 0; + } + } + + return job; + } else { + return null; + } } } diff --git a/src/com/hypixel/hytale/server/spawning/controllers/SpawnControllerSystem.java b/src/com/hypixel/hytale/server/spawning/controllers/SpawnControllerSystem.java index 33039ea..6e6cda5 100644 --- a/src/com/hypixel/hytale/server/spawning/controllers/SpawnControllerSystem.java +++ b/src/com/hypixel/hytale/server/spawning/controllers/SpawnControllerSystem.java @@ -9,9 +9,6 @@ import com.hypixel.hytale.server.spawning.jobs.SpawnJob; import javax.annotation.Nonnull; public abstract class SpawnControllerSystem> extends EntityTickingSystem { - public SpawnControllerSystem() { - } - protected void tickController(@Nonnull T spawnController, @Nonnull Store store) { World world = store.getExternalData().getWorld(); if (world.getPlayerCount() != 0 diff --git a/src/com/hypixel/hytale/server/spawning/controllers/SpawnJobSystem.java b/src/com/hypixel/hytale/server/spawning/controllers/SpawnJobSystem.java index a134e8c..e742da8 100644 --- a/src/com/hypixel/hytale/server/spawning/controllers/SpawnJobSystem.java +++ b/src/com/hypixel/hytale/server/spawning/controllers/SpawnJobSystem.java @@ -19,9 +19,6 @@ public abstract class SpawnJobSystem store, @Nonnull CommandBuffer commandBuffer) { World world = store.getExternalData().getWorld(); if (world.getPlayerCount() != 0 @@ -151,8 +148,5 @@ public abstract class SpawnJobSystem commandBuffer = context.getCommandBuffer(); diff --git a/src/com/hypixel/hytale/server/spawning/jobs/NPCBeaconSpawnJob.java b/src/com/hypixel/hytale/server/spawning/jobs/NPCBeaconSpawnJob.java index 8878d86..e756760 100644 --- a/src/com/hypixel/hytale/server/spawning/jobs/NPCBeaconSpawnJob.java +++ b/src/com/hypixel/hytale/server/spawning/jobs/NPCBeaconSpawnJob.java @@ -20,9 +20,6 @@ public class NPCBeaconSpawnJob extends SpawnJob { @Nullable private FlockAsset flockAsset; - public NPCBeaconSpawnJob() { - } - public int getRoleIndex() { return this.roleIndex; } diff --git a/src/com/hypixel/hytale/server/spawning/local/LocalSpawnBeacon.java b/src/com/hypixel/hytale/server/spawning/local/LocalSpawnBeacon.java index 382193c..6e4bd26 100644 --- a/src/com/hypixel/hytale/server/spawning/local/LocalSpawnBeacon.java +++ b/src/com/hypixel/hytale/server/spawning/local/LocalSpawnBeacon.java @@ -10,9 +10,6 @@ import javax.annotation.Nonnull; public class LocalSpawnBeacon implements Component { public static final BuilderCodec CODEC = BuilderCodec.builder(LocalSpawnBeacon.class, LocalSpawnBeacon::new).build(); - public LocalSpawnBeacon() { - } - public static ComponentType getComponentType() { return SpawningPlugin.get().getLocalSpawnBeaconComponentType(); } diff --git a/src/com/hypixel/hytale/server/spawning/local/LocalSpawnController.java b/src/com/hypixel/hytale/server/spawning/local/LocalSpawnController.java index b9bddfe..abfd9a8 100644 --- a/src/com/hypixel/hytale/server/spawning/local/LocalSpawnController.java +++ b/src/com/hypixel/hytale/server/spawning/local/LocalSpawnController.java @@ -13,9 +13,6 @@ public class LocalSpawnController implements Component { return SpawningPlugin.get().getLocalSpawnControllerComponentType(); } - public LocalSpawnController() { - } - public void setTimeToNextRunSeconds(double seconds) { this.timeToNextRunSeconds = seconds; } diff --git a/src/com/hypixel/hytale/server/spawning/local/LocalSpawnControllerSystem.java b/src/com/hypixel/hytale/server/spawning/local/LocalSpawnControllerSystem.java index 0bbb6a0..0b72699 100644 --- a/src/com/hypixel/hytale/server/spawning/local/LocalSpawnControllerSystem.java +++ b/src/com/hypixel/hytale/server/spawning/local/LocalSpawnControllerSystem.java @@ -62,7 +62,7 @@ public class LocalSpawnControllerSystem extends TickingSystem { this.spawnBeaconComponentType = spawnBeaconComponentType; this.localSpawnStateResourceType = localSpawnStateResourceType; this.beaconSpatialComponent = beaconSpatialComponent; - this.controllerArchetype = Archetype.of(spawnControllerComponentType, PlayerRef.getComponentType()); + this.controllerArchetype = Archetype.of(spawnControllerComponentType, PlayerRef.getComponentType(), transformComponentype, weatherTrackerComponentType); } @Override diff --git a/src/com/hypixel/hytale/server/spawning/local/LocalSpawnState.java b/src/com/hypixel/hytale/server/spawning/local/LocalSpawnState.java index e4d526b..1851881 100644 --- a/src/com/hypixel/hytale/server/spawning/local/LocalSpawnState.java +++ b/src/com/hypixel/hytale/server/spawning/local/LocalSpawnState.java @@ -15,9 +15,6 @@ public class LocalSpawnState implements Resource { private final List localPendingSpawns = new ObjectArrayList<>(); private boolean forceTriggerControllers; - public LocalSpawnState() { - } - public static ResourceType getResourceType() { return SpawningPlugin.get().getLocalSpawnStateResourceType(); } diff --git a/src/com/hypixel/hytale/server/spawning/managers/BeaconSpawnManager.java b/src/com/hypixel/hytale/server/spawning/managers/BeaconSpawnManager.java index df06dfb..551eb58 100644 --- a/src/com/hypixel/hytale/server/spawning/managers/BeaconSpawnManager.java +++ b/src/com/hypixel/hytale/server/spawning/managers/BeaconSpawnManager.java @@ -13,9 +13,6 @@ public class BeaconSpawnManager extends SpawnManager> wrappersByEnvironment = new Int2ObjectConcurrentHashMap<>(); - public BeaconSpawnManager() { - } - @Nullable public BeaconSpawnWrapper removeSpawnWrapper(int spawnConfigurationIndex) { BeaconSpawnWrapper wrapper = (BeaconSpawnWrapper)super.removeSpawnWrapper(spawnConfigurationIndex); diff --git a/src/com/hypixel/hytale/server/spawning/managers/SpawnManager.java b/src/com/hypixel/hytale/server/spawning/managers/SpawnManager.java index 1549d01..71d1651 100644 --- a/src/com/hypixel/hytale/server/spawning/managers/SpawnManager.java +++ b/src/com/hypixel/hytale/server/spawning/managers/SpawnManager.java @@ -19,9 +19,6 @@ public abstract class SpawnManager, U extends NPCSpawn private final Object2IntMap wrapperNameMap = new Object2IntOpenHashMap<>(); private final StampedLock wrapperLock = new StampedLock(); - public SpawnManager() { - } - public T getSpawnWrapper(int spawnConfigIndex) { long stamp = this.wrapperLock.readLock(); diff --git a/src/com/hypixel/hytale/server/spawning/spawnmarkers/SpawnMarkerEntity.java b/src/com/hypixel/hytale/server/spawning/spawnmarkers/SpawnMarkerEntity.java index 4de3cd3..89fe654 100644 --- a/src/com/hypixel/hytale/server/spawning/spawnmarkers/SpawnMarkerEntity.java +++ b/src/com/hypixel/hytale/server/spawning/spawnmarkers/SpawnMarkerEntity.java @@ -51,9 +51,12 @@ import javax.annotation.Nullable; public class SpawnMarkerEntity implements Component { private static final double SPAWN_LOST_TIMEOUT = 35.0; + @Nonnull + private static final InvalidatablePersistentRef[] EMPTY_REFERENCES = new InvalidatablePersistentRef[0]; public static final ArrayCodec NPC_REFERENCES_CODEC = new ArrayCodec<>( InvalidatablePersistentRef.CODEC, InvalidatablePersistentRef[]::new ); + @Nonnull public static final BuilderCodec CODEC = BuilderCodec.builder(SpawnMarkerEntity.class, SpawnMarkerEntity::new) .addField( new KeyedCodec<>("SpawnMarker", Codec.STRING), @@ -126,13 +129,14 @@ public class SpawnMarkerEntity implements Component { public SpawnMarkerEntity() { this.context = new SpawningContext(); + this.npcReferences = EMPTY_REFERENCES; } public SpawnMarker getCachedMarker() { return this.cachedMarker; } - public void setCachedMarker(SpawnMarker marker) { + public void setCachedMarker(@Nonnull SpawnMarker marker) { this.cachedMarker = marker; } @@ -148,7 +152,7 @@ public class SpawnMarkerEntity implements Component { this.respawnCounter = respawnCounter; } - public void setSpawnAfter(Instant spawnAfter) { + public void setSpawnAfter(@Nullable Instant spawnAfter) { this.spawnAfter = spawnAfter; } @@ -157,7 +161,7 @@ public class SpawnMarkerEntity implements Component { return this.spawnAfter; } - public void setGameTimeRespawn(Duration gameTimeRespawn) { + public void setGameTimeRespawn(@Nullable Duration gameTimeRespawn) { this.gameTimeRespawn = gameTimeRespawn; } @@ -177,7 +181,7 @@ public class SpawnMarkerEntity implements Component { return this.suppressedBy; } - public void setStoredFlock(StoredFlock storedFlock) { + public void setStoredFlock(@Nonnull StoredFlock storedFlock) { this.storedFlock = storedFlock; } @@ -211,8 +215,8 @@ public class SpawnMarkerEntity implements Component { return this.npcReferences; } - public void setNpcReferences(InvalidatablePersistentRef[] npcReferences) { - this.npcReferences = npcReferences; + public void setNpcReferences(@Nullable InvalidatablePersistentRef[] npcReferences) { + this.npcReferences = npcReferences != null ? npcReferences : EMPTY_REFERENCES; } @Nullable @@ -220,7 +224,7 @@ public class SpawnMarkerEntity implements Component { return this.tempStorageList; } - public void setTempStorageList(List, NPCEntity>> tempStorageList) { + public void setTempStorageList(@Nonnull List, NPCEntity>> tempStorageList) { this.tempStorageList = tempStorageList; } @@ -238,162 +242,176 @@ public class SpawnMarkerEntity implements Component { public boolean spawnNPC(@Nonnull Ref ref, @Nonnull SpawnMarker marker, @Nonnull Store store) { SpawnMarker.SpawnConfiguration spawn = marker.getWeightedConfigurations().get(ThreadLocalRandom.current()); - boolean realtime = marker.isRealtimeRespawn(); - if (realtime) { - this.respawnCounter = spawn.getRealtimeRespawnTime(); + if (spawn == null) { + SpawningPlugin.get().getLogger().at(Level.SEVERE).log("Marker %s has no spawn configuration to spawn", ref); + this.refreshTimeout(); + return false; } else { - this.spawnAfter = null; - this.gameTimeRespawn = spawn.getSpawnAfterGameTime(); - } - - UUIDComponent uuidComponent = store.getComponent(ref, UUIDComponent.getComponentType()); - - assert uuidComponent != null; - - UUID uuid = uuidComponent.getUuid(); - String roleName = spawn.getNpc(); - if (roleName != null && !roleName.isEmpty()) { - NPCPlugin npcModule = NPCPlugin.get(); - int roleIndex = npcModule.getIndex(roleName); - TransformComponent transformComponent = store.getComponent(ref, TransformComponent.getComponentType()); - - assert transformComponent != null; - - Vector3d position = transformComponent.getPosition(); - BuilderInfo builderInfo = npcModule.getRoleBuilderInfo(roleIndex); - if (builderInfo == null) { - SpawningPlugin.get().getLogger().at(Level.SEVERE).log("Marker %s attempted to spawn non-existent NPC role '%s'", uuid, roleName); - this.fail(ref, uuid, roleName, position, store, SpawnMarkerEntity.FailReason.NONEXISTENT_ROLE); - return false; + boolean realtime = marker.isRealtimeRespawn(); + if (realtime) { + this.respawnCounter = spawn.getRealtimeRespawnTime(); } else { - Builder role = builderInfo.isValid() ? builderInfo.getBuilder() : null; - if (role == null) { - SpawningPlugin.get().getLogger().at(Level.SEVERE).log("Marker %s attempted to spawn invalid NPC role '%s'", uuid, roleName); - this.fail(ref, uuid, roleName, position, store, SpawnMarkerEntity.FailReason.INVALID_ROLE); - return false; - } else if (!role.isSpawnable()) { - SpawningPlugin.get().getLogger().at(Level.SEVERE).log("Marker %s attempted to spawn a non-spawnable (abstract) role '%s'", uuid, roleName); - this.fail(ref, uuid, roleName, position, store, SpawnMarkerEntity.FailReason.INVALID_ROLE); - return false; - } else if (!this.context.setSpawnable((ISpawnableWithModel)role)) { - SpawningPlugin.get().getLogger().at(Level.SEVERE).log("Marker %s failed to spawn NPC role '%s' due to failed role validation", uuid, roleName); - this.fail(ref, uuid, roleName, position, store, SpawnMarkerEntity.FailReason.FAILED_ROLE_VALIDATION); + this.spawnAfter = null; + this.gameTimeRespawn = spawn.getSpawnAfterGameTime(); + } + + UUIDComponent uuidComponent = store.getComponent(ref, UUIDComponent.getComponentType()); + + assert uuidComponent != null; + + UUID uuid = uuidComponent.getUuid(); + String roleName = spawn.getNpc(); + if (roleName != null && !roleName.isEmpty()) { + NPCPlugin npcModule = NPCPlugin.get(); + int roleIndex = npcModule.getIndex(roleName); + TransformComponent transformComponent = store.getComponent(ref, TransformComponent.getComponentType()); + + assert transformComponent != null; + + Vector3d position = transformComponent.getPosition(); + BuilderInfo builderInfo = npcModule.getRoleBuilderInfo(roleIndex); + if (builderInfo == null) { + SpawningPlugin.get().getLogger().at(Level.SEVERE).log("Marker %s attempted to spawn non-existent NPC role '%s'", uuid, roleName); + this.fail(ref, uuid, roleName, position, store, SpawnMarkerEntity.FailReason.NONEXISTENT_ROLE); return false; } else { - ObjectList> results = SpatialResource.getThreadLocalReferenceList(); - SpatialResource, EntityStore> spatialResource = store.getResource(EntityModule.get().getPlayerSpatialResourceType()); - spatialResource.getSpatialStructure().collect(position, marker.getExclusionRadius(), results); - boolean hasPlayersInRange = !results.isEmpty(); - if (hasPlayersInRange) { - this.refreshTimeout(); + Builder role = builderInfo.isValid() ? builderInfo.getBuilder() : null; + if (role == null) { + SpawningPlugin.get().getLogger().at(Level.SEVERE).log("Marker %s attempted to spawn invalid NPC role '%s'", uuid, roleName); + this.fail(ref, uuid, roleName, position, store, SpawnMarkerEntity.FailReason.INVALID_ROLE); + return false; + } else if (!role.isSpawnable()) { + SpawningPlugin.get().getLogger().at(Level.SEVERE).log("Marker %s attempted to spawn a non-spawnable (abstract) role '%s'", uuid, roleName); + this.fail(ref, uuid, roleName, position, store, SpawnMarkerEntity.FailReason.INVALID_ROLE); + return false; + } else if (!this.context.setSpawnable((ISpawnableWithModel)role)) { + SpawningPlugin.get() + .getLogger() + .at(Level.SEVERE) + .log("Marker %s failed to spawn NPC role '%s' due to failed role validation", uuid, roleName); + this.fail(ref, uuid, roleName, position, store, SpawnMarkerEntity.FailReason.FAILED_ROLE_VALIDATION); return false; } else { - World world = store.getExternalData().getWorld(); - if (!this.context.set(world, position.x, position.y, position.z)) { - SpawningPlugin.get() - .getLogger() - .at(Level.FINE) - .log("Marker %s attempted to spawn NPC '%s' at %s but could not fit", uuid, roleName, position); - this.fail(ref, uuid, roleName, position, store, SpawnMarkerEntity.FailReason.NO_ROOM); + ObjectList> results = SpatialResource.getThreadLocalReferenceList(); + SpatialResource, EntityStore> spatialResource = store.getResource(EntityModule.get().getPlayerSpatialResourceType()); + spatialResource.getSpatialStructure().collect(position, marker.getExclusionRadius(), results); + boolean hasPlayersInRange = !results.isEmpty(); + if (hasPlayersInRange) { + this.refreshTimeout(); return false; } else { - SpawnTestResult testResult = this.context.canSpawn(true, false); - if (testResult != SpawnTestResult.TEST_OK) { + World world = store.getExternalData().getWorld(); + if (!this.context.set(world, position.x, position.y, position.z)) { SpawningPlugin.get() .getLogger() .at(Level.FINE) - .log("Marker %s attempted to spawn NPC '%s' at %s but could not fit: %s", uuid, roleName, position, testResult); + .log("Marker %s attempted to spawn NPC '%s' at %s but could not fit", uuid, roleName, position); this.fail(ref, uuid, roleName, position, store, SpawnMarkerEntity.FailReason.NO_ROOM); return false; } else { - this.spawnPosition.assign(this.context.xSpawn, this.context.ySpawn, this.context.zSpawn); - if (this.spawnPosition.distanceSquaredTo(position) > marker.getMaxDropHeightSquared()) { + SpawnTestResult testResult = this.context.canSpawn(true, false); + if (testResult != SpawnTestResult.TEST_OK) { SpawningPlugin.get() .getLogger() .at(Level.FINE) - .log("Marker %s attempted to spawn NPC '%s' but was offset too far from the ground at %s", uuid, roleName, position); - this.fail(ref, uuid, roleName, position, store, SpawnMarkerEntity.FailReason.TOO_HIGH); + .log("Marker %s attempted to spawn NPC '%s' at %s but could not fit: %s", uuid, roleName, position, testResult); + this.fail(ref, uuid, roleName, position, store, SpawnMarkerEntity.FailReason.NO_ROOM); return false; } else { - TriConsumer, Store> postSpawn = (_entity, _ref, _store) -> { - SpawnMarkerReference spawnMarkerReference = _store.ensureAndGetComponent(_ref, SpawnMarkerReference.getComponentType()); - spawnMarkerReference.getReference().setEntity(ref, _store); - spawnMarkerReference.refreshTimeoutCounter(); - WorldGenId worldgenIdComponent = _store.getComponent(ref, WorldGenId.getComponentType()); - int worldgenId = worldgenIdComponent != null ? worldgenIdComponent.getWorldGenId() : 0; - _store.putComponent(_ref, WorldGenId.getComponentType(), new WorldGenId(worldgenId)); - }; - Vector3f rotation = transformComponent.getRotation(); - Pair, NPCEntity> npcPair = npcModule.spawnEntity(store, roleIndex, this.spawnPosition, rotation, null, postSpawn); - if (npcPair == null) { - SpawningPlugin.get() - .getLogger() - .at(Level.SEVERE) - .log("Marker %s failed to spawn NPC role '%s' due to an internal error", uuid, roleName); - this.fail(ref, uuid, roleName, position, store, SpawnMarkerEntity.FailReason.INVALID_ROLE); - return false; - } else { - Ref npcRef = npcPair.first(); - NPCEntity npcComponent = npcPair.second(); - Ref flockReference = FlockPlugin.trySpawnFlock( - npcRef, npcComponent, store, roleIndex, this.spawnPosition, rotation, spawn.getFlockDefinition(), postSpawn - ); - EntityGroup group = flockReference == null ? null : store.getComponent(flockReference, EntityGroup.getComponentType()); - this.spawnCount = group != null ? group.size() : 1; - if (this.storedFlock != null) { - this.despawnStarted = false; - this.npcReferences = new InvalidatablePersistentRef[this.spawnCount]; - if (group != null) { - group.forEachMember((index, member, referenceArray) -> { - InvalidatablePersistentRef referencex = new InvalidatablePersistentRef(); - referencex.setEntity(member, store); - referenceArray[index] = referencex; - }, this.npcReferences); - } else { - InvalidatablePersistentRef reference = new InvalidatablePersistentRef(); - reference.setEntity(npcRef, store); - this.npcReferences[0] = reference; - } - - this.storedFlock.clear(); - } - + this.spawnPosition.assign(this.context.xSpawn, this.context.ySpawn, this.context.zSpawn); + if (this.spawnPosition.distanceSquaredTo(position) > marker.getMaxDropHeightSquared()) { SpawningPlugin.get() .getLogger() .at(Level.FINE) - .log( - "Marker %s spawned %s and set respawn to %s", - uuid, - npcComponent.getRoleName(), - realtime ? this.respawnCounter : this.gameTimeRespawn + .log("Marker %s attempted to spawn NPC '%s' but was offset too far from the ground at %s", uuid, roleName, position); + this.fail(ref, uuid, roleName, position, store, SpawnMarkerEntity.FailReason.TOO_HIGH); + return false; + } else { + TriConsumer, Store> postSpawn = (_entity, _ref, _store) -> { + SpawnMarkerReference spawnMarkerReference = _store.ensureAndGetComponent(_ref, SpawnMarkerReference.getComponentType()); + spawnMarkerReference.getReference().setEntity(ref, _store); + spawnMarkerReference.refreshTimeoutCounter(); + WorldGenId worldGenIdComponent = _store.getComponent(ref, WorldGenId.getComponentType()); + int worldGenId = worldGenIdComponent != null ? worldGenIdComponent.getWorldGenId() : 0; + _store.putComponent(_ref, WorldGenId.getComponentType(), new WorldGenId(worldGenId)); + }; + Vector3f rotation = transformComponent.getRotation(); + Pair, NPCEntity> npcPair = npcModule.spawnEntity(store, roleIndex, this.spawnPosition, rotation, null, postSpawn); + if (npcPair == null) { + SpawningPlugin.get() + .getLogger() + .at(Level.SEVERE) + .log("Marker %s failed to spawn NPC role '%s' due to an internal error", uuid, roleName); + this.fail(ref, uuid, roleName, position, store, SpawnMarkerEntity.FailReason.INVALID_ROLE); + return false; + } else { + Ref npcRef = npcPair.first(); + NPCEntity npcComponent = npcPair.second(); + Ref flockReference = FlockPlugin.trySpawnFlock( + npcRef, npcComponent, store, roleIndex, this.spawnPosition, rotation, spawn.getFlockDefinition(), postSpawn ); - this.refreshTimeout(); - return true; + EntityGroup group = flockReference == null ? null : store.getComponent(flockReference, EntityGroup.getComponentType()); + this.spawnCount = group != null ? group.size() : 1; + if (this.storedFlock != null) { + this.despawnStarted = false; + this.npcReferences = new InvalidatablePersistentRef[this.spawnCount]; + if (group != null) { + group.forEachMember((index, member, referenceArray) -> { + InvalidatablePersistentRef referencex = new InvalidatablePersistentRef(); + referencex.setEntity(member, store); + referenceArray[index] = referencex; + }, this.npcReferences); + } else { + InvalidatablePersistentRef reference = new InvalidatablePersistentRef(); + reference.setEntity(npcRef, store); + this.npcReferences[0] = reference; + } + + this.storedFlock.clear(); + } + + SpawningPlugin.get() + .getLogger() + .at(Level.FINE) + .log( + "Marker %s spawned %s and set respawn to %s", + uuid, + npcComponent.getRoleName(), + realtime ? this.respawnCounter : this.gameTimeRespawn + ); + this.refreshTimeout(); + return true; + } } } } } } } + } else { + SpawningPlugin.get() + .getLogger() + .at(Level.FINE) + .log("Marker %s performed noop spawn and set repawn to %s", uuid, realtime ? this.respawnCounter : this.gameTimeRespawn); + this.refreshTimeout(); + return true; } - } else { - SpawningPlugin.get() - .getLogger() - .at(Level.FINE) - .log("Marker %s performed noop spawn and set repawn to %s", uuid, realtime ? this.respawnCounter : this.gameTimeRespawn); - this.refreshTimeout(); - return true; } } private void fail( - @Nonnull Ref self, UUID uuid, String npc, Vector3d position, @Nonnull Store store, SpawnMarkerEntity.FailReason reason + @Nonnull Ref self, + @Nonnull UUID uuid, + @Nonnull String role, + @Nonnull Vector3d position, + @Nonnull Store store, + @Nonnull SpawnMarkerEntity.FailReason reason ) { if (++this.failedSpawns >= 5) { SpawningPlugin.get() .getLogger() .at(Level.WARNING) - .log("Marker %s at %s removed due to repeated spawning fails of %s with reason: %s", uuid, position, npc, reason); + .log("Marker %s at %s removed due to repeated spawning fails of %s with reason: %s", uuid, position, role, reason); store.removeEntity(self, RemoveReason.REMOVE); } else { this.refreshTimeout(); @@ -428,7 +446,7 @@ public class SpawnMarkerEntity implements Component { return this.cachedMarker.isManualTrigger() && this.spawnCount <= 0 ? this.spawnNPC(markerRef, this.cachedMarker, store) : false; } - public void suppress(UUID suppressor) { + public void suppress(@Nonnull UUID suppressor) { if (this.suppressedBy == null) { this.suppressedBy = new HashSet<>(); } @@ -436,8 +454,10 @@ public class SpawnMarkerEntity implements Component { this.suppressedBy.add(suppressor); } - public void releaseSuppression(UUID suppressor) { - this.suppressedBy.remove(suppressor); + public void releaseSuppression(@Nonnull UUID suppressor) { + if (this.suppressedBy != null) { + this.suppressedBy.remove(suppressor); + } } public void clearAllSuppressions() { @@ -519,8 +539,5 @@ public class SpawnMarkerEntity implements Component { FAILED_ROLE_VALIDATION, NO_ROOM, TOO_HIGH; - - private FailReason() { - } } } diff --git a/src/com/hypixel/hytale/server/spawning/spawnmarkers/SpawnMarkerSystems.java b/src/com/hypixel/hytale/server/spawning/spawnmarkers/SpawnMarkerSystems.java index 869d833..bee9908 100644 --- a/src/com/hypixel/hytale/server/spawning/spawnmarkers/SpawnMarkerSystems.java +++ b/src/com/hypixel/hytale/server/spawning/spawnmarkers/SpawnMarkerSystems.java @@ -55,6 +55,7 @@ import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import com.hypixel.hytale.server.flock.StoredFlock; import com.hypixel.hytale.server.npc.components.SpawnMarkerReference; import com.hypixel.hytale.server.npc.entities.NPCEntity; +import com.hypixel.hytale.server.npc.role.Role; import com.hypixel.hytale.server.spawning.assets.spawnmarker.config.SpawnMarker; import it.unimi.dsi.fastutil.Pair; import it.unimi.dsi.fastutil.objects.ObjectArrayList; @@ -68,20 +69,19 @@ import javax.annotation.Nullable; import org.bson.BsonDocument; public class SpawnMarkerSystems { + @Nonnull private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass(); - public SpawnMarkerSystems() { - } - public static class AddedFromWorldGen extends HolderSystem { + @Nonnull private final ComponentType componentType = SpawnMarkerEntity.getComponentType(); + @Nonnull private final ComponentType worldGenIdComponentType = WorldGenId.getComponentType(); + @Nonnull private final ComponentType fromWorldGenComponentType = FromWorldGen.getComponentType(); + @Nonnull private final Query query = Query.and(this.componentType, this.fromWorldGenComponentType); - public AddedFromWorldGen() { - } - @Nonnull @Override public Query getQuery() { @@ -96,7 +96,11 @@ public class SpawnMarkerSystems { @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { - holder.putComponent(this.worldGenIdComponentType, new WorldGenId(holder.getComponent(this.fromWorldGenComponentType).getWorldGenId())); + FromWorldGen fromWorldGenComponent = holder.getComponent(this.fromWorldGenComponentType); + + assert fromWorldGenComponent != null; + + holder.putComponent(this.worldGenIdComponentType, new WorldGenId(fromWorldGenComponent.getWorldGenId())); } @Override @@ -105,28 +109,33 @@ public class SpawnMarkerSystems { } public static class CacheMarker extends RefSystem { - private final ComponentType componentType; + private final ComponentType spawnMarkerComponentType; - public CacheMarker(ComponentType componentType) { - this.componentType = componentType; + public CacheMarker(@Nonnull ComponentType spawnMarkerComponentType) { + this.spawnMarkerComponentType = spawnMarkerComponentType; } @Override public Query getQuery() { - return this.componentType; + return this.spawnMarkerComponentType; } @Override public void onEntityAdded( @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { - SpawnMarkerEntity entity = store.getComponent(ref, this.componentType); - SpawnMarker marker = SpawnMarker.getAssetMap().getAsset(entity.getSpawnMarkerId()); - if (marker == null) { - SpawnMarkerSystems.LOGGER.at(Level.SEVERE).log("Marker %s removed due to missing spawn marker type: %s", ref, entity.getSpawnMarkerId()); + SpawnMarkerEntity spawnMarkerEntityComponent = store.getComponent(ref, this.spawnMarkerComponentType); + + assert spawnMarkerEntityComponent != null; + + SpawnMarker spawnMarker = SpawnMarker.getAssetMap().getAsset(spawnMarkerEntityComponent.getSpawnMarkerId()); + if (spawnMarker == null) { + SpawnMarkerSystems.LOGGER + .at(Level.SEVERE) + .log("Marker %s removed due to missing spawn marker type: %s", ref, spawnMarkerEntityComponent.getSpawnMarkerId()); commandBuffer.removeEntity(ref, RemoveReason.REMOVE); } else { - entity.setCachedMarker(marker); + spawnMarkerEntityComponent.setCachedMarker(spawnMarker); } } @@ -138,15 +147,18 @@ public class SpawnMarkerSystems { } public static class EnsureNetworkSendable extends HolderSystem { + @Nonnull private final Query query = SpawnMarkerEntity.getComponentType(); - public EnsureNetworkSendable() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { - if (!holder.getArchetype().contains(NetworkId.getComponentType())) { - holder.addComponent(NetworkId.getComponentType(), new NetworkId(store.getExternalData().takeNextNetworkId())); + Archetype archetype = holder.getArchetype(); + + assert archetype != null; + + ComponentType networkIdComponentType = NetworkId.getComponentType(); + if (!archetype.contains(networkIdComponentType)) { + holder.addComponent(networkIdComponentType, new NetworkId(store.getExternalData().takeNextNetworkId())); } holder.ensureComponent(Intangible.getComponentType()); @@ -156,6 +168,7 @@ public class SpawnMarkerSystems { public void onEntityRemoved(@Nonnull Holder holder, @Nonnull RemoveReason reason, @Nonnull Store store) { } + @Nonnull @Override public Query getQuery() { return this.query; @@ -163,7 +176,8 @@ public class SpawnMarkerSystems { } public static class EntityAdded extends RefSystem { - private final ComponentType componentType; + @Nonnull + private final ComponentType spawnMarkerEntityComponentType; @Nonnull private final ComponentType uuidComponentType; @Nonnull @@ -171,11 +185,11 @@ public class SpawnMarkerSystems { @Nonnull private final Query query; - public EntityAdded(ComponentType componentType) { - this.componentType = componentType; + public EntityAdded(@Nonnull ComponentType spawnMarkerEntityComponentType) { + this.spawnMarkerEntityComponentType = spawnMarkerEntityComponentType; this.uuidComponentType = UUIDComponent.getComponentType(); this.dependencies = Set.of(new SystemDependency<>(Order.AFTER, SpawnMarkerSystems.CacheMarker.class)); - this.query = Query.and(componentType, this.uuidComponentType); + this.query = Query.and(spawnMarkerEntityComponentType, this.uuidComponentType); } @Nonnull @@ -194,18 +208,21 @@ public class SpawnMarkerSystems { public void onEntityAdded( @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { - SpawnMarkerEntity entity = store.getComponent(ref, this.componentType); + SpawnMarkerEntity spawnMarkerEntityComponent = store.getComponent(ref, this.spawnMarkerEntityComponentType); + + assert spawnMarkerEntityComponent != null; + HytaleLogger.Api context = SpawnMarkerSystems.LOGGER.at(Level.FINE); if (context.isEnabled()) { context.log("Loaded marker %s", store.getComponent(ref, this.uuidComponentType)); } - if (entity.getStoredFlock() != null) { - entity.setTempStorageList(new ObjectArrayList<>()); + if (spawnMarkerEntityComponent.getStoredFlock() != null) { + spawnMarkerEntityComponent.setTempStorageList(new ObjectArrayList<>()); } - if (entity.getSpawnCount() != 0) { - entity.refreshTimeout(); + if (spawnMarkerEntityComponent.getSpawnCount() != 0) { + spawnMarkerEntityComponent.refreshTimeout(); } commandBuffer.ensureComponent(ref, PrefabCopyableComponent.getComponentType()); @@ -221,13 +238,14 @@ public class SpawnMarkerSystems { public static class EntityAddedFromExternal extends RefSystem { @Nonnull private final Query query; - private final ComponentType componentType; + @Nonnull + private final ComponentType spawnMarkerEntityComponentType; @Nonnull private final Set> dependencies; - public EntityAddedFromExternal(ComponentType componentType) { - this.query = Query.and(componentType, Query.or(FromPrefab.getComponentType(), FromWorldGen.getComponentType())); - this.componentType = componentType; + public EntityAddedFromExternal(@Nonnull ComponentType spawnMarkerEntityComponentType) { + this.query = Query.and(spawnMarkerEntityComponentType, Query.or(FromPrefab.getComponentType(), FromWorldGen.getComponentType())); + this.spawnMarkerEntityComponentType = spawnMarkerEntityComponentType; this.dependencies = Set.of( new SystemDependency<>(Order.BEFORE, SpawnMarkerSystems.EntityAdded.class), new SystemDependency<>(Order.AFTER, SpawnMarkerSystems.CacheMarker.class) @@ -238,13 +256,16 @@ public class SpawnMarkerSystems { public void onEntityAdded( @Nonnull Ref ref, @Nonnull AddReason reason, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { - SpawnMarkerEntity entity = store.getComponent(ref, this.componentType); - entity.setSpawnCount(0); - entity.setRespawnCounter(0.0); - entity.setSpawnAfter(null); - entity.setGameTimeRespawn(null); - if (entity.getCachedMarker().getDeactivationDistance() > 0.0) { - entity.setStoredFlock(new StoredFlock()); + SpawnMarkerEntity spawnMarkerEntityComponent = store.getComponent(ref, this.spawnMarkerEntityComponentType); + + assert spawnMarkerEntityComponent != null; + + spawnMarkerEntityComponent.setSpawnCount(0); + spawnMarkerEntityComponent.setRespawnCounter(0.0); + spawnMarkerEntityComponent.setSpawnAfter(null); + spawnMarkerEntityComponent.setGameTimeRespawn(null); + if (spawnMarkerEntityComponent.getCachedMarker().getDeactivationDistance() > 0.0) { + spawnMarkerEntityComponent.setStoredFlock(new StoredFlock()); } } @@ -275,37 +296,47 @@ public class SpawnMarkerSystems { @Deprecated(forRemoval = true) public static class LegacyEntityMigration extends EntityModule.MigrationSystem { + @Nonnull private final ComponentType persistentModelComponentType = PersistentModel.getComponentType(); + @Nonnull private final ComponentType nameplateComponentType = Nameplate.getComponentType(); + @Nonnull private final ComponentType uuidComponentType = UUIDComponent.getComponentType(); + @Nonnull private final ComponentType> unknownComponentsComponentType = EntityStore.REGISTRY.getUnknownComponentType(); + @Nonnull private final Query query = Query.and(this.unknownComponentsComponentType, Query.not(AllLegacyEntityTypesQuery.INSTANCE)); - public LegacyEntityMigration() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { - Map unknownComponents = holder.getComponent(this.unknownComponentsComponentType).getUnknownComponents(); + UnknownComponents unknownComponentsComponent = holder.getComponent(this.unknownComponentsComponentType); + + assert unknownComponentsComponent != null; + + Map unknownComponents = unknownComponentsComponent.getUnknownComponents(); BsonDocument spawnMarker = unknownComponents.remove("SpawnMarker"); if (spawnMarker != null) { - if (!holder.getArchetype().contains(this.persistentModelComponentType)) { + Archetype archetype = holder.getArchetype(); + + assert archetype != null; + + if (!archetype.contains(this.persistentModelComponentType)) { Model.ModelReference modelReference = Entity.MODEL.get(spawnMarker).get(); holder.addComponent(this.persistentModelComponentType, new PersistentModel(modelReference)); } - if (!holder.getArchetype().contains(this.nameplateComponentType)) { + if (!archetype.contains(this.nameplateComponentType)) { holder.addComponent(this.nameplateComponentType, new Nameplate(Entity.DISPLAY_NAME.get(spawnMarker).get())); } - if (!holder.getArchetype().contains(this.uuidComponentType)) { + if (!archetype.contains(this.uuidComponentType)) { holder.addComponent(this.uuidComponentType, new UUIDComponent(Entity.UUID.get(spawnMarker).get())); } holder.ensureComponent(HiddenFromAdventurePlayers.getComponentType()); - int worldgenId = Codec.INTEGER.decode(spawnMarker.get("WorldgenId")); - if (worldgenId != 0) { - holder.addComponent(WorldGenId.getComponentType(), new WorldGenId(worldgenId)); + int worldGenId = Codec.INTEGER.decode(spawnMarker.get("WorldgenId")); + if (worldGenId != 0) { + holder.addComponent(WorldGenId.getComponentType(), new WorldGenId(worldGenId)); } SpawnMarkerEntity marker = SpawnMarkerEntity.CODEC.decode(spawnMarker, new ExtraInfo(5)); @@ -331,28 +362,35 @@ public class SpawnMarkerSystems { } public static class Ticking extends EntityTickingSystem { - private final ComponentType componentType; + @Nonnull + private final ComponentType spawnMarkerEntityComponentType; @Nullable private final ComponentType npcComponentType; + @Nonnull private final ComponentType referenceIdComponentType; + @Nonnull + private final ComponentType transformComponentType = TransformComponent.getComponentType(); + @Nonnull + private final ComponentType headRotationComponentType = HeadRotation.getComponentType(); + @Nonnull + private final ComponentType modelComponentType = ModelComponent.getComponentType(); + @Nonnull private final ResourceType, EntityStore>> playerSpatialComponent; @Nonnull private final Set> dependencies; + @Nonnull private final Query query; - private final ComponentType transformComponentType = TransformComponent.getComponentType(); - private final ComponentType headRotationComponentType = HeadRotation.getComponentType(); - private final ComponentType modelComponentType = ModelComponent.getComponentType(); public Ticking( - ComponentType componentType, - ResourceType, EntityStore>> playerSpatialComponent + @Nonnull ComponentType spawnMarkerEntityComponentType, + @Nonnull ResourceType, EntityStore>> playerSpatialComponent ) { - this.componentType = componentType; + this.spawnMarkerEntityComponentType = spawnMarkerEntityComponentType; this.npcComponentType = NPCEntity.getComponentType(); this.referenceIdComponentType = PersistentRefCount.getComponentType(); this.playerSpatialComponent = playerSpatialComponent; this.dependencies = Set.of(new SystemDependency<>(Order.AFTER, PlayerSpatialSystem.class, OrderPriority.CLOSEST)); - this.query = Archetype.of(componentType, this.transformComponentType); + this.query = Archetype.of(spawnMarkerEntityComponentType, this.transformComponentType); } @Nonnull @@ -361,6 +399,7 @@ public class SpawnMarkerSystems { return this.dependencies; } + @Nonnull @Override public Query getQuery() { return this.query; @@ -379,26 +418,32 @@ public class SpawnMarkerSystems { @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { - SpawnMarkerEntity entity = archetypeChunk.getComponent(index, this.componentType); - TransformComponent transform = archetypeChunk.getComponent(index, this.transformComponentType); + SpawnMarkerEntity spawnMarkerEntityComponent = archetypeChunk.getComponent(index, this.spawnMarkerEntityComponentType); + + assert spawnMarkerEntityComponent != null; + + TransformComponent transformComponent = archetypeChunk.getComponent(index, this.transformComponentType); + + assert transformComponent != null; + World world = store.getExternalData().getWorld(); - SpawnMarker cachedMarker = entity.getCachedMarker(); - if (entity.getSpawnCount() > 0) { - StoredFlock storedFlock = entity.getStoredFlock(); + SpawnMarker cachedMarker = spawnMarkerEntityComponent.getCachedMarker(); + if (spawnMarkerEntityComponent.getSpawnCount() > 0) { + StoredFlock storedFlock = spawnMarkerEntityComponent.getStoredFlock(); if (storedFlock != null) { SpatialResource, EntityStore> spatialResource = store.getResource(this.playerSpatialComponent); ObjectList> results = SpatialResource.getThreadLocalReferenceList(); - spatialResource.getSpatialStructure().collect(transform.getPosition(), cachedMarker.getDeactivationDistance(), results); + spatialResource.getSpatialStructure().collect(transformComponent.getPosition(), cachedMarker.getDeactivationDistance(), results); boolean hasPlayersInRange = !results.isEmpty(); if (!hasPlayersInRange) { - if (!storedFlock.hasStoredNPCs() && entity.tickTimeToDeactivation(dt)) { - InvalidatablePersistentRef[] npcReferences = entity.getNpcReferences(); + if (!storedFlock.hasStoredNPCs() && spawnMarkerEntityComponent.tickTimeToDeactivation(dt)) { + InvalidatablePersistentRef[] npcReferences = spawnMarkerEntityComponent.getNpcReferences(); if (npcReferences == null) { return; } - if (!entity.isDespawnStarted()) { - List, NPCEntity>> tempStorageList = entity.getTempStorageList(); + if (!spawnMarkerEntityComponent.isDespawnStarted()) { + List, NPCEntity>> tempStorageList = spawnMarkerEntityComponent.getTempStorageList(); for (InvalidatablePersistentRef reference : npcReferences) { Ref npcRef = reference.getEntity(commandBuffer); @@ -410,7 +455,7 @@ public class SpawnMarkerSystems { tempStorageList.add(Pair.of(npcRef, npcComponent)); boolean isDead = commandBuffer.getArchetype(npcRef).contains(DeathComponent.getComponentType()); if (isDead || npcComponent.getRole().getStateSupport().isInBusyState()) { - entity.setTimeToDeactivation(cachedMarker.getDeactivationTime()); + spawnMarkerEntityComponent.setTimeToDeactivation(cachedMarker.getDeactivationTime()); tempStorageList.clear(); return; } @@ -423,16 +468,20 @@ public class SpawnMarkerSystems { NPCEntity npcComponentx = npcPair.second(); ModelComponent modelComponent = commandBuffer.getComponent(npcRef, this.modelComponentType); if (modelComponent != null && modelComponent.getModel().getAnimationSetMap().containsKey("Despawn")) { - double despawnAnimationTime = npcComponentx.getRole().getDespawnAnimationTime(); - if (despawnAnimationTime > entity.getTimeToDeactivation()) { - entity.setTimeToDeactivation(despawnAnimationTime); + Role role = npcComponentx.getRole(); + + assert role != null; + + double despawnAnimationTime = role.getDespawnAnimationTime(); + if (despawnAnimationTime > spawnMarkerEntityComponent.getTimeToDeactivation()) { + spawnMarkerEntityComponent.setTimeToDeactivation(despawnAnimationTime); } npcComponentx.playAnimation(npcRef, AnimationSlot.Status, "Despawn", commandBuffer); } } - entity.setDespawnStarted(true); + spawnMarkerEntityComponent.setDespawnStarted(true); tempStorageList.clear(); return; } @@ -449,19 +498,19 @@ public class SpawnMarkerSystems { for (InvalidatablePersistentRef referencex : npcReferences) { Ref npcRef = referencex.getEntity(_store); - if (npcRef == null) { - SpawnMarkerSystems.LOGGER - .atWarning() - .log("Connection with NPC from marker at %s lost due to being invalid/already unloaded", transform.getPosition()); - } else { + if (npcRef != null && npcRef.isValid()) { SpawnMarkerReference spawnMarkerReference = _store.ensureAndGetComponent(npcRef, SpawnMarkerReference.getComponentType()); spawnMarkerReference.getReference().setEntity(ref, store); tempStorageList.add(npcRef); + } else { + SpawnMarkerSystems.LOGGER + .atWarning() + .log("Connection with NPC from marker at %s lost due to being invalid/already unloaded", transformComponent.getPosition()); } } storedFlock.storeNPCs(tempStorageList, _store); - entity.setNpcReferences(null); + spawnMarkerEntityComponent.setNpcReferences(null); } ); } @@ -473,34 +522,43 @@ public class SpawnMarkerSystems { commandBuffer.run(_store -> { ObjectList> tempStorageList = SpatialResource.getThreadLocalReferenceList(); storedFlock.restoreNPCs(tempStorageList, _store); - entity.setSpawnCount(tempStorageList.size()); - Vector3d position = entity.getSpawnPosition(); - Vector3f rotation = transform.getRotation(); + spawnMarkerEntityComponent.setSpawnCount(tempStorageList.size()); + Vector3d position = spawnMarkerEntityComponent.getSpawnPosition(); + Vector3f rotation = transformComponent.getRotation(); InvalidatablePersistentRef[] npcReferencesx = new InvalidatablePersistentRef[tempStorageList.size()]; int ix = 0; for (int bound = tempStorageList.size(); ix < bound; ix++) { Ref refx = tempStorageList.get(ix); - NPCEntity npc = _store.getComponent(refx, this.npcComponentType); + NPCEntity npcComponentx = _store.getComponent(refx, this.npcComponentType); + + assert npcComponentx != null; + TransformComponent npcTransform = _store.getComponent(refx, this.transformComponentType); + + assert npcTransform != null; + HeadRotation npcHeadRotation = _store.getComponent(refx, this.headRotationComponentType); + + assert npcHeadRotation != null; + InvalidatablePersistentRef referencex = new InvalidatablePersistentRef(); referencex.setEntity(refx, _store); npcReferencesx[ix] = referencex; npcTransform.getPosition().assign(position); npcTransform.getRotation().assign(rotation); npcHeadRotation.setRotation(rotation); - npc.playAnimation(refx, AnimationSlot.Status, null, commandBuffer); + npcComponentx.playAnimation(refx, AnimationSlot.Status, null, commandBuffer); } - entity.setNpcReferences(npcReferencesx); - entity.setDespawnStarted(false); - entity.setTimeToDeactivation(cachedMarker.getDeactivationTime()); + spawnMarkerEntityComponent.setNpcReferences(npcReferencesx); + spawnMarkerEntityComponent.setDespawnStarted(false); + spawnMarkerEntityComponent.setTimeToDeactivation(cachedMarker.getDeactivationTime()); }); } } - if (entity.tickSpawnLostTimeout(dt)) { + if (spawnMarkerEntityComponent.tickSpawnLostTimeout(dt)) { PersistentRefCount refId = archetypeChunk.getComponent(index, this.referenceIdComponentType); if (refId != null) { refId.increment(); @@ -508,19 +566,20 @@ public class SpawnMarkerSystems { } Ref ref = archetypeChunk.getReferenceTo(index); - commandBuffer.run(_store -> entity.spawnNPC(ref, cachedMarker, _store)); + commandBuffer.run(_store -> spawnMarkerEntityComponent.spawnNPC(ref, cachedMarker, _store)); } } else if (world.getWorldConfig().isSpawnMarkersEnabled() && !cachedMarker.isManualTrigger() - && (entity.getSuppressedBy() == null || entity.getSuppressedBy().isEmpty())) { + && (spawnMarkerEntityComponent.getSuppressedBy() == null || spawnMarkerEntityComponent.getSuppressedBy().isEmpty())) { Ref ref = archetypeChunk.getReferenceTo(index); WorldTimeResource worldTimeResource = commandBuffer.getResource(WorldTimeResource.getResourceType()); if (cachedMarker.isRealtimeRespawn()) { - if (entity.tickRespawnTimer(dt)) { - commandBuffer.run(_store -> entity.spawnNPC(ref, cachedMarker, _store)); + if (spawnMarkerEntityComponent.tickRespawnTimer(dt)) { + commandBuffer.run(_store -> spawnMarkerEntityComponent.spawnNPC(ref, cachedMarker, _store)); } - } else if (entity.getSpawnAfter() == null || worldTimeResource.getGameTime().isAfter(entity.getSpawnAfter())) { - commandBuffer.run(_store -> entity.spawnNPC(ref, cachedMarker, _store)); + } else if (spawnMarkerEntityComponent.getSpawnAfter() == null + || worldTimeResource.getGameTime().isAfter(spawnMarkerEntityComponent.getSpawnAfter())) { + commandBuffer.run(_store -> spawnMarkerEntityComponent.spawnNPC(ref, cachedMarker, _store)); } } } diff --git a/src/com/hypixel/hytale/server/spawning/suppression/SuppressionSpanHelper.java b/src/com/hypixel/hytale/server/spawning/suppression/SuppressionSpanHelper.java index 7cbdb30..686a76a 100644 --- a/src/com/hypixel/hytale/server/spawning/suppression/SuppressionSpanHelper.java +++ b/src/com/hypixel/hytale/server/spawning/suppression/SuppressionSpanHelper.java @@ -12,9 +12,6 @@ public class SuppressionSpanHelper { private final List optimisedSuppressionSpans = new ObjectArrayList<>(); private int currentSpanIndex = 0; - public SuppressionSpanHelper() { - } - public void optimiseSuppressedSpans(int roleIndex, @Nullable ChunkSuppressionEntry entry) { if (entry != null) { ArrayDeque spanPool = SPAN_POOL.get(); @@ -112,9 +109,6 @@ public class SuppressionSpanHelper { private int min = -1; private int max = -1; - private Span() { - } - public void init(int min, int max) { this.min = min; this.max = max; diff --git a/src/com/hypixel/hytale/server/spawning/suppression/component/ChunkSuppressionQueue.java b/src/com/hypixel/hytale/server/spawning/suppression/component/ChunkSuppressionQueue.java index d1c52a7..7302c89 100644 --- a/src/com/hypixel/hytale/server/spawning/suppression/component/ChunkSuppressionQueue.java +++ b/src/com/hypixel/hytale/server/spawning/suppression/component/ChunkSuppressionQueue.java @@ -15,9 +15,6 @@ public class ChunkSuppressionQueue implements Resource { private final List, ChunkSuppressionEntry>> toAdd = new ObjectArrayList<>(); private final List> toRemove = new ObjectArrayList<>(); - public ChunkSuppressionQueue() { - } - public static ResourceType getResourceType() { return SpawningPlugin.get().getChunkSuppressionQueueResourceType(); } diff --git a/src/com/hypixel/hytale/server/spawning/suppression/component/SpawnSuppressionController.java b/src/com/hypixel/hytale/server/spawning/suppression/component/SpawnSuppressionController.java index 51e99c3..cd886f8 100644 --- a/src/com/hypixel/hytale/server/spawning/suppression/component/SpawnSuppressionController.java +++ b/src/com/hypixel/hytale/server/spawning/suppression/component/SpawnSuppressionController.java @@ -31,9 +31,6 @@ public class SpawnSuppressionController implements Resource { ); private Map spawnSuppressorMap = new ConcurrentHashMap<>(); - public SpawnSuppressionController() { - } - public static ResourceType getResourceType() { return SpawningPlugin.get().getSpawnSuppressionControllerResourceType(); } diff --git a/src/com/hypixel/hytale/server/spawning/suppression/system/ChunkSuppressionSystems.java b/src/com/hypixel/hytale/server/spawning/suppression/system/ChunkSuppressionSystems.java index 91dd9d4..8ed36fc 100644 --- a/src/com/hypixel/hytale/server/spawning/suppression/system/ChunkSuppressionSystems.java +++ b/src/com/hypixel/hytale/server/spawning/suppression/system/ChunkSuppressionSystems.java @@ -24,9 +24,6 @@ import java.util.logging.Level; import javax.annotation.Nonnull; public class ChunkSuppressionSystems { - public ChunkSuppressionSystems() { - } - public static class ChunkAdded extends RefSystem { private static final ComponentType COMPONENT_TYPE = BlockChunk.getComponentType(); private final ComponentType chunkSuppressionEntryComponentType; diff --git a/src/com/hypixel/hytale/server/spawning/suppression/system/SpawnSuppressionSystems.java b/src/com/hypixel/hytale/server/spawning/suppression/system/SpawnSuppressionSystems.java index cb45739..d3096a1 100644 --- a/src/com/hypixel/hytale/server/spawning/suppression/system/SpawnSuppressionSystems.java +++ b/src/com/hypixel/hytale/server/spawning/suppression/system/SpawnSuppressionSystems.java @@ -60,9 +60,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class SpawnSuppressionSystems { - public SpawnSuppressionSystems() { - } - private static void suppressSpawns( @Nonnull ResourceType chunkSuppressionQueueResourceType, @Nonnull ComponentType spawnMarkerEntityComponentType, @@ -149,9 +146,6 @@ public class SpawnSuppressionSystems { public static class EnsureNetworkSendable extends HolderSystem { private final Query query = Query.and(SpawnSuppressionComponent.getComponentType(), Query.not(NetworkId.getComponentType())); - public EnsureNetworkSendable() { - } - @Override public void onEntityAdd(@Nonnull Holder holder, @Nonnull AddReason reason, @Nonnull Store store) { holder.addComponent(NetworkId.getComponentType(), new NetworkId(store.getExternalData().takeNextNetworkId())); diff --git a/src/com/hypixel/hytale/server/spawning/util/ChunkColumnMask.java b/src/com/hypixel/hytale/server/spawning/util/ChunkColumnMask.java index eec79c6..68c608d 100644 --- a/src/com/hypixel/hytale/server/spawning/util/ChunkColumnMask.java +++ b/src/com/hypixel/hytale/server/spawning/util/ChunkColumnMask.java @@ -9,9 +9,6 @@ public class ChunkColumnMask { public static final int COLUMNS = 1024; private final BitSet columns = new BitSet(1024); - public ChunkColumnMask() { - } - public void copyFrom(@Nonnull ChunkColumnMask src) { BitSetUtil.copyValues(src.columns, this.columns); } diff --git a/src/com/hypixel/hytale/server/spawning/util/FloodFillEntryPoolProviderSimple.java b/src/com/hypixel/hytale/server/spawning/util/FloodFillEntryPoolProviderSimple.java index 6f914c2..b6aea59 100644 --- a/src/com/hypixel/hytale/server/spawning/util/FloodFillEntryPoolProviderSimple.java +++ b/src/com/hypixel/hytale/server/spawning/util/FloodFillEntryPoolProviderSimple.java @@ -10,9 +10,6 @@ public class FloodFillEntryPoolProviderSimple implements Resource { @Nonnull private final FloodFillEntryPoolSimple pool = new FloodFillEntryPoolSimple(); - public FloodFillEntryPoolProviderSimple() { - } - public static ResourceType getResourceType() { return SpawningPlugin.get().getFloodFillEntryPoolProviderSimpleResourceType(); } diff --git a/src/com/hypixel/hytale/server/spawning/util/FloodFillEntryPoolSimple.java b/src/com/hypixel/hytale/server/spawning/util/FloodFillEntryPoolSimple.java index 6a2abd6..04bd9ca 100644 --- a/src/com/hypixel/hytale/server/spawning/util/FloodFillEntryPoolSimple.java +++ b/src/com/hypixel/hytale/server/spawning/util/FloodFillEntryPoolSimple.java @@ -7,9 +7,6 @@ public class FloodFillEntryPoolSimple { private static final int ENTRY_SIZE = 5; private final List entryPool = new ObjectArrayList<>(); - public FloodFillEntryPoolSimple() { - } - public int[] allocate() { return this.entryPool.isEmpty() ? new int[5] : this.entryPool.removeLast(); } diff --git a/src/com/hypixel/hytale/server/spawning/util/FloodFillPositionSelector.java b/src/com/hypixel/hytale/server/spawning/util/FloodFillPositionSelector.java index 4b49f96..ec79b6b 100644 --- a/src/com/hypixel/hytale/server/spawning/util/FloodFillPositionSelector.java +++ b/src/com/hypixel/hytale/server/spawning/util/FloodFillPositionSelector.java @@ -659,17 +659,11 @@ public class FloodFillPositionSelector implements Component { DISABLED, IRREGULARITIES, ALL; - - private Debug() { - } } public static class SortBufferProvider { protected FloodFillPositionSelector.WeightedPosition[] buffer = new FloodFillPositionSelector.WeightedPosition[10]; - public SortBufferProvider() { - } - public FloodFillPositionSelector.WeightedPosition[] getBuffer(int size) { if (size <= this.buffer.length) { return this.buffer; diff --git a/src/com/hypixel/hytale/server/spawning/util/LightRangePredicate.java b/src/com/hypixel/hytale/server/spawning/util/LightRangePredicate.java index b95317f..fe5d9e7 100644 --- a/src/com/hypixel/hytale/server/spawning/util/LightRangePredicate.java +++ b/src/com/hypixel/hytale/server/spawning/util/LightRangePredicate.java @@ -33,9 +33,6 @@ public class LightRangePredicate { private boolean testGreenLightValue; private boolean testBlueLightValue; - public LightRangePredicate() { - } - public static int lightToPrecentage(byte light) { return MathUtil.fastRound(light * 100.0F / 15.0F); } diff --git a/src/com/hypixel/hytale/server/spawning/world/ChunkEnvironmentSpawnData.java b/src/com/hypixel/hytale/server/spawning/world/ChunkEnvironmentSpawnData.java index 1932e8d..9a46c8d 100644 --- a/src/com/hypixel/hytale/server/spawning/world/ChunkEnvironmentSpawnData.java +++ b/src/com/hypixel/hytale/server/spawning/world/ChunkEnvironmentSpawnData.java @@ -17,9 +17,6 @@ public class ChunkEnvironmentSpawnData { private int segmentCount; private double expectedNPCs; - public ChunkEnvironmentSpawnData() { - } - public double getExpectedNPCs() { return this.expectedNPCs; } diff --git a/src/com/hypixel/hytale/server/spawning/world/component/ChunkSpawnData.java b/src/com/hypixel/hytale/server/spawning/world/component/ChunkSpawnData.java index 81d8b54..e4611be 100644 --- a/src/com/hypixel/hytale/server/spawning/world/component/ChunkSpawnData.java +++ b/src/com/hypixel/hytale/server/spawning/world/component/ChunkSpawnData.java @@ -14,9 +14,6 @@ public class ChunkSpawnData implements Component { private boolean started; private long lastSpawn; - public ChunkSpawnData() { - } - public static ComponentType getComponentType() { return SpawningPlugin.get().getChunkSpawnDataComponentType(); } diff --git a/src/com/hypixel/hytale/server/spawning/world/component/ChunkSpawnedNPCData.java b/src/com/hypixel/hytale/server/spawning/world/component/ChunkSpawnedNPCData.java index 97b38a3..8f4cfd3 100644 --- a/src/com/hypixel/hytale/server/spawning/world/component/ChunkSpawnedNPCData.java +++ b/src/com/hypixel/hytale/server/spawning/world/component/ChunkSpawnedNPCData.java @@ -43,9 +43,6 @@ public class ChunkSpawnedNPCData implements Component { .build(); private final Int2DoubleMap environmentSpawnCounts = new Int2DoubleOpenHashMap(); - public ChunkSpawnedNPCData() { - } - public static ComponentType getComponentType() { return SpawningPlugin.get().getChunkSpawnedNPCDataComponentType(); } diff --git a/src/com/hypixel/hytale/server/spawning/world/component/WorldSpawnData.java b/src/com/hypixel/hytale/server/spawning/world/component/WorldSpawnData.java index 1fe1f77..59f5a1b 100644 --- a/src/com/hypixel/hytale/server/spawning/world/component/WorldSpawnData.java +++ b/src/com/hypixel/hytale/server/spawning/world/component/WorldSpawnData.java @@ -38,9 +38,6 @@ public class WorldSpawnData implements Resource { private int totalSpawnJobsCompleted; private final SpiralIterator spiralIterator = new SpiralIterator(); - public WorldSpawnData() { - } - public static ResourceType getResourceType() { return SpawningPlugin.get().getWorldSpawnDataResourceType(); } diff --git a/src/com/hypixel/hytale/server/spawning/world/system/ChunkSpawningSystems.java b/src/com/hypixel/hytale/server/spawning/world/system/ChunkSpawningSystems.java index 32b6bce..bfda40c 100644 --- a/src/com/hypixel/hytale/server/spawning/world/system/ChunkSpawningSystems.java +++ b/src/com/hypixel/hytale/server/spawning/world/system/ChunkSpawningSystems.java @@ -37,9 +37,6 @@ public class ChunkSpawningSystems { private static final Query QUERY = Archetype.of(WorldChunk.getComponentType(), ChunkSpawnData.getComponentType()); private static final Query TICKING_QUERY = Query.and(Query.not(ChunkStore.REGISTRY.getNonTickingComponentType()), QUERY); - public ChunkSpawningSystems() { - } - protected static boolean processStoppedChunk( @Nonnull Ref ref, @Nonnull Store store, diff --git a/src/com/hypixel/hytale/server/spawning/world/system/WorldSpawnJobSystems.java b/src/com/hypixel/hytale/server/spawning/world/system/WorldSpawnJobSystems.java index 3c6f4c2..c166e31 100644 --- a/src/com/hypixel/hytale/server/spawning/world/system/WorldSpawnJobSystems.java +++ b/src/com/hypixel/hytale/server/spawning/world/system/WorldSpawnJobSystems.java @@ -57,9 +57,6 @@ public class WorldSpawnJobSystems { private static final Query TICKING_QUERY = Query.and(Query.not(ChunkStore.REGISTRY.getNonTickingComponentType()), QUERY); private static final int JOB_BUDGET = 64; - public WorldSpawnJobSystems() { - } - @Nonnull private static WorldSpawnJobSystems.Result run( @Nonnull SpawnJobData spawnJobData, @@ -402,9 +399,6 @@ public class WorldSpawnJobSystems { FAILED, TRY_AGAIN, PERMANENT_FAILURE; - - private Result() { - } } public static class Ticking extends EntityTickingSystem { diff --git a/src/com/hypixel/hytale/server/worldgen/HytaleWorldGenProvider.java b/src/com/hypixel/hytale/server/worldgen/HytaleWorldGenProvider.java index 06730c0..87e9ce7 100644 --- a/src/com/hypixel/hytale/server/worldgen/HytaleWorldGenProvider.java +++ b/src/com/hypixel/hytale/server/worldgen/HytaleWorldGenProvider.java @@ -29,9 +29,6 @@ public class HytaleWorldGenProvider implements IWorldGenProvider { private String name = "Default"; private String path; - public HytaleWorldGenProvider() { - } - @Nonnull @Override public IWorldGen getGenerator() throws WorldGenLoadException { diff --git a/src/com/hypixel/hytale/server/worldgen/SeedStringResource.java b/src/com/hypixel/hytale/server/worldgen/SeedStringResource.java index b119a68..29cb35a 100644 --- a/src/com/hypixel/hytale/server/worldgen/SeedStringResource.java +++ b/src/com/hypixel/hytale/server/worldgen/SeedStringResource.java @@ -9,7 +9,10 @@ import com.hypixel.hytale.server.worldgen.loader.prefab.BlockPlacementMaskRegist import com.hypixel.hytale.server.worldgen.loader.util.FileMaskCache; import com.hypixel.hytale.server.worldgen.prefab.PrefabStoreRoot; import com.hypixel.hytale.server.worldgen.util.LogUtil; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import java.nio.file.Path; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Level; import javax.annotation.Nonnull; @@ -22,12 +25,20 @@ public class SeedStringResource implements SeedResource { protected Path dataFolder; @Nonnull protected WorldGenPrefabLoader loader; + @Nonnull + protected final Map uniqueIds; public SeedStringResource(@Nonnull PrefabStoreRoot prefabStore, @Nonnull Path dataFolder) { this.dataFolder = dataFolder; this.loader = new WorldGenPrefabLoader(prefabStore, dataFolder); this.biomeMaskRegistry = new FileMaskCache<>(); this.blockMaskRegistry = new BlockPlacementMaskRegistry(); + this.uniqueIds = new Object2ObjectOpenHashMap<>(); + } + + @Nonnull + public String getUniqueName(@Nonnull String prefix) { + return prefix + this.uniqueIds.computeIfAbsent(prefix, k -> new AtomicInteger(0)).getAndIncrement(); } public WorldGenPrefabLoader getLoader() { diff --git a/src/com/hypixel/hytale/server/worldgen/benchmark/ChunkWorldgenBenchmark.java b/src/com/hypixel/hytale/server/worldgen/benchmark/ChunkWorldgenBenchmark.java index 908ad3d..4835a6f 100644 --- a/src/com/hypixel/hytale/server/worldgen/benchmark/ChunkWorldgenBenchmark.java +++ b/src/com/hypixel/hytale/server/worldgen/benchmark/ChunkWorldgenBenchmark.java @@ -15,9 +15,6 @@ public class ChunkWorldgenBenchmark implements IWorldGenBenchmark { private final ConcurrentHashMap caveNodeCounts = new ConcurrentHashMap<>(); private boolean enabled = false; - public ChunkWorldgenBenchmark() { - } - @Override public void start() { this.enabled = true; diff --git a/src/com/hypixel/hytale/server/worldgen/biome/BiomeInterpolation.java b/src/com/hypixel/hytale/server/worldgen/biome/BiomeInterpolation.java index 9ca464d..312b77f 100644 --- a/src/com/hypixel/hytale/server/worldgen/biome/BiomeInterpolation.java +++ b/src/com/hypixel/hytale/server/worldgen/biome/BiomeInterpolation.java @@ -45,9 +45,6 @@ public class BiomeInterpolation { } protected static class EmptyInt2IntMap extends EmptyMap { - protected EmptyInt2IntMap() { - } - @Override public int defaultReturnValue() { return 25; diff --git a/src/com/hypixel/hytale/server/worldgen/cache/InterpolatedBiomeCountList.java b/src/com/hypixel/hytale/server/worldgen/cache/InterpolatedBiomeCountList.java index f3ce0cd..9b0341f 100644 --- a/src/com/hypixel/hytale/server/worldgen/cache/InterpolatedBiomeCountList.java +++ b/src/com/hypixel/hytale/server/worldgen/cache/InterpolatedBiomeCountList.java @@ -16,9 +16,6 @@ public class InterpolatedBiomeCountList { private final IntList biomeIds = new IntArrayList(); private Biome center; - public InterpolatedBiomeCountList() { - } - public InterpolatedBiomeCountList.BiomeCountResult get(@Nonnull Biome biome) { return this.get(biome.getId()); } diff --git a/src/com/hypixel/hytale/server/worldgen/cave/CaveBiomeMaskFlags.java b/src/com/hypixel/hytale/server/worldgen/cave/CaveBiomeMaskFlags.java index fe00b0c..c7aa2ea 100644 --- a/src/com/hypixel/hytale/server/worldgen/cave/CaveBiomeMaskFlags.java +++ b/src/com/hypixel/hytale/server/worldgen/cave/CaveBiomeMaskFlags.java @@ -10,9 +10,6 @@ public class CaveBiomeMaskFlags { public static final int POPULATE = 2; public static final int CONTINUE = 4; - public CaveBiomeMaskFlags() { - } - public static boolean canGenerate(int value) { return test(value, 1); } @@ -33,8 +30,5 @@ public class CaveBiomeMaskFlags { public static final int DEFAULT_RESULT = 4; public static final int DISALLOW_ALL = 0; public static final int ALLOW_ALL = 7; - - public Defaults() { - } } } diff --git a/src/com/hypixel/hytale/server/worldgen/cave/CaveBlockPriorityModifier.java b/src/com/hypixel/hytale/server/worldgen/cave/CaveBlockPriorityModifier.java index 9ba7488..cf53f39 100644 --- a/src/com/hypixel/hytale/server/worldgen/cave/CaveBlockPriorityModifier.java +++ b/src/com/hypixel/hytale/server/worldgen/cave/CaveBlockPriorityModifier.java @@ -5,9 +5,6 @@ import com.hypixel.hytale.server.worldgen.chunk.BlockPriorityModifier; public class CaveBlockPriorityModifier implements BlockPriorityModifier { public static final BlockPriorityModifier INSTANCE = new CaveBlockPriorityModifier(); - public CaveBlockPriorityModifier() { - } - @Override public byte modifyCurrent(byte current, byte target) { if (current == 8 && target == 6) { diff --git a/src/com/hypixel/hytale/server/worldgen/cave/CaveYawMode.java b/src/com/hypixel/hytale/server/worldgen/cave/CaveYawMode.java index 750c35a..448258e 100644 --- a/src/com/hypixel/hytale/server/worldgen/cave/CaveYawMode.java +++ b/src/com/hypixel/hytale/server/worldgen/cave/CaveYawMode.java @@ -23,8 +23,5 @@ public enum CaveYawMode { } }; - private CaveYawMode() { - } - public abstract float combine(float var1, @Nullable PrefabRotation var2); } diff --git a/src/com/hypixel/hytale/server/worldgen/cave/shape/AbstractCaveNodeShape.java b/src/com/hypixel/hytale/server/worldgen/cave/shape/AbstractCaveNodeShape.java index 6f27de1..dc44a90 100644 --- a/src/com/hypixel/hytale/server/worldgen/cave/shape/AbstractCaveNodeShape.java +++ b/src/com/hypixel/hytale/server/worldgen/cave/shape/AbstractCaveNodeShape.java @@ -15,9 +15,6 @@ import java.util.Random; import javax.annotation.Nonnull; public abstract class AbstractCaveNodeShape implements CaveNodeShape { - public AbstractCaveNodeShape() { - } - @Override public void populateChunk(int seed, @Nonnull ChunkGeneratorExecution execution, @Nonnull Cave cave, @Nonnull CaveNode node, @Nonnull Random random) { GeneratedBlockChunk chunk = execution.getChunk(); @@ -73,7 +70,7 @@ public abstract class AbstractCaveNodeShape implements CaveNodeShape { boolean isCandidateBlock = !surfaceLimited || current != 0; if (isCandidateBlock) { BlockFluidEntry blockEntry = CaveNodeShapeUtils.getFillingBlock(caveType, caveNodeType, y, random); - if (caveType.getBlockMask().eval(current, currentFluid, blockEntry)) { + if (caveType.getBlockMask().eval(current, currentFluid, blockEntry.blockId(), blockEntry.fluidId())) { if (execution.setBlock(cx, y, cz, (byte)6, blockEntry, environment)) { if (y < lowest) { lowest = y; diff --git a/src/com/hypixel/hytale/server/worldgen/cave/shape/CaveNodeShapeEnum.java b/src/com/hypixel/hytale/server/worldgen/cave/shape/CaveNodeShapeEnum.java index e1a5056..2605825 100644 --- a/src/com/hypixel/hytale/server/worldgen/cave/shape/CaveNodeShapeEnum.java +++ b/src/com/hypixel/hytale/server/worldgen/cave/shape/CaveNodeShapeEnum.java @@ -14,9 +14,6 @@ public enum CaveNodeShapeEnum { ELLIPSOID, DISTORTED; - private CaveNodeShapeEnum() { - } - public interface CaveNodeShapeGenerator { CaveNodeShape generateCaveNodeShape( Random var1, CaveType var2, CaveNode var3, CaveNodeType.CaveNodeChildEntry var4, Vector3d var5, float var6, float var7 diff --git a/src/com/hypixel/hytale/server/worldgen/cave/shape/CaveNodeShapeUtils.java b/src/com/hypixel/hytale/server/worldgen/cave/shape/CaveNodeShapeUtils.java index e94fa0e..992b824 100644 --- a/src/com/hypixel/hytale/server/worldgen/cave/shape/CaveNodeShapeUtils.java +++ b/src/com/hypixel/hytale/server/worldgen/cave/shape/CaveNodeShapeUtils.java @@ -26,9 +26,6 @@ public class CaveNodeShapeUtils { public static final BiDoubleToDoubleFunction MIN = Math::min; public static final BiDoubleToDoubleFunction MAX = Math::max; - public CaveNodeShapeUtils() { - } - @Nonnull public static Vector3d getBoxAnchor(@Nonnull Vector3d vector, @Nonnull IWorldBounds bounds, double tx, double ty, double tz) { double x = bounds.fractionX(tx); diff --git a/src/com/hypixel/hytale/server/worldgen/cave/shape/DistortedCaveNodeShape.java b/src/com/hypixel/hytale/server/worldgen/cave/shape/DistortedCaveNodeShape.java index 2a90c1e..f2d4f79 100644 --- a/src/com/hypixel/hytale/server/worldgen/cave/shape/DistortedCaveNodeShape.java +++ b/src/com/hypixel/hytale/server/worldgen/cave/shape/DistortedCaveNodeShape.java @@ -175,7 +175,7 @@ public class DistortedCaveNodeShape implements CaveNodeShape { boolean isCandidateBlock = !surfaceLimited || current != 0; if (isCandidateBlock) { BlockFluidEntry blockEntry = CaveNodeShapeUtils.getFillingBlock(caveType, caveNodeType, y, random); - if (caveType.getBlockMask().eval(current, currentFluid, blockEntry)) { + if (caveType.getBlockMask().eval(current, currentFluid, blockEntry.blockId(), blockEntry.fluidId())) { if (execution.setBlock(cx, y, cz, (byte)6, blockEntry, environment)) { if (y < lowest) { lowest = y; diff --git a/src/com/hypixel/hytale/server/worldgen/cave/shape/TetrahedronCaveNodeShape.java b/src/com/hypixel/hytale/server/worldgen/cave/shape/TetrahedronCaveNodeShape.java index 7b96cf8..61f9160 100644 --- a/src/com/hypixel/hytale/server/worldgen/cave/shape/TetrahedronCaveNodeShape.java +++ b/src/com/hypixel/hytale/server/worldgen/cave/shape/TetrahedronCaveNodeShape.java @@ -154,9 +154,6 @@ public class TetrahedronCaveNodeShape extends AbstractCaveNodeShape implements I } public static class TetrahedronCaveNodeShapeGenerator implements CaveNodeShapeEnum.CaveNodeShapeGenerator { - public TetrahedronCaveNodeShapeGenerator() { - } - @Nonnull @Override public CaveNodeShape generateCaveNodeShape( diff --git a/src/com/hypixel/hytale/server/worldgen/cave/shape/distorted/AbstractDistortedBody.java b/src/com/hypixel/hytale/server/worldgen/cave/shape/distorted/AbstractDistortedBody.java index 0bd4433..bfcc449 100644 --- a/src/com/hypixel/hytale/server/worldgen/cave/shape/distorted/AbstractDistortedBody.java +++ b/src/com/hypixel/hytale/server/worldgen/cave/shape/distorted/AbstractDistortedBody.java @@ -84,9 +84,6 @@ public abstract class AbstractDistortedBody extends AbstractDistortedShape { } protected abstract static class Factory implements DistortedShape.Factory { - protected Factory() { - } - @Override public DistortedShape create( Vector3d origin, diff --git a/src/com/hypixel/hytale/server/worldgen/cave/shape/distorted/DistortedCylinderShape.java b/src/com/hypixel/hytale/server/worldgen/cave/shape/distorted/DistortedCylinderShape.java index 243cb83..6cbd58b 100644 --- a/src/com/hypixel/hytale/server/worldgen/cave/shape/distorted/DistortedCylinderShape.java +++ b/src/com/hypixel/hytale/server/worldgen/cave/shape/distorted/DistortedCylinderShape.java @@ -188,9 +188,6 @@ public class DistortedCylinderShape extends AbstractDistortedExtrusion { } public static class Factory implements DistortedShape.Factory { - public Factory() { - } - @Nonnull @Override public DistortedShape create( diff --git a/src/com/hypixel/hytale/server/worldgen/cave/shape/distorted/DistortedEllipsoidShape.java b/src/com/hypixel/hytale/server/worldgen/cave/shape/distorted/DistortedEllipsoidShape.java index 762469a..c5dab3d 100644 --- a/src/com/hypixel/hytale/server/worldgen/cave/shape/distorted/DistortedEllipsoidShape.java +++ b/src/com/hypixel/hytale/server/worldgen/cave/shape/distorted/DistortedEllipsoidShape.java @@ -128,9 +128,6 @@ public class DistortedEllipsoidShape extends AbstractDistortedBody { } public static class Factory extends AbstractDistortedBody.Factory { - public Factory() { - } - @Nonnull @Override protected DistortedShape createShape( diff --git a/src/com/hypixel/hytale/server/worldgen/cave/shape/distorted/DistortedPipeShape.java b/src/com/hypixel/hytale/server/worldgen/cave/shape/distorted/DistortedPipeShape.java index f452abe..1663585 100644 --- a/src/com/hypixel/hytale/server/worldgen/cave/shape/distorted/DistortedPipeShape.java +++ b/src/com/hypixel/hytale/server/worldgen/cave/shape/distorted/DistortedPipeShape.java @@ -84,9 +84,6 @@ public class DistortedPipeShape extends DistortedCylinderShape { } public static class Factory implements DistortedShape.Factory { - public Factory() { - } - @Nonnull @Override public DistortedShape create( diff --git a/src/com/hypixel/hytale/server/worldgen/chunk/BlockPriorityChunk.java b/src/com/hypixel/hytale/server/worldgen/chunk/BlockPriorityChunk.java index 304aa3c..a3fe407 100644 --- a/src/com/hypixel/hytale/server/worldgen/chunk/BlockPriorityChunk.java +++ b/src/com/hypixel/hytale/server/worldgen/chunk/BlockPriorityChunk.java @@ -23,9 +23,6 @@ public class BlockPriorityChunk { @Nonnull private final byte[] blocks = new byte[327680]; - public BlockPriorityChunk() { - } - @Nonnull public BlockPriorityChunk reset() { Arrays.fill(this.blocks, (byte)0); diff --git a/src/com/hypixel/hytale/server/worldgen/chunk/ValidationUtil.java b/src/com/hypixel/hytale/server/worldgen/chunk/ValidationUtil.java index 2a9f9fc..7ec93d4 100644 --- a/src/com/hypixel/hytale/server/worldgen/chunk/ValidationUtil.java +++ b/src/com/hypixel/hytale/server/worldgen/chunk/ValidationUtil.java @@ -24,9 +24,6 @@ import java.util.logging.Level; import javax.annotation.Nonnull; public class ValidationUtil { - public ValidationUtil() { - } - public static boolean isInvalid(@Nonnull ZonePatternProvider zonePatternProvider, @Nonnull Executor executor) { return CompletableFuture.supplyAsync(() -> { Deque trace = new ArrayDeque<>(); diff --git a/src/com/hypixel/hytale/server/worldgen/chunk/populator/BlockPopulator.java b/src/com/hypixel/hytale/server/worldgen/chunk/populator/BlockPopulator.java index 168d718..a0ed3dd 100644 --- a/src/com/hypixel/hytale/server/worldgen/chunk/populator/BlockPopulator.java +++ b/src/com/hypixel/hytale/server/worldgen/chunk/populator/BlockPopulator.java @@ -19,9 +19,6 @@ import java.util.Random; import javax.annotation.Nonnull; public class BlockPopulator { - public BlockPopulator() { - } - public static void populate(int seed, @Nonnull ChunkGeneratorExecution execution) { Random random = new FastRandom(HashUtil.hash(seed, execution.getX(), execution.getZ(), 5647422603192711886L)); @@ -171,9 +168,6 @@ public class BlockPopulator { } private static class LayerPopulator { - private LayerPopulator() { - } - static void generateLayers( int seed, @Nonnull ChunkGeneratorExecution execution, int cx, int cz, int x, int z, @Nonnull Biome biome, @Nonnull IntList surfaceBlockList ) { diff --git a/src/com/hypixel/hytale/server/worldgen/chunk/populator/CavePopulator.java b/src/com/hypixel/hytale/server/worldgen/chunk/populator/CavePopulator.java index df30393..d9edf41 100644 --- a/src/com/hypixel/hytale/server/worldgen/chunk/populator/CavePopulator.java +++ b/src/com/hypixel/hytale/server/worldgen/chunk/populator/CavePopulator.java @@ -24,9 +24,6 @@ import java.util.Random; import javax.annotation.Nonnull; public class CavePopulator { - public CavePopulator() { - } - public static void populate(int seed, @Nonnull ChunkGeneratorExecution execution) { for (Zone zone : execution.getChunkGenerator().getZonePatternProvider().getZones()) { if (zone.caveGenerator() != null) { diff --git a/src/com/hypixel/hytale/server/worldgen/chunk/populator/PrefabPopulator.java b/src/com/hypixel/hytale/server/worldgen/chunk/populator/PrefabPopulator.java index 7871e91..8625559 100644 --- a/src/com/hypixel/hytale/server/worldgen/chunk/populator/PrefabPopulator.java +++ b/src/com/hypixel/hytale/server/worldgen/chunk/populator/PrefabPopulator.java @@ -60,9 +60,6 @@ public class PrefabPopulator { private final ObjectArrayList prefabs = new ObjectArrayList<>(); private final BitSet conflicts = new BitSet(); - public PrefabPopulator() { - } - public static void populate(int seed, @Nonnull ChunkGeneratorExecution execution) { ChunkGenerator.getResource().prefabPopulator.run(seed, execution); } diff --git a/src/com/hypixel/hytale/server/worldgen/chunk/populator/WaterPopulator.java b/src/com/hypixel/hytale/server/worldgen/chunk/populator/WaterPopulator.java index eb6a956..799db7a 100644 --- a/src/com/hypixel/hytale/server/worldgen/chunk/populator/WaterPopulator.java +++ b/src/com/hypixel/hytale/server/worldgen/chunk/populator/WaterPopulator.java @@ -8,9 +8,6 @@ import com.hypixel.hytale.server.worldgen.container.WaterContainer; import javax.annotation.Nonnull; public class WaterPopulator { - public WaterPopulator() { - } - public static void populate(int seed, @Nonnull ChunkGeneratorExecution execution) { for (int cx = 0; cx < 32; cx++) { for (int cz = 0; cz < 32; cz++) { diff --git a/src/com/hypixel/hytale/server/worldgen/climate/ClimateGraph.java b/src/com/hypixel/hytale/server/worldgen/climate/ClimateGraph.java index 4d90d7c..d50d2f3 100644 --- a/src/com/hypixel/hytale/server/worldgen/climate/ClimateGraph.java +++ b/src/com/hypixel/hytale/server/worldgen/climate/ClimateGraph.java @@ -211,8 +211,5 @@ public class ClimateGraph { public static enum FadeMode { PARENTS, CHILDREN; - - private FadeMode() { - } } } diff --git a/src/com/hypixel/hytale/server/worldgen/climate/ClimateNoise.java b/src/com/hypixel/hytale/server/worldgen/climate/ClimateNoise.java index 26a7785..2dd34c3 100644 --- a/src/com/hypixel/hytale/server/worldgen/climate/ClimateNoise.java +++ b/src/com/hypixel/hytale/server/worldgen/climate/ClimateNoise.java @@ -75,9 +75,6 @@ public class ClimateNoise { public double intensity = 0.0; public double fade = 0.0; public final ResultBuffer.ResultBuffer2d pos = new ResultBuffer.ResultBuffer2d(); - - public Buffer() { - } } public static class Grid { diff --git a/src/com/hypixel/hytale/server/worldgen/climate/ClimateSearch.java b/src/com/hypixel/hytale/server/worldgen/climate/ClimateSearch.java index d1862fc..801e2e0 100644 --- a/src/com/hypixel/hytale/server/worldgen/climate/ClimateSearch.java +++ b/src/com/hypixel/hytale/server/worldgen/climate/ClimateSearch.java @@ -14,9 +14,6 @@ public class ClimateSearch { public static final long SEED_OFFSET = 1659788403585L; public static final double TARGET_SCORE = 0.75; - public ClimateSearch() { - } - public static CompletableFuture search( int seed, int cx, int cy, int startRadius, int searchRadius, @Nonnull ClimateSearch.Rule rule, @Nonnull ClimateNoise noise, @Nonnull ClimateGraph graph ) { diff --git a/src/com/hypixel/hytale/server/worldgen/climate/DirectGrid.java b/src/com/hypixel/hytale/server/worldgen/climate/DirectGrid.java index 4106f15..4ea03d1 100644 --- a/src/com/hypixel/hytale/server/worldgen/climate/DirectGrid.java +++ b/src/com/hypixel/hytale/server/worldgen/climate/DirectGrid.java @@ -8,9 +8,6 @@ import com.hypixel.hytale.procedurallib.logic.point.PointConsumer; public class DirectGrid implements CellDistanceFunction { public static final DirectGrid INSTANCE = new DirectGrid(); - public DirectGrid() { - } - @Override public void nearest2D(int seed, double x, double y, int cellX, int cellY, ResultBuffer.ResultBuffer2d buffer, PointEvaluator pointEvaluator) { buffer.x = x; diff --git a/src/com/hypixel/hytale/server/worldgen/climate/util/DistanceTransform.java b/src/com/hypixel/hytale/server/worldgen/climate/util/DistanceTransform.java index 020bff4..cfc7a28 100644 --- a/src/com/hypixel/hytale/server/worldgen/climate/util/DistanceTransform.java +++ b/src/com/hypixel/hytale/server/worldgen/climate/util/DistanceTransform.java @@ -14,9 +14,6 @@ public class DistanceTransform { private static final int[] DY = new int[]{0, 0, -1, 1, -1, 1, -1, 1}; private static final double[] COST = new double[]{1.0, 1.0, 1.0, 1.0, Math.sqrt(2.0), Math.sqrt(2.0), Math.sqrt(2.0), Math.sqrt(2.0)}; - public DistanceTransform() { - } - public static void apply(@Nonnull IntMap source, @Nonnull DoubleMap dest, double radius) { if (radius <= 0.0) { throw new IllegalArgumentException("radius must be > 0"); diff --git a/src/com/hypixel/hytale/server/worldgen/loader/cave/CaveNodeChildEntryJsonLoader.java b/src/com/hypixel/hytale/server/worldgen/loader/cave/CaveNodeChildEntryJsonLoader.java index cf79b23..edd9cab 100644 --- a/src/com/hypixel/hytale/server/worldgen/loader/cave/CaveNodeChildEntryJsonLoader.java +++ b/src/com/hypixel/hytale/server/worldgen/loader/cave/CaveNodeChildEntryJsonLoader.java @@ -66,13 +66,13 @@ public class CaveNodeChildEntryJsonLoader extends JsonLoader @Nonnull protected CaveNodeType loadEntryNodeType() { - if (!this.has("Entry")) { + JsonElement entry = this.get("Entry"); + if (entry == null) { throw new IllegalArgumentException("\"Entry\" is not defined. Define an entry node type"); } else { - String entryNodeTypeString = this.get("Entry").getAsString(); CaveNodeTypeStorage caveNodeTypeStorage = new CaveNodeTypeStorage(this.seed, this.dataFolder, this.caveFolder, this.zoneContext); - return caveNodeTypeStorage.loadCaveNodeType(entryNodeTypeString); + if (entry.isJsonObject()) { + String entryNodeTypeString = this.seed.get().getUniqueName("CaveType#"); + return caveNodeTypeStorage.loadCaveNodeType(entryNodeTypeString, entry.getAsJsonObject()); + } else if (entry.isJsonPrimitive() && entry.getAsJsonPrimitive().isString()) { + String entryNodeTypeString = entry.getAsString(); + return caveNodeTypeStorage.loadCaveNodeType(entryNodeTypeString); + } else { + throw error("Invalid entry node type definition! Expected String or JsonObject: " + entry); + } } } @@ -137,7 +144,7 @@ public class CaveTypeJsonLoader extends JsonLoader @Nullable protected BlockMaskCondition loadBlockMask() { - BlockMaskCondition placementConfiguration = DefaultBlockMaskCondition.DEFAULT_TRUE; + BlockMaskCondition placementConfiguration = BlockMaskCondition.DEFAULT_TRUE; if (this.has("BlockMask")) { placementConfiguration = new BlockPlacementMaskJsonLoader(this.seed, this.dataFolder, this.getRaw("BlockMask")).load(); } diff --git a/src/com/hypixel/hytale/server/worldgen/loader/cave/CaveTypesJsonLoader.java b/src/com/hypixel/hytale/server/worldgen/loader/cave/CaveTypesJsonLoader.java index 0b37ebe..10c8b07 100644 --- a/src/com/hypixel/hytale/server/worldgen/loader/cave/CaveTypesJsonLoader.java +++ b/src/com/hypixel/hytale/server/worldgen/loader/cave/CaveTypesJsonLoader.java @@ -28,9 +28,14 @@ public class CaveTypesJsonLoader extends JsonLoader { - private static final BlockPlacementMask.IEntry WILDCARD_FALSE = new BlockPlacementMask.WildcardEntry(false); - private static final BlockPlacementMask.IEntry WILDCARD_TRUE = new BlockPlacementMask.WildcardEntry(true); +public class BlockPlacementMaskJsonLoader extends JsonLoader { private String fileName; public BlockPlacementMaskJsonLoader(@Nonnull SeedString seed, Path dataFolder, JsonElement json) { - super(seed.append(".BlockPlacementMask"), dataFolder, json); + super(seed.append(".BlockMaskCondition"), dataFolder, json); } - public BlockPlacementMask load() { + public BlockMaskCondition load() { BlockPlacementMaskRegistry registry = this.seed.get().getBlockMaskRegistry(); if (this.fileName != null) { - BlockPlacementMask mask = registry.getIfPresentFileMask(this.fileName); + BlockMaskCondition mask = registry.getIfPresentFileMask(this.fileName); if (mask != null) { return mask; } } - Long2ObjectMap specificMasks = null; - BlockPlacementMask.IMask defaultMask; + Long2ObjectMap specificMasks = Long2ObjectMaps.emptyMap(); + BlockMaskCondition.Mask defaultMask; if (this.json != null && !this.json.isJsonNull()) { if (this.has("Default")) { - defaultMask = new BlockPlacementMask.Mask(this.loadEntries(this.get("Default").getAsJsonArray())); + defaultMask = new BlockMaskCondition.Mask(this.loadEntries(this.get("Default").getAsJsonArray())); } else { - defaultMask = BlockPlacementMask.DEFAULT_MASK; + defaultMask = BlockMaskCondition.DEFAULT_MASK; } if (this.has("Specific")) { @@ -67,7 +66,7 @@ public class BlockPlacementMaskJsonLoader extends JsonLoader { +public class BlockPlacementMaskRegistry extends FileMaskCache { @Nonnull - private final Map masks = new HashMap<>(); + private final Map masks = new HashMap<>(); @Nonnull - private final Map entries = new HashMap<>(); - private BlockPlacementMask tempMask = new BlockPlacementMask(); - private BlockPlacementMask.BlockArrayEntry tempEntry = new BlockPlacementMask.BlockArrayEntry(); - - public BlockPlacementMaskRegistry() { - } + private final Map entries = new HashMap<>(); + private BlockMaskCondition tempMask = new BlockMaskCondition(); + private BlockMaskCondition.MaskEntry tempEntry = new BlockMaskCondition.MaskEntry(); @Nonnull - public BlockPlacementMask retainOrAllocateMask(BlockPlacementMask.IMask defaultMask, Long2ObjectMap specificMasks) { - BlockPlacementMask mask = this.tempMask; + public BlockMaskCondition retainOrAllocateMask(@Nonnull BlockMaskCondition.Mask defaultMask, @Nonnull Long2ObjectMap specificMasks) { + BlockMaskCondition mask = this.tempMask; mask.set(defaultMask, specificMasks); - BlockPlacementMask old = this.masks.putIfAbsent(mask, mask); + BlockMaskCondition old = this.masks.putIfAbsent(mask, mask); if (old != null) { return old; } else { - this.tempMask = new BlockPlacementMask(); + this.tempMask = new BlockMaskCondition(); return mask; } } @Nonnull - public BlockPlacementMask.BlockArrayEntry retainOrAllocateEntry(ResolvedBlockArray blocks, boolean replace) { - BlockPlacementMask.BlockArrayEntry entry = this.tempEntry; + public BlockMaskCondition.MaskEntry retainOrAllocateEntry(@Nonnull ResolvedBlockArray blocks, boolean replace) { + BlockMaskCondition.MaskEntry entry = this.tempEntry; entry.set(blocks, replace); - BlockPlacementMask.BlockArrayEntry old = this.entries.putIfAbsent(entry, entry); + BlockMaskCondition.MaskEntry old = this.entries.putIfAbsent(entry, entry); if (old != null) { return old; } else { - this.tempEntry = new BlockPlacementMask.BlockArrayEntry(); + this.tempEntry = new BlockMaskCondition.MaskEntry(); return entry; } } diff --git a/src/com/hypixel/hytale/server/worldgen/loader/prefab/PrefabPatternGeneratorJsonLoader.java b/src/com/hypixel/hytale/server/worldgen/loader/prefab/PrefabPatternGeneratorJsonLoader.java index c4d944a..da4f314 100644 --- a/src/com/hypixel/hytale/server/worldgen/loader/prefab/PrefabPatternGeneratorJsonLoader.java +++ b/src/com/hypixel/hytale/server/worldgen/loader/prefab/PrefabPatternGeneratorJsonLoader.java @@ -25,7 +25,6 @@ import com.hypixel.hytale.server.worldgen.prefab.PrefabPatternGenerator; import com.hypixel.hytale.server.worldgen.util.LogUtil; import com.hypixel.hytale.server.worldgen.util.ResolvedBlockArray; import com.hypixel.hytale.server.worldgen.util.condition.BlockMaskCondition; -import com.hypixel.hytale.server.worldgen.util.condition.DefaultBlockMaskCondition; import com.hypixel.hytale.server.worldgen.util.condition.HashSetBlockFluidCondition; import com.hypixel.hytale.server.worldgen.util.function.ConstantCoordinateDoubleSupplier; import com.hypixel.hytale.server.worldgen.util.function.ICoordinateDoubleSupplier; @@ -128,7 +127,7 @@ public class PrefabPatternGeneratorJsonLoader extends JsonLoader { @Nonnull private final Map fileElements = new HashMap<>(); - public FileMaskCache() { - } - public T getIfPresentFileMask(String filename) { return this.fileCache.get(filename); } diff --git a/src/com/hypixel/hytale/server/worldgen/prefab/BlockPlacementMask.java b/src/com/hypixel/hytale/server/worldgen/prefab/BlockPlacementMask.java deleted file mode 100644 index 6c02b09..0000000 --- a/src/com/hypixel/hytale/server/worldgen/prefab/BlockPlacementMask.java +++ /dev/null @@ -1,225 +0,0 @@ -package com.hypixel.hytale.server.worldgen.prefab; - -import com.hypixel.hytale.math.util.MathUtil; -import com.hypixel.hytale.server.worldgen.util.BlockFluidEntry; -import com.hypixel.hytale.server.worldgen.util.ResolvedBlockArray; -import com.hypixel.hytale.server.worldgen.util.condition.BlockMaskCondition; -import it.unimi.dsi.fastutil.longs.Long2ObjectMap; -import java.util.Arrays; -import java.util.Objects; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public class BlockPlacementMask implements BlockMaskCondition { - public static final BlockPlacementMask.IMask DEFAULT_MASK = new BlockPlacementMask.DefaultMask(); - private BlockPlacementMask.IMask defaultMask; - private Long2ObjectMap specificMasks; - - public BlockPlacementMask() { - } - - public void set(BlockPlacementMask.IMask defaultMask, Long2ObjectMap specificMasks) { - this.defaultMask = defaultMask; - this.specificMasks = specificMasks; - } - - @Override - public boolean eval(int currentBlock, int currentFluid, @Nonnull BlockFluidEntry entry) { - BlockPlacementMask.IMask mask = this.specificMasks == null ? null : this.specificMasks.get(MathUtil.packLong(entry.blockId(), entry.fluidId())); - if (mask == null) { - mask = this.defaultMask; - } - - return mask.shouldReplace(currentBlock, currentFluid); - } - - @Override - public boolean equals(@Nullable Object o) { - if (this == o) { - return true; - } else if (o != null && this.getClass() == o.getClass()) { - BlockPlacementMask that = (BlockPlacementMask)o; - return !this.defaultMask.equals(that.defaultMask) ? false : Objects.equals(this.specificMasks, that.specificMasks); - } else { - return false; - } - } - - @Override - public int hashCode() { - int result = this.defaultMask.hashCode(); - return 31 * result + (this.specificMasks != null ? this.specificMasks.hashCode() : 0); - } - - @Nonnull - @Override - public String toString() { - return "BlockPlacementMask{defaultMask=" + this.defaultMask + ", specificMasks=" + this.specificMasks + "}"; - } - - public static class BlockArrayEntry implements BlockPlacementMask.IEntry { - private ResolvedBlockArray blocks; - private boolean replace; - - public BlockArrayEntry() { - } - - public void set(ResolvedBlockArray blocks, boolean replace) { - this.blocks = blocks; - this.replace = replace; - } - - @Override - public boolean shouldHandle(int current, int fluid) { - return this.blocks.contains(current, fluid); - } - - @Override - public boolean shouldReplace() { - return this.replace; - } - - @Override - public boolean equals(@Nullable Object o) { - if (this == o) { - return true; - } else if (o != null && this.getClass() == o.getClass()) { - BlockPlacementMask.BlockArrayEntry that = (BlockPlacementMask.BlockArrayEntry)o; - return this.replace != that.replace ? false : this.blocks.equals(that.blocks); - } else { - return false; - } - } - - @Override - public int hashCode() { - int result = this.blocks.hashCode(); - return 31 * result + (this.replace ? 1 : 0); - } - - @Nonnull - @Override - public String toString() { - return "BlockArrayEntry{blocks=" + this.blocks + ", replace=" + this.replace + "}"; - } - } - - public static class DefaultMask implements BlockPlacementMask.IMask { - public DefaultMask() { - } - - @Override - public boolean shouldReplace(int block, int fluid) { - return block == 0 && fluid == 0; - } - - @Override - public int hashCode() { - return 137635105; - } - - @Override - public boolean equals(Object o) { - return o instanceof BlockPlacementMask.DefaultMask; - } - - @Nonnull - @Override - public String toString() { - return "DefaultMask{}"; - } - } - - public interface IEntry { - boolean shouldHandle(int var1, int var2); - - boolean shouldReplace(); - } - - public interface IMask { - boolean shouldReplace(int var1, int var2); - } - - public static class Mask implements BlockPlacementMask.IMask { - private final BlockPlacementMask.IEntry[] entries; - - public Mask(BlockPlacementMask.IEntry[] entries) { - this.entries = entries; - } - - @Override - public boolean shouldReplace(int current, int fluid) { - for (BlockPlacementMask.IEntry entry : this.entries) { - if (entry.shouldHandle(current, fluid)) { - return entry.shouldReplace(); - } - } - - return false; - } - - @Override - public boolean equals(@Nullable Object o) { - if (this == o) { - return true; - } else if (o != null && this.getClass() == o.getClass()) { - BlockPlacementMask.Mask mask = (BlockPlacementMask.Mask)o; - return Arrays.equals((Object[])this.entries, (Object[])mask.entries); - } else { - return false; - } - } - - @Override - public int hashCode() { - return Arrays.hashCode((Object[])this.entries); - } - - @Nonnull - @Override - public String toString() { - return "Mask{entries=" + Arrays.toString((Object[])this.entries) + "}"; - } - } - - public static class WildcardEntry implements BlockPlacementMask.IEntry { - private final boolean replace; - - public WildcardEntry(boolean replace) { - this.replace = replace; - } - - @Override - public boolean shouldHandle(int block, int fluid) { - return true; - } - - @Override - public boolean shouldReplace() { - return this.replace; - } - - @Override - public boolean equals(@Nullable Object o) { - if (this == o) { - return true; - } else if (o != null && this.getClass() == o.getClass()) { - BlockPlacementMask.WildcardEntry that = (BlockPlacementMask.WildcardEntry)o; - return this.replace == that.replace; - } else { - return false; - } - } - - @Override - public int hashCode() { - return this.replace ? 1 : 0; - } - - @Nonnull - @Override - public String toString() { - return "WildcardEntry{replace=" + this.replace + "}"; - } - } -} diff --git a/src/com/hypixel/hytale/server/worldgen/prefab/PrefabLoadingCache.java b/src/com/hypixel/hytale/server/worldgen/prefab/PrefabLoadingCache.java index 137b499..d148b58 100644 --- a/src/com/hypixel/hytale/server/worldgen/prefab/PrefabLoadingCache.java +++ b/src/com/hypixel/hytale/server/worldgen/prefab/PrefabLoadingCache.java @@ -13,9 +13,6 @@ public class PrefabLoadingCache { private final Map cache = new ConcurrentHashMap<>(); private final Function loader = p -> PrefabBufferUtil.loadBuffer(p.getPath()); - public PrefabLoadingCache() { - } - @Nonnull public IPrefabBuffer getPrefabAccessor(WorldGenPrefabSupplier prefabSupplier) { return this.cache.computeIfAbsent(prefabSupplier, this.loader).newAccess(); diff --git a/src/com/hypixel/hytale/server/worldgen/prefab/PrefabPasteUtil.java b/src/com/hypixel/hytale/server/worldgen/prefab/PrefabPasteUtil.java index 7bd67c0..58c2ebb 100644 --- a/src/com/hypixel/hytale/server/worldgen/prefab/PrefabPasteUtil.java +++ b/src/com/hypixel/hytale/server/worldgen/prefab/PrefabPasteUtil.java @@ -15,9 +15,7 @@ import com.hypixel.hytale.server.core.prefab.selection.buffer.PrefabBufferCall; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import com.hypixel.hytale.server.worldgen.chunk.ChunkGeneratorExecution; import com.hypixel.hytale.server.worldgen.loader.WorldGenPrefabSupplier; -import com.hypixel.hytale.server.worldgen.util.BlockFluidEntry; import com.hypixel.hytale.server.worldgen.util.condition.BlockMaskCondition; -import com.hypixel.hytale.server.worldgen.util.condition.DefaultBlockMaskCondition; import java.util.Random; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -25,9 +23,6 @@ import javax.annotation.Nullable; public class PrefabPasteUtil { public static final int MAX_RECURSION_DEPTH = 10; - public PrefabPasteUtil() { - } - public static void generate( @Nonnull PrefabPasteUtil.PrefabPasteBuffer buffer, PrefabRotation rotation, @Nonnull WorldGenPrefabSupplier supplier, int x, int y, int z, int cx, int cz ) { @@ -65,15 +60,15 @@ public class PrefabPasteUtil { } }, (cx, cy, cz, block, holder, supportValue, rotation, filler, buffer, fluidId, fluidLevel) -> { - if (buffer.blockMask != DefaultBlockMaskCondition.DEFAULT_FALSE) { + if (buffer.blockMask != BlockMaskCondition.DEFAULT_FALSE) { int bx = cx + buffer.posChunk.x; int by = cy + buffer.posChunk.y + buffer.yOffset; int bz = cz + buffer.posChunk.z; if (by >= 0 && by < 320) { - if (buffer.blockMask != DefaultBlockMaskCondition.DEFAULT_TRUE) { + if (buffer.blockMask != BlockMaskCondition.DEFAULT_TRUE) { int currentBlock = buffer.execution.getBlock(bx, by, bz); int currentFluid = buffer.execution.getFluid(bx, by, bz); - if (!buffer.blockMask.eval(currentBlock, currentFluid, new BlockFluidEntry(block, 0, fluidId))) { + if (!buffer.blockMask.eval(currentBlock, currentFluid, block, fluidId)) { return; } } @@ -226,7 +221,7 @@ public class PrefabPasteUtil { this.execution = null; this.fitHeightmap = false; this.deepSearch = false; - this.blockMask = DefaultBlockMaskCondition.DEFAULT_TRUE; + this.blockMask = BlockMaskCondition.DEFAULT_TRUE; this.environmentId = Integer.MIN_VALUE; this.heightCondition = DefaultCoordinateCondition.DEFAULT_TRUE; this.spawnCondition = DefaultCoordinateRndCondition.DEFAULT_TRUE; diff --git a/src/com/hypixel/hytale/server/worldgen/prefab/PrefabStoreRoot.java b/src/com/hypixel/hytale/server/worldgen/prefab/PrefabStoreRoot.java index a216885..aed7e79 100644 --- a/src/com/hypixel/hytale/server/worldgen/prefab/PrefabStoreRoot.java +++ b/src/com/hypixel/hytale/server/worldgen/prefab/PrefabStoreRoot.java @@ -10,9 +10,6 @@ public enum PrefabStoreRoot { public static final PrefabStoreRoot DEFAULT = WORLD_GEN; - private PrefabStoreRoot() { - } - @Nonnull public static Path resolvePrefabStore(@Nonnull PrefabStoreRoot store, @Nonnull Path dataFolder) { return switch (store) { diff --git a/src/com/hypixel/hytale/server/worldgen/util/ArrayUtli.java b/src/com/hypixel/hytale/server/worldgen/util/ArrayUtli.java index 34282bf..ef813ac 100644 --- a/src/com/hypixel/hytale/server/worldgen/util/ArrayUtli.java +++ b/src/com/hypixel/hytale/server/worldgen/util/ArrayUtli.java @@ -4,9 +4,6 @@ import java.util.Random; import javax.annotation.Nonnull; public class ArrayUtli { - public ArrayUtli() { - } - public static void shuffleArray(@Nonnull int[] ar, @Nonnull Random rnd) { for (int i = ar.length - 1; i > 0; i--) { int index = rnd.nextInt(i + 1); diff --git a/src/com/hypixel/hytale/server/worldgen/util/LogUtil.java b/src/com/hypixel/hytale/server/worldgen/util/LogUtil.java index e2aaa8e..647980f 100644 --- a/src/com/hypixel/hytale/server/worldgen/util/LogUtil.java +++ b/src/com/hypixel/hytale/server/worldgen/util/LogUtil.java @@ -6,9 +6,6 @@ import javax.annotation.Nonnull; public class LogUtil { private static final HytaleLogger LOGGER = HytaleLogger.get("WorldGenerator"); - public LogUtil() { - } - @Nonnull public static HytaleLogger getLogger() { return LOGGER; diff --git a/src/com/hypixel/hytale/server/worldgen/util/cache/ConcurrentSizedTimeoutCache.java b/src/com/hypixel/hytale/server/worldgen/util/cache/ConcurrentSizedTimeoutCache.java index 81866b8..c5b06a0 100644 --- a/src/com/hypixel/hytale/server/worldgen/util/cache/ConcurrentSizedTimeoutCache.java +++ b/src/com/hypixel/hytale/server/worldgen/util/cache/ConcurrentSizedTimeoutCache.java @@ -2,6 +2,7 @@ package com.hypixel.hytale.server.worldgen.util.cache; import com.hypixel.hytale.math.util.MathUtil; import com.hypixel.hytale.server.core.HytaleServer; +import com.hypixel.hytale.server.worldgen.util.LogUtil; import it.unimi.dsi.fastutil.HashCommon; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectIterator; @@ -17,6 +18,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.StampedLock; import java.util.function.BiConsumer; import java.util.function.Function; +import java.util.logging.Level; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -130,6 +132,7 @@ public class ConcurrentSizedTimeoutCache implements Cache { try { ConcurrentSizedTimeoutCache.CacheEntry newEntry = this.pool.isEmpty() ? new ConcurrentSizedTimeoutCache.CacheEntry<>() : this.pool.poll(); + Objects.requireNonNull(newEntry, "CacheEntry pool returned null entry!"); newEntry.key = (K)var23; newEntry.value = newValue; newEntry.timestamp = timestamp; @@ -165,7 +168,10 @@ public class ConcurrentSizedTimeoutCache implements Cache { while (it.hasNext()) { ConcurrentSizedTimeoutCache.CacheEntry entry = it.next().getValue(); - if (entry.timestamp >= expireTimestamp) { + if (entry == null) { + LogUtil.getLogger().at(Level.SEVERE).log("Found null entry in cache bucket during cleanup!"); + it.remove(); + } else if (entry.timestamp >= expireTimestamp) { it.remove(); if (destroyer != null) { destroyer.accept(entry.key, entry.value); @@ -212,9 +218,6 @@ public class ConcurrentSizedTimeoutCache implements Cache { public V value = (V)null; public long timestamp = 0L; - private CacheEntry() { - } - @Nonnull protected V markAndGet(long timestamp) { Objects.requireNonNull(this.value); diff --git a/src/com/hypixel/hytale/server/worldgen/util/cache/SizedTimeoutCache.java b/src/com/hypixel/hytale/server/worldgen/util/cache/SizedTimeoutCache.java index 22e9cbd..27615d3 100644 --- a/src/com/hypixel/hytale/server/worldgen/util/cache/SizedTimeoutCache.java +++ b/src/com/hypixel/hytale/server/worldgen/util/cache/SizedTimeoutCache.java @@ -234,8 +234,5 @@ public class SizedTimeoutCache implements Cache { @Nullable private K key; private long timestamp; - - private CacheEntry() { - } } } diff --git a/src/com/hypixel/hytale/server/worldgen/util/condition/BlockMaskCondition.java b/src/com/hypixel/hytale/server/worldgen/util/condition/BlockMaskCondition.java index aaef9d0..1a5208b 100644 --- a/src/com/hypixel/hytale/server/worldgen/util/condition/BlockMaskCondition.java +++ b/src/com/hypixel/hytale/server/worldgen/util/condition/BlockMaskCondition.java @@ -1,8 +1,160 @@ package com.hypixel.hytale.server.worldgen.util.condition; -import com.hypixel.hytale.server.worldgen.util.BlockFluidEntry; +import com.hypixel.hytale.math.util.MathUtil; +import com.hypixel.hytale.server.worldgen.util.ResolvedBlockArray; +import it.unimi.dsi.fastutil.longs.Long2ObjectMap; +import it.unimi.dsi.fastutil.longs.Long2ObjectMaps; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; -@FunctionalInterface -public interface BlockMaskCondition { - boolean eval(int var1, int var2, BlockFluidEntry var3); +public class BlockMaskCondition { + public static final BlockMaskCondition.Mask DEFAULT_MASK = new BlockMaskCondition.Mask(true, new BlockMaskCondition.MaskEntry[0]); + public static final BlockMaskCondition DEFAULT_TRUE = new BlockMaskCondition(); + public static final BlockMaskCondition DEFAULT_FALSE = new BlockMaskCondition(); + @Nonnull + private BlockMaskCondition.Mask defaultMask = DEFAULT_MASK; + @Nonnull + private Long2ObjectMap specificMasks = Long2ObjectMaps.emptyMap(); + + public void set(@Nonnull BlockMaskCondition.Mask defaultMask, @Nonnull Long2ObjectMap specificMasks) { + this.defaultMask = defaultMask; + this.specificMasks = specificMasks; + } + + public boolean eval(int currentBlock, int currentFluid, int nextBlockId, int nextFluidId) { + BlockMaskCondition.Mask mask = this.specificMasks.getOrDefault(MathUtil.packLong(nextBlockId, nextFluidId), this.defaultMask); + return mask.shouldReplace(currentBlock, currentFluid); + } + + @Override + public boolean equals(@Nullable Object o) { + if (this == o) { + return true; + } else if (o != null && this.getClass() == o.getClass()) { + BlockMaskCondition that = (BlockMaskCondition)o; + return !this.defaultMask.equals(that.defaultMask) ? false : Objects.equals(this.specificMasks, that.specificMasks); + } else { + return false; + } + } + + @Override + public int hashCode() { + int result = this.defaultMask.hashCode(); + return 31 * result + (this.specificMasks != null ? this.specificMasks.hashCode() : 0); + } + + @Nonnull + @Override + public String toString() { + return "BlockMaskCondition{defaultMask=" + this.defaultMask + ", specificMasks=" + this.specificMasks + "}"; + } + + public static class Mask { + private final boolean matchEmpty; + private final BlockMaskCondition.MaskEntry[] entries; + + public Mask(@Nonnull BlockMaskCondition.MaskEntry[] entries) { + this(false, entries); + } + + private Mask(boolean matchEmpty, @Nonnull BlockMaskCondition.MaskEntry[] entries) { + this.entries = entries; + this.matchEmpty = matchEmpty; + } + + public boolean shouldReplace(int current, int fluid) { + for (BlockMaskCondition.MaskEntry entry : this.entries) { + if (entry.shouldHandle(current, fluid)) { + return entry.shouldReplace(); + } + } + + return this.matchEmpty && (current == 0 || fluid == 0); + } + + @Override + public boolean equals(@Nullable Object o) { + if (this == o) { + return true; + } else if (o != null && this.getClass() == o.getClass()) { + BlockMaskCondition.Mask mask = (BlockMaskCondition.Mask)o; + return Arrays.equals((Object[])this.entries, (Object[])mask.entries); + } else { + return false; + } + } + + @Override + public int hashCode() { + return Arrays.hashCode((Object[])this.entries); + } + + @Nonnull + @Override + public String toString() { + return "Mask{entries=" + Arrays.toString((Object[])this.entries) + "}"; + } + } + + public static class MaskEntry { + public static final BlockMaskCondition.MaskEntry WILDCARD_TRUE = new BlockMaskCondition.MaskEntry(true, true); + public static final BlockMaskCondition.MaskEntry WILDCARD_FALSE = new BlockMaskCondition.MaskEntry(true, false); + private ResolvedBlockArray blocks = ResolvedBlockArray.EMPTY; + private final boolean any; + private boolean replace; + + public MaskEntry() { + this(false, false); + } + + private MaskEntry(boolean any, boolean replace) { + this.any = any; + this.replace = replace; + } + + public void set(ResolvedBlockArray blocks, boolean replace) { + this.blocks = blocks; + this.replace = replace; + } + + public boolean shouldHandle(int current, int fluid) { + return this.any || this.blocks.contains(current, fluid); + } + + public boolean shouldReplace() { + return this.replace; + } + + @Override + public boolean equals(@Nullable Object o) { + if (this == o) { + return true; + } else if (o != null && this.getClass() == o.getClass()) { + BlockMaskCondition.MaskEntry that = (BlockMaskCondition.MaskEntry)o; + if (this.any != that.any) { + return false; + } else { + return this.replace != that.replace ? false : this.blocks.equals(that.blocks); + } + } else { + return false; + } + } + + @Override + public int hashCode() { + int result = this.blocks.hashCode(); + result = 31 * result + (this.any ? 1 : 0); + return 31 * result + (this.replace ? 1 : 0); + } + + @Nonnull + @Override + public String toString() { + return "MaskEntry{blocks=" + this.blocks + ", replace=" + this.replace + "}"; + } + } } diff --git a/src/com/hypixel/hytale/server/worldgen/util/condition/DefaultBlockMaskCondition.java b/src/com/hypixel/hytale/server/worldgen/util/condition/DefaultBlockMaskCondition.java deleted file mode 100644 index 99fd1a1..0000000 --- a/src/com/hypixel/hytale/server/worldgen/util/condition/DefaultBlockMaskCondition.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.hypixel.hytale.server.worldgen.util.condition; - -import com.hypixel.hytale.server.worldgen.util.BlockFluidEntry; -import javax.annotation.Nonnull; - -public class DefaultBlockMaskCondition implements BlockMaskCondition { - public static final DefaultBlockMaskCondition DEFAULT_TRUE = new DefaultBlockMaskCondition(true); - public static final DefaultBlockMaskCondition DEFAULT_FALSE = new DefaultBlockMaskCondition(false); - private final boolean result; - - public DefaultBlockMaskCondition(boolean result) { - this.result = result; - } - - @Override - public boolean eval(int currentBlockId, int currentFluidId, BlockFluidEntry next) { - return this.result; - } - - @Nonnull - @Override - public String toString() { - return "DefaultBiIntCondition{result=" + this.result + "}"; - } -} diff --git a/src/com/hypixel/hytale/server/worldgen/util/condition/FilteredIntCondition.java b/src/com/hypixel/hytale/server/worldgen/util/condition/FilteredIntCondition.java deleted file mode 100644 index c2617b0..0000000 --- a/src/com/hypixel/hytale/server/worldgen/util/condition/FilteredIntCondition.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.hypixel.hytale.server.worldgen.util.condition; - -import com.hypixel.hytale.procedurallib.condition.IIntCondition; -import it.unimi.dsi.fastutil.ints.IntSets; -import javax.annotation.Nonnull; - -public class FilteredIntCondition implements IIntCondition { - private final IIntCondition filter; - private final IIntCondition condition; - - public FilteredIntCondition(int filterValue, IIntCondition condition) { - this(new HashSetIntCondition(IntSets.singleton(filterValue)), condition); - } - - public FilteredIntCondition(IIntCondition filter, IIntCondition condition) { - this.filter = filter; - this.condition = condition; - } - - @Override - public boolean eval(int value) { - return this.filter.eval(value) ? false : this.condition.eval(value); - } - - @Nonnull - @Override - public String toString() { - return "FilteredIntCondition{filter=" + this.filter + ", condition=" + this.condition + "}"; - } -} diff --git a/src/com/hypixel/hytale/server/worldgen/util/condition/flag/FlagOperator.java b/src/com/hypixel/hytale/server/worldgen/util/condition/flag/FlagOperator.java index 5d69bc0..9004e68 100644 --- a/src/com/hypixel/hytale/server/worldgen/util/condition/flag/FlagOperator.java +++ b/src/com/hypixel/hytale/server/worldgen/util/condition/flag/FlagOperator.java @@ -22,9 +22,6 @@ public enum FlagOperator implements IntBinaryOperator { } }; - private FlagOperator() { - } - public abstract int apply(int var1, int var2); @Override diff --git a/src/com/hypixel/hytale/server/worldgen/zone/ZoneColorMapping.java b/src/com/hypixel/hytale/server/worldgen/zone/ZoneColorMapping.java index bff01ec..eaf259d 100644 --- a/src/com/hypixel/hytale/server/worldgen/zone/ZoneColorMapping.java +++ b/src/com/hypixel/hytale/server/worldgen/zone/ZoneColorMapping.java @@ -8,9 +8,6 @@ public class ZoneColorMapping { @Nonnull protected final Int2ObjectMap mapping = new Int2ObjectOpenHashMap<>(); - public ZoneColorMapping() { - } - public void add(int rgb, Zone zone) { this.add(rgb, new Zone[]{zone}); } diff --git a/src/com/hypixel/hytale/sneakythrow/SneakyThrow.java b/src/com/hypixel/hytale/sneakythrow/SneakyThrow.java index bc5a726..aff7cd6 100644 --- a/src/com/hypixel/hytale/sneakythrow/SneakyThrow.java +++ b/src/com/hypixel/hytale/sneakythrow/SneakyThrow.java @@ -19,9 +19,6 @@ import java.util.function.Supplier; import javax.annotation.Nonnull; public class SneakyThrow { - public SneakyThrow() { - } - @Nonnull public static RuntimeException sneakyThrow(@Nonnull Throwable t) { if (t == null) { diff --git a/src/com/hypixel/hytale/storage/IndexedStorageFile.java b/src/com/hypixel/hytale/storage/IndexedStorageFile.java index 342ac57..5db3341 100644 --- a/src/com/hypixel/hytale/storage/IndexedStorageFile.java +++ b/src/com/hypixel/hytale/storage/IndexedStorageFile.java @@ -792,9 +792,6 @@ public class IndexedStorageFile implements Closeable { static class OffsetHelper { private int index; - OffsetHelper() { - } - public int next(int len) { int cur = this.index; this.index += len; diff --git a/src/com/hypixel/hytale/storage/IndexedStorageFile_v0.java b/src/com/hypixel/hytale/storage/IndexedStorageFile_v0.java index 8e676bf..7b1653c 100644 --- a/src/com/hypixel/hytale/storage/IndexedStorageFile_v0.java +++ b/src/com/hypixel/hytale/storage/IndexedStorageFile_v0.java @@ -962,9 +962,6 @@ public class IndexedStorageFile_v0 implements Closeable { static class OffsetHelper { private int index; - OffsetHelper() { - } - public int next(int len) { int cur = this.index; this.index += len; diff --git a/src/com/hypixel/hytale/unsafe/UnsafeUtil.java b/src/com/hypixel/hytale/unsafe/UnsafeUtil.java index 3e1dda8..d1302af 100644 --- a/src/com/hypixel/hytale/unsafe/UnsafeUtil.java +++ b/src/com/hypixel/hytale/unsafe/UnsafeUtil.java @@ -10,9 +10,6 @@ public class UnsafeUtil { @Nullable public static final Unsafe UNSAFE; - public UnsafeUtil() { - } - static { Unsafe instance; try { diff --git a/src/manifests.json b/src/manifests.json new file mode 100644 index 0000000..007b808 --- /dev/null +++ b/src/manifests.json @@ -0,0 +1,540 @@ +[{ + "Group": "Hytale", + "Name": "AssetEditor", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.asseteditor.AssetEditorPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:I18nModule": "*", + "Hytale:ItemModule": "*", + "Hytale:Model": "*" + } +} +,{ + "Group": "Hytale", + "Name": "BlockSpawner", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.blockspawner.BlockSpawnerPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:I18nModule": "*", + "Hytale:BlockStateModule": "*", + "Hytale:BlockModule": "*", + "Hytale:BlockPhysics": "*" + } +} +,{ + "Group": "Hytale", + "Name": "BlockTick", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.blocktick.BlockTickPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:LegacyModule": "*" + } +} +,{ + "Group": "Hytale", + "Name": "BlockPhysics", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.blockphysics.BlockPhysicsPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:BlockTick": "*", + "Hytale:BlockTypeModule": "*" + } +} +,{ + "Group": "Hytale", + "Name": "BuilderTools", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.buildertools.BuilderToolsPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:EntityModule": "*" + } +} +,{ + "Group": "Hytale", + "Name": "Crafting", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.crafting.CraftingPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:BlockStateModule": "*", + "Hytale:EntityModule": "*", + "Hytale:InteractionModule": "*" + } +} +,{ + "Group": "Hytale", + "Name": "CommandMacro", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.commandmacro.MacroCommandPlugin", + "ServerVersion": "*" +} +,{ + "Group": "Hytale", + "Name": "Instances", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.instances.InstancesPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:I18nModule": "*", + "Hytale:BlockStateModule": "*", + "Hytale:BlockPhysics": "*" + } +} +,{ + "Group": "Hytale", + "Name": "LANDiscovery", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.landiscovery.LANDiscoveryPlugin", + "ServerVersion": "*" +} +,{ + "Group": "Hytale", + "Name": "NPC", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.server.npc.NPCPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:AssetModule": "*", + "Hytale:TagSet": "*", + "Hytale:EntityModule": "*", + "Hytale:EntityStatsModule": "*", + "Hytale:DamageModule": "*" + }, + "OptionalDependencies": { + "Hytale:Objectives": "*", + "Hytale:Path": "*", + "Hytale:Teleport": "*" + }, + "SubPlugins": [ + { + "Name": "Spawning", + "Main": "com.hypixel.hytale.server.spawning.SpawningPlugin" + }, + { + "Name": "Flock", + "Main": "com.hypixel.hytale.server.flock.FlockPlugin" + } + ] +} +,{ + "Group": "Hytale", + "Name": "NPCObjectives", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.adventure.npcobjectives.NPCObjectivesPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:Objectives": "*", + "Hytale:NPC": "*", + "Hytale:Spawning": "*", + "Hytale:TagSet": "*" + } +} +,{ + "Group": "Hytale", + "Name": "ObjectiveReputation", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.adventure.objectivereputation.ObjectiveReputationPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:Objectives": "*", + "Hytale:Reputation": "*" + } +} +,{ + "Group": "Hytale", + "Name": "Objectives", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.adventure.objectives.ObjectivePlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:I18nModule": "*", + "Hytale:BlockStateModule": "*", + "Hytale:InteractionModule": "*", + "Hytale:EntityModule": "*" + } +} +,{ + "Group": "Hytale", + "Name": "ObjectiveShop", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.adventure.objectiveshop.ObjectiveShopPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:Objectives": "*", + "Hytale:Shop": "*" + } +} +,{ + "Group": "Hytale", + "Name": "Path", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.path.PathPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:EntityModule": "*", + "Hytale:BuilderTools": "*" + } +} +,{ + "Group": "Hytale", + "Name": "Reputation", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.adventure.reputation.ReputationPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:I18nModule": "*" + } +} +,{ + "Group": "Hytale", + "Name": "NPCReputation", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.adventure.npcreputation.NPCReputationPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:Reputation": "*", + "Hytale:NPC": "*", + "Hytale:TagSet": "*" + } +} +,{ + "Group": "Hytale", + "Name": "Shop", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.adventure.shop.ShopPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:InteractionModule": "*" + } +} +,{ + "Group": "Hytale", + "Name": "ShopReputation", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.adventure.shopreputation.ShopReputationPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:Shop": "*", + "Hytale:Reputation": "*" + } +} +,{ + "Group": "Hytale", + "Name": "NPCShop", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.adventure.npcshop.NPCShopPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:Shop": "*", + "Hytale:NPC": "*", + "Hytale:I18nModule": "*" + } +} +,{ + "Group": "Hytale", + "Name": "NPCEditor", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.npceditor.NPCEditorPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:NPC": "*", + "Hytale:AssetEditor": "*" + } +} +,{ + "Group": "Hytale", + "Name": "Stash", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.adventure.stash.StashPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:ItemModule": "*", + "Hytale:BlockStateModule": "*" + } +} +,{ + "Group": "Hytale", + "Name": "TagSet", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.tagset.TagSetPlugin", + "ServerVersion": "*" +} +,{ + "Group": "Hytale", + "Name": "Teleport", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.teleport.TeleportPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:I18nModule": "*", + "Hytale:EntityModule": "*" + } +} +,{ + "Group": "Hytale", + "Name": "Fluid", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.fluid.FluidPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:BlockTick": "*", + "Hytale:LegacyModule": "*" + } +} +,{ + "Group": "Hytale", + "Name": "Weather", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.weather.WeatherPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:EntityModule": "*" + } +} +,{ + "Group": "Hytale", + "Name": "WorldGen", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.worldgen.WorldGenPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:EntityModule": "*" + } +} +,{ + "Group": "Hytale", + "Name": "Farming", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.adventure.farming.FarmingPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:InteractionModule": "*", + "Hytale:BlockStateModule": "*", + "Hytale:BlockPhysics": "*" + } +} +,{ + "Group": "Hytale", + "Name": "Camera", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.adventure.camera.CameraPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:AssetModule": "*", + "Hytale:DamageModule": "*", + "Hytale:InteractionModule": "*" + } +} +,{ + "Group": "Hytale", + "Name": "WorldLocationCondition", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.adventure.worldlocationcondition.WorldLocationConditionPlugin", + "ServerVersion": "*", + "Dependencies": { + } +} +,{ + "Group": "Hytale", + "Name": "NPCCombatActionEvaluator", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.npccombatactionevaluator.NPCCombatActionEvaluatorPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:NPC": "*" + } +} +,{ + "Group": "Hytale", + "Name": "Model", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.model.ModelPlugin", + "ServerVersion": "*" +} +,{ + "Group": "Hytale", + "Name": "Mantling", + "Description": "Enable mantling", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.mantling.MantlingPlugin", + "ServerVersion": "*" +} +,{ + "Group": "Hytale", + "Name": "SafetyRoll", + "Description": "Enable Safety Roll", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.safetyroll.SafetyRollPlugin", + "ServerVersion": "*" +} +,{ + "Group": "Hytale", + "Name": "SprintForce", + "Description": "Enable sprint acceleration/deceleration", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.sprintforce.SprintForcePlugin", + "ServerVersion": "*" +} +,{ + "Group": "Hytale", + "Name": "CrouchSlide", + "Description": "Enable Crouch Sliding", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.crouchslide.CrouchSlidePlugin", + "ServerVersion": "*" +} +,{ + "Group": "Hytale", + "Name": "Parkour", + "Description": "Module to add a timer with a checkpoint system", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.parkour.ParkourPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:EntityModule": "*" + } +} +,{ + "Group": "Hytale", + "Name": "Mounts", + "Description": "Module to add mounts", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.mounts.MountPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:NPC": "*", + "Hytale:DamageModule": "*" + } +} +,{ + "Group": "Hytale", + "Name": "HytaleGenerator", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.hytalegenerator.plugin.HytaleGenerator", + "ServerVersion": "*" +} +,{ + "Group": "Hytale", + "Name": "Teleporter", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.adventure.teleporter.TeleporterPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:BlockStateModule": "*", + "Hytale:Teleport": "*" + } +} +,{ + "Group": "Hytale", + "Name": "Memories", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.adventure.memories.MemoriesPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:NPC": "*" + } +} +,{ + "Group": "Hytale", + "Name": "Deployables", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.deployables.DeployablesPlugin", + "ServerVersion": "*" +} +,{ + "Group": "Hytale", + "Name": "Portals", + "Description": "Module to add portals", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.portals.PortalsPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:NPC": "*", + "Hytale:Ambience": "*", + "Hytale:Instances": "*" + } +} +,{ + "Group": "Hytale", + "Name": "Beds", + "Description": "Module to handle beds and sleeping in them", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.beds.BedsPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:Mounts": "*" + } +} +,{ + "Group": "Hytale", + "Name": "Ambience", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.ambience.AmbiencePlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:EntityModule": "*" + } +} +,{ + "Group": "Hytale", + "Name": "CreativeHub", + "Version": "1.0.0", + "Website": "https://hypixel.com/", + "Main": "com.hypixel.hytale.builtin.creativehub.CreativeHubPlugin", + "ServerVersion": "*", + "Dependencies": { + "Hytale:I18nModule": "*", + "Hytale:Instances": "*" + } +} +] \ No newline at end of file