From d683e61c9820a9b0544efb56cc2e6eb7973363f8 Mon Sep 17 00:00:00 2001 From: LordMZTE Date: Tue, 29 Aug 2023 17:39:30 +0200 Subject: [PATCH] chore: format code --- .clang-format | 130 + .../wildbackport/WildBackport.java | 17 +- .../wildbackport/client/ClientSetup.java | 71 +- .../client/animation/FrogAnimations.java | 1240 ++++++- .../client/animation/WardenAnimations.java | 3054 ++++++++++++++++- .../client/animation/api/AnimatedModel.java | 30 +- .../client/animation/api/Animation.java | 22 +- .../client/animation/api/AnimationHelper.java | 46 +- .../client/animation/api/AnimationState.java | 15 +- .../client/animation/api/Keyframe.java | 3 +- .../client/animation/api/Transformation.java | 54 +- .../client/particle/SculkChargeParticle.java | 29 +- .../particle/SculkChargeParticleOptions.java | 49 +- .../particle/SculkChargePopParticle.java | 29 +- .../client/particle/SculkSoulParticle.java | 29 +- .../client/particle/ShriekParticle.java | 64 +- .../particle/ShriekParticleOptions.java | 48 +- .../client/particle/SonicBoomParticle.java | 18 +- .../client/registry/WBCriteriaTriggers.java | 13 +- .../client/registry/WBParticleTypes.java | 58 +- .../client/registry/WBSoundEvents.java | 277 +- .../client/registry/WBSoundTypes.java | 102 +- .../client/render/AllayRenderer.java | 6 +- .../client/render/ChestBoatRenderer.java | 67 +- .../client/render/FrogRenderer.java | 23 +- .../client/render/TadpoleRenderer.java | 6 +- .../client/render/WardenLayerRenderer.java | 84 +- .../client/render/WardenRenderer.java | 60 +- .../client/render/model/AllayModel.java | 97 +- .../client/render/model/ChestBoatModel.java | 126 +- .../client/render/model/FrogModel.java | 169 +- .../client/render/model/TadpoleModel.java | 26 +- .../client/render/model/WardenModel.java | 143 +- .../client/sound/CoreSoundType.java | 12 +- .../wildbackport/common/CommonSetup.java | 2 +- .../common/VanillaIntegration.java | 76 +- .../common/blocks/DrippingFluid.java | 40 +- .../common/blocks/FrogspawnBlock.java | 43 +- .../common/blocks/MangroveLeavesBlock.java | 14 +- .../common/blocks/MangrovePropaguleBlock.java | 88 +- .../common/blocks/MangroveRootsBlock.java | 36 +- .../common/blocks/MangroveTreeGrower.java | 13 +- .../wildbackport/common/blocks/MudBlock.java | 21 +- .../common/blocks/SculkBlock.java | 71 +- .../common/blocks/SculkCatalystBlock.java | 59 +- .../common/blocks/SculkShriekerBlock.java | 92 +- .../common/blocks/SculkSpreadManager.java | 290 +- .../common/blocks/SculkSpreadable.java | 63 +- .../common/blocks/SculkVeinBlock.java | 144 +- .../common/blocks/StateProperties.java | 18 +- .../entity/SculkCatalystBlockEntity.java | 34 +- .../entity/SculkShriekerBlockEntity.java | 105 +- .../common/effects/EffectFactor.java | 12 +- .../common/effects/FactorCalculationData.java | 65 +- .../wildbackport/common/entities/Allay.java | 146 +- .../common/entities/ChestBoat.java | 69 +- .../wildbackport/common/entities/Frog.java | 148 +- .../common/entities/MangroveBoat.java | 11 +- .../wildbackport/common/entities/Tadpole.java | 70 +- .../wildbackport/common/entities/Warden.java | 232 +- .../common/entities/access/Listener.java | 15 +- .../common/entities/access/Recovery.java | 6 +- .../common/entities/access/Vibration.java | 26 +- .../common/entities/access/WardenTracker.java | 2 +- .../common/entities/brain/AllayBrain.java | 83 +- .../common/entities/brain/FrogBrain.java | 202 +- .../common/entities/brain/TadpoleBrain.java | 45 +- .../common/entities/brain/WardenBrain.java | 182 +- .../brain/allay/FlyingRandomStroll.java | 13 +- .../allay/GiveInventoryToLookTarget.java | 54 +- .../brain/allay/StayCloseToTarget.java | 25 +- .../brain/frog/BiasedLongJumpTask.java | 36 +- .../common/entities/brain/frog/Croak.java | 5 +- .../brain/frog/FrogAttackablesSensor.java | 17 +- .../common/entities/brain/frog/FrogEat.java | 138 +- .../brain/frog/FrogJumpToRandomPos.java | 141 +- .../entities/brain/frog/IsInWaterSensor.java | 5 +- .../entities/brain/frog/LayFrogSpawn.java | 21 +- .../entities/brain/frog/WalkTowardsLand.java | 25 +- .../entities/brain/frog/WalkTowardsWater.java | 33 +- .../common/entities/brain/warden/Digging.java | 12 +- .../entities/brain/warden/Emerging.java | 14 +- .../entities/brain/warden/FindRoarTarget.java | 15 +- .../brain/warden/ForgetAttackTarget.java | 27 +- .../brain/warden/GoToTargetLocation.java | 32 +- .../warden/NearestLivingEntitySensor.java | 28 +- .../common/entities/brain/warden/Roar.java | 38 +- .../brain/warden/SetWardenLookTarget.java | 26 +- .../entities/brain/warden/Sniffing.java | 43 +- .../entities/brain/warden/SonicBoom.java | 102 +- .../entities/brain/warden/TryToSniff.java | 17 +- .../brain/warden/WardenEntitySensor.java | 40 +- .../common/entities/warden/Angriness.java | 9 +- .../entities/warden/MobPositionSource.java | 76 +- .../entities/warden/VibrationHandler.java | 220 +- .../entities/warden/WardenAngerManager.java | 214 +- .../entities/warden/WardenSpawnHelper.java | 43 +- .../entities/warden/WardenSpawnTracker.java | 67 +- .../common/items/ChestBoatItem.java | 36 +- .../items/CompassItemPropertyFunction.java | 67 +- .../common/items/DiscFragmentItem.java | 14 +- .../common/items/GoatHornItem.java | 76 +- .../wildbackport/common/items/Instrument.java | 9 +- .../common/items/TadpoleBucketItem.java | 58 +- .../common/registry/Instruments.java | 89 +- .../common/registry/WBBiomes.java | 79 +- .../common/registry/WBBlockEntities.java | 25 +- .../common/registry/WBBlocks.java | 416 ++- .../common/registry/WBEnchantments.java | 15 +- .../common/registry/WBGameEvents.java | 18 +- .../common/registry/WBGameRules.java | 9 +- .../wildbackport/common/registry/WBItems.java | 101 +- .../common/registry/WBMobEffects.java | 17 +- .../common/registry/WBPositionSources.java | 10 +- .../common/registry/WBRegistries.java | 12 +- .../common/registry/entity/WBActivities.java | 23 +- .../common/registry/entity/WBEntityTypes.java | 54 +- .../registry/entity/WBMemoryModules.java | 85 +- .../common/registry/entity/WBSensorTypes.java | 22 +- .../registry/worldgen/RootPlacerType.java | 13 +- .../common/registry/worldgen/WBFeatures.java | 26 +- .../registry/worldgen/WBStructures.java | 15 +- .../registry/worldgen/WBTreeDecorators.java | 25 +- .../registry/worldgen/WBTrunkPlacers.java | 14 +- .../registry/worldgen/WBWorldGeneration.java | 318 +- .../common/tag/InstrumentTags.java | 9 +- .../wildbackport/common/tag/WBBiomeTags.java | 15 +- .../wildbackport/common/tag/WBBlockTags.java | 27 +- .../common/tag/WBEntityTypeTags.java | 3 +- .../common/tag/WBGameEventTags.java | 12 +- .../wildbackport/common/tag/WBItemTags.java | 7 +- .../common/utils/DirectionUtils.java | 9 +- .../wildbackport/common/utils/MathUtils.java | 10 +- .../wildbackport/common/utils/MobUtils.java | 41 +- .../wildbackport/common/utils/ModUtils.java | 4 +- .../common/utils/ParticleUtils.java | 40 +- .../common/utils/PositionUtils.java | 26 +- .../common/worldgen/MangroveSwampSurface.java | 46 +- .../worldgen/PredicatedStateProvider.java | 33 +- .../common/worldgen/VeinGrower.java | 167 +- .../common/worldgen/WorldGenerator.java | 21 +- .../decorator/AboveRootPlacement.java | 25 +- .../decorator/AttachedToLeavesDecorator.java | 93 +- .../decorator/MangroveRootPlacement.java | 49 +- .../decorator/WeightedLeaveVineDecorator.java | 48 +- .../features/GrassDiskConfiguration.java | 26 +- .../worldgen/features/GrassDiskFeature.java | 24 +- .../worldgen/features/RootedTreeConfig.java | 128 +- .../worldgen/features/RootedTreeFeature.java | 186 +- .../worldgen/features/SculkGrowthFeature.java | 55 +- .../features/SculkPatchConfiguration.java | 56 +- .../worldgen/features/SculkPatchFeature.java | 33 +- .../worldgen/placers/MangroveRootPlacer.java | 106 +- .../common/worldgen/placers/RootPlacer.java | 92 +- .../placers/UpwardBranchingTrunk.java | 117 +- .../structure/AncientCityStructurePieces.java | 30 +- .../structure/StructureGeneration.java | 32 +- .../pools/AncientCityStructurePools.java | 477 ++- .../processors/BlockTagRotProcessor.java | 50 +- .../processors/WBProcessorLists.java | 91 +- .../wildbackport/core/api/ColorRegistry.java | 12 +- .../wildbackport/core/api/CoreRegistry.java | 13 +- .../wildbackport/core/api/Environment.java | 5 +- .../wildbackport/core/api/MobRegistry.java | 9 +- .../core/api/ParticleRegistry.java | 13 +- .../core/api/RegistryBuilder.java | 10 +- .../wildbackport/core/api/RenderRegistry.java | 17 +- .../core/api/worldgen/BiomeModifier.java | 14 +- .../core/api/worldgen/BiomeWriter.java | 26 +- .../core/mixin/access/AxeItemAccessor.java | 4 +- .../core/mixin/access/GameRulesAccessor.java | 7 +- .../access/MemoryModuleTypeAccessor.java | 4 +- .../core/mixin/access/ModelPartAccessor.java | 4 +- .../access/PointedDripstoneBlockAccessor.java | 7 +- .../access/PressurePlateBlockAccessor.java | 4 +- .../core/mixin/access/RecordItemAccessor.java | 3 +- .../core/mixin/access/RenderTypeAccessor.java | 10 +- .../core/mixin/access/SensorTypeAccessor.java | 4 +- .../core/mixin/access/StairBlockAccessor.java | 3 +- .../access/StructureTemplatePoolAccessor.java | 4 +- .../access/TreeDecoratorTypeAccessor.java | 3 +- .../mixin/access/TreeFeatureAccessor.java | 10 +- .../mixin/access/TrunkPlacerTypeAccessor.java | 3 +- .../core/mixin/client/LightTextureMixin.java | 89 +- .../core/mixin/client/LocalPlayerMixin.java | 27 +- .../core/mixin/client/ModelPartMixin.java | 41 +- .../mixin/client/PartDefinitionMixin.java | 4 +- .../mixin/common/BlockEntityTypeMixin.java | 4 +- .../mixin/common/FlyNodeEvaluatorMixin.java | 32 +- .../core/mixin/common/ItemsMixin.java | 9 +- .../core/mixin/common/LivingEntityMixin.java | 10 +- .../core/mixin/common/MobEffectMixin.java | 77 +- .../core/mixin/common/NoteBlockMixin.java | 13 +- .../core/mixin/common/PathfinderMobMixin.java | 17 +- .../core/mixin/common/PlayerMixin.java | 20 +- .../common/PointedDripstoneBlockMixin.java | 8 +- .../common/SculkSensorBlockEntityMixin.java | 22 +- .../mixin/common/SculkSensorBlockMixin.java | 11 +- .../core/mixin/common/SlimeMixin.java | 30 +- .../mixin/common/VibrationListenerMixin.java | 8 +- .../core/mixin/extension/BoatTypeMixin.java | 39 +- .../core/mixin/extension/PoseMixin.java | 26 +- .../network/ClientPacketListenerMixin.java | 33 +- ...ClientboundUpdateMobEffectPacketMixin.java | 34 +- .../network/MultiPlayerGameModeMixin.java | 10 +- .../ServerGamePacketListenerImplMixin.java | 6 +- .../common/registry/fabric/WBItemsImpl.java | 16 +- .../api/event/fabric/InteractionsImpl.java | 5 +- .../core/api/fabric/ColorRegistryImpl.java | 12 +- .../core/api/fabric/MobRegistryImpl.java | 9 +- .../core/api/fabric/ParticleRegistryImpl.java | 10 +- .../core/api/fabric/RenderRegistryImpl.java | 17 +- .../core/api/fabric/WoodTypeRegistryImpl.java | 5 +- .../worldgen/fabric/BiomeModifierImpl.java | 9 +- .../worldgen/fabric/FabricBiomeWriter.java | 28 +- .../mixin/fabric/client/FogRendererMixin.java | 57 +- .../core/mixin/fabric/client/SheetsMixin.java | 10 +- .../fabric/TerrablenderSetup.java | 37 +- .../common/registry/forge/WBItemsImpl.java | 16 +- .../api/event/forge/InteractionsImpl.java | 21 +- .../core/api/forge/ColorRegistryImpl.java | 28 +- .../core/api/forge/CoreRegistryImpl.java | 14 +- .../core/api/forge/EventBuses.java | 19 +- .../core/api/forge/MobRegistryImpl.java | 14 +- .../core/api/forge/ParticleRegistryImpl.java | 34 +- .../core/api/forge/RenderRegistryImpl.java | 33 +- .../core/api/forge/WoodTypeRegistryImpl.java | 3 +- .../api/worldgen/forge/BiomeModifierImpl.java | 3 +- .../api/worldgen/forge/ForgeBiomeWriter.java | 18 +- .../wildbackport/forge/DarknessSetup.java | 41 +- .../wildbackport/forge/RemappingSetup.java | 34 +- .../wildbackport/forge/WildBackportForge.java | 37 +- 232 files changed, 12816 insertions(+), 2583 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..d48bed8 --- /dev/null +++ b/.clang-format @@ -0,0 +1,130 @@ +--- +AccessModifierOffset: 0 +AlignAfterOpenBracket: BlockIndent +AlignArrayOfStructures: None +AlignConsecutiveAssignments: None +AlignConsecutiveMacros: None +AlignConsecutiveBitFields: None +AlignConsecutiveDeclarations: None +AlignEscapedNewlines: DontAlign +AlignOperands: DontAlign +AlignTrailingComments: false +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: Empty +AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: MultiLine +AttributeMacros: [] +BinPackArguments: false +BinPackParameters: false +BitFieldColonSpacing: After +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: false +BreakAfterJavaFieldAnnotations: true +#BreakArrays: false +BreakBeforeBinaryOperators: All +BreakBeforeBraces: Custom +BreakBeforeConceptDeclarations: true +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: AfterColon +BreakInheritanceList: AfterColon +BreakStringLiterals: true +ColumnLimit: 90 +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: false +DeriveLineEnding: false +DerivePointerAlignment: false +DisableFormat: false # wtf +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: Always +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: false +ForEachMacros: ["BOOST_FOREACH"] +IfMacros: [] +IncludeBlocks: Regroup +IndentAccessModifiers: false +IndentCaseBlocks: false +IndentCaseLabels: true +IndentExternBlock: Indent +IndentGotoLabels: true +IndentPPDirectives: BeforeHash +#IndentRequiresClause: false +IndentWidth: 4 +IndentWrappedFunctionNames: false +#InsertBraces: false +InsertTrailingCommas: Wrapped +JavaImportGroups: ["java"] +JavaScriptQuotes: Double +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +LambdaBodyIndentation: OuterScope +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: All +PackConstructorInitializers: NextLine +PointerAlignment: Left +QualifierAlignment: Left +ReferenceAlignment: Left +ReflowComments: true +#RemoveSemicolon: true +#RequiresClausePosition: OwnLine +#RequiresExpressionIndentation: OuterScope +SeparateDefinitionBlocks: Always +SortIncludes: CaseInsensitive +SortJavaStaticImport: Before +SortUsingDeclarations: true +SpaceAfterCStyleCast: true +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: false +SpaceAroundPointerQualifiers: After +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: false +SpaceBeforeInheritanceColon: false +SpaceBeforeParens: ControlStatementsExceptControlMacros +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesInAngles: Never +SpacesInCStyleCastParentheses: false +SpacesInConditionalStatement: false +SpacesInContainerLiterals: false +SpacesInLineCommentPrefix: + Minimum: 0 + Maximum: -1 +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: c++20 +StatementAttributeLikeMacros: [] +StatementMacros: [] +TabWidth: 4 +TypenameMacros: [] +UseCRLF: false # wtf +UseTab: Never +WhitespaceSensitiveMacros: ["BOOST_PP_STRINGSIZE"] diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/WildBackport.java b/common/src/main/java/com/cursedcauldron/wildbackport/WildBackport.java index 27bd139..a6a17ec 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/WildBackport.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/WildBackport.java @@ -14,14 +14,14 @@ import com.cursedcauldron.wildbackport.common.registry.WBGameRules; import com.cursedcauldron.wildbackport.common.registry.WBItems; import com.cursedcauldron.wildbackport.common.registry.WBMobEffects; import com.cursedcauldron.wildbackport.common.registry.WBPositionSources; -import com.cursedcauldron.wildbackport.common.registry.worldgen.WBFeatures; -import com.cursedcauldron.wildbackport.common.registry.worldgen.RootPlacerType; -import com.cursedcauldron.wildbackport.common.registry.worldgen.WBTreeDecorators; -import com.cursedcauldron.wildbackport.common.registry.worldgen.WBTrunkPlacers; import com.cursedcauldron.wildbackport.common.registry.entity.WBActivities; import com.cursedcauldron.wildbackport.common.registry.entity.WBEntityTypes; import com.cursedcauldron.wildbackport.common.registry.entity.WBMemoryModules; import com.cursedcauldron.wildbackport.common.registry.entity.WBSensorTypes; +import com.cursedcauldron.wildbackport.common.registry.worldgen.RootPlacerType; +import com.cursedcauldron.wildbackport.common.registry.worldgen.WBFeatures; +import com.cursedcauldron.wildbackport.common.registry.worldgen.WBTreeDecorators; +import com.cursedcauldron.wildbackport.common.registry.worldgen.WBTrunkPlacers; import com.cursedcauldron.wildbackport.common.tag.InstrumentTags; import com.cursedcauldron.wildbackport.common.tag.WBBiomeTags; import com.cursedcauldron.wildbackport.common.tag.WBBlockTags; @@ -72,8 +72,11 @@ public class WildBackport { WBItemTags.TAGS.bootstrap(); InstrumentTags.TAGS.bootstrap(); -// ItemProperties.register(WBItems.RECOVERY_COMPASS.get(), new ResourceLocation("angle"), new CompassItemPropertyFunction((level, stack, entity) -> { -// return entity instanceof Player player ? Recovery.of(player).getLastDeathLocation().orElse(null) : null; -// })); + // ItemProperties.register(WBItems.RECOVERY_COMPASS.get(), new + // ResourceLocation("angle"), new CompassItemPropertyFunction((level, + // stack, entity) -> { + // return entity instanceof Player player ? + // Recovery.of(player).getLastDeathLocation().orElse(null) : null; + // })); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/ClientSetup.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/ClientSetup.java index 124a332..b59f728 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/ClientSetup.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/ClientSetup.java @@ -41,28 +41,58 @@ public class ClientSetup { */ public static void onClient() { // Colors - ColorRegistry.register((state, getter, pos, tint) -> (getter == null || pos == null) ? FoliageColor.getDefaultColor() : BiomeColors.getAverageFoliageColor(getter, pos), WBBlocks.MANGROVE_LEAVES); + ColorRegistry.register( + (state, getter, pos, tint) + -> (getter == null || pos == null) + ? FoliageColor.getDefaultColor() + : BiomeColors.getAverageFoliageColor(getter, pos), + WBBlocks.MANGROVE_LEAVES + ); ColorRegistry.register((stack, tint) -> 9619016, WBBlocks.MANGROVE_LEAVES); // Entity Renderers - RenderRegistry.setLayerDefinition(AllayRenderer.MODEL_LAYER, AllayModel::createBodyLayer); + RenderRegistry.setLayerDefinition( + AllayRenderer.MODEL_LAYER, AllayModel::createBodyLayer + ); RenderRegistry.setEntityRender(WBEntityTypes.ALLAY, AllayRenderer::new); - RenderRegistry.setLayerDefinition(WardenRenderer.MODEL_LAYER, WardenModel::createBodyLayer); + RenderRegistry.setLayerDefinition( + WardenRenderer.MODEL_LAYER, WardenModel::createBodyLayer + ); RenderRegistry.setEntityRender(WBEntityTypes.WARDEN, WardenRenderer::new); - RenderRegistry.setLayerDefinition(FrogRenderer.MODEL_LAYER, FrogModel::createBodyLayer); + RenderRegistry.setLayerDefinition( + FrogRenderer.MODEL_LAYER, FrogModel::createBodyLayer + ); RenderRegistry.setEntityRender(WBEntityTypes.FROG, FrogRenderer::new); - RenderRegistry.setLayerDefinition(TadpoleRenderer.MODEL_LAYER, TadpoleModel::createBodyLayer); + RenderRegistry.setLayerDefinition( + TadpoleRenderer.MODEL_LAYER, TadpoleModel::createBodyLayer + ); RenderRegistry.setEntityRender(WBEntityTypes.TADPOLE, TadpoleRenderer::new); - for (Boat.Type type : Boat.Type.values()) RenderRegistry.setLayerDefinition(ChestBoatModel.createChestBoat(type), () -> ChestBoatModel.createBodyModel(true)); - RenderRegistry.setEntityRender(WBEntityTypes.MANGROVE_BOAT, context -> new ChestBoatRenderer(context, false)); - RenderRegistry.setEntityRender(WBEntityTypes.CHEST_BOAT, context -> new ChestBoatRenderer(context, true)); + for (Boat.Type type : Boat.Type.values()) + RenderRegistry.setLayerDefinition( + ChestBoatModel.createChestBoat(type), + () -> ChestBoatModel.createBodyModel(true) + ); + RenderRegistry.setEntityRender( + WBEntityTypes.MANGROVE_BOAT, context -> new ChestBoatRenderer(context, false) + ); + RenderRegistry.setEntityRender( + WBEntityTypes.CHEST_BOAT, context -> new ChestBoatRenderer(context, true) + ); // Particle Renderers - ParticleRegistry.create(WBParticleTypes.SCULK_SOUL, SculkSoulParticle.Provider::new); - ParticleRegistry.create(WBParticleTypes.SCULK_CHARGE, SculkChargeParticle.Provider::new); - ParticleRegistry.create(WBParticleTypes.SCULK_CHARGE_POP, SculkChargePopParticle.Provider::new); + ParticleRegistry.create( + WBParticleTypes.SCULK_SOUL, SculkSoulParticle.Provider::new + ); + ParticleRegistry.create( + WBParticleTypes.SCULK_CHARGE, SculkChargeParticle.Provider::new + ); + ParticleRegistry.create( + WBParticleTypes.SCULK_CHARGE_POP, SculkChargePopParticle.Provider::new + ); ParticleRegistry.create(WBParticleTypes.SHRIEK, ShriekParticle.Provider::new); - ParticleRegistry.create(WBParticleTypes.SONIC_BOOM, SonicBoomParticle.Provider::new); + ParticleRegistry.create( + WBParticleTypes.SONIC_BOOM, SonicBoomParticle.Provider::new + ); } /** @@ -70,14 +100,15 @@ public class ClientSetup { */ public static void onPostClient() { // Block Render Types - RenderRegistry.setBlockRenderType(RenderType.cutout(), - WBBlocks.SCULK_VEIN.get(), - WBBlocks.SCULK_SHRIEKER.get(), - WBBlocks.FROGSPAWN.get(), - WBBlocks.MANGROVE_ROOTS.get(), - WBBlocks.MANGROVE_TRAPDOOR.get(), - WBBlocks.MANGROVE_PROPAGULE.get(), - WBBlocks.POTTED_MANGROVE_PROPAGULE.get() + RenderRegistry.setBlockRenderType( + RenderType.cutout(), + WBBlocks.SCULK_VEIN.get(), + WBBlocks.SCULK_SHRIEKER.get(), + WBBlocks.FROGSPAWN.get(), + WBBlocks.MANGROVE_ROOTS.get(), + WBBlocks.MANGROVE_TRAPDOOR.get(), + WBBlocks.MANGROVE_PROPAGULE.get(), + WBBlocks.POTTED_MANGROVE_PROPAGULE.get() ); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/FrogAnimations.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/FrogAnimations.java index f233982..66ee3dd 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/FrogAnimations.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/FrogAnimations.java @@ -6,64 +6,1194 @@ import com.cursedcauldron.wildbackport.client.animation.api.Keyframe; import com.cursedcauldron.wildbackport.client.animation.api.Transformation; public class FrogAnimations { - public static final Animation CROAKING = Animation.Builder.create(4.5F).looping() - .addBoneAnimation("croaking_body", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.6667F, AnimationHelper.translate(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.7083F, AnimationHelper.translate(0.0F, 1.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(3.2083F, AnimationHelper.translate(0.0F, 1.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(3.25F, AnimationHelper.translate(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL))) - .addBoneAnimation("croaking_body", new Transformation(Transformation.Targets.SCALE, new Keyframe(0.6667F, AnimationHelper.scale(1.0F, 1.0F, 1.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.7083F, AnimationHelper.scale(1.0F, 1.0F, 1.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.7917F, AnimationHelper.scale(1.3F, 2.1F, 1.6F), Transformation.Interpolations.LINEAL), new Keyframe(0.875F, AnimationHelper.scale(1.3F, 2.1F, 1.6F), Transformation.Interpolations.LINEAL), new Keyframe(0.9583F, AnimationHelper.scale(1.0F, 1.0F, 1.0F), Transformation.Interpolations.LINEAL), new Keyframe(2.5F, AnimationHelper.scale(1.0F, 1.0F, 1.0F), Transformation.Interpolations.LINEAL), new Keyframe(2.5833F, AnimationHelper.scale(1.3F, 2.1F, 1.6F), Transformation.Interpolations.LINEAL), new Keyframe(2.6667F, AnimationHelper.scale(1.3F, 2.1F, 1.6F), Transformation.Interpolations.LINEAL), new Keyframe(2.75F, AnimationHelper.scale(1.0F, 1.0F, 1.0F), Transformation.Interpolations.LINEAL), new Keyframe(2.8333F, AnimationHelper.scale(1.0F, 1.0F, 1.0F), Transformation.Interpolations.LINEAL), new Keyframe(2.9167F, AnimationHelper.scale(1.3F, 2.1F, 1.6F), Transformation.Interpolations.LINEAL), new Keyframe(3.125F, AnimationHelper.scale(1.3F, 2.1F, 1.8F), Transformation.Interpolations.LINEAL), new Keyframe(3.2083F, AnimationHelper.scale(1.0F, 1.0F, 1.0F), Transformation.Interpolations.LINEAL), new Keyframe(3.25F, AnimationHelper.scale(1.0F, 1.0F, 1.0F), Transformation.Interpolations.LINEAL))) - .build(); + public static final Animation CROAKING + = Animation.Builder.create(4.5F) + .looping() + .addBoneAnimation( + "croaking_body", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.6667F, + AnimationHelper.translate(0.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.7083F, + AnimationHelper.translate(0.0F, 1.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 3.2083F, + AnimationHelper.translate(0.0F, 1.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 3.25F, + AnimationHelper.translate(0.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "croaking_body", + new Transformation( + Transformation.Targets.SCALE, + new Keyframe( + 0.6667F, + AnimationHelper.scale(1.0F, 1.0F, 1.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.7083F, + AnimationHelper.scale(1.0F, 1.0F, 1.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.7917F, + AnimationHelper.scale(1.3F, 2.1F, 1.6F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.875F, + AnimationHelper.scale(1.3F, 2.1F, 1.6F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.9583F, + AnimationHelper.scale(1.0F, 1.0F, 1.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 2.5F, + AnimationHelper.scale(1.0F, 1.0F, 1.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 2.5833F, + AnimationHelper.scale(1.3F, 2.1F, 1.6F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 2.6667F, + AnimationHelper.scale(1.3F, 2.1F, 1.6F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 2.75F, + AnimationHelper.scale(1.0F, 1.0F, 1.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 2.8333F, + AnimationHelper.scale(1.0F, 1.0F, 1.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 2.9167F, + AnimationHelper.scale(1.3F, 2.1F, 1.6F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 3.125F, + AnimationHelper.scale(1.3F, 2.1F, 1.8F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 3.2083F, + AnimationHelper.scale(1.0F, 1.0F, 1.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 3.25F, + AnimationHelper.scale(1.0F, 1.0F, 1.0F), + Transformation.Interpolations.LINEAL + ) + ) + ) + .build(); - public static final Animation WALKING = Animation.Builder.create(1.25F).looping() - .addBoneAnimation("left_arm", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0F, AnimationHelper.rotation(0.0F, -5.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.2917F, AnimationHelper.rotation(7.5F, -2.67F, -7.5F), Transformation.Interpolations.LINEAL), new Keyframe(0.625F, AnimationHelper.rotation(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.7917F, AnimationHelper.rotation(22.5F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(1.125F, AnimationHelper.rotation(-45.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(1.25F, AnimationHelper.rotation(0.0F, -5.0F, 0.0F), Transformation.Interpolations.LINEAL))) - .addBoneAnimation("left_arm", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0F, AnimationHelper.translate(0.0F, 0.1F, -2.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.2917F, AnimationHelper.translate(-0.5F, -0.25F, -0.13F), Transformation.Interpolations.LINEAL), new Keyframe(0.625F, AnimationHelper.translate(-0.5F, 0.1F, 2.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.9583F, AnimationHelper.translate(0.5F, 1.0F, -0.11F), Transformation.Interpolations.LINEAL), new Keyframe(1.25F, AnimationHelper.translate(0.0F, 0.1F, -2.0F), Transformation.Interpolations.LINEAL))) - .addBoneAnimation("right_arm", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0F, AnimationHelper.rotation(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.125F, AnimationHelper.rotation(22.5F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.4583F, AnimationHelper.rotation(-45.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.625F, AnimationHelper.rotation(0.0F, 5.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.9583F, AnimationHelper.rotation(7.5F, 2.33F, 7.5F), Transformation.Interpolations.LINEAL), new Keyframe(1.25F, AnimationHelper.rotation(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL))) - .addBoneAnimation("right_arm", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0F, AnimationHelper.translate(0.5F, 0.1F, 2.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.2917F, AnimationHelper.translate(-0.5F, 1.0F, 0.12F), Transformation.Interpolations.LINEAL), new Keyframe(0.625F, AnimationHelper.translate(0.0F, 0.1F, -2.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.9583F, AnimationHelper.translate(0.5F, -0.25F, -0.13F), Transformation.Interpolations.LINEAL), new Keyframe(1.25F, AnimationHelper.translate(0.5F, 0.1F, 2.0F), Transformation.Interpolations.LINEAL))) - .addBoneAnimation("left_leg", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0F, AnimationHelper.rotation(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.1667F, AnimationHelper.rotation(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.2917F, AnimationHelper.rotation(45.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.625F, AnimationHelper.rotation(-45.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.7917F, AnimationHelper.rotation(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(1.25F, AnimationHelper.rotation(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL))) - .addBoneAnimation("left_leg", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0F, AnimationHelper.translate(0.0F, 0.1F, 1.2F), Transformation.Interpolations.LINEAL), new Keyframe(0.1667F, AnimationHelper.translate(0.0F, 0.1F, 2.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.4583F, AnimationHelper.translate(0.0F, 2.0F, 1.06F), Transformation.Interpolations.LINEAL), new Keyframe(0.7917F, AnimationHelper.translate(0.0F, 0.1F, -1.0F), Transformation.Interpolations.LINEAL), new Keyframe(1.25F, AnimationHelper.translate(0.0F, 0.1F, 1.2F), Transformation.Interpolations.LINEAL))) - .addBoneAnimation("right_leg", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0F, AnimationHelper.rotation(-33.75F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.0417F, AnimationHelper.rotation(-45.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.1667F, AnimationHelper.rotation(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.7917F, AnimationHelper.rotation(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.9583F, AnimationHelper.rotation(45.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(1.25F, AnimationHelper.rotation(-33.75F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL))) - .addBoneAnimation("right_leg", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0F, AnimationHelper.translate(0.0F, 1.14F, 0.11F), Transformation.Interpolations.LINEAL), new Keyframe(0.1667F, AnimationHelper.translate(0.0F, 0.1F, -1.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.7917F, AnimationHelper.translate(0.0F, 0.1F, 2.0F), Transformation.Interpolations.LINEAL), new Keyframe(1.125F, AnimationHelper.translate(0.0F, 2.0F, 0.95F), Transformation.Interpolations.LINEAL), new Keyframe(1.25F, AnimationHelper.translate(0.0F, 1.14F, 0.11F), Transformation.Interpolations.LINEAL))) - .addBoneAnimation("body", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0F, AnimationHelper.rotation(0.0F, 5.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.2917F, AnimationHelper.rotation(-7.5F, 0.33F, 7.5F), Transformation.Interpolations.LINEAL), new Keyframe(0.625F, AnimationHelper.rotation(0.0F, -5.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.9583F, AnimationHelper.rotation(-7.5F, 0.33F, -7.5F), Transformation.Interpolations.LINEAL), new Keyframe(1.25F, AnimationHelper.rotation(0.0F, 5.0F, 0.0F), Transformation.Interpolations.LINEAL))) - .build(); + public static final Animation WALKING + = Animation.Builder.create(1.25F) + .looping() + .addBoneAnimation( + "left_arm", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0F, + AnimationHelper.rotation(0.0F, -5.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.2917F, + AnimationHelper.rotation(7.5F, -2.67F, -7.5F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.625F, + AnimationHelper.rotation(0.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.7917F, + AnimationHelper.rotation(22.5F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 1.125F, + AnimationHelper.rotation(-45.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 1.25F, + AnimationHelper.rotation(0.0F, -5.0F, 0.0F), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "left_arm", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0F, + AnimationHelper.translate(0.0F, 0.1F, -2.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.2917F, + AnimationHelper.translate(-0.5F, -0.25F, -0.13F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.625F, + AnimationHelper.translate(-0.5F, 0.1F, 2.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.9583F, + AnimationHelper.translate(0.5F, 1.0F, -0.11F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 1.25F, + AnimationHelper.translate(0.0F, 0.1F, -2.0F), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "right_arm", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0F, + AnimationHelper.rotation(0.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.125F, + AnimationHelper.rotation(22.5F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.4583F, + AnimationHelper.rotation(-45.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.625F, + AnimationHelper.rotation(0.0F, 5.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.9583F, + AnimationHelper.rotation(7.5F, 2.33F, 7.5F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 1.25F, + AnimationHelper.rotation(0.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "right_arm", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0F, + AnimationHelper.translate(0.5F, 0.1F, 2.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.2917F, + AnimationHelper.translate(-0.5F, 1.0F, 0.12F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.625F, + AnimationHelper.translate(0.0F, 0.1F, -2.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.9583F, + AnimationHelper.translate(0.5F, -0.25F, -0.13F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 1.25F, + AnimationHelper.translate(0.5F, 0.1F, 2.0F), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "left_leg", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0F, + AnimationHelper.rotation(0.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.1667F, + AnimationHelper.rotation(0.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.2917F, + AnimationHelper.rotation(45.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.625F, + AnimationHelper.rotation(-45.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.7917F, + AnimationHelper.rotation(0.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 1.25F, + AnimationHelper.rotation(0.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "left_leg", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0F, + AnimationHelper.translate(0.0F, 0.1F, 1.2F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.1667F, + AnimationHelper.translate(0.0F, 0.1F, 2.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.4583F, + AnimationHelper.translate(0.0F, 2.0F, 1.06F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.7917F, + AnimationHelper.translate(0.0F, 0.1F, -1.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 1.25F, + AnimationHelper.translate(0.0F, 0.1F, 1.2F), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "right_leg", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0F, + AnimationHelper.rotation(-33.75F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.0417F, + AnimationHelper.rotation(-45.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.1667F, + AnimationHelper.rotation(0.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.7917F, + AnimationHelper.rotation(0.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.9583F, + AnimationHelper.rotation(45.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 1.25F, + AnimationHelper.rotation(-33.75F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "right_leg", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0F, + AnimationHelper.translate(0.0F, 1.14F, 0.11F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.1667F, + AnimationHelper.translate(0.0F, 0.1F, -1.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.7917F, + AnimationHelper.translate(0.0F, 0.1F, 2.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 1.125F, + AnimationHelper.translate(0.0F, 2.0F, 0.95F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 1.25F, + AnimationHelper.translate(0.0F, 1.14F, 0.11F), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "body", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0F, + AnimationHelper.rotation(0.0F, 5.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.2917F, + AnimationHelper.rotation(-7.5F, 0.33F, 7.5F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.625F, + AnimationHelper.rotation(0.0F, -5.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.9583F, + AnimationHelper.rotation(-7.5F, 0.33F, -7.5F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 1.25F, + AnimationHelper.rotation(0.0F, 5.0F, 0.0F), + Transformation.Interpolations.LINEAL + ) + ) + ) + .build(); - public static final Animation LONG_JUMPING = Animation.Builder.create(0.5F) - .addBoneAnimation("body", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0F, AnimationHelper.rotation(-22.5F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.5F, AnimationHelper.rotation(-22.5F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL))) - .addBoneAnimation("body", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0F, AnimationHelper.translate(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.5F, AnimationHelper.translate(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL))) - .addBoneAnimation("left_arm", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0F, AnimationHelper.rotation(-56.14F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.5F, AnimationHelper.rotation(-56.14F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL))) - .addBoneAnimation("left_arm", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0F, AnimationHelper.translate(0.0F, 1.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.5F, AnimationHelper.translate(0.0F, 1.0F, 0.0F), Transformation.Interpolations.LINEAL))) - .addBoneAnimation("right_arm", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0F, AnimationHelper.rotation(-56.14F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.5F, AnimationHelper.rotation(-56.14F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL))) - .addBoneAnimation("right_arm", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0F, AnimationHelper.translate(0.0F, 1.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.5F, AnimationHelper.translate(0.0F, 1.0F, 0.0F), Transformation.Interpolations.LINEAL))) - .addBoneAnimation("left_leg", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0F, AnimationHelper.rotation(45.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.5F, AnimationHelper.rotation(45.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL))) - .addBoneAnimation("left_leg", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0F, AnimationHelper.translate(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.5F, AnimationHelper.translate(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL))) - .addBoneAnimation("right_leg", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0F, AnimationHelper.rotation(45.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.5F, AnimationHelper.rotation(45.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL))) - .addBoneAnimation("right_leg", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0F, AnimationHelper.translate(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL), new Keyframe(0.5F, AnimationHelper.translate(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAL))) - .build(); + public static final Animation LONG_JUMPING + = Animation.Builder.create(0.5F) + .addBoneAnimation( + "body", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0F, + AnimationHelper.rotation(-22.5F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.5F, + AnimationHelper.rotation(-22.5F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "body", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0F, + AnimationHelper.translate(0.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.5F, + AnimationHelper.translate(0.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "left_arm", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0F, + AnimationHelper.rotation(-56.14F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.5F, + AnimationHelper.rotation(-56.14F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "left_arm", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0F, + AnimationHelper.translate(0.0F, 1.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.5F, + AnimationHelper.translate(0.0F, 1.0F, 0.0F), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "right_arm", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0F, + AnimationHelper.rotation(-56.14F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.5F, + AnimationHelper.rotation(-56.14F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "right_arm", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0F, + AnimationHelper.translate(0.0F, 1.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.5F, + AnimationHelper.translate(0.0F, 1.0F, 0.0F), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "left_leg", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0F, + AnimationHelper.rotation(45.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.5F, + AnimationHelper.rotation(45.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "left_leg", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0F, + AnimationHelper.translate(0.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.5F, + AnimationHelper.translate(0.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "right_leg", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0F, + AnimationHelper.rotation(45.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.5F, + AnimationHelper.rotation(45.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "right_leg", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0F, + AnimationHelper.translate(0.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.5F, + AnimationHelper.translate(0.0F, 0.0F, 0.0F), + Transformation.Interpolations.LINEAL + ) + ) + ) + .build(); - public static final Animation USING_TONGUE = Animation.Builder.create(0.5f) - .addBoneAnimation("head", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.LINEAL), new Keyframe(0.0833f, AnimationHelper.rotation(-60.0f, 0.0f, 0.0f), Transformation.Interpolations.LINEAL), new Keyframe(0.4167f, AnimationHelper.rotation(-60.0f, 0.0f, 0.0f), Transformation.Interpolations.LINEAL), new Keyframe(0.5f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.LINEAL))) - .addBoneAnimation("head", new Transformation(Transformation.Targets.SCALE, new Keyframe(0.0f, AnimationHelper.rotation(1.0f, 1.0f, 1.0f), Transformation.Interpolations.LINEAL), new Keyframe(0.0833f, AnimationHelper.rotation(0.998f, 1.0f, 1.0f), Transformation.Interpolations.LINEAL), new Keyframe(0.4167f, AnimationHelper.rotation(0.998f, 1.0f, 1.0f), Transformation.Interpolations.LINEAL), new Keyframe(0.5f, AnimationHelper.rotation(1.0f, 1.0f, 1.0f), Transformation.Interpolations.LINEAL))) - .addBoneAnimation("tongue", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.LINEAL), new Keyframe(0.0833f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.LINEAL), new Keyframe(0.4167f, AnimationHelper.rotation(-18.0f, 0.0f, 0.0f), Transformation.Interpolations.LINEAL), new Keyframe(0.5f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.LINEAL))) - .addBoneAnimation("tongue", new Transformation(Transformation.Targets.SCALE, new Keyframe(0.0833f, AnimationHelper.scale(1.0, 1.0, 1.0), Transformation.Interpolations.LINEAL), new Keyframe(0.1667f, AnimationHelper.scale(0.5, 1.0, 5.0), Transformation.Interpolations.LINEAL), new Keyframe(0.4167f, AnimationHelper.scale(1.0, 1.0, 1.0), Transformation.Interpolations.LINEAL))) - .build(); + public static final Animation USING_TONGUE + = Animation.Builder.create(0.5f) + .addBoneAnimation( + "head", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.0833f, + AnimationHelper.rotation(-60.0f, 0.0f, 0.0f), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.4167f, + AnimationHelper.rotation(-60.0f, 0.0f, 0.0f), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.5f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "head", + new Transformation( + Transformation.Targets.SCALE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(1.0f, 1.0f, 1.0f), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.0833f, + AnimationHelper.rotation(0.998f, 1.0f, 1.0f), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.4167f, + AnimationHelper.rotation(0.998f, 1.0f, 1.0f), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.5f, + AnimationHelper.rotation(1.0f, 1.0f, 1.0f), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "tongue", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.0833f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.4167f, + AnimationHelper.rotation(-18.0f, 0.0f, 0.0f), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.5f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "tongue", + new Transformation( + Transformation.Targets.SCALE, + new Keyframe( + 0.0833f, + AnimationHelper.scale(1.0, 1.0, 1.0), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.1667f, + AnimationHelper.scale(0.5, 1.0, 5.0), + Transformation.Interpolations.LINEAL + ), + new Keyframe( + 0.4167f, + AnimationHelper.scale(1.0, 1.0, 1.0), + Transformation.Interpolations.LINEAL + ) + ) + ) + .build(); - public static final Animation SWIMMING = Animation.Builder.create(1.04167F).looping() - .addBoneAnimation("body", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0F, AnimationHelper.rotation(0.0F, 0.0F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.3333F, AnimationHelper.rotation(10.0F, 0.0F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.6667F, AnimationHelper.rotation(-10.0F, 0.0F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(1.0417F, AnimationHelper.rotation(0.0F, 0.0F, 0.0F), Transformation.Interpolations.CATMULL))) - .addBoneAnimation("left_arm", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0F, AnimationHelper.rotation(90.0F, 22.5F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.4583F, AnimationHelper.rotation(45.0F, 22.5F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.6667F, AnimationHelper.rotation(-22.5F, -22.5F, -22.5F), Transformation.Interpolations.CATMULL), new Keyframe(0.875F, AnimationHelper.rotation(-45.0F, -22.5F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.9583F, AnimationHelper.rotation(22.5F, 0.0F, 22.5F), Transformation.Interpolations.CATMULL), new Keyframe(1.0417F, AnimationHelper.rotation(90.0F, 22.5F, 0.0F), Transformation.Interpolations.CATMULL))) - .addBoneAnimation("left_arm", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0F, AnimationHelper.translate(0.0F, -0.64F, 2.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.4583F, AnimationHelper.translate(0.0F, -0.64F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.6667F, AnimationHelper.translate(0.0F, 0.0F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.875F, AnimationHelper.translate(0.0F, -0.27F, -1.14F), Transformation.Interpolations.CATMULL), new Keyframe(0.9583F, AnimationHelper.translate(0.0F, -1.45F, 0.43F), Transformation.Interpolations.CATMULL), new Keyframe(1.0417F, AnimationHelper.translate(0.0F, -0.64F, 2.0F), Transformation.Interpolations.CATMULL))) - .addBoneAnimation("right_arm", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0F, AnimationHelper.rotation(90.0F, -22.5F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.4583F, AnimationHelper.rotation(45.0F, -22.5F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.6667F, AnimationHelper.rotation(-22.5F, 22.5F, 22.5F), Transformation.Interpolations.CATMULL), new Keyframe(0.875F, AnimationHelper.rotation(-45.0F, 22.5F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.9583F, AnimationHelper.rotation(22.5F, 0.0F, -22.5F), Transformation.Interpolations.CATMULL), new Keyframe(1.0417F, AnimationHelper.rotation(90.0F, -22.5F, 0.0F), Transformation.Interpolations.CATMULL))) - .addBoneAnimation("right_arm", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0F, AnimationHelper.translate(0.0F, -0.64F, 2.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.4583F, AnimationHelper.translate(0.0F, -0.64F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.6667F, AnimationHelper.translate(0.0F, 0.0F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.875F, AnimationHelper.translate(0.0F, -0.27F, -1.14F), Transformation.Interpolations.CATMULL), new Keyframe(0.9583F, AnimationHelper.translate(0.0F, -1.45F, 0.43F), Transformation.Interpolations.CATMULL), new Keyframe(1.0417F, AnimationHelper.translate(0.0F, -0.64F, 2.0F), Transformation.Interpolations.CATMULL))) - .addBoneAnimation("left_leg", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0F, AnimationHelper.rotation(90.0F, 0.0F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.25F, AnimationHelper.rotation(90.0F, 0.0F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.4583F, AnimationHelper.rotation(67.5F, -45.0F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.7917F, AnimationHelper.rotation(90.0F, 45.0F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.9583F, AnimationHelper.rotation(90.0F, 0.0F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(1.0417F, AnimationHelper.rotation(90.0F, 0.0F, 0.0F), Transformation.Interpolations.CATMULL))) - .addBoneAnimation("left_leg", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0F, AnimationHelper.translate(-2.5F, 0.0F, 1.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.25F, AnimationHelper.translate(-2.0F, 0.0F, 1.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.4583F, AnimationHelper.translate(1.0F, -2.0F, -1.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.7917F, AnimationHelper.translate(0.58F, 0.0F, -2.83F), Transformation.Interpolations.CATMULL), new Keyframe(0.9583F, AnimationHelper.translate(-2.5F, 0.0F, 1.0F), Transformation.Interpolations.CATMULL), new Keyframe(1.0417F, AnimationHelper.translate(-2.5F, 0.0F, 1.0F), Transformation.Interpolations.CATMULL))) - .addBoneAnimation("right_leg", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0F, AnimationHelper.rotation(90.0F, 0.0F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.25F, AnimationHelper.rotation(90.0F, 0.0F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.4583F, AnimationHelper.rotation(67.5F, 45.0F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.7917F, AnimationHelper.rotation(90.0F, -45.0F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.9583F, AnimationHelper.rotation(90.0F, 0.0F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(1.0417F, AnimationHelper.rotation(90.0F, 0.0F, 0.0F), Transformation.Interpolations.CATMULL))) - .addBoneAnimation("right_leg", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0F, AnimationHelper.translate(2.5F, 0.0F, 1.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.25F, AnimationHelper.translate(2.0F, 0.0F, 1.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.4583F, AnimationHelper.translate(-1.0F, -2.0F, -1.0F), Transformation.Interpolations.CATMULL), new Keyframe(0.7917F, AnimationHelper.translate(-0.58F, 0.0F, -2.83F), Transformation.Interpolations.CATMULL), new Keyframe(0.9583F, AnimationHelper.translate(2.5F, 0.0F, 1.0F), Transformation.Interpolations.CATMULL), new Keyframe(1.0417F, AnimationHelper.translate(2.5F, 0.0F, 1.0F), Transformation.Interpolations.CATMULL))) - .build(); + public static final Animation SWIMMING + = Animation.Builder.create(1.04167F) + .looping() + .addBoneAnimation( + "body", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0F, + AnimationHelper.rotation(0.0F, 0.0F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.3333F, + AnimationHelper.rotation(10.0F, 0.0F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.6667F, + AnimationHelper.rotation(-10.0F, 0.0F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.0417F, + AnimationHelper.rotation(0.0F, 0.0F, 0.0F), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "left_arm", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0F, + AnimationHelper.rotation(90.0F, 22.5F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.4583F, + AnimationHelper.rotation(45.0F, 22.5F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.6667F, + AnimationHelper.rotation(-22.5F, -22.5F, -22.5F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.875F, + AnimationHelper.rotation(-45.0F, -22.5F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.9583F, + AnimationHelper.rotation(22.5F, 0.0F, 22.5F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.0417F, + AnimationHelper.rotation(90.0F, 22.5F, 0.0F), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "left_arm", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0F, + AnimationHelper.translate(0.0F, -0.64F, 2.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.4583F, + AnimationHelper.translate(0.0F, -0.64F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.6667F, + AnimationHelper.translate(0.0F, 0.0F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.875F, + AnimationHelper.translate(0.0F, -0.27F, -1.14F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.9583F, + AnimationHelper.translate(0.0F, -1.45F, 0.43F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.0417F, + AnimationHelper.translate(0.0F, -0.64F, 2.0F), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "right_arm", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0F, + AnimationHelper.rotation(90.0F, -22.5F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.4583F, + AnimationHelper.rotation(45.0F, -22.5F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.6667F, + AnimationHelper.rotation(-22.5F, 22.5F, 22.5F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.875F, + AnimationHelper.rotation(-45.0F, 22.5F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.9583F, + AnimationHelper.rotation(22.5F, 0.0F, -22.5F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.0417F, + AnimationHelper.rotation(90.0F, -22.5F, 0.0F), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "right_arm", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0F, + AnimationHelper.translate(0.0F, -0.64F, 2.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.4583F, + AnimationHelper.translate(0.0F, -0.64F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.6667F, + AnimationHelper.translate(0.0F, 0.0F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.875F, + AnimationHelper.translate(0.0F, -0.27F, -1.14F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.9583F, + AnimationHelper.translate(0.0F, -1.45F, 0.43F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.0417F, + AnimationHelper.translate(0.0F, -0.64F, 2.0F), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "left_leg", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0F, + AnimationHelper.rotation(90.0F, 0.0F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.25F, + AnimationHelper.rotation(90.0F, 0.0F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.4583F, + AnimationHelper.rotation(67.5F, -45.0F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.7917F, + AnimationHelper.rotation(90.0F, 45.0F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.9583F, + AnimationHelper.rotation(90.0F, 0.0F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.0417F, + AnimationHelper.rotation(90.0F, 0.0F, 0.0F), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "left_leg", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0F, + AnimationHelper.translate(-2.5F, 0.0F, 1.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.25F, + AnimationHelper.translate(-2.0F, 0.0F, 1.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.4583F, + AnimationHelper.translate(1.0F, -2.0F, -1.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.7917F, + AnimationHelper.translate(0.58F, 0.0F, -2.83F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.9583F, + AnimationHelper.translate(-2.5F, 0.0F, 1.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.0417F, + AnimationHelper.translate(-2.5F, 0.0F, 1.0F), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "right_leg", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0F, + AnimationHelper.rotation(90.0F, 0.0F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.25F, + AnimationHelper.rotation(90.0F, 0.0F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.4583F, + AnimationHelper.rotation(67.5F, 45.0F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.7917F, + AnimationHelper.rotation(90.0F, -45.0F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.9583F, + AnimationHelper.rotation(90.0F, 0.0F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.0417F, + AnimationHelper.rotation(90.0F, 0.0F, 0.0F), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "right_leg", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0F, + AnimationHelper.translate(2.5F, 0.0F, 1.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.25F, + AnimationHelper.translate(2.0F, 0.0F, 1.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.4583F, + AnimationHelper.translate(-1.0F, -2.0F, -1.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.7917F, + AnimationHelper.translate(-0.58F, 0.0F, -2.83F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.9583F, + AnimationHelper.translate(2.5F, 0.0F, 1.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.0417F, + AnimationHelper.translate(2.5F, 0.0F, 1.0F), + Transformation.Interpolations.CATMULL + ) + ) + ) + .build(); - public static final Animation IDLING_IN_WATER = Animation.Builder.create(3.0F).looping() - .addBoneAnimation("body", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0F, AnimationHelper.rotation(0.0F, 0.0F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(1.625F, AnimationHelper.rotation(-10.0F, 0.0F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(3.0F, AnimationHelper.rotation(0.0F, 0.0F, 0.0F), Transformation.Interpolations.CATMULL))) - .addBoneAnimation("left_arm", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0F, AnimationHelper.rotation(0.0F, 0.0F, -22.5F), Transformation.Interpolations.CATMULL), new Keyframe(2.2083F, AnimationHelper.rotation(0.0F, 0.0F, -45.0F), Transformation.Interpolations.CATMULL), new Keyframe(3.0F, AnimationHelper.rotation(0.0F, 0.0F, -22.5F), Transformation.Interpolations.CATMULL))) - .addBoneAnimation("left_arm", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0F, AnimationHelper.translate(-1.0F, 0.0F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(2.2083F, AnimationHelper.translate(-1.0F, -0.5F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(3.0F, AnimationHelper.translate(-1.0F, 0.0F, 0.0F), Transformation.Interpolations.CATMULL))) - .addBoneAnimation("right_arm", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0F, AnimationHelper.rotation(0.0F, 0.0F, 22.5F), Transformation.Interpolations.CATMULL), new Keyframe(2.2083F, AnimationHelper.rotation(0.0F, 0.0F, 45.0F), Transformation.Interpolations.CATMULL), new Keyframe(3.0F, AnimationHelper.rotation(0.0F, 0.0F, 22.5F), Transformation.Interpolations.CATMULL))) - .addBoneAnimation("right_arm", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0F, AnimationHelper.translate(1.0F, 0.0F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(2.2083F, AnimationHelper.translate(1.0F, -0.5F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(3.0F, AnimationHelper.translate(1.0F, 0.0F, 0.0F), Transformation.Interpolations.CATMULL))) - .addBoneAnimation("left_leg", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0F, AnimationHelper.rotation(22.5F, -22.5F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(1.0F, AnimationHelper.rotation(22.5F, -22.5F, -45.0F), Transformation.Interpolations.CATMULL), new Keyframe(3.0F, AnimationHelper.rotation(22.5F, -22.5F, 0.0F), Transformation.Interpolations.CATMULL))) - .addBoneAnimation("left_leg", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0F, AnimationHelper.translate(0.0F, 0.0F, 1.0F), Transformation.Interpolations.CATMULL), new Keyframe(1.0F, AnimationHelper.translate(0.0F, -1.0F, 1.0F), Transformation.Interpolations.CATMULL), new Keyframe(3.0F, AnimationHelper.translate(0.0F, 0.0F, 1.0F), Transformation.Interpolations.CATMULL))) - .addBoneAnimation("right_leg", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0F, AnimationHelper.rotation(22.5F, 22.5F, 0.0F), Transformation.Interpolations.CATMULL), new Keyframe(1.0F, AnimationHelper.rotation(22.5F, 22.5F, 45.0F), Transformation.Interpolations.CATMULL), new Keyframe(3.0F, AnimationHelper.rotation(22.5F, 22.5F, 0.0F), Transformation.Interpolations.CATMULL))) - .addBoneAnimation("right_leg", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0F, AnimationHelper.translate(0.0F, 0.0F, 1.0F), Transformation.Interpolations.CATMULL), new Keyframe(1.0F, AnimationHelper.translate(0.0F, -1.0F, 1.0F), Transformation.Interpolations.CATMULL), new Keyframe(3.0F, AnimationHelper.translate(0.0F, 0.0F, 1.0F), Transformation.Interpolations.CATMULL))) - .build(); + public static final Animation IDLING_IN_WATER + = Animation.Builder.create(3.0F) + .looping() + .addBoneAnimation( + "body", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0F, + AnimationHelper.rotation(0.0F, 0.0F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.625F, + AnimationHelper.rotation(-10.0F, 0.0F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.0F, + AnimationHelper.rotation(0.0F, 0.0F, 0.0F), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "left_arm", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0F, + AnimationHelper.rotation(0.0F, 0.0F, -22.5F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.2083F, + AnimationHelper.rotation(0.0F, 0.0F, -45.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.0F, + AnimationHelper.rotation(0.0F, 0.0F, -22.5F), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "left_arm", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0F, + AnimationHelper.translate(-1.0F, 0.0F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.2083F, + AnimationHelper.translate(-1.0F, -0.5F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.0F, + AnimationHelper.translate(-1.0F, 0.0F, 0.0F), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "right_arm", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0F, + AnimationHelper.rotation(0.0F, 0.0F, 22.5F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.2083F, + AnimationHelper.rotation(0.0F, 0.0F, 45.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.0F, + AnimationHelper.rotation(0.0F, 0.0F, 22.5F), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "right_arm", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0F, + AnimationHelper.translate(1.0F, 0.0F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.2083F, + AnimationHelper.translate(1.0F, -0.5F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.0F, + AnimationHelper.translate(1.0F, 0.0F, 0.0F), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "left_leg", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0F, + AnimationHelper.rotation(22.5F, -22.5F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.0F, + AnimationHelper.rotation(22.5F, -22.5F, -45.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.0F, + AnimationHelper.rotation(22.5F, -22.5F, 0.0F), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "left_leg", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0F, + AnimationHelper.translate(0.0F, 0.0F, 1.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.0F, + AnimationHelper.translate(0.0F, -1.0F, 1.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.0F, + AnimationHelper.translate(0.0F, 0.0F, 1.0F), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "right_leg", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0F, + AnimationHelper.rotation(22.5F, 22.5F, 0.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.0F, + AnimationHelper.rotation(22.5F, 22.5F, 45.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.0F, + AnimationHelper.rotation(22.5F, 22.5F, 0.0F), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "right_leg", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0F, + AnimationHelper.translate(0.0F, 0.0F, 1.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.0F, + AnimationHelper.translate(0.0F, -1.0F, 1.0F), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.0F, + AnimationHelper.translate(0.0F, 0.0F, 1.0F), + Transformation.Interpolations.CATMULL + ) + ) + ) + .build(); } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/WardenAnimations.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/WardenAnimations.java index b4a5281..d06f5f7 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/WardenAnimations.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/WardenAnimations.java @@ -6,10 +6,3052 @@ import com.cursedcauldron.wildbackport.client.animation.api.Keyframe; import com.cursedcauldron.wildbackport.client.animation.api.Transformation; public class WardenAnimations { - public static final Animation EMERGING = Animation.Builder.create(6.68f).addBoneAnimation("body", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.52f, AnimationHelper.rotation(0.0f, 0.0f, -22.5f), Transformation.Interpolations.CATMULL), new Keyframe(1.2f, AnimationHelper.rotation(0.0f, 0.0f, -7.5f), Transformation.Interpolations.CATMULL), new Keyframe(1.68f, AnimationHelper.rotation(0.0f, 0.0f, 10.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.8f, AnimationHelper.rotation(0.0f, 0.0f, 10.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.28f, AnimationHelper.rotation(0.0f, 0.0f, 10.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.88f, AnimationHelper.rotation(0.0f, 0.0f, 10.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.76f, AnimationHelper.rotation(25.0f, 0.0f, -7.5f), Transformation.Interpolations.CATMULL), new Keyframe(3.92f, AnimationHelper.rotation(35.0f, 0.0f, -7.5f), Transformation.Interpolations.CATMULL), new Keyframe(4.08f, AnimationHelper.rotation(25.0f, 0.0f, -7.5f), Transformation.Interpolations.CATMULL), new Keyframe(4.44f, AnimationHelper.rotation(47.5f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.56f, AnimationHelper.rotation(47.5f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.68f, AnimationHelper.rotation(47.5f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.0f, AnimationHelper.rotation(70.0f, 0.0f, 2.5f), Transformation.Interpolations.CATMULL), new Keyframe(5.8f, AnimationHelper.rotation(70.0f, 0.0f, 2.5f), Transformation.Interpolations.CATMULL), new Keyframe(6.64f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("body", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, -63.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.52f, AnimationHelper.translate(0.0f, -56.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.2f, AnimationHelper.translate(0.0f, -32.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.68f, AnimationHelper.translate(0.0f, -32.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.8f, AnimationHelper.translate(0.0f, -32.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.28f, AnimationHelper.translate(0.0f, -32.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.88f, AnimationHelper.translate(0.0f, -32.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.16f, AnimationHelper.translate(0.0f, -27.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.76f, AnimationHelper.translate(0.0f, -14.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.92f, AnimationHelper.translate(0.0f, -11.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.08f, AnimationHelper.translate(0.0f, -14.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.44f, AnimationHelper.translate(0.0f, -6.0f, -3.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.56f, AnimationHelper.translate(0.0f, -4.0f, -3.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.68f, AnimationHelper.translate(0.0f, -6.0f, -3.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.0f, AnimationHelper.translate(0.0f, -3.0f, -4.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.8f, AnimationHelper.translate(0.0f, -3.0f, -4.0f), Transformation.Interpolations.CATMULL), new Keyframe(6.64f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("head", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.52f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.92f, AnimationHelper.rotation(0.74f, 0.0f, -40.38f), Transformation.Interpolations.CATMULL), new Keyframe(1.16f, AnimationHelper.rotation(-67.5f, 0.0f, -2.5f), Transformation.Interpolations.CATMULL), new Keyframe(1.24f, AnimationHelper.rotation(-67.5f, 0.0f, -2.5f), Transformation.Interpolations.CATMULL), new Keyframe(1.32f, AnimationHelper.rotation(-47.5f, 0.0f, -2.5f), Transformation.Interpolations.CATMULL), new Keyframe(1.4f, AnimationHelper.rotation(-67.5f, 0.0f, -2.5f), Transformation.Interpolations.CATMULL), new Keyframe(1.68f, AnimationHelper.rotation(-67.5f, 0.0f, 15.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.76f, AnimationHelper.rotation(-67.5f, 0.0f, -5.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.84f, AnimationHelper.rotation(-52.5f, 0.0f, -5.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.92f, AnimationHelper.rotation(-67.5f, 0.0f, -5.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.64f, AnimationHelper.rotation(-17.5f, 0.0f, -10.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.76f, AnimationHelper.rotation(70.0f, 0.0f, 12.5f), Transformation.Interpolations.CATMULL), new Keyframe(4.04f, AnimationHelper.rotation(70.0f, 0.0f, 12.5f), Transformation.Interpolations.CATMULL), new Keyframe(4.12f, AnimationHelper.rotation(80.0f, 0.0f, 12.5f), Transformation.Interpolations.CATMULL), new Keyframe(4.24f, AnimationHelper.rotation(70.0f, 0.0f, 12.5f), Transformation.Interpolations.CATMULL), new Keyframe(5.0f, AnimationHelper.rotation(77.5f, 0.0f, -2.5f), Transformation.Interpolations.CATMULL), new Keyframe(6.64f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("head", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.52f, AnimationHelper.translate(-8.0f, -11.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.92f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.24f, AnimationHelper.translate(0.0f, 0.47f, -0.95f), Transformation.Interpolations.CATMULL), new Keyframe(1.32f, AnimationHelper.translate(0.0f, 0.47f, -0.95f), Transformation.Interpolations.CATMULL), new Keyframe(1.4f, AnimationHelper.translate(0.0f, 0.47f, -0.95f), Transformation.Interpolations.CATMULL), new Keyframe(1.68f, AnimationHelper.translate(0.0f, 1.0f, -2.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.76f, AnimationHelper.translate(0.0f, 1.0f, -2.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.84f, AnimationHelper.translate(0.0f, 1.0f, -2.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.92f, AnimationHelper.translate(0.0f, 1.0f, -2.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.64f, AnimationHelper.translate(0.0f, -2.0f, -2.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.76f, AnimationHelper.translate(0.0f, -4.0f, 1.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.04f, AnimationHelper.translate(0.0f, -1.0f, 1.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.12f, AnimationHelper.translate(0.0f, -1.0f, 1.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.24f, AnimationHelper.translate(0.0f, -1.0f, 1.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.0f, AnimationHelper.translate(0.0f, -1.0f, 1.0f), Transformation.Interpolations.CATMULL), new Keyframe(6.64f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("right_ear", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.52f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.28f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.88f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.36f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.56f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.8f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(6.64f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("right_ear", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.52f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.28f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.88f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.36f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.56f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.8f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(6.64f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("left_ear", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.52f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.28f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.88f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.36f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.56f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.8f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(6.64f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("left_ear", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.52f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.28f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.88f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.36f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.56f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.8f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(6.64f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("right_arm", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.52f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.2f, AnimationHelper.rotation(-152.5f, 2.5f, 7.5f), Transformation.Interpolations.CATMULL), new Keyframe(1.68f, AnimationHelper.rotation(-180.0f, 12.5f, -10.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.8f, AnimationHelper.rotation(-90.0f, 12.5f, -10.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.28f, AnimationHelper.rotation(-90.0f, 12.5f, -10.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.88f, AnimationHelper.rotation(-90.0f, 12.5f, -10.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.08f, AnimationHelper.rotation(-95.0f, 12.5f, -10.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.24f, AnimationHelper.rotation(-83.93f, 3.93f, 5.71f), Transformation.Interpolations.CATMULL), new Keyframe(3.36f, AnimationHelper.rotation(-80.0f, 7.5f, 17.5f), Transformation.Interpolations.CATMULL), new Keyframe(3.76f, AnimationHelper.rotation(-67.5f, 2.5f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.08f, AnimationHelper.rotation(-67.5f, 2.5f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.44f, AnimationHelper.rotation(-55.0f, 2.5f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.56f, AnimationHelper.rotation(-60.0f, 2.5f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.68f, AnimationHelper.rotation(-55.0f, 2.5f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.0f, AnimationHelper.rotation(-67.5f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.56f, AnimationHelper.rotation(-50.45f, 0.0f, 2.69f), Transformation.Interpolations.CATMULL), new Keyframe(6.08f, AnimationHelper.rotation(-62.72f, 0.0f, 4.3f), Transformation.Interpolations.CATMULL), new Keyframe(6.64f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("right_arm", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.52f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.2f, AnimationHelper.translate(0.0f, -21.0f, 9.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.68f, AnimationHelper.translate(2.0f, -2.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.8f, AnimationHelper.translate(2.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.28f, AnimationHelper.translate(2.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.88f, AnimationHelper.translate(2.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.08f, AnimationHelper.translate(2.0f, -2.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.24f, AnimationHelper.translate(2.0f, 2.71f, 3.86f), Transformation.Interpolations.CATMULL), new Keyframe(3.36f, AnimationHelper.translate(2.0f, 1.0f, 5.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.76f, AnimationHelper.translate(2.0f, 3.0f, 3.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.08f, AnimationHelper.translate(2.0f, 3.0f, 3.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.44f, AnimationHelper.translate(2.67f, 4.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.56f, AnimationHelper.translate(2.67f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.68f, AnimationHelper.translate(2.67f, 4.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.0f, AnimationHelper.translate(0.67f, 3.0f, 4.0f), Transformation.Interpolations.CATMULL), new Keyframe(6.64f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("left_arm", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.12f, AnimationHelper.rotation(-167.5f, -17.5f, -7.5f), Transformation.Interpolations.CATMULL), new Keyframe(0.6f, AnimationHelper.rotation(-167.5f, -17.5f, -7.5f), Transformation.Interpolations.CATMULL), new Keyframe(0.88f, AnimationHelper.rotation(-175.0f, -17.5f, 15.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.16f, AnimationHelper.rotation(-190.0f, -17.5f, 5.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.28f, AnimationHelper.rotation(-90.0f, -5.0f, 5.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.68f, AnimationHelper.rotation(-90.0f, -17.5f, -12.5f), Transformation.Interpolations.CATMULL), new Keyframe(1.8f, AnimationHelper.rotation(-90.0f, -17.5f, -12.5f), Transformation.Interpolations.CATMULL), new Keyframe(2.28f, AnimationHelper.rotation(-90.0f, -17.5f, -12.5f), Transformation.Interpolations.CATMULL), new Keyframe(2.88f, AnimationHelper.rotation(-90.0f, -17.5f, -12.5f), Transformation.Interpolations.CATMULL), new Keyframe(3.04f, AnimationHelper.rotation(-81.29f, -10.64f, -14.21f), Transformation.Interpolations.CATMULL), new Keyframe(3.16f, AnimationHelper.rotation(-83.5f, -5.5f, -15.5f), Transformation.Interpolations.CATMULL), new Keyframe(3.76f, AnimationHelper.rotation(-62.5f, -7.5f, 5.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.92f, AnimationHelper.rotation(-58.75f, -3.75f, 5.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.08f, AnimationHelper.rotation(-55.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.44f, AnimationHelper.rotation(-52.5f, 0.0f, 5.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.56f, AnimationHelper.rotation(-50.0f, 0.0f, 5.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.68f, AnimationHelper.rotation(-52.5f, 0.0f, 5.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.0f, AnimationHelper.rotation(-72.5f, -2.5f, 5.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.56f, AnimationHelper.rotation(-57.5f, -4.54f, 2.99f), Transformation.Interpolations.CATMULL), new Keyframe(6.08f, AnimationHelper.rotation(-70.99f, -5.77f, 1.78f), Transformation.Interpolations.CATMULL), new Keyframe(6.64f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("left_arm", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.12f, AnimationHelper.translate(0.0f, -8.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.6f, AnimationHelper.translate(0.0f, -8.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.88f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.2f, AnimationHelper.translate(-2.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.68f, AnimationHelper.translate(-4.0f, 3.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.8f, AnimationHelper.translate(-4.0f, 3.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.28f, AnimationHelper.translate(-4.0f, 3.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.88f, AnimationHelper.translate(-4.0f, 3.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.04f, AnimationHelper.translate(-3.23f, 5.7f, 4.97f), Transformation.Interpolations.CATMULL), new Keyframe(3.16f, AnimationHelper.translate(-1.49f, 2.22f, 5.25f), Transformation.Interpolations.CATMULL), new Keyframe(3.76f, AnimationHelper.translate(-1.14f, 1.71f, 1.86f), Transformation.Interpolations.CATMULL), new Keyframe(3.92f, AnimationHelper.translate(-1.14f, 1.21f, 3.86f), Transformation.Interpolations.CATMULL), new Keyframe(4.08f, AnimationHelper.translate(-1.14f, 2.71f, 4.86f), Transformation.Interpolations.CATMULL), new Keyframe(4.44f, AnimationHelper.translate(-1.0f, 1.0f, 3.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.56f, AnimationHelper.translate(0.0f, 1.0f, 1.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.68f, AnimationHelper.translate(0.0f, 1.0f, 3.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.0f, AnimationHelper.translate(-2.0f, 0.0f, 4.0f), Transformation.Interpolations.CATMULL), new Keyframe(6.64f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("right_leg", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.52f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.28f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.88f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.36f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.32f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.48f, AnimationHelper.rotation(55.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.6f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.8f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(6.64f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("right_leg", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, -63.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.52f, AnimationHelper.translate(0.0f, -56.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.2f, AnimationHelper.translate(0.0f, -32.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.68f, AnimationHelper.translate(0.0f, -32.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.8f, AnimationHelper.translate(0.0f, -32.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.28f, AnimationHelper.translate(0.0f, -32.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.88f, AnimationHelper.translate(0.0f, -32.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.36f, AnimationHelper.translate(0.0f, -22.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.76f, AnimationHelper.translate(0.0f, -12.28f, 2.48f), Transformation.Interpolations.CATMULL), new Keyframe(3.92f, AnimationHelper.translate(0.0f, -9.28f, 2.48f), Transformation.Interpolations.CATMULL), new Keyframe(4.08f, AnimationHelper.translate(0.0f, -12.28f, 2.48f), Transformation.Interpolations.CATMULL), new Keyframe(4.32f, AnimationHelper.translate(0.0f, -4.14f, 4.14f), Transformation.Interpolations.CATMULL), new Keyframe(4.48f, AnimationHelper.translate(0.0f, -0.57f, -8.43f), Transformation.Interpolations.CATMULL), new Keyframe(4.6f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.8f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(6.64f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("left_leg", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.52f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.28f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.88f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.36f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.84f, AnimationHelper.rotation(20.0f, 0.0f, -17.5f), Transformation.Interpolations.CATMULL), new Keyframe(4.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.68f, AnimationHelper.rotation(20.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.84f, AnimationHelper.rotation(10.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.8f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(6.64f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("left_leg", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, -63.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.52f, AnimationHelper.translate(0.0f, -56.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.2f, AnimationHelper.translate(0.0f, -32.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.68f, AnimationHelper.translate(0.0f, -32.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.8f, AnimationHelper.translate(0.0f, -32.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.28f, AnimationHelper.translate(0.0f, -32.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.88f, AnimationHelper.translate(0.0f, -32.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.36f, AnimationHelper.translate(0.0f, -22.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.84f, AnimationHelper.translate(-4.0f, 2.0f, -7.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.0f, AnimationHelper.translate(-4.0f, 0.0f, -5.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.68f, AnimationHelper.translate(-4.0f, 0.0f, -9.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.84f, AnimationHelper.translate(-2.0f, 2.0f, -3.5f), Transformation.Interpolations.CATMULL), new Keyframe(5.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(5.8f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(6.64f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).build(); - public static final Animation DIGGING = Animation.Builder.create(5.0f).addBoneAnimation("body", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.25f, AnimationHelper.rotation(4.13441f, 0.94736f, 1.2694f), Transformation.Interpolations.CATMULL), new Keyframe(0.5f, AnimationHelper.rotation(50.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.7083f, AnimationHelper.rotation(54.45407f, -13.53935f, -18.14183f), Transformation.Interpolations.CATMULL), new Keyframe(1.0417f, AnimationHelper.rotation(59.46442f, -10.8885f, 35.7954f), Transformation.Interpolations.CATMULL), new Keyframe(1.3333f, AnimationHelper.rotation(82.28261f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.625f, AnimationHelper.rotation(53.23606f, 10.04715f, -29.72932f), Transformation.Interpolations.CATMULL), new Keyframe(2.2083f, AnimationHelper.rotation(-17.71739f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.5417f, AnimationHelper.rotation(112.28261f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.6667f, AnimationHelper.rotation(116.06889f, 5.11581f, -24.50117f), Transformation.Interpolations.CATMULL), new Keyframe(2.8333f, AnimationHelper.rotation(121.56244f, -4.17248f, 19.57737f), Transformation.Interpolations.CATMULL), new Keyframe(3.0417f, AnimationHelper.rotation(138.5689f, 5.11581f, -24.50117f), Transformation.Interpolations.CATMULL), new Keyframe(3.25f, AnimationHelper.rotation(144.06244f, -4.17248f, 19.57737f), Transformation.Interpolations.CATMULL), new Keyframe(3.375f, AnimationHelper.rotation(147.28261f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.625f, AnimationHelper.rotation(147.28261f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.875f, AnimationHelper.rotation(134.36221f, 8.81113f, -8.90172f), Transformation.Interpolations.CATMULL), new Keyframe(4.0417f, AnimationHelper.rotation(132.05966f, -8.35927f, 9.70506f), Transformation.Interpolations.CATMULL), new Keyframe(4.25f, AnimationHelper.rotation(134.36221f, 8.81113f, -8.90172f), Transformation.Interpolations.CATMULL), new Keyframe(4.5f, AnimationHelper.rotation(147.5f, 0.0f, 0.0f), Transformation.Interpolations.LINEAL))).addBoneAnimation("body", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.5f, AnimationHelper.translate(0.0f, -16.48454f, -6.5784f), Transformation.Interpolations.CATMULL), new Keyframe(0.7083f, AnimationHelper.translate(0.0f, -16.48454f, -6.5784f), Transformation.Interpolations.CATMULL), new Keyframe(1.0417f, AnimationHelper.translate(0.0f, -16.97f, -7.11f), Transformation.Interpolations.CATMULL), new Keyframe(1.625f, AnimationHelper.translate(0.0f, -13.97f, -7.11f), Transformation.Interpolations.CATMULL), new Keyframe(2.2083f, AnimationHelper.translate(0.0f, -11.48454f, -0.5784f), Transformation.Interpolations.CATMULL), new Keyframe(2.5417f, AnimationHelper.translate(0.0f, -16.48454f, -6.5784f), Transformation.Interpolations.CATMULL), new Keyframe(2.6667f, AnimationHelper.translate(0.0f, -20.27f, -5.42f), Transformation.Interpolations.CATMULL), new Keyframe(3.375f, AnimationHelper.translate(0.0f, -21.48454f, -5.5784f), Transformation.Interpolations.CATMULL), new Keyframe(4.0417f, AnimationHelper.translate(0.0f, -22.48454f, -5.5784f), Transformation.Interpolations.CATMULL), new Keyframe(4.5f, AnimationHelper.translate(0.0f, -40.0f, -8.0f), Transformation.Interpolations.LINEAL))).addBoneAnimation("head", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.6667f, AnimationHelper.rotation(12.5f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.2083f, AnimationHelper.rotation(12.5f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.75f, AnimationHelper.rotation(45.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.375f, AnimationHelper.rotation(-22.5f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.5417f, AnimationHelper.rotation(67.5f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.375f, AnimationHelper.rotation(67.5f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("head", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.375f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.LINEAL))).addBoneAnimation("right_arm", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.5f, AnimationHelper.rotation(-101.8036f, -21.29587f, 30.61478f), Transformation.Interpolations.CATMULL), new Keyframe(0.7083f, AnimationHelper.rotation(-101.8036f, -21.29587f, 30.61478f), Transformation.Interpolations.CATMULL), new Keyframe(1.0f, AnimationHelper.rotation(48.7585f, -17.61941f, 9.9865f), Transformation.Interpolations.CATMULL), new Keyframe(1.1667f, AnimationHelper.rotation(48.7585f, -17.61941f, 9.9865f), Transformation.Interpolations.CATMULL), new Keyframe(1.4583f, AnimationHelper.rotation(-101.8036f, -21.29587f, 30.61478f), Transformation.Interpolations.CATMULL), new Keyframe(1.75f, AnimationHelper.rotation(-89.04994f, -4.19657f, -1.47845f), Transformation.Interpolations.CATMULL), new Keyframe(2.2083f, AnimationHelper.rotation(-158.30728f, 3.7152f, -1.52352f), Transformation.Interpolations.CATMULL), new Keyframe(2.5417f, AnimationHelper.rotation(-89.04994f, -4.19657f, -1.47845f), Transformation.Interpolations.CATMULL), new Keyframe(4.375f, AnimationHelper.rotation(-120.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("right_arm", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.7083f, AnimationHelper.translate(2.22f, 0.0f, 0.86f), Transformation.Interpolations.CATMULL), new Keyframe(1.0f, AnimationHelper.translate(3.12f, 0.0f, 4.29f), Transformation.Interpolations.CATMULL), new Keyframe(2.2083f, AnimationHelper.translate(1.0f, 0.0f, 4.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.375f, AnimationHelper.translate(0.0f, 0.0f, 4.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("left_arm", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.2917f, AnimationHelper.rotation(-63.89288f, -0.52011f, 2.09491f), Transformation.Interpolations.CATMULL), new Keyframe(0.5f, AnimationHelper.rotation(-63.89288f, -0.52011f, 2.09491f), Transformation.Interpolations.CATMULL), new Keyframe(0.7083f, AnimationHelper.rotation(-62.87857f, 15.15061f, 9.97445f), Transformation.Interpolations.CATMULL), new Keyframe(0.9167f, AnimationHelper.rotation(-86.93642f, 17.45026f, 4.05284f), Transformation.Interpolations.CATMULL), new Keyframe(1.1667f, AnimationHelper.rotation(-86.93642f, 17.45026f, 4.05284f), Transformation.Interpolations.CATMULL), new Keyframe(1.4583f, AnimationHelper.rotation(-86.93642f, 17.45026f, 4.05284f), Transformation.Interpolations.CATMULL), new Keyframe(1.6667f, AnimationHelper.rotation(63.0984f, 8.83573f, -8.71284f), Transformation.Interpolations.CATMULL), new Keyframe(1.8333f, AnimationHelper.rotation(35.5984f, 8.83573f, -8.71284f), Transformation.Interpolations.CATMULL), new Keyframe(2.2083f, AnimationHelper.rotation(-153.27473f, -0.02953f, 3.5235f), Transformation.Interpolations.CATMULL), new Keyframe(2.5417f, AnimationHelper.rotation(-87.07754f, -0.02625f, 3.132f), Transformation.Interpolations.CATMULL), new Keyframe(4.375f, AnimationHelper.rotation(-120.0f, 0.0f, 0.0f), Transformation.Interpolations.LINEAL))).addBoneAnimation("left_arm", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.5f, AnimationHelper.translate(-0.28f, 5.0f, 10.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.7083f, AnimationHelper.translate(-1.51f, 4.35f, 4.33f), Transformation.Interpolations.CATMULL), new Keyframe(0.9167f, AnimationHelper.translate(-0.6f, 3.61f, 4.63f), Transformation.Interpolations.CATMULL), new Keyframe(1.1667f, AnimationHelper.translate(-0.6f, 3.61f, 0.63f), Transformation.Interpolations.CATMULL), new Keyframe(1.6667f, AnimationHelper.translate(-2.85f, -0.1f, 3.33f), Transformation.Interpolations.CATMULL), new Keyframe(2.2083f, AnimationHelper.translate(-1.0f, 0.0f, 4.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.375f, AnimationHelper.translate(0.0f, 0.0f, 4.0f), Transformation.Interpolations.LINEAL))).addBoneAnimation("right_leg", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.5f, AnimationHelper.rotation(113.27f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.7083f, AnimationHelper.rotation(113.27f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.3333f, AnimationHelper.rotation(113.27f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.5833f, AnimationHelper.rotation(182.5f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.8333f, AnimationHelper.rotation(120.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.0833f, AnimationHelper.rotation(182.5f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.2917f, AnimationHelper.rotation(120.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.5f, AnimationHelper.rotation(90.0f, 0.0f, 0.0f), Transformation.Interpolations.LINEAL))).addBoneAnimation("right_leg", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.5f, AnimationHelper.translate(0.0f, -13.98f, -2.37f), Transformation.Interpolations.CATMULL), new Keyframe(0.7083f, AnimationHelper.translate(0.0f, -13.98f, -2.37f), Transformation.Interpolations.CATMULL), new Keyframe(3.3333f, AnimationHelper.translate(0.0f, -13.98f, -2.37f), Transformation.Interpolations.CATMULL), new Keyframe(3.5833f, AnimationHelper.translate(0.0f, -7.0f, -3.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.8333f, AnimationHelper.translate(0.0f, -9.0f, -3.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.0833f, AnimationHelper.translate(0.0f, -16.71f, -3.69f), Transformation.Interpolations.CATMULL), new Keyframe(4.2917f, AnimationHelper.translate(0.0f, -28.0f, -5.0f), Transformation.Interpolations.LINEAL))).addBoneAnimation("left_leg", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.5f, AnimationHelper.rotation(114.98f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.7083f, AnimationHelper.rotation(114.98f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.3333f, AnimationHelper.rotation(114.98f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.5833f, AnimationHelper.rotation(90.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.8333f, AnimationHelper.rotation(172.5f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.0833f, AnimationHelper.rotation(90.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.2917f, AnimationHelper.rotation(197.5f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.5f, AnimationHelper.rotation(90.0f, 0.0f, 0.0f), Transformation.Interpolations.LINEAL))).addBoneAnimation("left_leg", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.5f, AnimationHelper.translate(0.0f, -14.01f, -2.35f), Transformation.Interpolations.CATMULL), new Keyframe(0.7083f, AnimationHelper.translate(0.0f, -14.01f, -2.35f), Transformation.Interpolations.CATMULL), new Keyframe(3.3333f, AnimationHelper.translate(0.0f, -14.01f, -2.35f), Transformation.Interpolations.CATMULL), new Keyframe(3.5833f, AnimationHelper.translate(0.0f, -5.0f, -4.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.8333f, AnimationHelper.translate(0.0f, -7.0f, -4.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.0833f, AnimationHelper.translate(0.0f, -15.5f, -3.76f), Transformation.Interpolations.CATMULL), new Keyframe(4.2917f, AnimationHelper.translate(0.0f, -28.0f, -5.0f), Transformation.Interpolations.LINEAL))).build(); - public static final Animation ROARING = Animation.Builder.create(4.2f).addBoneAnimation("body", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.24f, AnimationHelper.rotation(-25.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.6f, AnimationHelper.rotation(32.5f, 0.0f, -7.5f), Transformation.Interpolations.CATMULL), new Keyframe(1.84f, AnimationHelper.rotation(38.33f, 0.0f, 2.99f), Transformation.Interpolations.CATMULL), new Keyframe(2.08f, AnimationHelper.rotation(40.97f, 0.0f, -4.3f), Transformation.Interpolations.CATMULL), new Keyframe(2.36f, AnimationHelper.rotation(44.41f, 0.0f, 6.29f), Transformation.Interpolations.CATMULL), new Keyframe(3.0f, AnimationHelper.rotation(47.5f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.2f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("body", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.24f, AnimationHelper.translate(0.0f, -1.0f, 3.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.6f, AnimationHelper.translate(0.0f, -3.0f, -6.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.0f, AnimationHelper.translate(0.0f, -3.0f, -6.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.2f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("head", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.24f, AnimationHelper.rotation(-32.5f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.6f, AnimationHelper.rotation(-32.5f, 0.0f, -27.5f), Transformation.Interpolations.CATMULL), new Keyframe(1.8f, AnimationHelper.rotation(-32.5f, 0.0f, 26.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.04f, AnimationHelper.rotation(-32.5f, 0.0f, -27.5f), Transformation.Interpolations.CATMULL), new Keyframe(2.44f, AnimationHelper.rotation(-32.5f, 0.0f, 26.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.84f, AnimationHelper.rotation(-5.0f, 0.0f, -12.5f), Transformation.Interpolations.CATMULL), new Keyframe(4.2f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("head", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.24f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.6f, AnimationHelper.translate(0.0f, -2.0f, -6.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.2f, AnimationHelper.translate(0.0f, -2.0f, -6.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.48f, AnimationHelper.translate(0.0f, -2.0f, -6.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.2f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("right_ear", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.24f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.76f, AnimationHelper.rotation(0.0f, 0.0f, -10.85f), Transformation.Interpolations.CATMULL), new Keyframe(2.08f, AnimationHelper.rotation(0.0f, 0.0f, 12.5f), Transformation.Interpolations.CATMULL), new Keyframe(2.4f, AnimationHelper.rotation(0.0f, 0.0f, -10.85f), Transformation.Interpolations.CATMULL), new Keyframe(2.72f, AnimationHelper.rotation(0.0f, 0.0f, 12.5f), Transformation.Interpolations.CATMULL), new Keyframe(3.0f, AnimationHelper.rotation(0.0f, 0.0f, -10.85f), Transformation.Interpolations.CATMULL), new Keyframe(4.2f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("left_ear", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.24f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.76f, AnimationHelper.rotation(0.0f, 0.0f, -15.85f), Transformation.Interpolations.CATMULL), new Keyframe(2.08f, AnimationHelper.rotation(0.0f, 0.0f, 12.5f), Transformation.Interpolations.CATMULL), new Keyframe(2.4f, AnimationHelper.rotation(0.0f, 0.0f, -15.85f), Transformation.Interpolations.CATMULL), new Keyframe(2.72f, AnimationHelper.rotation(0.0f, 0.0f, 12.5f), Transformation.Interpolations.CATMULL), new Keyframe(3.0f, AnimationHelper.rotation(0.0f, 0.0f, -15.85f), Transformation.Interpolations.CATMULL), new Keyframe(4.2f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("right_arm", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.72f, AnimationHelper.rotation(-120.0f, 0.0f, -20.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.24f, AnimationHelper.rotation(-77.5f, 3.75f, 15.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.48f, AnimationHelper.rotation(67.5f, -32.5f, 20.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.48f, AnimationHelper.rotation(37.5f, -32.5f, 25.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.88f, AnimationHelper.rotation(27.6f, -17.1f, 32.5f), Transformation.Interpolations.CATMULL), new Keyframe(4.2f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("right_arm", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.72f, AnimationHelper.translate(3.0f, -2.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.48f, AnimationHelper.translate(4.0f, -2.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.48f, AnimationHelper.translate(4.0f, -2.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.2f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("left_arm", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.72f, AnimationHelper.rotation(-125.0f, 0.0f, 20.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.24f, AnimationHelper.rotation(-76.25f, -17.5f, -7.5f), Transformation.Interpolations.CATMULL), new Keyframe(1.48f, AnimationHelper.rotation(62.5f, 42.5f, -12.5f), Transformation.Interpolations.CATMULL), new Keyframe(2.48f, AnimationHelper.rotation(37.5f, 27.5f, -27.5f), Transformation.Interpolations.CATMULL), new Keyframe(2.88f, AnimationHelper.rotation(25.0f, 18.4f, -30.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.2f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("left_arm", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.72f, AnimationHelper.translate(-3.0f, -2.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.48f, AnimationHelper.translate(-4.0f, -2.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.48f, AnimationHelper.translate(-4.0f, -2.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(4.2f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).build(); - public static final Animation SNIFFING = Animation.Builder.create(4.16f).addBoneAnimation("body", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.56f, AnimationHelper.rotation(17.5f, 32.5f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.96f, AnimationHelper.rotation(0.0f, 32.5f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.2f, AnimationHelper.rotation(10.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.8f, AnimationHelper.rotation(10.0f, -30.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.32f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("head", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.68f, AnimationHelper.rotation(0.0f, 40.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.96f, AnimationHelper.rotation(-22.5f, 40.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.24f, AnimationHelper.rotation(0.0f, 20.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.52f, AnimationHelper.rotation(-35.0f, 20.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.76f, AnimationHelper.rotation(0.0f, 20.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.28f, AnimationHelper.rotation(0.0f, -20.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.88f, AnimationHelper.rotation(0.0f, -20.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.32f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("right_arm", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.96f, AnimationHelper.rotation(17.5f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.2f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.76f, AnimationHelper.rotation(-15.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.32f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("left_arm", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.96f, AnimationHelper.rotation(-15.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.2f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.76f, AnimationHelper.rotation(17.5f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.32f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).build(); - public static final Animation ATTACKING = Animation.Builder.create(0.33333f).addBoneAnimation("body", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.0417f, AnimationHelper.rotation(-22.5f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.2083f, AnimationHelper.rotation(22.5f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.3333f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("body", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.0417f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.2083f, AnimationHelper.translate(0.0f, -1.0f, -2.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.3333f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("head", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.0417f, AnimationHelper.rotation(22.5f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.25f, AnimationHelper.rotation(-30.17493f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.3333f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("head", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.0417f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.25f, AnimationHelper.translate(0.0f, -2.0f, -2.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.3333f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("right_arm", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.0417f, AnimationHelper.rotation(-120.36119f, 40.78947f, -20.94102f), Transformation.Interpolations.CATMULL), new Keyframe(0.1667f, AnimationHelper.rotation(-90.0f, -45.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.3333f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("right_arm", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.0417f, AnimationHelper.translate(4.0f, 0.0f, 5.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.1667f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.3333f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("left_arm", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.0417f, AnimationHelper.rotation(-120.36119f, -40.78947f, 20.94102f), Transformation.Interpolations.CATMULL), new Keyframe(0.1667f, AnimationHelper.rotation(-61.1632f, 42.85882f, 11.52421f), Transformation.Interpolations.CATMULL), new Keyframe(0.3333f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("left_arm", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.0417f, AnimationHelper.translate(-4.0f, 0.0f, 5.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.1667f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.3333f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).build(); - public static final Animation SONIC_BOOM = Animation.Builder.create(3.0f).addBoneAnimation("body", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.0833f, AnimationHelper.rotation(47.5f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.625f, AnimationHelper.rotation(55.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.9167f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.0f, AnimationHelper.rotation(-32.5f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.4583f, AnimationHelper.rotation(-32.5f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.7083f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.875f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("body", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.0833f, AnimationHelper.translate(0.0f, -3.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.625f, AnimationHelper.translate(0.0f, -4.0f, -1.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.9167f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.7083f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.875f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("right_ribcage", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.5417f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.7917f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.875f, AnimationHelper.rotation(0.0f, 125.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.5f, AnimationHelper.rotation(0.0f, 125.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.6667f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("left_ribcage", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.5417f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.7917f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.875f, AnimationHelper.rotation(0.0f, -125.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.5f, AnimationHelper.rotation(0.0f, -125.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.6667f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("head", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.0f, AnimationHelper.rotation(67.5f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.75f, AnimationHelper.rotation(80.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.9167f, AnimationHelper.rotation(-45.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.5f, AnimationHelper.rotation(-45.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.7083f, AnimationHelper.rotation(-45.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.875f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("head", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.9167f, AnimationHelper.translate(0.0f, 0.0f, -3.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.5f, AnimationHelper.translate(0.0f, 0.0f, -3.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.7083f, AnimationHelper.translate(0.0f, 0.0f, -3.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.875f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("right_arm", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.875f, AnimationHelper.rotation(-42.28659f, -32.69813f, -5.00825f), Transformation.Interpolations.CATMULL), new Keyframe(1.1667f, AnimationHelper.rotation(-29.83757f, -35.39626f, -45.28089f), Transformation.Interpolations.CATMULL), new Keyframe(1.3333f, AnimationHelper.rotation(-29.83757f, -35.39626f, -45.28089f), Transformation.Interpolations.CATMULL), new Keyframe(1.6667f, AnimationHelper.rotation(-72.28659f, -32.69813f, -5.00825f), Transformation.Interpolations.CATMULL), new Keyframe(1.8333f, AnimationHelper.rotation(35.26439f, -30.0f, 35.26439f), Transformation.Interpolations.CATMULL), new Keyframe(1.9167f, AnimationHelper.rotation(73.75484f, -13.0931f, 19.20518f), Transformation.Interpolations.CATMULL), new Keyframe(2.5f, AnimationHelper.rotation(73.75484f, -13.0931f, 19.20518f), Transformation.Interpolations.CATMULL), new Keyframe(2.75f, AnimationHelper.rotation(58.20713f, -21.1064f, 28.7261f), Transformation.Interpolations.CATMULL), new Keyframe(3.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("right_arm", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.8333f, AnimationHelper.translate(3.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.75f, AnimationHelper.translate(3.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("left_arm", new Transformation(Transformation.Targets.ROTATE, new Keyframe(0.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(0.875f, AnimationHelper.rotation(-33.80694f, 32.31058f, 6.87997f), Transformation.Interpolations.CATMULL), new Keyframe(1.1667f, AnimationHelper.rotation(-17.87827f, 34.62115f, 49.02433f), Transformation.Interpolations.CATMULL), new Keyframe(1.3333f, AnimationHelper.rotation(-17.87827f, 34.62115f, 49.02433f), Transformation.Interpolations.CATMULL), new Keyframe(1.6667f, AnimationHelper.rotation(-51.30694f, 32.31058f, 6.87997f), Transformation.Interpolations.CATMULL), new Keyframe(1.8333f, AnimationHelper.rotation(35.26439f, 30.0f, -35.26439f), Transformation.Interpolations.CATMULL), new Keyframe(1.9167f, AnimationHelper.rotation(73.75484f, 13.0931f, -19.20518f), Transformation.Interpolations.CATMULL), new Keyframe(2.5f, AnimationHelper.rotation(73.75484f, 13.0931f, -19.20518f), Transformation.Interpolations.CATMULL), new Keyframe(2.75f, AnimationHelper.rotation(58.20713f, 21.1064f, -28.7261f), Transformation.Interpolations.CATMULL), new Keyframe(3.0f, AnimationHelper.rotation(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).addBoneAnimation("left_arm", new Transformation(Transformation.Targets.TRANSLATE, new Keyframe(0.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(1.8333f, AnimationHelper.translate(-3.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(2.75f, AnimationHelper.translate(-3.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL), new Keyframe(3.0f, AnimationHelper.translate(0.0f, 0.0f, 0.0f), Transformation.Interpolations.CATMULL))).build(); + public static final Animation EMERGING + = Animation.Builder.create(6.68f) + .addBoneAnimation( + "body", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.52f, + AnimationHelper.rotation(0.0f, 0.0f, -22.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.2f, + AnimationHelper.rotation(0.0f, 0.0f, -7.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.68f, + AnimationHelper.rotation(0.0f, 0.0f, 10.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.8f, + AnimationHelper.rotation(0.0f, 0.0f, 10.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.28f, + AnimationHelper.rotation(0.0f, 0.0f, 10.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.88f, + AnimationHelper.rotation(0.0f, 0.0f, 10.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.76f, + AnimationHelper.rotation(25.0f, 0.0f, -7.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.92f, + AnimationHelper.rotation(35.0f, 0.0f, -7.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.08f, + AnimationHelper.rotation(25.0f, 0.0f, -7.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.44f, + AnimationHelper.rotation(47.5f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.56f, + AnimationHelper.rotation(47.5f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.68f, + AnimationHelper.rotation(47.5f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.0f, + AnimationHelper.rotation(70.0f, 0.0f, 2.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.8f, + AnimationHelper.rotation(70.0f, 0.0f, 2.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 6.64f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "body", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, -63.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.52f, + AnimationHelper.translate(0.0f, -56.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.2f, + AnimationHelper.translate(0.0f, -32.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.68f, + AnimationHelper.translate(0.0f, -32.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.8f, + AnimationHelper.translate(0.0f, -32.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.28f, + AnimationHelper.translate(0.0f, -32.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.88f, + AnimationHelper.translate(0.0f, -32.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.16f, + AnimationHelper.translate(0.0f, -27.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.76f, + AnimationHelper.translate(0.0f, -14.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.92f, + AnimationHelper.translate(0.0f, -11.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.08f, + AnimationHelper.translate(0.0f, -14.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.44f, + AnimationHelper.translate(0.0f, -6.0f, -3.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.56f, + AnimationHelper.translate(0.0f, -4.0f, -3.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.68f, + AnimationHelper.translate(0.0f, -6.0f, -3.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.0f, + AnimationHelper.translate(0.0f, -3.0f, -4.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.8f, + AnimationHelper.translate(0.0f, -3.0f, -4.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 6.64f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "head", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.52f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.92f, + AnimationHelper.rotation(0.74f, 0.0f, -40.38f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.16f, + AnimationHelper.rotation(-67.5f, 0.0f, -2.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.24f, + AnimationHelper.rotation(-67.5f, 0.0f, -2.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.32f, + AnimationHelper.rotation(-47.5f, 0.0f, -2.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.4f, + AnimationHelper.rotation(-67.5f, 0.0f, -2.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.68f, + AnimationHelper.rotation(-67.5f, 0.0f, 15.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.76f, + AnimationHelper.rotation(-67.5f, 0.0f, -5.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.84f, + AnimationHelper.rotation(-52.5f, 0.0f, -5.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.92f, + AnimationHelper.rotation(-67.5f, 0.0f, -5.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.64f, + AnimationHelper.rotation(-17.5f, 0.0f, -10.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.76f, + AnimationHelper.rotation(70.0f, 0.0f, 12.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.04f, + AnimationHelper.rotation(70.0f, 0.0f, 12.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.12f, + AnimationHelper.rotation(80.0f, 0.0f, 12.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.24f, + AnimationHelper.rotation(70.0f, 0.0f, 12.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.0f, + AnimationHelper.rotation(77.5f, 0.0f, -2.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 6.64f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "head", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.52f, + AnimationHelper.translate(-8.0f, -11.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.92f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.24f, + AnimationHelper.translate(0.0f, 0.47f, -0.95f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.32f, + AnimationHelper.translate(0.0f, 0.47f, -0.95f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.4f, + AnimationHelper.translate(0.0f, 0.47f, -0.95f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.68f, + AnimationHelper.translate(0.0f, 1.0f, -2.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.76f, + AnimationHelper.translate(0.0f, 1.0f, -2.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.84f, + AnimationHelper.translate(0.0f, 1.0f, -2.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.92f, + AnimationHelper.translate(0.0f, 1.0f, -2.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.64f, + AnimationHelper.translate(0.0f, -2.0f, -2.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.76f, + AnimationHelper.translate(0.0f, -4.0f, 1.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.04f, + AnimationHelper.translate(0.0f, -1.0f, 1.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.12f, + AnimationHelper.translate(0.0f, -1.0f, 1.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.24f, + AnimationHelper.translate(0.0f, -1.0f, 1.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.0f, + AnimationHelper.translate(0.0f, -1.0f, 1.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 6.64f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "right_ear", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.52f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.28f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.88f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.36f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.56f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.8f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 6.64f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "right_ear", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.52f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.28f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.88f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.36f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.56f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.8f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 6.64f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "left_ear", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.52f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.28f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.88f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.36f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.56f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.8f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 6.64f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "left_ear", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.52f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.28f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.88f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.36f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.56f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.8f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 6.64f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "right_arm", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.52f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.2f, + AnimationHelper.rotation(-152.5f, 2.5f, 7.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.68f, + AnimationHelper.rotation(-180.0f, 12.5f, -10.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.8f, + AnimationHelper.rotation(-90.0f, 12.5f, -10.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.28f, + AnimationHelper.rotation(-90.0f, 12.5f, -10.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.88f, + AnimationHelper.rotation(-90.0f, 12.5f, -10.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.08f, + AnimationHelper.rotation(-95.0f, 12.5f, -10.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.24f, + AnimationHelper.rotation(-83.93f, 3.93f, 5.71f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.36f, + AnimationHelper.rotation(-80.0f, 7.5f, 17.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.76f, + AnimationHelper.rotation(-67.5f, 2.5f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.08f, + AnimationHelper.rotation(-67.5f, 2.5f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.44f, + AnimationHelper.rotation(-55.0f, 2.5f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.56f, + AnimationHelper.rotation(-60.0f, 2.5f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.68f, + AnimationHelper.rotation(-55.0f, 2.5f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.0f, + AnimationHelper.rotation(-67.5f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.56f, + AnimationHelper.rotation(-50.45f, 0.0f, 2.69f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 6.08f, + AnimationHelper.rotation(-62.72f, 0.0f, 4.3f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 6.64f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "right_arm", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.52f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.2f, + AnimationHelper.translate(0.0f, -21.0f, 9.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.68f, + AnimationHelper.translate(2.0f, -2.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.8f, + AnimationHelper.translate(2.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.28f, + AnimationHelper.translate(2.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.88f, + AnimationHelper.translate(2.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.08f, + AnimationHelper.translate(2.0f, -2.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.24f, + AnimationHelper.translate(2.0f, 2.71f, 3.86f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.36f, + AnimationHelper.translate(2.0f, 1.0f, 5.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.76f, + AnimationHelper.translate(2.0f, 3.0f, 3.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.08f, + AnimationHelper.translate(2.0f, 3.0f, 3.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.44f, + AnimationHelper.translate(2.67f, 4.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.56f, + AnimationHelper.translate(2.67f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.68f, + AnimationHelper.translate(2.67f, 4.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.0f, + AnimationHelper.translate(0.67f, 3.0f, 4.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 6.64f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "left_arm", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.12f, + AnimationHelper.rotation(-167.5f, -17.5f, -7.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.6f, + AnimationHelper.rotation(-167.5f, -17.5f, -7.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.88f, + AnimationHelper.rotation(-175.0f, -17.5f, 15.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.16f, + AnimationHelper.rotation(-190.0f, -17.5f, 5.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.28f, + AnimationHelper.rotation(-90.0f, -5.0f, 5.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.68f, + AnimationHelper.rotation(-90.0f, -17.5f, -12.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.8f, + AnimationHelper.rotation(-90.0f, -17.5f, -12.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.28f, + AnimationHelper.rotation(-90.0f, -17.5f, -12.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.88f, + AnimationHelper.rotation(-90.0f, -17.5f, -12.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.04f, + AnimationHelper.rotation(-81.29f, -10.64f, -14.21f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.16f, + AnimationHelper.rotation(-83.5f, -5.5f, -15.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.76f, + AnimationHelper.rotation(-62.5f, -7.5f, 5.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.92f, + AnimationHelper.rotation(-58.75f, -3.75f, 5.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.08f, + AnimationHelper.rotation(-55.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.44f, + AnimationHelper.rotation(-52.5f, 0.0f, 5.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.56f, + AnimationHelper.rotation(-50.0f, 0.0f, 5.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.68f, + AnimationHelper.rotation(-52.5f, 0.0f, 5.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.0f, + AnimationHelper.rotation(-72.5f, -2.5f, 5.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.56f, + AnimationHelper.rotation(-57.5f, -4.54f, 2.99f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 6.08f, + AnimationHelper.rotation(-70.99f, -5.77f, 1.78f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 6.64f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "left_arm", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.12f, + AnimationHelper.translate(0.0f, -8.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.6f, + AnimationHelper.translate(0.0f, -8.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.88f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.2f, + AnimationHelper.translate(-2.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.68f, + AnimationHelper.translate(-4.0f, 3.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.8f, + AnimationHelper.translate(-4.0f, 3.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.28f, + AnimationHelper.translate(-4.0f, 3.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.88f, + AnimationHelper.translate(-4.0f, 3.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.04f, + AnimationHelper.translate(-3.23f, 5.7f, 4.97f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.16f, + AnimationHelper.translate(-1.49f, 2.22f, 5.25f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.76f, + AnimationHelper.translate(-1.14f, 1.71f, 1.86f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.92f, + AnimationHelper.translate(-1.14f, 1.21f, 3.86f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.08f, + AnimationHelper.translate(-1.14f, 2.71f, 4.86f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.44f, + AnimationHelper.translate(-1.0f, 1.0f, 3.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.56f, + AnimationHelper.translate(0.0f, 1.0f, 1.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.68f, + AnimationHelper.translate(0.0f, 1.0f, 3.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.0f, + AnimationHelper.translate(-2.0f, 0.0f, 4.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 6.64f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "right_leg", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.52f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.28f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.88f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.36f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.32f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.48f, + AnimationHelper.rotation(55.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.6f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.8f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 6.64f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "right_leg", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, -63.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.52f, + AnimationHelper.translate(0.0f, -56.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.2f, + AnimationHelper.translate(0.0f, -32.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.68f, + AnimationHelper.translate(0.0f, -32.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.8f, + AnimationHelper.translate(0.0f, -32.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.28f, + AnimationHelper.translate(0.0f, -32.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.88f, + AnimationHelper.translate(0.0f, -32.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.36f, + AnimationHelper.translate(0.0f, -22.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.76f, + AnimationHelper.translate(0.0f, -12.28f, 2.48f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.92f, + AnimationHelper.translate(0.0f, -9.28f, 2.48f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.08f, + AnimationHelper.translate(0.0f, -12.28f, 2.48f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.32f, + AnimationHelper.translate(0.0f, -4.14f, 4.14f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.48f, + AnimationHelper.translate(0.0f, -0.57f, -8.43f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.6f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.8f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 6.64f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "left_leg", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.52f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.28f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.88f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.36f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.84f, + AnimationHelper.rotation(20.0f, 0.0f, -17.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.68f, + AnimationHelper.rotation(20.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.84f, + AnimationHelper.rotation(10.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.8f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 6.64f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "left_leg", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, -63.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.52f, + AnimationHelper.translate(0.0f, -56.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.2f, + AnimationHelper.translate(0.0f, -32.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.68f, + AnimationHelper.translate(0.0f, -32.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.8f, + AnimationHelper.translate(0.0f, -32.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.28f, + AnimationHelper.translate(0.0f, -32.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.88f, + AnimationHelper.translate(0.0f, -32.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.36f, + AnimationHelper.translate(0.0f, -22.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.84f, + AnimationHelper.translate(-4.0f, 2.0f, -7.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.0f, + AnimationHelper.translate(-4.0f, 0.0f, -5.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.68f, + AnimationHelper.translate(-4.0f, 0.0f, -9.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.84f, + AnimationHelper.translate(-2.0f, 2.0f, -3.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 5.8f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 6.64f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .build(); + public static final Animation DIGGING + = Animation.Builder.create(5.0f) + .addBoneAnimation( + "body", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.25f, + AnimationHelper.rotation(4.13441f, 0.94736f, 1.2694f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.5f, + AnimationHelper.rotation(50.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.7083f, + AnimationHelper.rotation(54.45407f, -13.53935f, -18.14183f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.0417f, + AnimationHelper.rotation(59.46442f, -10.8885f, 35.7954f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.3333f, + AnimationHelper.rotation(82.28261f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.625f, + AnimationHelper.rotation(53.23606f, 10.04715f, -29.72932f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.2083f, + AnimationHelper.rotation(-17.71739f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.5417f, + AnimationHelper.rotation(112.28261f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.6667f, + AnimationHelper.rotation(116.06889f, 5.11581f, -24.50117f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.8333f, + AnimationHelper.rotation(121.56244f, -4.17248f, 19.57737f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.0417f, + AnimationHelper.rotation(138.5689f, 5.11581f, -24.50117f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.25f, + AnimationHelper.rotation(144.06244f, -4.17248f, 19.57737f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.375f, + AnimationHelper.rotation(147.28261f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.625f, + AnimationHelper.rotation(147.28261f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.875f, + AnimationHelper.rotation(134.36221f, 8.81113f, -8.90172f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.0417f, + AnimationHelper.rotation(132.05966f, -8.35927f, 9.70506f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.25f, + AnimationHelper.rotation(134.36221f, 8.81113f, -8.90172f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.5f, + AnimationHelper.rotation(147.5f, 0.0f, 0.0f), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "body", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.5f, + AnimationHelper.translate(0.0f, -16.48454f, -6.5784f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.7083f, + AnimationHelper.translate(0.0f, -16.48454f, -6.5784f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.0417f, + AnimationHelper.translate(0.0f, -16.97f, -7.11f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.625f, + AnimationHelper.translate(0.0f, -13.97f, -7.11f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.2083f, + AnimationHelper.translate(0.0f, -11.48454f, -0.5784f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.5417f, + AnimationHelper.translate(0.0f, -16.48454f, -6.5784f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.6667f, + AnimationHelper.translate(0.0f, -20.27f, -5.42f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.375f, + AnimationHelper.translate(0.0f, -21.48454f, -5.5784f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.0417f, + AnimationHelper.translate(0.0f, -22.48454f, -5.5784f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.5f, + AnimationHelper.translate(0.0f, -40.0f, -8.0f), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "head", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.6667f, + AnimationHelper.rotation(12.5f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.2083f, + AnimationHelper.rotation(12.5f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.75f, + AnimationHelper.rotation(45.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.375f, + AnimationHelper.rotation(-22.5f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.5417f, + AnimationHelper.rotation(67.5f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.375f, + AnimationHelper.rotation(67.5f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "head", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.375f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "right_arm", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.5f, + AnimationHelper.rotation(-101.8036f, -21.29587f, 30.61478f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.7083f, + AnimationHelper.rotation(-101.8036f, -21.29587f, 30.61478f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.0f, + AnimationHelper.rotation(48.7585f, -17.61941f, 9.9865f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.1667f, + AnimationHelper.rotation(48.7585f, -17.61941f, 9.9865f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.4583f, + AnimationHelper.rotation(-101.8036f, -21.29587f, 30.61478f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.75f, + AnimationHelper.rotation(-89.04994f, -4.19657f, -1.47845f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.2083f, + AnimationHelper.rotation(-158.30728f, 3.7152f, -1.52352f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.5417f, + AnimationHelper.rotation(-89.04994f, -4.19657f, -1.47845f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.375f, + AnimationHelper.rotation(-120.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "right_arm", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.7083f, + AnimationHelper.translate(2.22f, 0.0f, 0.86f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.0f, + AnimationHelper.translate(3.12f, 0.0f, 4.29f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.2083f, + AnimationHelper.translate(1.0f, 0.0f, 4.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.375f, + AnimationHelper.translate(0.0f, 0.0f, 4.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "left_arm", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.2917f, + AnimationHelper.rotation(-63.89288f, -0.52011f, 2.09491f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.5f, + AnimationHelper.rotation(-63.89288f, -0.52011f, 2.09491f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.7083f, + AnimationHelper.rotation(-62.87857f, 15.15061f, 9.97445f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.9167f, + AnimationHelper.rotation(-86.93642f, 17.45026f, 4.05284f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.1667f, + AnimationHelper.rotation(-86.93642f, 17.45026f, 4.05284f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.4583f, + AnimationHelper.rotation(-86.93642f, 17.45026f, 4.05284f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.6667f, + AnimationHelper.rotation(63.0984f, 8.83573f, -8.71284f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.8333f, + AnimationHelper.rotation(35.5984f, 8.83573f, -8.71284f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.2083f, + AnimationHelper.rotation(-153.27473f, -0.02953f, 3.5235f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.5417f, + AnimationHelper.rotation(-87.07754f, -0.02625f, 3.132f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.375f, + AnimationHelper.rotation(-120.0f, 0.0f, 0.0f), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "left_arm", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.5f, + AnimationHelper.translate(-0.28f, 5.0f, 10.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.7083f, + AnimationHelper.translate(-1.51f, 4.35f, 4.33f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.9167f, + AnimationHelper.translate(-0.6f, 3.61f, 4.63f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.1667f, + AnimationHelper.translate(-0.6f, 3.61f, 0.63f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.6667f, + AnimationHelper.translate(-2.85f, -0.1f, 3.33f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.2083f, + AnimationHelper.translate(-1.0f, 0.0f, 4.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.375f, + AnimationHelper.translate(0.0f, 0.0f, 4.0f), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "right_leg", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.5f, + AnimationHelper.rotation(113.27f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.7083f, + AnimationHelper.rotation(113.27f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.3333f, + AnimationHelper.rotation(113.27f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.5833f, + AnimationHelper.rotation(182.5f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.8333f, + AnimationHelper.rotation(120.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.0833f, + AnimationHelper.rotation(182.5f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.2917f, + AnimationHelper.rotation(120.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.5f, + AnimationHelper.rotation(90.0f, 0.0f, 0.0f), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "right_leg", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.5f, + AnimationHelper.translate(0.0f, -13.98f, -2.37f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.7083f, + AnimationHelper.translate(0.0f, -13.98f, -2.37f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.3333f, + AnimationHelper.translate(0.0f, -13.98f, -2.37f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.5833f, + AnimationHelper.translate(0.0f, -7.0f, -3.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.8333f, + AnimationHelper.translate(0.0f, -9.0f, -3.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.0833f, + AnimationHelper.translate(0.0f, -16.71f, -3.69f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.2917f, + AnimationHelper.translate(0.0f, -28.0f, -5.0f), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "left_leg", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.5f, + AnimationHelper.rotation(114.98f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.7083f, + AnimationHelper.rotation(114.98f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.3333f, + AnimationHelper.rotation(114.98f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.5833f, + AnimationHelper.rotation(90.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.8333f, + AnimationHelper.rotation(172.5f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.0833f, + AnimationHelper.rotation(90.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.2917f, + AnimationHelper.rotation(197.5f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.5f, + AnimationHelper.rotation(90.0f, 0.0f, 0.0f), + Transformation.Interpolations.LINEAL + ) + ) + ) + .addBoneAnimation( + "left_leg", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.5f, + AnimationHelper.translate(0.0f, -14.01f, -2.35f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.7083f, + AnimationHelper.translate(0.0f, -14.01f, -2.35f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.3333f, + AnimationHelper.translate(0.0f, -14.01f, -2.35f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.5833f, + AnimationHelper.translate(0.0f, -5.0f, -4.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.8333f, + AnimationHelper.translate(0.0f, -7.0f, -4.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.0833f, + AnimationHelper.translate(0.0f, -15.5f, -3.76f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.2917f, + AnimationHelper.translate(0.0f, -28.0f, -5.0f), + Transformation.Interpolations.LINEAL + ) + ) + ) + .build(); + public static final Animation ROARING + = Animation.Builder.create(4.2f) + .addBoneAnimation( + "body", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.24f, + AnimationHelper.rotation(-25.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.6f, + AnimationHelper.rotation(32.5f, 0.0f, -7.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.84f, + AnimationHelper.rotation(38.33f, 0.0f, 2.99f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.08f, + AnimationHelper.rotation(40.97f, 0.0f, -4.3f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.36f, + AnimationHelper.rotation(44.41f, 0.0f, 6.29f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.0f, + AnimationHelper.rotation(47.5f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.2f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "body", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.24f, + AnimationHelper.translate(0.0f, -1.0f, 3.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.6f, + AnimationHelper.translate(0.0f, -3.0f, -6.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.0f, + AnimationHelper.translate(0.0f, -3.0f, -6.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.2f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "head", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.24f, + AnimationHelper.rotation(-32.5f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.6f, + AnimationHelper.rotation(-32.5f, 0.0f, -27.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.8f, + AnimationHelper.rotation(-32.5f, 0.0f, 26.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.04f, + AnimationHelper.rotation(-32.5f, 0.0f, -27.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.44f, + AnimationHelper.rotation(-32.5f, 0.0f, 26.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.84f, + AnimationHelper.rotation(-5.0f, 0.0f, -12.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.2f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "head", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.24f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.6f, + AnimationHelper.translate(0.0f, -2.0f, -6.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.2f, + AnimationHelper.translate(0.0f, -2.0f, -6.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.48f, + AnimationHelper.translate(0.0f, -2.0f, -6.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.2f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "right_ear", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.24f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.76f, + AnimationHelper.rotation(0.0f, 0.0f, -10.85f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.08f, + AnimationHelper.rotation(0.0f, 0.0f, 12.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.4f, + AnimationHelper.rotation(0.0f, 0.0f, -10.85f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.72f, + AnimationHelper.rotation(0.0f, 0.0f, 12.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.0f, + AnimationHelper.rotation(0.0f, 0.0f, -10.85f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.2f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "left_ear", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.24f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.76f, + AnimationHelper.rotation(0.0f, 0.0f, -15.85f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.08f, + AnimationHelper.rotation(0.0f, 0.0f, 12.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.4f, + AnimationHelper.rotation(0.0f, 0.0f, -15.85f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.72f, + AnimationHelper.rotation(0.0f, 0.0f, 12.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.0f, + AnimationHelper.rotation(0.0f, 0.0f, -15.85f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.2f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "right_arm", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.72f, + AnimationHelper.rotation(-120.0f, 0.0f, -20.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.24f, + AnimationHelper.rotation(-77.5f, 3.75f, 15.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.48f, + AnimationHelper.rotation(67.5f, -32.5f, 20.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.48f, + AnimationHelper.rotation(37.5f, -32.5f, 25.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.88f, + AnimationHelper.rotation(27.6f, -17.1f, 32.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.2f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "right_arm", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.72f, + AnimationHelper.translate(3.0f, -2.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.48f, + AnimationHelper.translate(4.0f, -2.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.48f, + AnimationHelper.translate(4.0f, -2.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.2f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "left_arm", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.72f, + AnimationHelper.rotation(-125.0f, 0.0f, 20.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.24f, + AnimationHelper.rotation(-76.25f, -17.5f, -7.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.48f, + AnimationHelper.rotation(62.5f, 42.5f, -12.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.48f, + AnimationHelper.rotation(37.5f, 27.5f, -27.5f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.88f, + AnimationHelper.rotation(25.0f, 18.4f, -30.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.2f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "left_arm", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.72f, + AnimationHelper.translate(-3.0f, -2.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.48f, + AnimationHelper.translate(-4.0f, -2.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.48f, + AnimationHelper.translate(-4.0f, -2.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 4.2f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .build(); + public static final Animation SNIFFING + = Animation.Builder.create(4.16f) + .addBoneAnimation( + "body", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.56f, + AnimationHelper.rotation(17.5f, 32.5f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.96f, + AnimationHelper.rotation(0.0f, 32.5f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.2f, + AnimationHelper.rotation(10.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.8f, + AnimationHelper.rotation(10.0f, -30.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.32f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "head", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.68f, + AnimationHelper.rotation(0.0f, 40.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.96f, + AnimationHelper.rotation(-22.5f, 40.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.24f, + AnimationHelper.rotation(0.0f, 20.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.52f, + AnimationHelper.rotation(-35.0f, 20.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.76f, + AnimationHelper.rotation(0.0f, 20.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.28f, + AnimationHelper.rotation(0.0f, -20.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.88f, + AnimationHelper.rotation(0.0f, -20.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.32f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "right_arm", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.96f, + AnimationHelper.rotation(17.5f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.2f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.76f, + AnimationHelper.rotation(-15.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.32f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "left_arm", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.96f, + AnimationHelper.rotation(-15.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.2f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.76f, + AnimationHelper.rotation(17.5f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.32f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .build(); + public static final Animation ATTACKING + = Animation.Builder.create(0.33333f) + .addBoneAnimation( + "body", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.0417f, + AnimationHelper.rotation(-22.5f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.2083f, + AnimationHelper.rotation(22.5f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.3333f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "body", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.0417f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.2083f, + AnimationHelper.translate(0.0f, -1.0f, -2.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.3333f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "head", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.0417f, + AnimationHelper.rotation(22.5f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.25f, + AnimationHelper.rotation(-30.17493f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.3333f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "head", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.0417f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.25f, + AnimationHelper.translate(0.0f, -2.0f, -2.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.3333f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "right_arm", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.0417f, + AnimationHelper.rotation(-120.36119f, 40.78947f, -20.94102f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.1667f, + AnimationHelper.rotation(-90.0f, -45.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.3333f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "right_arm", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.0417f, + AnimationHelper.translate(4.0f, 0.0f, 5.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.1667f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.3333f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "left_arm", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.0417f, + AnimationHelper.rotation(-120.36119f, -40.78947f, 20.94102f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.1667f, + AnimationHelper.rotation(-61.1632f, 42.85882f, 11.52421f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.3333f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "left_arm", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.0417f, + AnimationHelper.translate(-4.0f, 0.0f, 5.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.1667f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.3333f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .build(); + public static final Animation SONIC_BOOM + = Animation.Builder.create(3.0f) + .addBoneAnimation( + "body", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.0833f, + AnimationHelper.rotation(47.5f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.625f, + AnimationHelper.rotation(55.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.9167f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.0f, + AnimationHelper.rotation(-32.5f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.4583f, + AnimationHelper.rotation(-32.5f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.7083f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.875f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "body", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.0833f, + AnimationHelper.translate(0.0f, -3.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.625f, + AnimationHelper.translate(0.0f, -4.0f, -1.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.9167f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.7083f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.875f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "right_ribcage", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.5417f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.7917f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.875f, + AnimationHelper.rotation(0.0f, 125.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.5f, + AnimationHelper.rotation(0.0f, 125.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.6667f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "left_ribcage", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.5417f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.7917f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.875f, + AnimationHelper.rotation(0.0f, -125.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.5f, + AnimationHelper.rotation(0.0f, -125.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.6667f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "head", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.0f, + AnimationHelper.rotation(67.5f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.75f, + AnimationHelper.rotation(80.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.9167f, + AnimationHelper.rotation(-45.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.5f, + AnimationHelper.rotation(-45.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.7083f, + AnimationHelper.rotation(-45.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.875f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "head", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.9167f, + AnimationHelper.translate(0.0f, 0.0f, -3.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.5f, + AnimationHelper.translate(0.0f, 0.0f, -3.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.7083f, + AnimationHelper.translate(0.0f, 0.0f, -3.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.875f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "right_arm", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.875f, + AnimationHelper.rotation(-42.28659f, -32.69813f, -5.00825f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.1667f, + AnimationHelper.rotation(-29.83757f, -35.39626f, -45.28089f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.3333f, + AnimationHelper.rotation(-29.83757f, -35.39626f, -45.28089f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.6667f, + AnimationHelper.rotation(-72.28659f, -32.69813f, -5.00825f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.8333f, + AnimationHelper.rotation(35.26439f, -30.0f, 35.26439f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.9167f, + AnimationHelper.rotation(73.75484f, -13.0931f, 19.20518f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.5f, + AnimationHelper.rotation(73.75484f, -13.0931f, 19.20518f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.75f, + AnimationHelper.rotation(58.20713f, -21.1064f, 28.7261f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "right_arm", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.8333f, + AnimationHelper.translate(3.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.75f, + AnimationHelper.translate(3.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "left_arm", + new Transformation( + Transformation.Targets.ROTATE, + new Keyframe( + 0.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 0.875f, + AnimationHelper.rotation(-33.80694f, 32.31058f, 6.87997f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.1667f, + AnimationHelper.rotation(-17.87827f, 34.62115f, 49.02433f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.3333f, + AnimationHelper.rotation(-17.87827f, 34.62115f, 49.02433f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.6667f, + AnimationHelper.rotation(-51.30694f, 32.31058f, 6.87997f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.8333f, + AnimationHelper.rotation(35.26439f, 30.0f, -35.26439f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.9167f, + AnimationHelper.rotation(73.75484f, 13.0931f, -19.20518f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.5f, + AnimationHelper.rotation(73.75484f, 13.0931f, -19.20518f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.75f, + AnimationHelper.rotation(58.20713f, 21.1064f, -28.7261f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.0f, + AnimationHelper.rotation(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .addBoneAnimation( + "left_arm", + new Transformation( + Transformation.Targets.TRANSLATE, + new Keyframe( + 0.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 1.8333f, + AnimationHelper.translate(-3.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 2.75f, + AnimationHelper.translate(-3.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ), + new Keyframe( + 3.0f, + AnimationHelper.translate(0.0f, 0.0f, 0.0f), + Transformation.Interpolations.CATMULL + ) + ) + ) + .build(); } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/api/AnimatedModel.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/api/AnimatedModel.java index 89c6ab3..af655b3 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/api/AnimatedModel.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/api/AnimatedModel.java @@ -1,5 +1,8 @@ package com.cursedcauldron.wildbackport.client.animation.api; +import java.util.Optional; +import java.util.function.Function; + import com.cursedcauldron.wildbackport.core.mixin.access.ModelPartAccessor; import com.mojang.math.Vector3f; import net.fabricmc.api.EnvType; @@ -10,9 +13,6 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; -import java.util.Optional; -import java.util.function.Function; - //<> @Environment(EnvType.CLIENT) @@ -28,15 +28,31 @@ public abstract class AnimatedModel extends HierarchicalModel< } public Optional getChild(String name) { - return this.root().getAllParts().filter(part -> ((ModelPartAccessor)(Object)part).getChildren().containsKey(name)).findFirst().map(part -> part.getChild(name)); + return this.root() + .getAllParts() + .filter( + part + -> ((ModelPartAccessor) (Object) part).getChildren().containsKey(name) + ) + .findFirst() + .map(part -> part.getChild(name)); } - protected void animate(AnimationState state, Animation animation, float animationProgress) { + protected void + animate(AnimationState state, Animation animation, float animationProgress) { this.animate(state, animation, animationProgress, 1.0F); } - protected void animate(AnimationState animationState, Animation animation, float animationProgress, float speedMultiplier) { + protected void animate( + AnimationState animationState, + Animation animation, + float animationProgress, + float speedMultiplier + ) { animationState.run(animationProgress, speedMultiplier); - animationState.run(state -> AnimationHelper.animate(this, animation, state.runningTime(), 1.0F, CACHE)); + animationState.run( + state + -> AnimationHelper.animate(this, animation, state.runningTime(), 1.0F, CACHE) + ); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/api/Animation.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/api/Animation.java index 042aa53..151bfe6 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/api/Animation.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/api/Animation.java @@ -1,18 +1,23 @@ package com.cursedcauldron.wildbackport.client.animation.api; +import java.util.List; +import java.util.Map; + import com.google.common.collect.Maps; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import org.apache.commons.compress.utils.Lists; -import java.util.List; -import java.util.Map; - @Environment(EnvType.CLIENT) -public record Animation(float lengthInSeconds, boolean looping, Map> boneAnimations) { +public record Animation( + float lengthInSeconds, + boolean looping, + Map> boneAnimations +) { public static class Builder { private final float lengthInSeconds; - private final Map> transformations = Maps.newHashMap(); + private final Map> transformations + = Maps.newHashMap(); private boolean looping; public static Builder create(float lengthInSeconds) { @@ -29,12 +34,15 @@ public record Animation(float lengthInSeconds, boolean looping, Map Lists.newArrayList()).add(transformation); + this.transformations.computeIfAbsent(name2, name -> Lists.newArrayList()) + .add(transformation); return this; } public Animation build() { - return new Animation(this.lengthInSeconds, this.looping, this.transformations); + return new Animation( + this.lengthInSeconds, this.looping, this.transformations + ); } } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/api/AnimationHelper.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/api/AnimationHelper.java index 50c5446..5a03a25 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/api/AnimationHelper.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/api/AnimationHelper.java @@ -1,41 +1,59 @@ package com.cursedcauldron.wildbackport.client.animation.api; +import java.util.List; +import java.util.Map; +import java.util.Optional; + import com.mojang.math.Vector3f; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.model.geom.ModelPart; import net.minecraft.util.Mth; -import java.util.List; -import java.util.Map; -import java.util.Optional; - //<> @Environment(EnvType.CLIENT) public class AnimationHelper { - public static void animate(AnimatedModel model, Animation animation, long runningTime, float speed, Vector3f cache) { + public static void animate( + AnimatedModel model, + Animation animation, + long runningTime, + float speed, + Vector3f cache + ) { float runningSeconds = getRunningSeconds(animation, runningTime); - for (Map.Entry> animations : animation.boneAnimations().entrySet()) { + for (Map.Entry> animations : + animation.boneAnimations().entrySet()) { Optional modelPart = model.getChild(animations.getKey()); List transformations = animations.getValue(); modelPart.ifPresent(part -> transformations.forEach(transformation -> { Keyframe[] keyframes = transformation.keyframes(); - int start = Math.max(0, Mth.binarySearch(0, keyframes.length, i -> runningSeconds <= keyframes[i].timestamp()) - 1); + int start = Math.max( + 0, + Mth.binarySearch( + 0, + keyframes.length, + i -> runningSeconds <= keyframes[i].timestamp() + ) - 1 + ); int end = Math.min(keyframes.length - 1, start + 1); Keyframe frameStart = keyframes[start]; Keyframe frameEnd = keyframes[end]; float current = runningSeconds - frameStart.timestamp(); - float delta = Mth.clamp(current / (frameEnd.timestamp() - frameStart.timestamp()), 0.0f, 1.0f); - frameEnd.interpolation().apply(cache, delta, keyframes, start, end, speed); + float delta = Mth.clamp( + current / (frameEnd.timestamp() - frameStart.timestamp()), 0.0f, 1.0f + ); + frameEnd.interpolation().apply( + cache, delta, keyframes, start, end, speed + ); transformation.target().apply(part, cache); })); } } private static float getRunningSeconds(Animation animation, long runningTime) { - float time = (float)runningTime / 1000.0f; + float time = (float) runningTime / 1000.0f; return animation.looping() ? time % animation.lengthInSeconds() : time; } @@ -44,10 +62,14 @@ public class AnimationHelper { } public static Vector3f rotation(float x, float y, float z) { - return new Vector3f(x * ((float)Math.PI / 180), y * ((float)Math.PI / 180), z * ((float)Math.PI / 180)); + return new Vector3f( + x * ((float) Math.PI / 180), + y * ((float) Math.PI / 180), + z * ((float) Math.PI / 180) + ); } public static Vector3f scale(double x, double y, double z) { - return new Vector3f((float)(x - 1.0), (float)(y - 1.0), (float)(z - 1.0)); + return new Vector3f((float) (x - 1.0), (float) (y - 1.0), (float) (z - 1.0)); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/api/AnimationState.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/api/AnimationState.java index e5a669e..b902d8f 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/api/AnimationState.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/api/AnimationState.java @@ -1,9 +1,9 @@ package com.cursedcauldron.wildbackport.client.animation.api; -import net.minecraft.util.Mth; - import java.util.function.Consumer; +import net.minecraft.util.Mth; + //<> public class AnimationState { @@ -11,12 +11,13 @@ public class AnimationState { private long runningTime; public void start(int ticks) { - this.startedAt = (long)ticks * 1000L / 20L; + this.startedAt = (long) ticks * 1000L / 20L; this.runningTime = 0L; } public void startIfNotRunning(int ticks) { - if (!this.isRunning()) this.start(ticks); + if (!this.isRunning()) + this.start(ticks); } public void stop() { @@ -24,13 +25,15 @@ public class AnimationState { } public void run(Consumer consumer) { - if (this.isRunning()) consumer.accept(this); + if (this.isRunning()) + consumer.accept(this); } public void run(float animationProgress, float speedMultiplier) { if (this.isRunning()) { long runningAt = Mth.lfloor(animationProgress * 1000.0F / 20.0F); - this.runningTime += (long)((float)(runningAt - this.startedAt) * speedMultiplier); + this.runningTime + += (long) ((float) (runningAt - this.startedAt) * speedMultiplier); this.startedAt = runningAt; } } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/api/Keyframe.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/api/Keyframe.java index 765cea3..948ab73 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/api/Keyframe.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/api/Keyframe.java @@ -5,4 +5,5 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @Environment(EnvType.CLIENT) -public record Keyframe(float timestamp, Vector3f target, Transformation.Interpolation interpolation) {} \ No newline at end of file +public record +Keyframe(float timestamp, Vector3f target, Transformation.Interpolation interpolation) {} \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/api/Transformation.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/api/Transformation.java index cb0ed8e..537e2d7 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/api/Transformation.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/animation/api/Transformation.java @@ -14,29 +14,65 @@ public record Transformation(Target target, Keyframe... keyframes) { } public static class Interpolations { - public static final Interpolation LINEAL = (cache, delta, keyframes, start, end, speed) -> { + public static final Interpolation LINEAL + = (cache, delta, keyframes, start, end, speed) -> { Vector3f frameStart = keyframes[start].target(); Vector3f frameEnd = keyframes[end].target(); - cache.set(Mth.lerp(delta, frameStart.x(), frameEnd.x()) * speed, Mth.lerp(delta, frameStart.y(), frameEnd.y()) * speed, Mth.lerp(delta, frameStart.z(), frameEnd.z()) * speed); + cache.set( + Mth.lerp(delta, frameStart.x(), frameEnd.x()) * speed, + Mth.lerp(delta, frameStart.y(), frameEnd.y()) * speed, + Mth.lerp(delta, frameStart.z(), frameEnd.z()) * speed + ); return cache; }; - public static final Interpolation CATMULL = (cache, delta, keyframes, start, end, speed) -> { + public static final Interpolation CATMULL + = (cache, delta, keyframes, start, end, speed) -> { Vector3f frameStartPoint = keyframes[Math.max(0, start - 1)].target(); Vector3f frameStart = keyframes[start].target(); Vector3f frameEnd = keyframes[end].target(); - Vector3f frameEndPoint = keyframes[Math.min(keyframes.length - 1, end + 1)].target(); - cache.set(MathUtils.catmullrom(delta, frameStartPoint.x(), frameStart.x(), frameEnd.x(), frameEndPoint.x()) * speed, MathUtils.catmullrom(delta, frameStartPoint.y(), frameStart.y(), frameEnd.y(), frameEndPoint.y()) * speed, MathUtils.catmullrom(delta, frameStartPoint.z(), frameStart.z(), frameEnd.z(), frameEndPoint.z()) * speed); + Vector3f frameEndPoint + = keyframes[Math.min(keyframes.length - 1, end + 1)].target(); + cache.set( + MathUtils.catmullrom( + delta, + frameStartPoint.x(), + frameStart.x(), + frameEnd.x(), + frameEndPoint.x() + ) * speed, + MathUtils.catmullrom( + delta, + frameStartPoint.y(), + frameStart.y(), + frameEnd.y(), + frameEndPoint.y() + ) * speed, + MathUtils.catmullrom( + delta, + frameStartPoint.z(), + frameStart.z(), + frameEnd.z(), + frameEndPoint.z() + ) * speed + ); return cache; }; } public static class Targets { - public static final Target TRANSLATE = Animated::translate; - public static final Target ROTATE = Animated::rotate; - public static final Target SCALE = Animated::scaleY; + public static final Target TRANSLATE = Animated::translate; + public static final Target ROTATE = Animated::rotate; + public static final Target SCALE = Animated::scaleY; } public interface Interpolation { - Vector3f apply(Vector3f cache, float delta, Keyframe[] keyframes, int start, int end, float speed); + Vector3f apply( + Vector3f cache, + float delta, + Keyframe[] keyframes, + int start, + int end, + float speed + ); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/SculkChargeParticle.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/SculkChargeParticle.java index 2f69920..c202d6f 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/SculkChargeParticle.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/SculkChargeParticle.java @@ -13,7 +13,16 @@ import net.minecraft.client.particle.TextureSheetParticle; public class SculkChargeParticle extends TextureSheetParticle { private final SpriteSet sprites; - public SculkChargeParticle(ClientLevel level, double x, double y, double z, double xMotion, double yMotion, double zMotion, SpriteSet sprites) { + public SculkChargeParticle( + ClientLevel level, + double x, + double y, + double z, + double xMotion, + double yMotion, + double zMotion, + SpriteSet sprites + ) { super(level, x, y, z, xMotion, yMotion, zMotion); this.sprites = sprites; this.friction = 0.96F; @@ -38,10 +47,22 @@ public class SculkChargeParticle extends TextureSheetParticle { this.setSpriteFromAge(this.sprites); } - public record Provider(SpriteSet sprites) implements ParticleProvider { + public record Provider(SpriteSet sprites) + implements ParticleProvider { @Override - public Particle createParticle(SculkChargeParticleOptions options, ClientLevel level, double x, double y, double z, double xMotion, double yMotion, double zMotion) { - SculkChargeParticle particle = new SculkChargeParticle(level, x, y, z, xMotion, yMotion, zMotion, this.sprites); + public Particle createParticle( + SculkChargeParticleOptions options, + ClientLevel level, + double x, + double y, + double z, + double xMotion, + double yMotion, + double zMotion + ) { + SculkChargeParticle particle = new SculkChargeParticle( + level, x, y, z, xMotion, yMotion, zMotion, this.sprites + ); particle.setAlpha(1.0F); particle.setParticleSpeed(xMotion, yMotion, zMotion); particle.oRoll = particle.roll = options.roll(); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/SculkChargeParticleOptions.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/SculkChargeParticleOptions.java index 1453765..8522bc3 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/SculkChargeParticleOptions.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/SculkChargeParticleOptions.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.client.particle; +import java.util.Locale; + import com.cursedcauldron.wildbackport.client.registry.WBParticleTypes; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; @@ -10,26 +12,32 @@ import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleType; import net.minecraft.network.FriendlyByteBuf; -import java.util.Locale; - public record SculkChargeParticleOptions(float roll) implements ParticleOptions { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> { - return instance.group(Codec.FLOAT.fieldOf("roll").forGetter(options -> { - return options.roll; - })).apply(instance, SculkChargeParticleOptions::new); - }); + public static final Codec CODEC + = RecordCodecBuilder.create(instance -> { + return instance + .group(Codec.FLOAT.fieldOf("roll").forGetter(options -> { + return options.roll; + })) + .apply(instance, SculkChargeParticleOptions::new); + }); - public static final Deserializer DESERIALIZER = new Deserializer<>() { - @Override - public SculkChargeParticleOptions fromCommand(ParticleType type, StringReader reader) throws CommandSyntaxException { - return new SculkChargeParticleOptions(reader.readFloat()); - } + public static final Deserializer DESERIALIZER + = new Deserializer<>() { + @Override + public SculkChargeParticleOptions fromCommand( + ParticleType type, StringReader reader + ) throws CommandSyntaxException { + return new SculkChargeParticleOptions(reader.readFloat()); + } - @Override - public SculkChargeParticleOptions fromNetwork(ParticleType type, FriendlyByteBuf buf) { - return new SculkChargeParticleOptions(buf.readFloat()); - } - }; + @Override + public SculkChargeParticleOptions fromNetwork( + ParticleType type, FriendlyByteBuf buf + ) { + return new SculkChargeParticleOptions(buf.readFloat()); + } + }; @Override public ParticleType getType() { @@ -43,6 +51,11 @@ public record SculkChargeParticleOptions(float roll) implements ParticleOptions @Override public String writeToString() { - return String.format(Locale.ROOT, "%s %.2f", Registry.PARTICLE_TYPE.getId(this.getType()), this.roll); + return String.format( + Locale.ROOT, + "%s %.2f", + Registry.PARTICLE_TYPE.getId(this.getType()), + this.roll + ); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/SculkChargePopParticle.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/SculkChargePopParticle.java index 0c669d4..91fbfe5 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/SculkChargePopParticle.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/SculkChargePopParticle.java @@ -16,7 +16,16 @@ import net.minecraft.core.particles.SimpleParticleType; public class SculkChargePopParticle extends TextureSheetParticle { private final SpriteSet sprites; - public SculkChargePopParticle(ClientLevel level, double x, double y, double z, double xMotion, double yMotion, double zMotion, SpriteSet sprites) { + public SculkChargePopParticle( + ClientLevel level, + double x, + double y, + double z, + double xMotion, + double yMotion, + double zMotion, + SpriteSet sprites + ) { super(level, x, y, z, xMotion, yMotion, zMotion); this.sprites = sprites; this.friction = 0.96F; @@ -41,10 +50,22 @@ public class SculkChargePopParticle extends TextureSheetParticle { this.setSpriteFromAge(this.sprites); } - public record Provider(SpriteSet sprites) implements ParticleProvider { + public record Provider(SpriteSet sprites) + implements ParticleProvider { @Override - public Particle createParticle(SimpleParticleType type, ClientLevel level, double x, double y, double z, double xMotion, double yMotion, double zMotion) { - SculkChargePopParticle particle = new SculkChargePopParticle(level, x, y, z, xMotion, yMotion, zMotion, this.sprites); + public Particle createParticle( + SimpleParticleType type, + ClientLevel level, + double x, + double y, + double z, + double xMotion, + double yMotion, + double zMotion + ) { + SculkChargePopParticle particle = new SculkChargePopParticle( + level, x, y, z, xMotion, yMotion, zMotion, this.sprites + ); particle.setAlpha(1.0F); particle.setParticleSpeed(xMotion, yMotion, zMotion); particle.setLifetime(level.getRandom().nextInt(4) + 6); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/SculkSoulParticle.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/SculkSoulParticle.java index 7c500a1..f7e4942 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/SculkSoulParticle.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/SculkSoulParticle.java @@ -16,7 +16,16 @@ import net.minecraft.core.particles.SimpleParticleType; public class SculkSoulParticle extends RisingParticle { private final SpriteSet sprites; - public SculkSoulParticle(ClientLevel level, double x, double y, double z, double xMotion, double yMotion, double zMotion, SpriteSet sprites) { + public SculkSoulParticle( + ClientLevel level, + double x, + double y, + double z, + double xMotion, + double yMotion, + double zMotion, + SpriteSet sprites + ) { super(level, x, y, z, xMotion, yMotion, zMotion); this.sprites = sprites; this.getQuadSize(1.5F); @@ -40,10 +49,22 @@ public class SculkSoulParticle extends RisingParticle { } @Environment(EnvType.CLIENT) - public record Provider(SpriteSet sprites) implements ParticleProvider { + public record Provider(SpriteSet sprites) + implements ParticleProvider { @Override - public Particle createParticle(SimpleParticleType type, ClientLevel level, double x, double y, double z, double xMotion, double yMotion, double zMotion) { - SculkSoulParticle particle = new SculkSoulParticle(level, x, y, z, xMotion, yMotion, zMotion, this.sprites); + public Particle createParticle( + SimpleParticleType type, + ClientLevel level, + double x, + double y, + double z, + double xMotion, + double yMotion, + double zMotion + ) { + SculkSoulParticle particle = new SculkSoulParticle( + level, x, y, z, xMotion, yMotion, zMotion, this.sprites + ); particle.setAlpha(1.0F); return particle; } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/ShriekParticle.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/ShriekParticle.java index 88d71c8..9ffd222 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/ShriekParticle.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/ShriekParticle.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.client.particle; +import java.util.function.Consumer; + import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Quaternion; import com.mojang.math.Vector3f; @@ -14,10 +16,9 @@ import net.minecraft.client.particle.TextureSheetParticle; import net.minecraft.util.Mth; import net.minecraft.world.phys.Vec3; -import java.util.function.Consumer; - public class ShriekParticle extends TextureSheetParticle { - private static final Vector3f AXIS = Util.make(new Vector3f(0.5F, 0.5F, 0.5F), Vector3f::normalize); + private static final Vector3f AXIS + = Util.make(new Vector3f(0.5F, 0.5F, 0.5F), Vector3f::normalize); private static final Vector3f OFFSET = new Vector3f(-1.0F, -1.0F, 0.0F); private int delay; @@ -34,32 +35,47 @@ public class ShriekParticle extends TextureSheetParticle { @Override public float getQuadSize(float tickDelta) { - return this.quadSize * Mth.clamp(((float)this.age + tickDelta) / (float)this.lifetime * 0.75F, 0.0F, 1.0F); + return this.quadSize + * Mth.clamp( + ((float) this.age + tickDelta) / (float) this.lifetime * 0.75F, 0.0F, 1.0F + ); } @Override public void render(VertexConsumer vertex, Camera camera, float tickDelta) { - if (this.delay > 0) return; - this.alpha = 1.0F - Mth.clamp(((float)this.age + tickDelta) / (float)this.lifetime * 0.75F, 0.0F, 1.0F); + if (this.delay > 0) + return; + this.alpha = 1.0F + - Mth.clamp( + ((float) this.age + tickDelta) / (float) this.lifetime * 0.75F, 0.0F, 1.0F + ); this.render(vertex, camera, tickDelta, quaternion -> { quaternion.mul(Vector3f.YP.rotation(0.0F)); quaternion.mul(Vector3f.XP.rotation(-1.0472F)); }); this.render(vertex, camera, tickDelta, quaternion -> { - quaternion.mul(Vector3f.YP.rotation((float)(-Math.PI))); + quaternion.mul(Vector3f.YP.rotation((float) (-Math.PI))); quaternion.mul(Vector3f.XP.rotation(1.0472F)); }); } - private void render(VertexConsumer vertex, Camera camera, float tickDelta, Consumer consumer) { + private void render( + VertexConsumer vertex, + Camera camera, + float tickDelta, + Consumer consumer + ) { Vec3 pos = camera.getPosition(); - float x = (float)(Mth.lerp(tickDelta, this.xo, this.x) - pos.x()); - float y = (float)(Mth.lerp(tickDelta, this.yo, this.y) - pos.y()); - float z = (float)(Mth.lerp(tickDelta, this.zo, this.z) - pos.z()); + float x = (float) (Mth.lerp(tickDelta, this.xo, this.x) - pos.x()); + float y = (float) (Mth.lerp(tickDelta, this.yo, this.y) - pos.y()); + float z = (float) (Mth.lerp(tickDelta, this.zo, this.z) - pos.z()); Quaternion quaternion = new Quaternion(AXIS, 0.0F, true); consumer.accept(quaternion); OFFSET.transform(quaternion); - Vector3f[] vectors = new Vector3f[] {new Vector3f(-1.0F, -1.0F, 0.0F), new Vector3f(-1.0F, 1.0F, 0.0F), new Vector3f(1.0F, 1.0F, 0.0F), new Vector3f(1.0F, -1.0F, 0.0F)}; + Vector3f[] vectors = new Vector3f[] { new Vector3f(-1.0F, -1.0F, 0.0F), + new Vector3f(-1.0F, 1.0F, 0.0F), + new Vector3f(1.0F, 1.0F, 0.0F), + new Vector3f(1.0F, -1.0F, 0.0F) }; float quadSize = this.getQuadSize(tickDelta); for (int i = 0; i < 4; i++) { @@ -74,11 +90,15 @@ public class ShriekParticle extends TextureSheetParticle { this.addVertex(vertex, vectors[1], this.getU1(), this.getV0(), light); this.addVertex(vertex, vectors[2], this.getU0(), this.getV0(), light); this.addVertex(vertex, vectors[3], this.getU0(), this.getV1(), light); - } - private void addVertex(VertexConsumer vertex, Vector3f vector, float u, float v, int light) { - vertex.vertex(vector.x(), vector.y(), vector.z()).uv(u, v).color(this.rCol, this.gCol, this.bCol, this.alpha).uv2(light).endVertex(); + private void + addVertex(VertexConsumer vertex, Vector3f vector, float u, float v, int light) { + vertex.vertex(vector.x(), vector.y(), vector.z()) + .uv(u, v) + .color(this.rCol, this.gCol, this.bCol, this.alpha) + .uv2(light) + .endVertex(); } @Override @@ -100,9 +120,19 @@ public class ShriekParticle extends TextureSheetParticle { super.tick(); } - public record Provider(SpriteSet spriteSet) implements ParticleProvider { + public record Provider(SpriteSet spriteSet) + implements ParticleProvider { @Override - public Particle createParticle(ShriekParticleOptions options, ClientLevel level, double x, double y, double z, double xMotion, double yMotion, double zMotion) { + public Particle createParticle( + ShriekParticleOptions options, + ClientLevel level, + double x, + double y, + double z, + double xMotion, + double yMotion, + double zMotion + ) { ShriekParticle particle = new ShriekParticle(level, x, y, z, options.delay()); particle.pickSprite(this.spriteSet); particle.setAlpha(1.0F); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/ShriekParticleOptions.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/ShriekParticleOptions.java index e1f84a6..64c735f 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/ShriekParticleOptions.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/ShriekParticleOptions.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.client.particle; +import java.util.Locale; + import com.cursedcauldron.wildbackport.client.registry.WBParticleTypes; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; @@ -10,27 +12,33 @@ import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleType; import net.minecraft.network.FriendlyByteBuf; -import java.util.Locale; - public record ShriekParticleOptions(int delay) implements ParticleOptions { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> { - return instance.group(Codec.INT.fieldOf("delay").forGetter(options -> { - return options.delay; - })).apply(instance, ShriekParticleOptions::new); - }); + public static final Codec CODEC + = RecordCodecBuilder.create(instance -> { + return instance + .group(Codec.INT.fieldOf("delay").forGetter(options -> { + return options.delay; + })) + .apply(instance, ShriekParticleOptions::new); + }); - public static final ParticleOptions.Deserializer DESERIALIZER = new ParticleOptions.Deserializer<>() { - @Override - public ShriekParticleOptions fromCommand(ParticleType type, StringReader reader) throws CommandSyntaxException { - reader.expect(' '); - return new ShriekParticleOptions(reader.readInt()); - } + public static final ParticleOptions.Deserializer DESERIALIZER + = new ParticleOptions.Deserializer<>() { + @Override + public ShriekParticleOptions fromCommand( + ParticleType type, StringReader reader + ) throws CommandSyntaxException { + reader.expect(' '); + return new ShriekParticleOptions(reader.readInt()); + } - @Override - public ShriekParticleOptions fromNetwork(ParticleType type, FriendlyByteBuf buf) { - return new ShriekParticleOptions(buf.readVarInt()); - } - }; + @Override + public ShriekParticleOptions fromNetwork( + ParticleType type, FriendlyByteBuf buf + ) { + return new ShriekParticleOptions(buf.readVarInt()); + } + }; @Override public void writeToNetwork(FriendlyByteBuf buf) { @@ -39,7 +47,9 @@ public record ShriekParticleOptions(int delay) implements ParticleOptions { @Override public String writeToString() { - return String.format(Locale.ROOT, "%s %d", Registry.PARTICLE_TYPE.getId(this.getType()), this.delay); + return String.format( + Locale.ROOT, "%s %d", Registry.PARTICLE_TYPE.getId(this.getType()), this.delay + ); } @Override diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/SonicBoomParticle.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/SonicBoomParticle.java index 520a149..ca8857a 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/SonicBoomParticle.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/particle/SonicBoomParticle.java @@ -8,16 +8,28 @@ import net.minecraft.client.particle.SpriteSet; import net.minecraft.core.particles.SimpleParticleType; public class SonicBoomParticle extends HugeExplosionParticle { - public SonicBoomParticle(ClientLevel level, double x, double y, double z, double speed, SpriteSet sprites) { + public SonicBoomParticle( + ClientLevel level, double x, double y, double z, double speed, SpriteSet sprites + ) { super(level, x, y, z, speed, sprites); this.lifetime = 16; this.quadSize = 1.5F; this.setSpriteFromAge(sprites); } - public record Provider(SpriteSet sprites) implements ParticleProvider { + public record Provider(SpriteSet sprites) + implements ParticleProvider { @Override - public Particle createParticle(SimpleParticleType particle, ClientLevel level, double x, double y, double z, double xMotion, double yMotion, double zMotion) { + public Particle createParticle( + SimpleParticleType particle, + ClientLevel level, + double x, + double y, + double z, + double xMotion, + double yMotion, + double zMotion + ) { return new SonicBoomParticle(level, x, y, z, xMotion, this.sprites); } } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/registry/WBCriteriaTriggers.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/registry/WBCriteriaTriggers.java index 1913983..e9e3b83 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/registry/WBCriteriaTriggers.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/registry/WBCriteriaTriggers.java @@ -11,9 +11,16 @@ import net.minecraft.resources.ResourceLocation; //<> public class WBCriteriaTriggers { - public static final KilledTrigger KILL_MOB_NEAR_SCULK_CATALYST = create(new KilledTrigger(new ResourceLocation("minecraft", "kill_mob_near_sculk_catalyst"))); -// public static final ItemUsedOnBlockTrigger ALLAY_DROP_ITEM_ON_BLOCK = create(new ItemUsedOnBlockTrigger(new ResourceLocation(WildBackport.MOD_ID, "kill_mob_near_sculk_catalyst"))); - public static final LocationTrigger AVOID_VIBRATION = create(new LocationTrigger(new ResourceLocation("minecraft", "avoid_vibration"))); + public static final KilledTrigger KILL_MOB_NEAR_SCULK_CATALYST + = create(new KilledTrigger( + new ResourceLocation("minecraft", "kill_mob_near_sculk_catalyst") + )); + // public static final ItemUsedOnBlockTrigger ALLAY_DROP_ITEM_ON_BLOCK = create(new + // ItemUsedOnBlockTrigger(new ResourceLocation(WildBackport.MOD_ID, + // "kill_mob_near_sculk_catalyst"))); + public static final LocationTrigger AVOID_VIBRATION + = create(new LocationTrigger(new ResourceLocation("minecraft", "avoid_vibration")) + ); public static > T create(T type) { return CriteriaTriggersAccessor.callRegister(type); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/registry/WBParticleTypes.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/registry/WBParticleTypes.java index 0af7254..c8f0fc5 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/registry/WBParticleTypes.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/registry/WBParticleTypes.java @@ -1,5 +1,8 @@ package com.cursedcauldron.wildbackport.client.registry; +import java.util.function.Function; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.client.particle.SculkChargeParticleOptions; import com.cursedcauldron.wildbackport.client.particle.ShriekParticleOptions; @@ -11,29 +14,54 @@ import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleType; import net.minecraft.core.particles.SimpleParticleType; -import java.util.function.Function; -import java.util.function.Supplier; - //<> public class WBParticleTypes { - public static final CoreRegistry> PARTICLES = CoreRegistry.create(Registry.PARTICLE_TYPE, "minecraft"); + public static final CoreRegistry> PARTICLES + = CoreRegistry.create(Registry.PARTICLE_TYPE, "minecraft"); - public static final Supplier SCULK_SOUL = create("sculk_soul", false); - public static final Supplier> SCULK_CHARGE = create("sculk_charge", SculkChargeParticleOptions.DESERIALIZER, type -> SculkChargeParticleOptions.CODEC, true); - public static final Supplier SCULK_CHARGE_POP = create("sculk_charge_pop", true); - public static final Supplier> SHRIEK = create("shriek", ShriekParticleOptions.DESERIALIZER, type -> ShriekParticleOptions.CODEC, true); - public static final Supplier SONIC_BOOM = create("sonic_boom", true); + public static final Supplier SCULK_SOUL + = create("sculk_soul", false); + public static final Supplier> SCULK_CHARGE + = create( + "sculk_charge", + SculkChargeParticleOptions.DESERIALIZER, + type + -> SculkChargeParticleOptions.CODEC, + true + ); + public static final Supplier SCULK_CHARGE_POP + = create("sculk_charge_pop", true); + public static final Supplier> SHRIEK = create( + "shriek", + ShriekParticleOptions.DESERIALIZER, + type + -> ShriekParticleOptions.CODEC, + true + ); + public static final Supplier SONIC_BOOM + = create("sonic_boom", true); private static Supplier create(String key, boolean alwaysShow) { - return PARTICLES.register(key, () -> SimpleParticleTypeAccessor.createSimpleParticleType(alwaysShow)); + return PARTICLES.register( + key, () -> SimpleParticleTypeAccessor.createSimpleParticleType(alwaysShow) + ); } - private static Supplier> create(String key, ParticleOptions.Deserializer deserializer, Function, Codec> function, boolean alwaysShow) { - return PARTICLES.register(key, () -> new ParticleType<>(alwaysShow, deserializer) { - @Override public Codec codec() { - return function.apply(this); + private static Supplier> create( + String key, + ParticleOptions.Deserializer deserializer, + Function, Codec> function, + boolean alwaysShow + ) { + return PARTICLES.register( + key, + () -> new ParticleType<>(alwaysShow, deserializer) { + @Override + public Codec codec() { + return function.apply(this); + } } - }); + ); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/registry/WBSoundEvents.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/registry/WBSoundEvents.java index 3a7ede8..59ee270 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/registry/WBSoundEvents.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/registry/WBSoundEvents.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.client.registry; +import java.util.stream.IntStream; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.core.api.CoreRegistry; import com.google.common.collect.ImmutableList; @@ -7,128 +9,181 @@ import net.minecraft.core.Registry; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; -import java.util.stream.IntStream; - //<> public class WBSoundEvents { - public static final CoreRegistry SOUNDS = CoreRegistry.create(Registry.SOUND_EVENT, "minecraft"); + public static final CoreRegistry SOUNDS + = CoreRegistry.create(Registry.SOUND_EVENT, "minecraft"); // Blocks - public static final SoundEvent BLOCK_SCULK_VEIN_BREAK = create("block.sculk_vein.break"); - public static final SoundEvent BLOCK_SCULK_VEIN_FALL = create("block.sculk_vein.fall"); - public static final SoundEvent BLOCK_SCULK_VEIN_HIT = create("block.sculk_vein.hit"); - public static final SoundEvent BLOCK_SCULK_VEIN_PLACE = create("block.sculk_vein.place"); - public static final SoundEvent BLOCK_SCULK_VEIN_STEP = create("block.sculk_vein.step"); - public static final SoundEvent BLOCK_SCULK_CATALYST_BLOOM = create("block.sculk_catalyst.bloom"); - public static final SoundEvent BLOCK_SCULK_CATALYST_BREAK = create("block.sculk_catalyst.break"); - public static final SoundEvent BLOCK_SCULK_CATALYST_FALL = create("block.sculk_catalyst.fall"); - public static final SoundEvent BLOCK_SCULK_CATALYST_HIT = create("block.sculk_catalyst.hit"); - public static final SoundEvent BLOCK_SCULK_CATALYST_PLACE = create("block.sculk_catalyst.place"); - public static final SoundEvent BLOCK_SCULK_CATALYST_STEP = create("block.sculk_catalyst.step"); - public static final SoundEvent BLOCK_SCULK_SPREAD = create("block.sculk.spread"); - public static final SoundEvent BLOCK_SCULK_CHARGE = create("block.sculk.charge"); - public static final SoundEvent BLOCK_SCULK_BREAK = create("block.sculk.break"); - public static final SoundEvent BLOCK_SCULK_FALL = create("block.sculk.fall"); - public static final SoundEvent BLOCK_SCULK_HIT = create("block.sculk.hit"); - public static final SoundEvent BLOCK_SCULK_PLACE = create("block.sculk.place"); - public static final SoundEvent BLOCK_SCULK_STEP = create("block.sculk.step"); - public static final SoundEvent BLOCK_SCULK_SHRIEKER_BREAK = create("block.sculk_shrieker.break"); - public static final SoundEvent BLOCK_SCULK_SHRIEKER_FALL = create("block.sculk_shrieker.fall"); - public static final SoundEvent BLOCK_SCULK_SHRIEKER_HIT = create("block.sculk_shrieker.hit"); - public static final SoundEvent BLOCK_SCULK_SHRIEKER_PLACE = create("block.sculk_shrieker.place"); - public static final SoundEvent BLOCK_SCULK_SHRIEKER_STEP = create("block.sculk_shrieker.step"); - public static final SoundEvent BLOCK_SCULK_SHRIEKER_SHRIEK = create("block.sculk_shrieker.shriek"); - public static final SoundEvent BLOCK_FROGLIGHT_BREAK = create("block.froglight.break"); - public static final SoundEvent BLOCK_FROGLIGHT_FALL = create("block.froglight.fall"); - public static final SoundEvent BLOCK_FROGLIGHT_HIT = create("block.froglight.hit"); - public static final SoundEvent BLOCK_FROGLIGHT_PLACE = create("block.froglight.place"); - public static final SoundEvent BLOCK_FROGLIGHT_STEP = create("block.froglight.step"); - public static final SoundEvent BLOCK_FROGSPAWN_BREAK = create("block.frogspawn.break"); - public static final SoundEvent BLOCK_FROGSPAWN_FALL = create("block.frogspawn.fall"); - public static final SoundEvent BLOCK_FROGSPAWN_HATCH = create("block.frogspawn.hatch"); - public static final SoundEvent BLOCK_FROGSPAWN_HIT = create("block.frogspawn.hit"); - public static final SoundEvent BLOCK_FROGSPAWN_PLACE = create("block.frogspawn.place"); - public static final SoundEvent BLOCK_FROGSPAWN_STEP = create("block.frogspawn.step"); - public static final SoundEvent BLOCK_MANGROVE_ROOTS_BREAK = create("block.mangrove_roots.break"); - public static final SoundEvent BLOCK_MANGROVE_ROOTS_FALL = create("block.mangrove_roots.fall"); - public static final SoundEvent BLOCK_MANGROVE_ROOTS_HIT = create("block.mangrove_roots.hit"); - public static final SoundEvent BLOCK_MANGROVE_ROOTS_PLACE = create("block.mangrove_roots.place"); - public static final SoundEvent BLOCK_MANGROVE_ROOTS_STEP = create("block.mangrove_roots.step"); - public static final SoundEvent BLOCK_MUD_BREAK = create("block.mud.break"); - public static final SoundEvent BLOCK_MUD_FALL = create("block.mud.fall"); - public static final SoundEvent BLOCK_MUD_HIT = create("block.mud.hit"); - public static final SoundEvent BLOCK_MUD_PLACE = create("block.mud.place"); - public static final SoundEvent BLOCK_MUD_STEP = create("block.mud.step"); - public static final SoundEvent BLOCK_MUD_BRICKS_BREAK = create("block.mud_bricks.break"); - public static final SoundEvent BLOCK_MUD_BRICKS_FALL = create("block.mud_bricks.fall"); - public static final SoundEvent BLOCK_MUD_BRICKS_HIT = create("block.mud_bricks.hit"); - public static final SoundEvent BLOCK_MUD_BRICKS_PLACE = create("block.mud_bricks.place"); - public static final SoundEvent BLOCK_MUD_BRICKS_STEP = create("block.mud_bricks.step"); - public static final SoundEvent BLOCK_MUDDY_MANGROVE_ROOTS_BREAK = create("block.muddy_mangrove_roots.break"); - public static final SoundEvent BLOCK_MUDDY_MANGROVE_ROOTS_FALL = create("block.muddy_mangrove_roots.fall"); - public static final SoundEvent BLOCK_MUDDY_MANGROVE_ROOTS_HIT = create("block.muddy_mangrove_roots.hit"); - public static final SoundEvent BLOCK_MUDDY_MANGROVE_ROOTS_PLACE = create("block.muddy_mangrove_roots.place"); - public static final SoundEvent BLOCK_MUDDY_MANGROVE_ROOTS_STEP = create("block.muddy_mangrove_roots.step"); - public static final SoundEvent BLOCK_PACKED_MUD_BREAK = create("block.packed_mud.break"); - public static final SoundEvent BLOCK_PACKED_MUD_FALL = create("block.packed_mud.fall"); - public static final SoundEvent BLOCK_PACKED_MUD_HIT = create("block.packed_mud.hit"); - public static final SoundEvent BLOCK_PACKED_MUD_PLACE = create("block.packed_mud.place"); - public static final SoundEvent BLOCK_PACKED_MUD_STEP = create("block.packed_mud.step"); + public static final SoundEvent BLOCK_SCULK_VEIN_BREAK + = create("block.sculk_vein.break"); + public static final SoundEvent BLOCK_SCULK_VEIN_FALL + = create("block.sculk_vein.fall"); + public static final SoundEvent BLOCK_SCULK_VEIN_HIT = create("block.sculk_vein.hit"); + public static final SoundEvent BLOCK_SCULK_VEIN_PLACE + = create("block.sculk_vein.place"); + public static final SoundEvent BLOCK_SCULK_VEIN_STEP + = create("block.sculk_vein.step"); + public static final SoundEvent BLOCK_SCULK_CATALYST_BLOOM + = create("block.sculk_catalyst.bloom"); + public static final SoundEvent BLOCK_SCULK_CATALYST_BREAK + = create("block.sculk_catalyst.break"); + public static final SoundEvent BLOCK_SCULK_CATALYST_FALL + = create("block.sculk_catalyst.fall"); + public static final SoundEvent BLOCK_SCULK_CATALYST_HIT + = create("block.sculk_catalyst.hit"); + public static final SoundEvent BLOCK_SCULK_CATALYST_PLACE + = create("block.sculk_catalyst.place"); + public static final SoundEvent BLOCK_SCULK_CATALYST_STEP + = create("block.sculk_catalyst.step"); + public static final SoundEvent BLOCK_SCULK_SPREAD = create("block.sculk.spread"); + public static final SoundEvent BLOCK_SCULK_CHARGE = create("block.sculk.charge"); + public static final SoundEvent BLOCK_SCULK_BREAK = create("block.sculk.break"); + public static final SoundEvent BLOCK_SCULK_FALL = create("block.sculk.fall"); + public static final SoundEvent BLOCK_SCULK_HIT = create("block.sculk.hit"); + public static final SoundEvent BLOCK_SCULK_PLACE = create("block.sculk.place"); + public static final SoundEvent BLOCK_SCULK_STEP = create("block.sculk.step"); + public static final SoundEvent BLOCK_SCULK_SHRIEKER_BREAK + = create("block.sculk_shrieker.break"); + public static final SoundEvent BLOCK_SCULK_SHRIEKER_FALL + = create("block.sculk_shrieker.fall"); + public static final SoundEvent BLOCK_SCULK_SHRIEKER_HIT + = create("block.sculk_shrieker.hit"); + public static final SoundEvent BLOCK_SCULK_SHRIEKER_PLACE + = create("block.sculk_shrieker.place"); + public static final SoundEvent BLOCK_SCULK_SHRIEKER_STEP + = create("block.sculk_shrieker.step"); + public static final SoundEvent BLOCK_SCULK_SHRIEKER_SHRIEK + = create("block.sculk_shrieker.shriek"); + public static final SoundEvent BLOCK_FROGLIGHT_BREAK + = create("block.froglight.break"); + public static final SoundEvent BLOCK_FROGLIGHT_FALL = create("block.froglight.fall"); + public static final SoundEvent BLOCK_FROGLIGHT_HIT = create("block.froglight.hit"); + public static final SoundEvent BLOCK_FROGLIGHT_PLACE + = create("block.froglight.place"); + public static final SoundEvent BLOCK_FROGLIGHT_STEP = create("block.froglight.step"); + public static final SoundEvent BLOCK_FROGSPAWN_BREAK + = create("block.frogspawn.break"); + public static final SoundEvent BLOCK_FROGSPAWN_FALL = create("block.frogspawn.fall"); + public static final SoundEvent BLOCK_FROGSPAWN_HATCH + = create("block.frogspawn.hatch"); + public static final SoundEvent BLOCK_FROGSPAWN_HIT = create("block.frogspawn.hit"); + public static final SoundEvent BLOCK_FROGSPAWN_PLACE + = create("block.frogspawn.place"); + public static final SoundEvent BLOCK_FROGSPAWN_STEP = create("block.frogspawn.step"); + public static final SoundEvent BLOCK_MANGROVE_ROOTS_BREAK + = create("block.mangrove_roots.break"); + public static final SoundEvent BLOCK_MANGROVE_ROOTS_FALL + = create("block.mangrove_roots.fall"); + public static final SoundEvent BLOCK_MANGROVE_ROOTS_HIT + = create("block.mangrove_roots.hit"); + public static final SoundEvent BLOCK_MANGROVE_ROOTS_PLACE + = create("block.mangrove_roots.place"); + public static final SoundEvent BLOCK_MANGROVE_ROOTS_STEP + = create("block.mangrove_roots.step"); + public static final SoundEvent BLOCK_MUD_BREAK = create("block.mud.break"); + public static final SoundEvent BLOCK_MUD_FALL = create("block.mud.fall"); + public static final SoundEvent BLOCK_MUD_HIT = create("block.mud.hit"); + public static final SoundEvent BLOCK_MUD_PLACE = create("block.mud.place"); + public static final SoundEvent BLOCK_MUD_STEP = create("block.mud.step"); + public static final SoundEvent BLOCK_MUD_BRICKS_BREAK + = create("block.mud_bricks.break"); + public static final SoundEvent BLOCK_MUD_BRICKS_FALL + = create("block.mud_bricks.fall"); + public static final SoundEvent BLOCK_MUD_BRICKS_HIT = create("block.mud_bricks.hit"); + public static final SoundEvent BLOCK_MUD_BRICKS_PLACE + = create("block.mud_bricks.place"); + public static final SoundEvent BLOCK_MUD_BRICKS_STEP + = create("block.mud_bricks.step"); + public static final SoundEvent BLOCK_MUDDY_MANGROVE_ROOTS_BREAK + = create("block.muddy_mangrove_roots.break"); + public static final SoundEvent BLOCK_MUDDY_MANGROVE_ROOTS_FALL + = create("block.muddy_mangrove_roots.fall"); + public static final SoundEvent BLOCK_MUDDY_MANGROVE_ROOTS_HIT + = create("block.muddy_mangrove_roots.hit"); + public static final SoundEvent BLOCK_MUDDY_MANGROVE_ROOTS_PLACE + = create("block.muddy_mangrove_roots.place"); + public static final SoundEvent BLOCK_MUDDY_MANGROVE_ROOTS_STEP + = create("block.muddy_mangrove_roots.step"); + public static final SoundEvent BLOCK_PACKED_MUD_BREAK + = create("block.packed_mud.break"); + public static final SoundEvent BLOCK_PACKED_MUD_FALL + = create("block.packed_mud.fall"); + public static final SoundEvent BLOCK_PACKED_MUD_HIT = create("block.packed_mud.hit"); + public static final SoundEvent BLOCK_PACKED_MUD_PLACE + = create("block.packed_mud.place"); + public static final SoundEvent BLOCK_PACKED_MUD_STEP + = create("block.packed_mud.step"); // Items - public static final SoundEvent BUCKED_EMPTY_TADPOLE = create("item.bucket.empty_tadpole"); - public static final SoundEvent BUCKED_FILL_TADPOLE = create("item.bucket.fill_tadpole"); - public static final ImmutableList GOAT_HORN_SOUNDS = IntStream.range(0, 8).mapToObj(value -> { - return create("item.goat_horn.sound." + value); - }).collect(ImmutableList.toImmutableList()); + public static final SoundEvent BUCKED_EMPTY_TADPOLE + = create("item.bucket.empty_tadpole"); + public static final SoundEvent BUCKED_FILL_TADPOLE + = create("item.bucket.fill_tadpole"); + public static final ImmutableList GOAT_HORN_SOUNDS + = IntStream.range(0, 8) + .mapToObj(value -> { return create("item.goat_horn.sound." + value); }) + .collect(ImmutableList.toImmutableList()); // Entities - public static final SoundEvent ALLAY_AMBIENT_WITH_ITEM = create("entity.allay.ambient_with_item"); - public static final SoundEvent ALLAY_AMBIENT_WITHOUT_ITEM = create("entity.allay.ambient_without_item"); - public static final SoundEvent ALLAY_DEATH = create("entity.allay.death"); - public static final SoundEvent ALLAY_HURT = create("entity.allay.hurt"); - public static final SoundEvent ALLAY_ITEM_GIVEN = create("entity.allay.item_given"); - public static final SoundEvent ALLAY_ITEM_TAKEN = create("entity.allay.item_taken"); - public static final SoundEvent ALLAY_ITEM_THROW = create("entity.allay.item_thrown"); - public static final SoundEvent FROG_AMBIENT = create("entity.frog.ambient"); - public static final SoundEvent FROG_DEATH = create("entity.frog.death"); - public static final SoundEvent FROG_EAT = create("entity.frog.eat"); - public static final SoundEvent FROG_HURT = create("entity.frog.hurt"); - public static final SoundEvent FROG_LAY_SPAWN = create("entity.frog.lay_spawn"); - public static final SoundEvent FROG_LONG_JUMP = create("entity.frog.long_jump"); - public static final SoundEvent FROG_STEP = create("entity.frog.step"); - public static final SoundEvent FROG_TONGUE = create("entity.frog.tongue"); -// public static final SoundEvent PARROT_IMITATE_WARDEN = create("entity.parrot.imitate_warden"); - public static final SoundEvent TADPOLE_DEATH = create("entity.tadpole.death"); - public static final SoundEvent TADPOLE_FLOP = create("entity.tadpole.flop"); - public static final SoundEvent TADPOLE_GROW_UP = create("entity.tadpole.grow_up"); - public static final SoundEvent TADPOLE_HURT = create("entity.tadpole.hurt"); - public static final SoundEvent WARDEN_AMBIENT = create("entity.warden.ambient"); - public static final SoundEvent WARDEN_LISTENING = create("entity.warden.listening"); - public static final SoundEvent WARDEN_LISTENING_ANGRY = create("entity.warden.listening_angry"); - public static final SoundEvent WARDEN_ANGRY = create("entity.warden.angry"); - public static final SoundEvent WARDEN_HURT = create("entity.warden.hurt"); - public static final SoundEvent WARDEN_DEATH = create("entity.warden.death"); - public static final SoundEvent WARDEN_STEP = create("entity.warden.step"); - public static final SoundEvent WARDEN_TENDRIL_CLICKS = create("entity.warden.tendril_clicks"); - public static final SoundEvent WARDEN_HEARTBEAT = create("entity.warden.heartbeat"); - public static final SoundEvent WARDEN_AGITATED = create("entity.warden.agitated"); - public static final SoundEvent WARDEN_ATTACK_IMPACT = create("entity.warden.attack_impact"); - public static final SoundEvent WARDEN_ROAR = create("entity.warden.roar"); - public static final SoundEvent WARDEN_SNIFF = create("entity.warden.sniff"); - public static final SoundEvent WARDEN_EMERGE = create("entity.warden.emerge"); - public static final SoundEvent WARDEN_DIG = create("entity.warden.dig"); - public static final SoundEvent WARDEN_NEARBY_CLOSEST = create("entity.warden.nearby_closest"); - public static final SoundEvent WARDEN_NEARBY_CLOSER = create("entity.warden.nearby_closer"); - public static final SoundEvent WARDEN_NEARBY_CLOSE = create("entity.warden.nearby_close"); - public static final SoundEvent WARDEN_SONIC_BOOM = create("entity.warden.sonic_boom"); - public static final SoundEvent WARDEN_SONIC_CHARGE = create("entity.warden.sonic_charge"); + public static final SoundEvent ALLAY_AMBIENT_WITH_ITEM + = create("entity.allay.ambient_with_item"); + public static final SoundEvent ALLAY_AMBIENT_WITHOUT_ITEM + = create("entity.allay.ambient_without_item"); + public static final SoundEvent ALLAY_DEATH = create("entity.allay.death"); + public static final SoundEvent ALLAY_HURT = create("entity.allay.hurt"); + public static final SoundEvent ALLAY_ITEM_GIVEN = create("entity.allay.item_given"); + public static final SoundEvent ALLAY_ITEM_TAKEN = create("entity.allay.item_taken"); + public static final SoundEvent ALLAY_ITEM_THROW = create("entity.allay.item_thrown"); + public static final SoundEvent FROG_AMBIENT = create("entity.frog.ambient"); + public static final SoundEvent FROG_DEATH = create("entity.frog.death"); + public static final SoundEvent FROG_EAT = create("entity.frog.eat"); + public static final SoundEvent FROG_HURT = create("entity.frog.hurt"); + public static final SoundEvent FROG_LAY_SPAWN = create("entity.frog.lay_spawn"); + public static final SoundEvent FROG_LONG_JUMP = create("entity.frog.long_jump"); + public static final SoundEvent FROG_STEP = create("entity.frog.step"); + public static final SoundEvent FROG_TONGUE = create("entity.frog.tongue"); + // public static final SoundEvent PARROT_IMITATE_WARDEN = + // create("entity.parrot.imitate_warden"); + public static final SoundEvent TADPOLE_DEATH = create("entity.tadpole.death"); + public static final SoundEvent TADPOLE_FLOP = create("entity.tadpole.flop"); + public static final SoundEvent TADPOLE_GROW_UP = create("entity.tadpole.grow_up"); + public static final SoundEvent TADPOLE_HURT = create("entity.tadpole.hurt"); + public static final SoundEvent WARDEN_AMBIENT = create("entity.warden.ambient"); + public static final SoundEvent WARDEN_LISTENING = create("entity.warden.listening"); + public static final SoundEvent WARDEN_LISTENING_ANGRY + = create("entity.warden.listening_angry"); + public static final SoundEvent WARDEN_ANGRY = create("entity.warden.angry"); + public static final SoundEvent WARDEN_HURT = create("entity.warden.hurt"); + public static final SoundEvent WARDEN_DEATH = create("entity.warden.death"); + public static final SoundEvent WARDEN_STEP = create("entity.warden.step"); + public static final SoundEvent WARDEN_TENDRIL_CLICKS + = create("entity.warden.tendril_clicks"); + public static final SoundEvent WARDEN_HEARTBEAT = create("entity.warden.heartbeat"); + public static final SoundEvent WARDEN_AGITATED = create("entity.warden.agitated"); + public static final SoundEvent WARDEN_ATTACK_IMPACT + = create("entity.warden.attack_impact"); + public static final SoundEvent WARDEN_ROAR = create("entity.warden.roar"); + public static final SoundEvent WARDEN_SNIFF = create("entity.warden.sniff"); + public static final SoundEvent WARDEN_EMERGE = create("entity.warden.emerge"); + public static final SoundEvent WARDEN_DIG = create("entity.warden.dig"); + public static final SoundEvent WARDEN_NEARBY_CLOSEST + = create("entity.warden.nearby_closest"); + public static final SoundEvent WARDEN_NEARBY_CLOSER + = create("entity.warden.nearby_closer"); + public static final SoundEvent WARDEN_NEARBY_CLOSE + = create("entity.warden.nearby_close"); + public static final SoundEvent WARDEN_SONIC_BOOM = create("entity.warden.sonic_boom"); + public static final SoundEvent WARDEN_SONIC_CHARGE + = create("entity.warden.sonic_charge"); // Music - public static final SoundEvent MUSIC_DISC_5 = create("music_disc.5"); -// public static final SoundEvent MUSIC_BIOME_DEEP_DARK = create("music.overworld.deep_dark"); - + public static final SoundEvent MUSIC_DISC_5 = create("music_disc.5"); + + // public static final SoundEvent MUSIC_BIOME_DEEP_DARK = + // create("music.overworld.deep_dark"); + public static SoundEvent create(String key) { SoundEvent sound = new SoundEvent(new ResourceLocation("minecraft", key)); SOUNDS.register(key, () -> sound); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/registry/WBSoundTypes.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/registry/WBSoundTypes.java index 1e11432..fdea183 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/registry/WBSoundTypes.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/registry/WBSoundTypes.java @@ -7,19 +7,93 @@ import net.minecraft.world.level.block.SoundType; //<> public class WBSoundTypes { - public static final SoundType SCULK = create(WBSoundEvents.BLOCK_SCULK_BREAK, WBSoundEvents.BLOCK_SCULK_STEP, WBSoundEvents.BLOCK_SCULK_PLACE, WBSoundEvents.BLOCK_SCULK_HIT, WBSoundEvents.BLOCK_SCULK_FALL); - public static final SoundType SCULK_CATALYST = create(WBSoundEvents.BLOCK_SCULK_CATALYST_BREAK, WBSoundEvents.BLOCK_SCULK_CATALYST_STEP, WBSoundEvents.BLOCK_SCULK_CATALYST_PLACE, WBSoundEvents.BLOCK_SCULK_CATALYST_HIT, WBSoundEvents.BLOCK_SCULK_CATALYST_FALL); - public static final SoundType SCULK_VEIN = create(WBSoundEvents.BLOCK_SCULK_VEIN_BREAK, WBSoundEvents.BLOCK_SCULK_VEIN_STEP, WBSoundEvents.BLOCK_SCULK_VEIN_PLACE, WBSoundEvents.BLOCK_SCULK_VEIN_HIT, WBSoundEvents.BLOCK_SCULK_VEIN_FALL); - public static final SoundType SCULK_SHRIEKER = create(WBSoundEvents.BLOCK_SCULK_SHRIEKER_BREAK, WBSoundEvents.BLOCK_SCULK_SHRIEKER_STEP, WBSoundEvents.BLOCK_SCULK_SHRIEKER_PLACE, WBSoundEvents.BLOCK_SCULK_SHRIEKER_HIT, WBSoundEvents.BLOCK_SCULK_SHRIEKER_FALL); - public static final SoundType FROGLIGHT = create(WBSoundEvents.BLOCK_FROGLIGHT_BREAK, WBSoundEvents.BLOCK_FROGLIGHT_STEP, WBSoundEvents.BLOCK_FROGLIGHT_PLACE, WBSoundEvents.BLOCK_FROGLIGHT_HIT, WBSoundEvents.BLOCK_FROGLIGHT_FALL); - public static final SoundType FROGSPAWN = create(WBSoundEvents.BLOCK_FROGSPAWN_BREAK, WBSoundEvents.BLOCK_FROGSPAWN_STEP, WBSoundEvents.BLOCK_FROGSPAWN_PLACE, WBSoundEvents.BLOCK_FROGSPAWN_HIT, WBSoundEvents.BLOCK_FROGSPAWN_FALL); - public static final SoundType MANGROVE_ROOTS = create(WBSoundEvents.BLOCK_MANGROVE_ROOTS_BREAK, WBSoundEvents.BLOCK_MANGROVE_ROOTS_STEP, WBSoundEvents.BLOCK_MANGROVE_ROOTS_PLACE, WBSoundEvents.BLOCK_MANGROVE_ROOTS_HIT, WBSoundEvents.BLOCK_MANGROVE_ROOTS_FALL); - public static final SoundType MUD = create(WBSoundEvents.BLOCK_MUD_BREAK, WBSoundEvents.BLOCK_MUD_STEP, WBSoundEvents.BLOCK_MUD_PLACE, WBSoundEvents.BLOCK_MUD_HIT, WBSoundEvents.BLOCK_MUD_FALL); - public static final SoundType MUD_BRICKS = create(WBSoundEvents.BLOCK_MUD_BRICKS_BREAK, WBSoundEvents.BLOCK_MUD_BRICKS_STEP, WBSoundEvents.BLOCK_MUD_BRICKS_PLACE, WBSoundEvents.BLOCK_MUD_BRICKS_HIT, WBSoundEvents.BLOCK_MUD_BRICKS_FALL); - public static final SoundType MUDDY_MANGROVE_ROOTS = create(WBSoundEvents.BLOCK_MUDDY_MANGROVE_ROOTS_BREAK, WBSoundEvents.BLOCK_MUDDY_MANGROVE_ROOTS_STEP, WBSoundEvents.BLOCK_MUDDY_MANGROVE_ROOTS_PLACE, WBSoundEvents.BLOCK_MUDDY_MANGROVE_ROOTS_HIT, WBSoundEvents.BLOCK_MUDDY_MANGROVE_ROOTS_FALL); - public static final SoundType PACKED_MUD = create(WBSoundEvents.BLOCK_PACKED_MUD_BREAK, WBSoundEvents.BLOCK_PACKED_MUD_STEP, WBSoundEvents.BLOCK_PACKED_MUD_PLACE, WBSoundEvents.BLOCK_PACKED_MUD_HIT, WBSoundEvents.BLOCK_PACKED_MUD_FALL); + public static final SoundType SCULK = create( + WBSoundEvents.BLOCK_SCULK_BREAK, + WBSoundEvents.BLOCK_SCULK_STEP, + WBSoundEvents.BLOCK_SCULK_PLACE, + WBSoundEvents.BLOCK_SCULK_HIT, + WBSoundEvents.BLOCK_SCULK_FALL + ); + public static final SoundType SCULK_CATALYST = create( + WBSoundEvents.BLOCK_SCULK_CATALYST_BREAK, + WBSoundEvents.BLOCK_SCULK_CATALYST_STEP, + WBSoundEvents.BLOCK_SCULK_CATALYST_PLACE, + WBSoundEvents.BLOCK_SCULK_CATALYST_HIT, + WBSoundEvents.BLOCK_SCULK_CATALYST_FALL + ); + public static final SoundType SCULK_VEIN = create( + WBSoundEvents.BLOCK_SCULK_VEIN_BREAK, + WBSoundEvents.BLOCK_SCULK_VEIN_STEP, + WBSoundEvents.BLOCK_SCULK_VEIN_PLACE, + WBSoundEvents.BLOCK_SCULK_VEIN_HIT, + WBSoundEvents.BLOCK_SCULK_VEIN_FALL + ); + public static final SoundType SCULK_SHRIEKER = create( + WBSoundEvents.BLOCK_SCULK_SHRIEKER_BREAK, + WBSoundEvents.BLOCK_SCULK_SHRIEKER_STEP, + WBSoundEvents.BLOCK_SCULK_SHRIEKER_PLACE, + WBSoundEvents.BLOCK_SCULK_SHRIEKER_HIT, + WBSoundEvents.BLOCK_SCULK_SHRIEKER_FALL + ); + public static final SoundType FROGLIGHT = create( + WBSoundEvents.BLOCK_FROGLIGHT_BREAK, + WBSoundEvents.BLOCK_FROGLIGHT_STEP, + WBSoundEvents.BLOCK_FROGLIGHT_PLACE, + WBSoundEvents.BLOCK_FROGLIGHT_HIT, + WBSoundEvents.BLOCK_FROGLIGHT_FALL + ); + public static final SoundType FROGSPAWN = create( + WBSoundEvents.BLOCK_FROGSPAWN_BREAK, + WBSoundEvents.BLOCK_FROGSPAWN_STEP, + WBSoundEvents.BLOCK_FROGSPAWN_PLACE, + WBSoundEvents.BLOCK_FROGSPAWN_HIT, + WBSoundEvents.BLOCK_FROGSPAWN_FALL + ); + public static final SoundType MANGROVE_ROOTS = create( + WBSoundEvents.BLOCK_MANGROVE_ROOTS_BREAK, + WBSoundEvents.BLOCK_MANGROVE_ROOTS_STEP, + WBSoundEvents.BLOCK_MANGROVE_ROOTS_PLACE, + WBSoundEvents.BLOCK_MANGROVE_ROOTS_HIT, + WBSoundEvents.BLOCK_MANGROVE_ROOTS_FALL + ); + public static final SoundType MUD = create( + WBSoundEvents.BLOCK_MUD_BREAK, + WBSoundEvents.BLOCK_MUD_STEP, + WBSoundEvents.BLOCK_MUD_PLACE, + WBSoundEvents.BLOCK_MUD_HIT, + WBSoundEvents.BLOCK_MUD_FALL + ); + public static final SoundType MUD_BRICKS = create( + WBSoundEvents.BLOCK_MUD_BRICKS_BREAK, + WBSoundEvents.BLOCK_MUD_BRICKS_STEP, + WBSoundEvents.BLOCK_MUD_BRICKS_PLACE, + WBSoundEvents.BLOCK_MUD_BRICKS_HIT, + WBSoundEvents.BLOCK_MUD_BRICKS_FALL + ); + public static final SoundType MUDDY_MANGROVE_ROOTS = create( + WBSoundEvents.BLOCK_MUDDY_MANGROVE_ROOTS_BREAK, + WBSoundEvents.BLOCK_MUDDY_MANGROVE_ROOTS_STEP, + WBSoundEvents.BLOCK_MUDDY_MANGROVE_ROOTS_PLACE, + WBSoundEvents.BLOCK_MUDDY_MANGROVE_ROOTS_HIT, + WBSoundEvents.BLOCK_MUDDY_MANGROVE_ROOTS_FALL + ); + public static final SoundType PACKED_MUD = create( + WBSoundEvents.BLOCK_PACKED_MUD_BREAK, + WBSoundEvents.BLOCK_PACKED_MUD_STEP, + WBSoundEvents.BLOCK_PACKED_MUD_PLACE, + WBSoundEvents.BLOCK_PACKED_MUD_HIT, + WBSoundEvents.BLOCK_PACKED_MUD_FALL + ); - public static SoundType create(SoundEvent breakSnd, SoundEvent stepSnd, SoundEvent placeSnd, SoundEvent hitSnd, SoundEvent fallSnd) { - return new CoreSoundType(() -> breakSnd, () -> stepSnd, () -> placeSnd, () -> hitSnd, () -> fallSnd); - } + public static SoundType create( + SoundEvent breakSnd, + SoundEvent stepSnd, + SoundEvent placeSnd, + SoundEvent hitSnd, + SoundEvent fallSnd + ) { + return new CoreSoundType( + () -> breakSnd, () -> stepSnd, () -> placeSnd, () -> hitSnd, () -> fallSnd + ); + } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/render/AllayRenderer.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/render/AllayRenderer.java index cee29b0..9924203 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/render/AllayRenderer.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/render/AllayRenderer.java @@ -11,8 +11,10 @@ import net.minecraft.core.BlockPos; import net.minecraft.resources.ResourceLocation; public class AllayRenderer extends MobRenderer { - public static final ModelLayerLocation MODEL_LAYER = new ModelLayerLocation(new ResourceLocation("minecraft", "allay"), "main"); - private static final ResourceLocation TEXTURE = new ResourceLocation("minecraft", "textures/entity/allay/allay.png"); + public static final ModelLayerLocation MODEL_LAYER + = new ModelLayerLocation(new ResourceLocation("minecraft", "allay"), "main"); + private static final ResourceLocation TEXTURE + = new ResourceLocation("minecraft", "textures/entity/allay/allay.png"); public AllayRenderer(EntityRendererProvider.Context context) { super(context, new AllayModel(context.bakeLayer(MODEL_LAYER)), 0.4F); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/render/ChestBoatRenderer.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/render/ChestBoatRenderer.java index 345ae84..3c7d403 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/render/ChestBoatRenderer.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/render/ChestBoatRenderer.java @@ -1,5 +1,8 @@ package com.cursedcauldron.wildbackport.client.render; +import java.util.Map; +import java.util.stream.Stream; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.client.render.model.ChestBoatModel; import com.cursedcauldron.wildbackport.common.entities.MangroveBoat; @@ -21,9 +24,6 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.world.entity.vehicle.Boat; -import java.util.Map; -import java.util.stream.Stream; - //<> public class ChestBoatRenderer extends EntityRenderer { @@ -32,47 +32,82 @@ public class ChestBoatRenderer extends EntityRenderer { public ChestBoatRenderer(EntityRendererProvider.Context context, boolean chest) { super(context); this.shadowRadius = 0.8F; - this.boatResources = Stream.of(Boat.Type.values()).collect(ImmutableMap.toImmutableMap(type -> type, type -> Pair.of(getTexture(type, chest), this.createModel(context, type, chest)))); + this.boatResources + = Stream.of(Boat.Type.values()) + .collect(ImmutableMap.toImmutableMap( + type + -> type, + type + -> Pair.of( + getTexture(type, chest), this.createModel(context, type, chest) + ) + )); } - private ChestBoatModel createModel(EntityRendererProvider.Context context, Boat.Type type, boolean chest) { - ModelLayerLocation layer = chest ? ChestBoatModel.createChestBoat(type) : ModelLayers.createBoatModelName(type); + private ChestBoatModel + createModel(EntityRendererProvider.Context context, Boat.Type type, boolean chest) { + ModelLayerLocation layer = chest ? ChestBoatModel.createChestBoat(type) + : ModelLayers.createBoatModelName(type); return new ChestBoatModel(context.bakeLayer(layer), chest); } private static ResourceLocation getTexture(Boat.Type type, boolean chested) { if (chested) { - return new ResourceLocation("minecraft", "textures/entity/chest_boat/" + type.getName() + ".png"); + return new ResourceLocation( + "minecraft", "textures/entity/chest_boat/" + type.getName() + ".png" + ); } else { - return new ResourceLocation("minecraft", "textures/entity/boat/" + type.getName() + ".png"); + return new ResourceLocation( + "minecraft", "textures/entity/boat/" + type.getName() + ".png" + ); } } @Override - public void render(MangroveBoat boat, float yaw, float angle, PoseStack stack, MultiBufferSource buffer, int light) { + public void render( + MangroveBoat boat, + float yaw, + float angle, + PoseStack stack, + MultiBufferSource buffer, + int light + ) { stack.pushPose(); stack.translate(0.0D, 0.375D, 0.0D); stack.mulPose(Vector3f.YP.rotationDegrees(180.0F - yaw)); - float hurtTilt = (float)boat.getHurtTime() - angle; + float hurtTilt = (float) boat.getHurtTime() - angle; float damageTilt = boat.getDamage() - angle; - if (damageTilt < 0.0F) damageTilt = 0.0F; + if (damageTilt < 0.0F) + damageTilt = 0.0F; - if (hurtTilt > 0.0F) stack.mulPose(Vector3f.XP.rotationDegrees(Mth.sin(hurtTilt) * hurtTilt * damageTilt / 10.0F * (float)boat.getHurtDir())); + if (hurtTilt > 0.0F) + stack.mulPose(Vector3f.XP.rotationDegrees( + Mth.sin(hurtTilt) * hurtTilt * damageTilt / 10.0F + * (float) boat.getHurtDir() + )); float bubbleTilt = boat.getBubbleAngle(angle); - if (!Mth.equal(bubbleTilt, 0.0F)) stack.mulPose(new Quaternion(new Vector3f(1.0F, 0.0F, 1.0F), boat.getBubbleAngle(angle), true)); + if (!Mth.equal(bubbleTilt, 0.0F)) + stack.mulPose(new Quaternion( + new Vector3f(1.0F, 0.0F, 1.0F), boat.getBubbleAngle(angle), true + )); - Pair resource = this.boatResources.get(boat.getBoatType()); + Pair resource + = this.boatResources.get(boat.getBoatType()); ResourceLocation location = resource.first; ChestBoatModel model = resource.second; stack.scale(-1.0F, -1.0F, 1.0F); stack.mulPose(Vector3f.YP.rotationDegrees(90.0F)); model.setupAnim(boat, angle, 0.0F, -0.1F, 0.0F, 0.0F); VertexConsumer render = buffer.getBuffer(model.renderType(location)); - model.renderToBuffer(stack, render, light, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F); + model.renderToBuffer( + stack, render, light, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F + ); if (!boat.isUnderWater()) { VertexConsumer waterRender = buffer.getBuffer(RenderType.waterMask()); - model.waterPatch().render(stack, waterRender, light, OverlayTexture.NO_OVERLAY); + model.waterPatch().render( + stack, waterRender, light, OverlayTexture.NO_OVERLAY + ); } stack.popPose(); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/render/FrogRenderer.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/render/FrogRenderer.java index 783a438..35994fe 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/render/FrogRenderer.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/render/FrogRenderer.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.client.render; +import java.util.Map; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.client.render.model.FrogModel; import com.cursedcauldron.wildbackport.common.entities.Frog; @@ -10,16 +12,21 @@ import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.MobRenderer; import net.minecraft.resources.ResourceLocation; -import java.util.Map; - public class FrogRenderer extends MobRenderer> { - public static final ModelLayerLocation MODEL_LAYER = new ModelLayerLocation(new ResourceLocation("frog"), "main"); + public static final ModelLayerLocation MODEL_LAYER + = new ModelLayerLocation(new ResourceLocation("frog"), "main"); - private static final Map TEXTURES = Util.make(Maps.newHashMap(), hashMap -> { - for (Frog.Variant variant : Frog.Variant.values()) { - hashMap.put(variant, new ResourceLocation(String.format("textures/entity/frog/%s_frog.png", variant.getName()))); - } - }); + private static final Map TEXTURES + = Util.make(Maps.newHashMap(), hashMap -> { + for (Frog.Variant variant : Frog.Variant.values()) { + hashMap.put( + variant, + new ResourceLocation(String.format( + "textures/entity/frog/%s_frog.png", variant.getName() + )) + ); + } + }); public FrogRenderer(EntityRendererProvider.Context context) { super(context, new FrogModel<>(context.bakeLayer(MODEL_LAYER)), 0.3f); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/render/TadpoleRenderer.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/render/TadpoleRenderer.java index 796577a..f60a310 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/render/TadpoleRenderer.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/render/TadpoleRenderer.java @@ -9,9 +9,11 @@ import net.minecraft.client.renderer.entity.MobRenderer; import net.minecraft.resources.ResourceLocation; public class TadpoleRenderer extends MobRenderer> { - public static final ModelLayerLocation MODEL_LAYER = new ModelLayerLocation(new ResourceLocation("tadpole"), "main"); + public static final ModelLayerLocation MODEL_LAYER + = new ModelLayerLocation(new ResourceLocation("tadpole"), "main"); - private static final ResourceLocation TEXTURE = new ResourceLocation("textures/entity/tadpole/tadpole.png"); + private static final ResourceLocation TEXTURE + = new ResourceLocation("textures/entity/tadpole/tadpole.png"); public TadpoleRenderer(EntityRendererProvider.Context context) { super(context, new TadpoleModel<>(context.bakeLayer(MODEL_LAYER)), 0.14F); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/render/WardenLayerRenderer.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/render/WardenLayerRenderer.java index 000245c..e4526af 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/render/WardenLayerRenderer.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/render/WardenLayerRenderer.java @@ -1,5 +1,8 @@ package com.cursedcauldron.wildbackport.client.render; +import java.util.List; +import java.util.function.BiFunction; + import com.cursedcauldron.wildbackport.client.render.model.Drawable; import com.cursedcauldron.wildbackport.client.render.model.WardenModel; import com.cursedcauldron.wildbackport.common.entities.Warden; @@ -22,23 +25,48 @@ import net.minecraft.client.renderer.entity.RenderLayerParent; import net.minecraft.client.renderer.entity.layers.RenderLayer; import net.minecraft.resources.ResourceLocation; -import java.util.List; -import java.util.function.BiFunction; - //<> @Environment(EnvType.CLIENT) -public class WardenLayerRenderer> extends RenderLayer { - public static final BiFunction ENTITY_TRANSLUCENT_EMISSIVE = Util.memoize((location, create) -> { - RenderType.CompositeState compositeState = RenderType.CompositeState.builder().setShaderState(RenderStateShardAccessor.getRENDERTYPE_EYES_SHADER()).setTextureState(new RenderStateShard.TextureStateShard(location, false, false)).setTransparencyState(RenderStateShardAccessor.getTRANSLUCENT_TRANSPARENCY()).setCullState(RenderStateShardAccessor.getNO_CULL()).setWriteMaskState(RenderStateShardAccessor.getCOLOR_WRITE()).setOverlayState(RenderStateShardAccessor.getOVERLAY()).createCompositeState(create); - return RenderTypeAccessor.callCreate("entity_translucent_emissive", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, true, compositeState); - }); +public class WardenLayerRenderer> + extends RenderLayer { + public static final BiFunction + ENTITY_TRANSLUCENT_EMISSIVE = Util.memoize((location, create) -> { + RenderType.CompositeState compositeState + = RenderType.CompositeState.builder() + .setShaderState(RenderStateShardAccessor.getRENDERTYPE_EYES_SHADER() + ) + .setTextureState( + new RenderStateShard.TextureStateShard(location, false, false) + ) + .setTransparencyState( + RenderStateShardAccessor.getTRANSLUCENT_TRANSPARENCY() + ) + .setCullState(RenderStateShardAccessor.getNO_CULL()) + .setWriteMaskState(RenderStateShardAccessor.getCOLOR_WRITE()) + .setOverlayState(RenderStateShardAccessor.getOVERLAY()) + .createCompositeState(create); + return RenderTypeAccessor.callCreate( + "entity_translucent_emissive", + DefaultVertexFormat.NEW_ENTITY, + VertexFormat.Mode.QUADS, + 256, + true, + true, + compositeState + ); + }); private final ResourceLocation texture; private final AnimationAngleAdjuster animationAngleAdjuster; private final ModelPartVisibility modelPartVisibility; - public WardenLayerRenderer(RenderLayerParent ctx, ResourceLocation texture, AnimationAngleAdjuster animationAngleAdjuster, ModelPartVisibility modelPartVisibility) { + public WardenLayerRenderer( + RenderLayerParent ctx, + ResourceLocation texture, + AnimationAngleAdjuster animationAngleAdjuster, + ModelPartVisibility modelPartVisibility + ) { super(ctx); this.texture = texture; this.animationAngleAdjuster = animationAngleAdjuster; @@ -46,23 +74,49 @@ public class WardenLayerRenderer> ext } @Override - public void render(PoseStack stack, MultiBufferSource source, int light, T entity, float angle, float distance, float tickDelta, float animationProgress, float yaw, float pitch) { + public void render( + PoseStack stack, + MultiBufferSource source, + int light, + T entity, + float angle, + float distance, + float tickDelta, + float animationProgress, + float yaw, + float pitch + ) { if (!entity.isInvisible()) { this.updateModelPartVisibility(); - VertexConsumer consumer = source.getBuffer(ENTITY_TRANSLUCENT_EMISSIVE.apply(this.texture, true)); - this.getParentModel().renderToBuffer(stack, consumer, light, LivingEntityRenderer.getOverlayCoords(entity, 0.0F), 1.0F, 1.0F, 1.0F, this.animationAngleAdjuster.apply(entity, tickDelta, animationProgress)); + VertexConsumer consumer + = source.getBuffer(ENTITY_TRANSLUCENT_EMISSIVE.apply(this.texture, true)); + this.getParentModel().renderToBuffer( + stack, + consumer, + light, + LivingEntityRenderer.getOverlayCoords(entity, 0.0F), + 1.0F, + 1.0F, + 1.0F, + this.animationAngleAdjuster.apply(entity, tickDelta, animationProgress) + ); this.unhideAllModelParts(); } } private void updateModelPartVisibility() { - List parts = this.modelPartVisibility.getPartsToDraw(this.getParentModel()); - this.getParentModel().root().getAllParts().forEach(part -> Drawable.of(part).setSkipDraw(true)); + List parts + = this.modelPartVisibility.getPartsToDraw(this.getParentModel()); + this.getParentModel().root().getAllParts().forEach( + part -> Drawable.of(part).setSkipDraw(true) + ); parts.forEach(part -> Drawable.of(part).setSkipDraw(false)); } private void unhideAllModelParts() { - this.getParentModel().root().getAllParts().forEach(part -> Drawable.of(part).setSkipDraw(false)); + this.getParentModel().root().getAllParts().forEach( + part -> Drawable.of(part).setSkipDraw(false) + ); } public interface AnimationAngleAdjuster { diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/render/WardenRenderer.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/render/WardenRenderer.java index 5fc6afe..633c4ac 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/render/WardenRenderer.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/render/WardenRenderer.java @@ -15,21 +15,59 @@ import net.minecraft.util.Mth; @Environment(EnvType.CLIENT) public class WardenRenderer extends MobRenderer> { - public static final ModelLayerLocation MODEL_LAYER = new ModelLayerLocation(new ResourceLocation("warden"), "main"); + public static final ModelLayerLocation MODEL_LAYER + = new ModelLayerLocation(new ResourceLocation("warden"), "main"); - private static final ResourceLocation TEXTURE = new ResourceLocation("textures/entity/warden/warden.png"); - private static final ResourceLocation BIOLUMINESCENT_LAYER_TEXTURE = new ResourceLocation("textures/entity/warden/warden_bioluminescent_layer.png"); - private static final ResourceLocation HEART_TEXTURE = new ResourceLocation("textures/entity/warden/warden_heart.png"); - private static final ResourceLocation PULSATING_SPOTS_1_TEXTURE = new ResourceLocation("textures/entity/warden/warden_pulsating_spots_1.png"); - private static final ResourceLocation PULSATING_SPOTS_2_TEXTURE = new ResourceLocation("textures/entity/warden/warden_pulsating_spots_2.png"); + private static final ResourceLocation TEXTURE + = new ResourceLocation("textures/entity/warden/warden.png"); + private static final ResourceLocation BIOLUMINESCENT_LAYER_TEXTURE + = new ResourceLocation("textures/entity/warden/warden_bioluminescent_layer.png"); + private static final ResourceLocation HEART_TEXTURE + = new ResourceLocation("textures/entity/warden/warden_heart.png"); + private static final ResourceLocation PULSATING_SPOTS_1_TEXTURE + = new ResourceLocation("textures/entity/warden/warden_pulsating_spots_1.png"); + private static final ResourceLocation PULSATING_SPOTS_2_TEXTURE + = new ResourceLocation("textures/entity/warden/warden_pulsating_spots_2.png"); public WardenRenderer(EntityRendererProvider.Context ctx) { super(ctx, new WardenModel<>(ctx.bakeLayer(MODEL_LAYER)), 0.9F); - this.addLayer(new WardenLayerRenderer<>(this, BIOLUMINESCENT_LAYER_TEXTURE, (entity, tickDelta, animationProgress) -> 1.0F, WardenModel::getHeadAndLimbs)); - this.addLayer(new WardenLayerRenderer<>(this, PULSATING_SPOTS_1_TEXTURE, (entity, tickDelta, animationProgress) -> Math.max(0.0F, Mth.cos(animationProgress * 0.045F) * 0.25F), WardenModel::getBodyHeadAndLimbs)); - this.addLayer(new WardenLayerRenderer<>(this, PULSATING_SPOTS_2_TEXTURE, (entity, tickDelta, animationProgress) -> Math.max(0.0F, Mth.cos(animationProgress * 0.045F + (float)Math.PI) * 0.25F), WardenModel::getBodyHeadAndLimbs)); - this.addLayer(new WardenLayerRenderer<>(this, TEXTURE, (entity, tickDelta, animationProgress) -> entity.getTendrilPitch(tickDelta), WardenModel::getTendrils)); - this.addLayer(new WardenLayerRenderer<>(this, HEART_TEXTURE, (entity, tickDelta, animationProgress) -> entity.getHeartPitch(tickDelta), WardenModel::getBody)); + this.addLayer(new WardenLayerRenderer<>( + this, + BIOLUMINESCENT_LAYER_TEXTURE, + (entity, tickDelta, animationProgress) + -> 1.0F, + WardenModel::getHeadAndLimbs + )); + this.addLayer(new WardenLayerRenderer<>( + this, + PULSATING_SPOTS_1_TEXTURE, + (entity, tickDelta, animationProgress) + -> Math.max(0.0F, Mth.cos(animationProgress * 0.045F) * 0.25F), + WardenModel::getBodyHeadAndLimbs + )); + this.addLayer(new WardenLayerRenderer<>( + this, + PULSATING_SPOTS_2_TEXTURE, + (entity, tickDelta, animationProgress) + -> Math.max( + 0.0F, Mth.cos(animationProgress * 0.045F + (float) Math.PI) * 0.25F + ), + WardenModel::getBodyHeadAndLimbs + )); + this.addLayer(new WardenLayerRenderer<>( + this, + TEXTURE, + (entity, tickDelta, animationProgress) + -> entity.getTendrilPitch(tickDelta), + WardenModel::getTendrils + )); + this.addLayer(new WardenLayerRenderer<>( + this, + HEART_TEXTURE, + (entity, tickDelta, animationProgress) + -> entity.getHeartPitch(tickDelta), + WardenModel::getBody + )); } @Override diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/render/model/AllayModel.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/render/model/AllayModel.java index 0340f5f..857ea68 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/render/model/AllayModel.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/render/model/AllayModel.java @@ -40,25 +40,72 @@ public class AllayModel extends HierarchicalModel implements ArmedModel { public static LayerDefinition createBodyLayer() { MeshDefinition mesh = new MeshDefinition(); - PartDefinition root = mesh.getRoot().addOrReplaceChild("root", CubeListBuilder.create(), PartPose.offset(0.0F, 23.5F, 0.0F)); - root.addOrReplaceChild("head", CubeListBuilder.create().texOffs(0, 0).addBox(-2.5F, -5.0F, -2.5F, 5.0F, 5.0F, 5.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, -3.99F, 0.0F)); - PartDefinition body = root.addOrReplaceChild("body", CubeListBuilder.create().texOffs(0, 10).addBox(-1.5F, 0.0F, -1.0F, 3.0F, 4.0F, 2.0F, new CubeDeformation(0.0F)).texOffs(0, 16).addBox(-1.5F, 0.0F, -1.0F, 3.0F, 5.0F, 2.0F, new CubeDeformation(-0.2F)), PartPose.offset(0.0F, -4.0F, 0.0F)); - body.addOrReplaceChild("right_arm", CubeListBuilder.create().texOffs(23, 0).addBox(-0.75F, -0.5F, -1.0F, 1.0F, 4.0F, 2.0F, new CubeDeformation(-0.01F)), PartPose.offset(-1.75F, 0.5F, 0.0F)); - body.addOrReplaceChild("left_arm", CubeListBuilder.create().texOffs(23, 6).addBox(-0.25F, -0.5F, -1.0F, 1.0F, 4.0F, 2.0F, new CubeDeformation(-0.01F)), PartPose.offset(1.75F, 0.5F, 0.0F)); - body.addOrReplaceChild("right_wing", CubeListBuilder.create().texOffs(16, 14).addBox(0.0F, 1.0F, 0.0F, 0.0F, 5.0F, 8.0F, new CubeDeformation(0.0F)), PartPose.offset(-0.5F, 0.0F, 0.65F)); - body.addOrReplaceChild("left_wing", CubeListBuilder.create().texOffs(16, 14).addBox(0.0F, 1.0F, 0.0F, 0.0F, 5.0F, 8.0F, new CubeDeformation(0.0F)), PartPose.offset(0.5F, 0.0F, 0.65F)); + PartDefinition root = mesh.getRoot().addOrReplaceChild( + "root", CubeListBuilder.create(), PartPose.offset(0.0F, 23.5F, 0.0F) + ); + root.addOrReplaceChild( + "head", + CubeListBuilder.create().texOffs(0, 0).addBox( + -2.5F, -5.0F, -2.5F, 5.0F, 5.0F, 5.0F, new CubeDeformation(0.0F) + ), + PartPose.offset(0.0F, -3.99F, 0.0F) + ); + PartDefinition body = root.addOrReplaceChild( + "body", + CubeListBuilder.create() + .texOffs(0, 10) + .addBox(-1.5F, 0.0F, -1.0F, 3.0F, 4.0F, 2.0F, new CubeDeformation(0.0F)) + .texOffs(0, 16) + .addBox(-1.5F, 0.0F, -1.0F, 3.0F, 5.0F, 2.0F, new CubeDeformation(-0.2F)), + PartPose.offset(0.0F, -4.0F, 0.0F) + ); + body.addOrReplaceChild( + "right_arm", + CubeListBuilder.create().texOffs(23, 0).addBox( + -0.75F, -0.5F, -1.0F, 1.0F, 4.0F, 2.0F, new CubeDeformation(-0.01F) + ), + PartPose.offset(-1.75F, 0.5F, 0.0F) + ); + body.addOrReplaceChild( + "left_arm", + CubeListBuilder.create().texOffs(23, 6).addBox( + -0.25F, -0.5F, -1.0F, 1.0F, 4.0F, 2.0F, new CubeDeformation(-0.01F) + ), + PartPose.offset(1.75F, 0.5F, 0.0F) + ); + body.addOrReplaceChild( + "right_wing", + CubeListBuilder.create().texOffs(16, 14).addBox( + 0.0F, 1.0F, 0.0F, 0.0F, 5.0F, 8.0F, new CubeDeformation(0.0F) + ), + PartPose.offset(-0.5F, 0.0F, 0.65F) + ); + body.addOrReplaceChild( + "left_wing", + CubeListBuilder.create().texOffs(16, 14).addBox( + 0.0F, 1.0F, 0.0F, 0.0F, 5.0F, 8.0F, new CubeDeformation(0.0F) + ), + PartPose.offset(0.5F, 0.0F, 0.65F) + ); return LayerDefinition.create(mesh, 32, 32); } @Override - public void setupAnim(Allay entity, float angle, float distance, float animationProgress, float yaw, float pitch) { + public void setupAnim( + Allay entity, + float angle, + float distance, + float animationProgress, + float yaw, + float pitch + ) { this.root().getAllParts().forEach(Animated::resetToDefault); - this.head.xRot = pitch * ((float)Math.PI / 180F); - this.head.yRot = yaw * ((float)Math.PI / 180F); - float f = animationProgress * 20.0F * ((float)Math.PI / 180F) + distance; - float f1 = Mth.cos(f) * (float)Math.PI * 0.15F; - float f2 = animationProgress - (float)entity.tickCount; - float f3 = animationProgress * 9.0F * ((float)Math.PI / 180F); + this.head.xRot = pitch * ((float) Math.PI / 180F); + this.head.yRot = yaw * ((float) Math.PI / 180F); + float f = animationProgress * 20.0F * ((float) Math.PI / 180F) + distance; + float f1 = Mth.cos(f) * (float) Math.PI * 0.15F; + float f2 = animationProgress - (float) entity.tickCount; + float f3 = animationProgress * 9.0F * ((float) Math.PI / 180F); float f4 = Math.min(distance / 0.3F, 1.0F); float f5 = 1.0F - f4; float holdingItemAnimation = entity.getHoldingItemAnimationProgress(f2); @@ -68,12 +115,17 @@ public class AllayModel extends HierarchicalModel implements ArmedModel { this.left_wing.yRot = 0.61086524F - f1; float f7 = f4 * 0.6981317F; this.body.xRot = f7; - float f8 = Mth.lerp(holdingItemAnimation, f7, Mth.lerp(f4, (-(float)Math.PI / 3F), (-(float)Math.PI / 4F))); - this.root.y += (float)Math.cos(f3) * 0.25F * f5; + float f8 = Mth.lerp( + holdingItemAnimation, + f7, + Mth.lerp(f4, (-(float) Math.PI / 3F), (-(float) Math.PI / 4F)) + ); + this.root.y += (float) Math.cos(f3) * 0.25F * f5; this.right_arm.xRot = f8; this.left_arm.xRot = f8; float f9 = f5 * (1.0F - holdingItemAnimation); - float f10 = 0.43633232F - Mth.cos(f3 + ((float)Math.PI * 1.5F)) * (float)Math.PI * 0.075F * f9; + float f10 = 0.43633232F + - Mth.cos(f3 + ((float) Math.PI * 1.5F)) * (float) Math.PI * 0.075F * f9; this.left_arm.zRot = -f10; this.right_arm.zRot = f10; this.right_arm.yRot = 0.27925268F * holdingItemAnimation; @@ -81,7 +133,16 @@ public class AllayModel extends HierarchicalModel implements ArmedModel { } @Override - public void renderToBuffer(PoseStack stack, VertexConsumer consumer, int i, int j, float f, float g, float h, float k) { + public void renderToBuffer( + PoseStack stack, + VertexConsumer consumer, + int i, + int j, + float f, + float g, + float h, + float k + ) { this.root.render(stack, consumer, i, j); } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/render/model/ChestBoatModel.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/render/model/ChestBoatModel.java index a1209ab..c0d15e0 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/render/model/ChestBoatModel.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/render/model/ChestBoatModel.java @@ -28,7 +28,15 @@ public class ChestBoatModel extends ListModel { this.rightPaddle = root.getChild("right_paddle"); this.waterPatch = root.getChild("water_patch"); ImmutableList.Builder builder = new ImmutableList.Builder<>(); - builder.add(root.getChild("bottom"), root.getChild("back"), root.getChild("front"), root.getChild("right"), root.getChild("left"), this.leftPaddle, this.rightPaddle); + builder.add( + root.getChild("bottom"), + root.getChild("back"), + root.getChild("front"), + root.getChild("right"), + root.getChild("left"), + this.leftPaddle, + this.rightPaddle + ); if (chest) { builder.add(root.getChild("chest_bottom")); builder.add(root.getChild("chest_lid")); @@ -41,25 +49,100 @@ public class ChestBoatModel extends ListModel { public static LayerDefinition createBodyModel(boolean chested) { MeshDefinition mesh = new MeshDefinition(); PartDefinition part = mesh.getRoot(); - part.addOrReplaceChild("bottom", CubeListBuilder.create().texOffs(0, 0).addBox(-14.0F, -9.0F, -3.0F, 28.0F, 16.0F, 3.0F), PartPose.offsetAndRotation(0.0F, 3.0F, 1.0F, 1.5707964F, 0.0F, 0.0F)); - part.addOrReplaceChild("back", CubeListBuilder.create().texOffs(0, 19).addBox(-13.0F, -7.0F, -1.0F, 18.0F, 6.0F, 2.0F), PartPose.offsetAndRotation(-15.0F, 4.0F, 4.0F, 0.0F, 4.712389F, 0.0F)); - part.addOrReplaceChild("front", CubeListBuilder.create().texOffs(0, 27).addBox(-8.0F, -7.0F, -1.0F, 16.0F, 6.0F, 2.0F), PartPose.offsetAndRotation(15.0F, 4.0F, 0.0F, 0.0F, 1.5707964F, 0.0F)); - part.addOrReplaceChild("right", CubeListBuilder.create().texOffs(0, 35).addBox(-14.0F, -7.0F, -1.0F, 28.0F, 6.0F, 2.0F), PartPose.offsetAndRotation(0.0F, 4.0F, -9.0F, 0.0F, 3.1415927F, 0.0F)); - part.addOrReplaceChild("left", CubeListBuilder.create().texOffs(0, 43).addBox(-14.0F, -7.0F, -1.0F, 28.0F, 6.0F, 2.0F), PartPose.offset(0.0F, 4.0F, 9.0F)); + part.addOrReplaceChild( + "bottom", + CubeListBuilder.create().texOffs(0, 0).addBox( + -14.0F, -9.0F, -3.0F, 28.0F, 16.0F, 3.0F + ), + PartPose.offsetAndRotation(0.0F, 3.0F, 1.0F, 1.5707964F, 0.0F, 0.0F) + ); + part.addOrReplaceChild( + "back", + CubeListBuilder.create().texOffs(0, 19).addBox( + -13.0F, -7.0F, -1.0F, 18.0F, 6.0F, 2.0F + ), + PartPose.offsetAndRotation(-15.0F, 4.0F, 4.0F, 0.0F, 4.712389F, 0.0F) + ); + part.addOrReplaceChild( + "front", + CubeListBuilder.create().texOffs(0, 27).addBox( + -8.0F, -7.0F, -1.0F, 16.0F, 6.0F, 2.0F + ), + PartPose.offsetAndRotation(15.0F, 4.0F, 0.0F, 0.0F, 1.5707964F, 0.0F) + ); + part.addOrReplaceChild( + "right", + CubeListBuilder.create().texOffs(0, 35).addBox( + -14.0F, -7.0F, -1.0F, 28.0F, 6.0F, 2.0F + ), + PartPose.offsetAndRotation(0.0F, 4.0F, -9.0F, 0.0F, 3.1415927F, 0.0F) + ); + part.addOrReplaceChild( + "left", + CubeListBuilder.create().texOffs(0, 43).addBox( + -14.0F, -7.0F, -1.0F, 28.0F, 6.0F, 2.0F + ), + PartPose.offset(0.0F, 4.0F, 9.0F) + ); if (chested) { - part.addOrReplaceChild("chest_bottom", CubeListBuilder.create().texOffs(0, 76).addBox(0.0f, 0.0f, 0.0f, 12.0f, 8.0f, 12.0f), PartPose.offsetAndRotation(-2.0f, -5.0f, -6.0f, 0.0f, -1.5707964f, 0.0f)); - part.addOrReplaceChild("chest_lid", CubeListBuilder.create().texOffs(0, 59).addBox(0.0f, 0.0f, 0.0f, 12.0f, 4.0f, 12.0f), PartPose.offsetAndRotation(-2.0f, -9.0f, -6.0f, 0.0f, -1.5707964f, 0.0f)); - part.addOrReplaceChild("chest_lock", CubeListBuilder.create().texOffs(0, 59).addBox(0.0f, 0.0f, 0.0f, 2.0f, 4.0f, 1.0f), PartPose.offsetAndRotation(-1.0f, -6.0f, -1.0f, 0.0f, -1.5707964f, 0.0f)); + part.addOrReplaceChild( + "chest_bottom", + CubeListBuilder.create().texOffs(0, 76).addBox( + 0.0f, 0.0f, 0.0f, 12.0f, 8.0f, 12.0f + ), + PartPose.offsetAndRotation(-2.0f, -5.0f, -6.0f, 0.0f, -1.5707964f, 0.0f) + ); + part.addOrReplaceChild( + "chest_lid", + CubeListBuilder.create().texOffs(0, 59).addBox( + 0.0f, 0.0f, 0.0f, 12.0f, 4.0f, 12.0f + ), + PartPose.offsetAndRotation(-2.0f, -9.0f, -6.0f, 0.0f, -1.5707964f, 0.0f) + ); + part.addOrReplaceChild( + "chest_lock", + CubeListBuilder.create().texOffs(0, 59).addBox( + 0.0f, 0.0f, 0.0f, 2.0f, 4.0f, 1.0f + ), + PartPose.offsetAndRotation(-1.0f, -6.0f, -1.0f, 0.0f, -1.5707964f, 0.0f) + ); } - part.addOrReplaceChild("left_paddle", CubeListBuilder.create().texOffs(62, 0).addBox(-1.0F, 0.0F, -5.0F, 2.0F, 2.0F, 18.0F).addBox(-1.001F, -3.0F, 8.0F, 1.0F, 6.0F, 7.0F), PartPose.offsetAndRotation(3.0F, -5.0F, 9.0F, 0.0F, 0.0F, 0.19634955F)); - part.addOrReplaceChild("right_paddle", CubeListBuilder.create().texOffs(62, 20).addBox(-1.0F, 0.0F, -5.0F, 2.0F, 2.0F, 18.0F).addBox(0.001F, -3.0F, 8.0F, 1.0F, 6.0F, 7.0F), PartPose.offsetAndRotation(3.0F, -5.0F, -9.0F, 0.0F, 3.1415927F, 0.19634955F)); - part.addOrReplaceChild("water_patch", CubeListBuilder.create().texOffs(0, 0).addBox(-14.0F, -9.0F, -3.0F, 28.0F, 16.0F, 3.0F), PartPose.offsetAndRotation(0.0F, -3.0F, 1.0F, 1.5707964F, 0.0F, 0.0F)); + part.addOrReplaceChild( + "left_paddle", + CubeListBuilder.create() + .texOffs(62, 0) + .addBox(-1.0F, 0.0F, -5.0F, 2.0F, 2.0F, 18.0F) + .addBox(-1.001F, -3.0F, 8.0F, 1.0F, 6.0F, 7.0F), + PartPose.offsetAndRotation(3.0F, -5.0F, 9.0F, 0.0F, 0.0F, 0.19634955F) + ); + part.addOrReplaceChild( + "right_paddle", + CubeListBuilder.create() + .texOffs(62, 20) + .addBox(-1.0F, 0.0F, -5.0F, 2.0F, 2.0F, 18.0F) + .addBox(0.001F, -3.0F, 8.0F, 1.0F, 6.0F, 7.0F), + PartPose.offsetAndRotation(3.0F, -5.0F, -9.0F, 0.0F, 3.1415927F, 0.19634955F) + ); + part.addOrReplaceChild( + "water_patch", + CubeListBuilder.create().texOffs(0, 0).addBox( + -14.0F, -9.0F, -3.0F, 28.0F, 16.0F, 3.0F + ), + PartPose.offsetAndRotation(0.0F, -3.0F, 1.0F, 1.5707964F, 0.0F, 0.0F) + ); return LayerDefinition.create(mesh, 128, chested ? 128 : 64); } @Override - public void setupAnim(MangroveBoat boat, float angle, float distance, float animationProgress, float yaw, float pitch) { + public void setupAnim( + MangroveBoat boat, + float angle, + float distance, + float animationProgress, + float yaw, + float pitch + ) { animatePaddle(boat, 0, this.leftPaddle, angle); animatePaddle(boat, 1, this.rightPaddle, angle); } @@ -72,14 +155,21 @@ public class ChestBoatModel extends ListModel { return this.waterPatch; } - private static void animatePaddle(MangroveBoat boat, int sigma, ModelPart part, float angle) { + private static void + animatePaddle(MangroveBoat boat, int sigma, ModelPart part, float angle) { float time = boat.getRowingTime(sigma, angle); - part.xRot = Mth.clampedLerp(-1.0471976F, -0.2617994F, (Mth.sin(-time) + 1.0F) / 2.0F); - part.yRot = Mth.clampedLerp(-0.7853982F, 0.7853982F, (Mth.sin(-time + 1.0F) + 1.0F) / 2.0F); - if (sigma == 1) part.yRot = (float)Math.PI - part.yRot; + part.xRot + = Mth.clampedLerp(-1.0471976F, -0.2617994F, (Mth.sin(-time) + 1.0F) / 2.0F); + part.yRot = Mth.clampedLerp( + -0.7853982F, 0.7853982F, (Mth.sin(-time + 1.0F) + 1.0F) / 2.0F + ); + if (sigma == 1) + part.yRot = (float) Math.PI - part.yRot; } public static ModelLayerLocation createChestBoat(Boat.Type type) { - return new ModelLayerLocation(new ResourceLocation("chest_boat/" + type.getName()), "main"); + return new ModelLayerLocation( + new ResourceLocation("chest_boat/" + type.getName()), "main" + ); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/render/model/FrogModel.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/render/model/FrogModel.java index 71b919c..9f79578 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/render/model/FrogModel.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/render/model/FrogModel.java @@ -40,35 +40,156 @@ public class FrogModel extends AnimatedModel { public static LayerDefinition createBodyLayer() { MeshDefinition mesh = new MeshDefinition(); PartDefinition root = mesh.getRoot(); - PartDefinition bone = root.addOrReplaceChild("root", CubeListBuilder.create(), PartPose.offset(0.0f, 24.0f, 0.0f)); - PartDefinition body = bone.addOrReplaceChild("body", CubeListBuilder.create().texOffs(3, 1).addBox(-3.5f, -2.0f, -8.0f, 7.0f, 3.0f, 9.0f).texOffs(23, 22).addBox(-3.5f, -1.0f, -8.0f, 7.0f, 0.0f, 9.0f), PartPose.offset(0.0f, -2.0f, 4.0f)); - PartDefinition head = body.addOrReplaceChild("head", CubeListBuilder.create().texOffs(23, 13).addBox(-3.5f, -1.0f, -7.0f, 7.0f, 0.0f, 9.0f).texOffs(0, 13).addBox(-3.5f, -2.0f, -7.0f, 7.0f, 3.0f, 9.0f), PartPose.offset(0.0f, -2.0f, -1.0f)); - PartDefinition eyes = head.addOrReplaceChild("eyes", CubeListBuilder.create(), PartPose.offset(-0.5f, 0.0f, 2.0f)); - eyes.addOrReplaceChild("right_eye", CubeListBuilder.create().texOffs(0, 0).addBox(-1.5f, -1.0f, -1.5f, 3.0f, 2.0f, 3.0f), PartPose.offset(-1.5f, -3.0f, -6.5f)); - eyes.addOrReplaceChild("left_eye", CubeListBuilder.create().texOffs(0, 5).addBox(-1.5f, -1.0f, -1.5f, 3.0f, 2.0f, 3.0f), PartPose.offset(2.5f, -3.0f, -6.5f)); - body.addOrReplaceChild("croaking_body", CubeListBuilder.create().texOffs(26, 5).addBox(-3.5f, -0.1f, -2.9f, 7.0f, 2.0f, 3.0f, new CubeDeformation(-0.1f)), PartPose.offset(0.0f, -1.0f, -5.0f)); - body.addOrReplaceChild("tongue", CubeListBuilder.create().texOffs(17, 13).addBox(-2.0f, 0.0f, -7.1f, 4.0f, 0.0f, 7.0f), PartPose.offset(0.0f, -1.01f, 1.0f)); - PartDefinition left_arm = body.addOrReplaceChild("left_arm", CubeListBuilder.create().texOffs(0, 32).addBox(-1.0f, 0.0f, -1.0f, 2.0f, 3.0f, 3.0f), PartPose.offset(4.0f, -1.0f, -6.5f)); - left_arm.addOrReplaceChild("left_hand", CubeListBuilder.create().texOffs(18, 40).addBox(-4.0f, 0.01f, -4.0f, 8.0f, 0.0f, 8.0f), PartPose.offset(0.0f, 3.0f, -1.0f)); - PartDefinition right_arm = body.addOrReplaceChild("right_arm", CubeListBuilder.create().texOffs(0, 38).addBox(-1.0f, 0.0f, -1.0f, 2.0f, 3.0f, 3.0f), PartPose.offset(-4.0f, -1.0f, -6.5f)); - right_arm.addOrReplaceChild("right_hand", CubeListBuilder.create().texOffs(2, 40).addBox(-4.0f, 0.01f, -5.0f, 8.0f, 0.0f, 8.0f), PartPose.offset(0.0f, 3.0f, 0.0f)); - PartDefinition left_leg = bone.addOrReplaceChild("left_leg", CubeListBuilder.create().texOffs(14, 25).addBox(-1.0f, 0.0f, -2.0f, 3.0f, 3.0f, 4.0f), PartPose.offset(3.5f, -3.0f, 4.0f)); - left_leg.addOrReplaceChild("left_foot", CubeListBuilder.create().texOffs(2, 32).addBox(-4.0f, 0.01f, -4.0f, 8.0f, 0.0f, 8.0f), PartPose.offset(2.0f, 3.0f, 0.0f)); - PartDefinition right_leg = bone.addOrReplaceChild("right_leg", CubeListBuilder.create().texOffs(0, 25).addBox(-2.0f, 0.0f, -2.0f, 3.0f, 3.0f, 4.0f), PartPose.offset(-3.5f, -3.0f, 4.0f)); - right_leg.addOrReplaceChild("right_foot", CubeListBuilder.create().texOffs(18, 32).addBox(-4.0f, 0.01f, -4.0f, 8.0f, 0.0f, 8.0f), PartPose.offset(-2.0f, 3.0f, 0.0f)); + PartDefinition bone = root.addOrReplaceChild( + "root", CubeListBuilder.create(), PartPose.offset(0.0f, 24.0f, 0.0f) + ); + PartDefinition body = bone.addOrReplaceChild( + "body", + CubeListBuilder.create() + .texOffs(3, 1) + .addBox(-3.5f, -2.0f, -8.0f, 7.0f, 3.0f, 9.0f) + .texOffs(23, 22) + .addBox(-3.5f, -1.0f, -8.0f, 7.0f, 0.0f, 9.0f), + PartPose.offset(0.0f, -2.0f, 4.0f) + ); + PartDefinition head = body.addOrReplaceChild( + "head", + CubeListBuilder.create() + .texOffs(23, 13) + .addBox(-3.5f, -1.0f, -7.0f, 7.0f, 0.0f, 9.0f) + .texOffs(0, 13) + .addBox(-3.5f, -2.0f, -7.0f, 7.0f, 3.0f, 9.0f), + PartPose.offset(0.0f, -2.0f, -1.0f) + ); + PartDefinition eyes = head.addOrReplaceChild( + "eyes", CubeListBuilder.create(), PartPose.offset(-0.5f, 0.0f, 2.0f) + ); + eyes.addOrReplaceChild( + "right_eye", + CubeListBuilder.create().texOffs(0, 0).addBox( + -1.5f, -1.0f, -1.5f, 3.0f, 2.0f, 3.0f + ), + PartPose.offset(-1.5f, -3.0f, -6.5f) + ); + eyes.addOrReplaceChild( + "left_eye", + CubeListBuilder.create().texOffs(0, 5).addBox( + -1.5f, -1.0f, -1.5f, 3.0f, 2.0f, 3.0f + ), + PartPose.offset(2.5f, -3.0f, -6.5f) + ); + body.addOrReplaceChild( + "croaking_body", + CubeListBuilder.create().texOffs(26, 5).addBox( + -3.5f, -0.1f, -2.9f, 7.0f, 2.0f, 3.0f, new CubeDeformation(-0.1f) + ), + PartPose.offset(0.0f, -1.0f, -5.0f) + ); + body.addOrReplaceChild( + "tongue", + CubeListBuilder.create().texOffs(17, 13).addBox( + -2.0f, 0.0f, -7.1f, 4.0f, 0.0f, 7.0f + ), + PartPose.offset(0.0f, -1.01f, 1.0f) + ); + PartDefinition left_arm = body.addOrReplaceChild( + "left_arm", + CubeListBuilder.create().texOffs(0, 32).addBox( + -1.0f, 0.0f, -1.0f, 2.0f, 3.0f, 3.0f + ), + PartPose.offset(4.0f, -1.0f, -6.5f) + ); + left_arm.addOrReplaceChild( + "left_hand", + CubeListBuilder.create().texOffs(18, 40).addBox( + -4.0f, 0.01f, -4.0f, 8.0f, 0.0f, 8.0f + ), + PartPose.offset(0.0f, 3.0f, -1.0f) + ); + PartDefinition right_arm = body.addOrReplaceChild( + "right_arm", + CubeListBuilder.create().texOffs(0, 38).addBox( + -1.0f, 0.0f, -1.0f, 2.0f, 3.0f, 3.0f + ), + PartPose.offset(-4.0f, -1.0f, -6.5f) + ); + right_arm.addOrReplaceChild( + "right_hand", + CubeListBuilder.create().texOffs(2, 40).addBox( + -4.0f, 0.01f, -5.0f, 8.0f, 0.0f, 8.0f + ), + PartPose.offset(0.0f, 3.0f, 0.0f) + ); + PartDefinition left_leg = bone.addOrReplaceChild( + "left_leg", + CubeListBuilder.create().texOffs(14, 25).addBox( + -1.0f, 0.0f, -2.0f, 3.0f, 3.0f, 4.0f + ), + PartPose.offset(3.5f, -3.0f, 4.0f) + ); + left_leg.addOrReplaceChild( + "left_foot", + CubeListBuilder.create().texOffs(2, 32).addBox( + -4.0f, 0.01f, -4.0f, 8.0f, 0.0f, 8.0f + ), + PartPose.offset(2.0f, 3.0f, 0.0f) + ); + PartDefinition right_leg = bone.addOrReplaceChild( + "right_leg", + CubeListBuilder.create().texOffs(0, 25).addBox( + -2.0f, 0.0f, -2.0f, 3.0f, 3.0f, 4.0f + ), + PartPose.offset(-3.5f, -3.0f, 4.0f) + ); + right_leg.addOrReplaceChild( + "right_foot", + CubeListBuilder.create().texOffs(18, 32).addBox( + -4.0f, 0.01f, -4.0f, 8.0f, 0.0f, 8.0f + ), + PartPose.offset(-2.0f, 3.0f, 0.0f) + ); return LayerDefinition.create(mesh, 48, 48); } @Override - public void setupAnim(T entity, float angle, float distance, float animationProgress, float yaw, float pitch) { + public void setupAnim( + T entity, + float angle, + float distance, + float animationProgress, + float yaw, + float pitch + ) { this.root.getAllParts().forEach(Animated::resetToDefault); - float speedMultiplier = Math.min((float)entity.getDeltaMovement().lengthSqr() * 200.0F, 8.0F); - this.animate(entity.longJumpingAnimationState, FrogAnimations.LONG_JUMPING, animationProgress); - this.animate(entity.croakingAnimationState, FrogAnimations.CROAKING, animationProgress); - this.animate(entity.usingTongueAnimationState, FrogAnimations.USING_TONGUE, animationProgress); - this.animate(entity.walkingAnimationState, FrogAnimations.WALKING, animationProgress, speedMultiplier); - this.animate(entity.swimmingAnimationState, FrogAnimations.SWIMMING, animationProgress); - this.animate(entity.idlingInWaterAnimationState, FrogAnimations.IDLING_IN_WATER, animationProgress); + float speedMultiplier + = Math.min((float) entity.getDeltaMovement().lengthSqr() * 200.0F, 8.0F); + this.animate( + entity.longJumpingAnimationState, + FrogAnimations.LONG_JUMPING, + animationProgress + ); + this.animate( + entity.croakingAnimationState, FrogAnimations.CROAKING, animationProgress + ); + this.animate( + entity.usingTongueAnimationState, + FrogAnimations.USING_TONGUE, + animationProgress + ); + this.animate( + entity.walkingAnimationState, + FrogAnimations.WALKING, + animationProgress, + speedMultiplier + ); + this.animate( + entity.swimmingAnimationState, FrogAnimations.SWIMMING, animationProgress + ); + this.animate( + entity.idlingInWaterAnimationState, + FrogAnimations.IDLING_IN_WATER, + animationProgress + ); this.croakingBody.visible = entity.croakingAnimationState.isRunning(); } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/render/model/TadpoleModel.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/render/model/TadpoleModel.java index ab162d8..6e95b60 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/render/model/TadpoleModel.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/render/model/TadpoleModel.java @@ -24,8 +24,20 @@ public class TadpoleModel extends AgeableListModel { public static LayerDefinition createBodyLayer() { MeshDefinition mesh = new MeshDefinition(); PartDefinition root = mesh.getRoot(); - root.addOrReplaceChild("body", CubeListBuilder.create().texOffs(0, 0).addBox(-1.5F, -1.0F, 0.0F, 3.0F, 2.0F, 3.0F), PartPose.offset(0.0F, 22.0F, -3.0F)); - root.addOrReplaceChild("tail", CubeListBuilder.create().texOffs(0, 0).addBox(0.0F, -1.0F, 0.0F, 0.0F, 2.0F, 7.0F), PartPose.offset(0.0F, 22.0F, 0.0F)); + root.addOrReplaceChild( + "body", + CubeListBuilder.create().texOffs(0, 0).addBox( + -1.5F, -1.0F, 0.0F, 3.0F, 2.0F, 3.0F + ), + PartPose.offset(0.0F, 22.0F, -3.0F) + ); + root.addOrReplaceChild( + "tail", + CubeListBuilder.create().texOffs(0, 0).addBox( + 0.0F, -1.0F, 0.0F, 0.0F, 2.0F, 7.0F + ), + PartPose.offset(0.0F, 22.0F, 0.0F) + ); return LayerDefinition.create(mesh, 16, 16); } @@ -40,9 +52,15 @@ public class TadpoleModel extends AgeableListModel { } @Override - public void setupAnim(T entity, float angle, float distance, float animationProgress, float yaw, float pitch) { + public void setupAnim( + T entity, + float angle, + float distance, + float animationProgress, + float yaw, + float pitch + ) { float angles = entity.isInWater() ? 1.0F : 1.5F; this.tail.yRot = -angles * 0.25F * Mth.sin(0.3F * animationProgress); } - } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/render/model/WardenModel.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/render/model/WardenModel.java index e8f8d30..8d856de 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/render/model/WardenModel.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/render/model/WardenModel.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.client.render.model; +import java.util.List; + import com.cursedcauldron.wildbackport.client.animation.WardenAnimations; import com.cursedcauldron.wildbackport.client.animation.api.Animated; import com.cursedcauldron.wildbackport.client.animation.api.AnimatedModel; @@ -14,8 +16,6 @@ import net.minecraft.client.model.geom.builders.PartDefinition; import net.minecraft.client.renderer.RenderType; import net.minecraft.util.Mth; -import java.util.List; - //<> public class WardenModel extends AnimatedModel { @@ -52,46 +52,133 @@ public class WardenModel extends AnimatedModel { this.leftRibcage = this.body.getChild("left_ribcage"); this.tendrils = ImmutableList.of(this.leftTendril, this.rightTendril); this.justBody = ImmutableList.of(this.body); - this.headAndLimbs = ImmutableList.of(this.head, this.leftArm, this.rightArm, this.leftLeg, this.rightLeg); - this.bodyHeadAndLimbs = ImmutableList.of(this.body, this.head, this.leftArm, this.rightArm, this.leftLeg, this.rightLeg); + this.headAndLimbs = ImmutableList.of( + this.head, this.leftArm, this.rightArm, this.leftLeg, this.rightLeg + ); + this.bodyHeadAndLimbs = ImmutableList.of( + this.body, this.head, this.leftArm, this.rightArm, this.leftLeg, this.rightLeg + ); } public static LayerDefinition createBodyLayer() { MeshDefinition mesh = new MeshDefinition(); PartDefinition root = mesh.getRoot(); - PartDefinition bone = root.addOrReplaceChild("bone", CubeListBuilder.create(), PartPose.offset(0.0f, 24.0f, 0.0f)); - PartDefinition body = bone.addOrReplaceChild("body", CubeListBuilder.create().texOffs(0, 0).addBox(-9.0f, -13.0f, -4.0f, 18.0f, 21.0f, 11.0f), PartPose.offset(0.0f, -21.0f, 0.0f)); - body.addOrReplaceChild("right_ribcage", CubeListBuilder.create().texOffs(90, 11).addBox(-2.0f, -11.0f, -0.1f, 9.0f, 21.0f, 0.0f), PartPose.offset(-7.0f, -2.0f, -4.0f)); - body.addOrReplaceChild("left_ribcage", CubeListBuilder.create().texOffs(90, 11).mirror().addBox(-7.0f, -11.0f, -0.1f, 9.0f, 21.0f, 0.0f).mirror(false), PartPose.offset(7.0f, -2.0f, -4.0f)); - PartDefinition head = body.addOrReplaceChild("head", CubeListBuilder.create().texOffs(0, 32).addBox(-8.0f, -16.0f, -5.0f, 16.0f, 16.0f, 10.0f), PartPose.offset(0.0f, -13.0f, 0.0f)); - head.addOrReplaceChild("right_tendril", CubeListBuilder.create().texOffs(52, 32).addBox(-16.0f, -13.0f, 0.0f, 16.0f, 16.0f, 0.0f), PartPose.offset(-8.0f, -12.0f, 0.0f)); - head.addOrReplaceChild("left_tendril", CubeListBuilder.create().texOffs(58, 0).addBox(0.0f, -13.0f, 0.0f, 16.0f, 16.0f, 0.0f), PartPose.offset(8.0f, -12.0f, 0.0f)); - body.addOrReplaceChild("right_arm", CubeListBuilder.create().texOffs(44, 50).addBox(-4.0f, 0.0f, -4.0f, 8.0f, 28.0f, 8.0f), PartPose.offset(-13.0f, -13.0f, 1.0f)); - body.addOrReplaceChild("left_arm", CubeListBuilder.create().texOffs(0, 58).addBox(-4.0f, 0.0f, -4.0f, 8.0f, 28.0f, 8.0f), PartPose.offset(13.0f, -13.0f, 1.0f)); - bone.addOrReplaceChild("right_leg", CubeListBuilder.create().texOffs(76, 48).addBox(-3.1f, 0.0f, -3.0f, 6.0f, 13.0f, 6.0f), PartPose.offset(-5.9f, -13.0f, 0.0f)); - bone.addOrReplaceChild("left_leg", CubeListBuilder.create().texOffs(76, 76).addBox(-2.9f, 0.0f, -3.0f, 6.0f, 13.0f, 6.0f), PartPose.offset(5.9f, -13.0f, 0.0f)); + PartDefinition bone = root.addOrReplaceChild( + "bone", CubeListBuilder.create(), PartPose.offset(0.0f, 24.0f, 0.0f) + ); + PartDefinition body = bone.addOrReplaceChild( + "body", + CubeListBuilder.create().texOffs(0, 0).addBox( + -9.0f, -13.0f, -4.0f, 18.0f, 21.0f, 11.0f + ), + PartPose.offset(0.0f, -21.0f, 0.0f) + ); + body.addOrReplaceChild( + "right_ribcage", + CubeListBuilder.create().texOffs(90, 11).addBox( + -2.0f, -11.0f, -0.1f, 9.0f, 21.0f, 0.0f + ), + PartPose.offset(-7.0f, -2.0f, -4.0f) + ); + body.addOrReplaceChild( + "left_ribcage", + CubeListBuilder.create() + .texOffs(90, 11) + .mirror() + .addBox(-7.0f, -11.0f, -0.1f, 9.0f, 21.0f, 0.0f) + .mirror(false), + PartPose.offset(7.0f, -2.0f, -4.0f) + ); + PartDefinition head = body.addOrReplaceChild( + "head", + CubeListBuilder.create().texOffs(0, 32).addBox( + -8.0f, -16.0f, -5.0f, 16.0f, 16.0f, 10.0f + ), + PartPose.offset(0.0f, -13.0f, 0.0f) + ); + head.addOrReplaceChild( + "right_tendril", + CubeListBuilder.create().texOffs(52, 32).addBox( + -16.0f, -13.0f, 0.0f, 16.0f, 16.0f, 0.0f + ), + PartPose.offset(-8.0f, -12.0f, 0.0f) + ); + head.addOrReplaceChild( + "left_tendril", + CubeListBuilder.create().texOffs(58, 0).addBox( + 0.0f, -13.0f, 0.0f, 16.0f, 16.0f, 0.0f + ), + PartPose.offset(8.0f, -12.0f, 0.0f) + ); + body.addOrReplaceChild( + "right_arm", + CubeListBuilder.create().texOffs(44, 50).addBox( + -4.0f, 0.0f, -4.0f, 8.0f, 28.0f, 8.0f + ), + PartPose.offset(-13.0f, -13.0f, 1.0f) + ); + body.addOrReplaceChild( + "left_arm", + CubeListBuilder.create().texOffs(0, 58).addBox( + -4.0f, 0.0f, -4.0f, 8.0f, 28.0f, 8.0f + ), + PartPose.offset(13.0f, -13.0f, 1.0f) + ); + bone.addOrReplaceChild( + "right_leg", + CubeListBuilder.create().texOffs(76, 48).addBox( + -3.1f, 0.0f, -3.0f, 6.0f, 13.0f, 6.0f + ), + PartPose.offset(-5.9f, -13.0f, 0.0f) + ); + bone.addOrReplaceChild( + "left_leg", + CubeListBuilder.create().texOffs(76, 76).addBox( + -2.9f, 0.0f, -3.0f, 6.0f, 13.0f, 6.0f + ), + PartPose.offset(5.9f, -13.0f, 0.0f) + ); return LayerDefinition.create(mesh, 128, 128); } @Override - public void setupAnim(T entity, float angle, float distance, float animationProgress, float yaw, float pitch) { + public void setupAnim( + T entity, + float angle, + float distance, + float animationProgress, + float yaw, + float pitch + ) { this.root.getAllParts().forEach(Animated::resetToDefault); - float tickDelta = animationProgress - (float)entity.tickCount; + float tickDelta = animationProgress - (float) entity.tickCount; this.setHeadAngle(yaw, pitch); this.setLimbAngles(angle, distance); this.setHeadAndBodyAngles(animationProgress); this.setTendrilPitches(entity, animationProgress, tickDelta); - this.animate(entity.attackingAnimationState, WardenAnimations.ATTACKING, animationProgress); - this.animate(entity.sonicBoomAnimationState, WardenAnimations.SONIC_BOOM, animationProgress); - this.animate(entity.diggingAnimationState, WardenAnimations.DIGGING, animationProgress); - this.animate(entity.emergingAnimationState, WardenAnimations.EMERGING, animationProgress); - this.animate(entity.roaringAnimationState, WardenAnimations.ROARING, animationProgress); - this.animate(entity.sniffingAnimationState, WardenAnimations.SNIFFING, animationProgress); + this.animate( + entity.attackingAnimationState, WardenAnimations.ATTACKING, animationProgress + ); + this.animate( + entity.sonicBoomAnimationState, WardenAnimations.SONIC_BOOM, animationProgress + ); + this.animate( + entity.diggingAnimationState, WardenAnimations.DIGGING, animationProgress + ); + this.animate( + entity.emergingAnimationState, WardenAnimations.EMERGING, animationProgress + ); + this.animate( + entity.roaringAnimationState, WardenAnimations.ROARING, animationProgress + ); + this.animate( + entity.sniffingAnimationState, WardenAnimations.SNIFFING, animationProgress + ); } private void setHeadAngle(float yaw, float pitch) { - this.head.xRot = pitch * ((float)Math.PI / 180); - this.head.yRot = yaw * ((float)Math.PI / 180); + this.head.xRot = pitch * ((float) Math.PI / 180); + this.head.yRot = yaw * ((float) Math.PI / 180); } private void setHeadAndBodyAngles(float animationProgress) { @@ -115,7 +202,7 @@ public class WardenModel extends AnimatedModel { this.body.zRot = 0.1F * sin * roll; this.body.xRot = 1.0F * cos * pitch; this.leftLeg.xRot = 1.0F * cos * roll; - this.rightLeg.xRot = 1.0F * Mth.cos(mod + (float)Math.PI) * roll; + this.rightLeg.xRot = 1.0F * Mth.cos(mod + (float) Math.PI) * roll; this.leftArm.xRot = -(0.8F * cos * roll); this.leftArm.zRot = 0.0F; this.rightArm.xRot = -(0.8F * sin * roll); @@ -135,7 +222,9 @@ public class WardenModel extends AnimatedModel { } private void setTendrilPitches(T warden, float animationProgress, float tickDelta) { - float pitch = warden.getTendrilPitch(tickDelta) * (float)(Math.cos((double)animationProgress * 2.25D) * Math.PI * (double)0.1F); + float pitch = warden.getTendrilPitch(tickDelta) + * (float + ) (Math.cos((double) animationProgress * 2.25D) * Math.PI * (double) 0.1F); this.leftTendril.xRot = pitch; this.rightTendril.xRot = -pitch; } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/client/sound/CoreSoundType.java b/common/src/main/java/com/cursedcauldron/wildbackport/client/sound/CoreSoundType.java index 785cc31..b5a5019 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/client/sound/CoreSoundType.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/client/sound/CoreSoundType.java @@ -1,10 +1,10 @@ package com.cursedcauldron.wildbackport.client.sound; +import java.util.function.Supplier; + import net.minecraft.sounds.SoundEvent; import net.minecraft.world.level.block.SoundType; -import java.util.function.Supplier; - public class CoreSoundType extends SoundType { private final Supplier breakSound; private final Supplier stepSound; @@ -13,7 +13,13 @@ public class CoreSoundType extends SoundType { private final Supplier fallSound; @SuppressWarnings("all") - public CoreSoundType(Supplier breakSound, Supplier stepSound, Supplier placeSound, Supplier hitSound, Supplier fallSound) { + public CoreSoundType( + Supplier breakSound, + Supplier stepSound, + Supplier placeSound, + Supplier hitSound, + Supplier fallSound + ) { super(1.0F, 1.0F, null, null, null, null, null); this.breakSound = breakSound; this.stepSound = stepSound; diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/CommonSetup.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/CommonSetup.java index 7dc3266..2748bc8 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/CommonSetup.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/CommonSetup.java @@ -7,9 +7,9 @@ import com.cursedcauldron.wildbackport.common.entities.Warden; import com.cursedcauldron.wildbackport.common.entities.access.Recovery; import com.cursedcauldron.wildbackport.common.items.CompassItemPropertyFunction; import com.cursedcauldron.wildbackport.common.registry.WBItems; -import com.cursedcauldron.wildbackport.common.worldgen.structure.StructureGeneration; import com.cursedcauldron.wildbackport.common.registry.entity.WBEntityTypes; import com.cursedcauldron.wildbackport.common.registry.worldgen.WBWorldGeneration; +import com.cursedcauldron.wildbackport.common.worldgen.structure.StructureGeneration; import com.cursedcauldron.wildbackport.core.api.MobRegistry; import com.cursedcauldron.wildbackport.core.api.worldgen.BiomeModifier; import net.minecraft.client.renderer.item.ItemProperties; diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/VanillaIntegration.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/VanillaIntegration.java index 899dcb2..1e06d4b 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/VanillaIntegration.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/VanillaIntegration.java @@ -53,7 +53,9 @@ public class VanillaIntegration { // Strippables addStrippable(WBBlocks.MANGROVE_LOG.get(), WBBlocks.STRIPPED_MANGROVE_LOG.get()); - addStrippable(WBBlocks.MANGROVE_WOOD.get(), WBBlocks.STRIPPED_MANGROVE_WOOD.get()); + addStrippable( + WBBlocks.MANGROVE_WOOD.get(), WBBlocks.STRIPPED_MANGROVE_WOOD.get() + ); // Turning Dirt into Mud Interactions.addRightClick(context -> { @@ -62,18 +64,40 @@ public class VanillaIntegration { Player player = context.getPlayer(); ItemStack stack = context.getItemInHand(); BlockState state = level.getBlockState(pos); - if (player != null && context.getClickedFace() != Direction.DOWN && state.is(WBBlockTags.CONVERTABLE_TO_MUD) && PotionUtils.getPotion(stack) == Potions.WATER) { - level.playSound(null, pos, SoundEvents.GENERIC_SPLASH, SoundSource.PLAYERS, 1.0F, 1.0F); - player.setItemInHand(context.getHand(), ItemUtils.createFilledResult(stack, player, new ItemStack(Items.GLASS_BOTTLE))); + if (player != null && context.getClickedFace() != Direction.DOWN + && state.is(WBBlockTags.CONVERTABLE_TO_MUD) + && PotionUtils.getPotion(stack) == Potions.WATER) { + level.playSound( + null, pos, SoundEvents.GENERIC_SPLASH, SoundSource.PLAYERS, 1.0F, 1.0F + ); + player.setItemInHand( + context.getHand(), + ItemUtils.createFilledResult( + stack, player, new ItemStack(Items.GLASS_BOTTLE) + ) + ); player.awardStat(Stats.ITEM_USED.get(stack.getItem())); if (!level.isClientSide()) { for (int i = 0; i < 5; i++) { - ((ServerLevel)level).sendParticles(ParticleTypes.SPLASH, (double)pos.getX() + level.random.nextDouble(), pos.getY() + 1, (double)pos.getZ() + level.random.nextDouble(), 1, 0.0D, 0.0D, 0.0D, 1.0D); + ((ServerLevel) level) + .sendParticles( + ParticleTypes.SPLASH, + (double) pos.getX() + level.random.nextDouble(), + pos.getY() + 1, + (double) pos.getZ() + level.random.nextDouble(), + 1, + 0.0D, + 0.0D, + 0.0D, + 1.0D + ); } } - level.playSound(null, pos, SoundEvents.BOTTLE_EMPTY, SoundSource.BLOCKS, 1.0F, 1.0F); + level.playSound( + null, pos, SoundEvents.BOTTLE_EMPTY, SoundSource.BLOCKS, 1.0F, 1.0F + ); level.gameEvent(GameEvent.FLUID_PLACE, pos); level.setBlockAndUpdate(pos, WBBlocks.MUD.get().defaultBlockState()); return InteractionResult.sidedSuccess(level.isClientSide()); @@ -83,27 +107,51 @@ public class VanillaIntegration { }); DispenserBlock.registerBehavior(Items.POTION, new DefaultDispenseItemBehavior() { - private final DefaultDispenseItemBehavior behavior = new DefaultDispenseItemBehavior(); + private final DefaultDispenseItemBehavior behavior + = new DefaultDispenseItemBehavior(); - @Override protected ItemStack execute(BlockSource source, ItemStack stack) { + @Override + protected ItemStack execute(BlockSource source, ItemStack stack) { if (PotionUtils.getPotion(stack) != Potions.WATER) { return this.behavior.dispense(source, stack); } else { ServerLevel level = source.getLevel(); BlockPos sourcePos = source.getPos(); - BlockPos dispenserPos = source.getPos().relative(source.getBlockState().getValue(DispenserBlock.FACING)); - if (!level.getBlockState(dispenserPos).is(WBBlockTags.CONVERTABLE_TO_MUD)) { + BlockPos dispenserPos = source.getPos().relative( + source.getBlockState().getValue(DispenserBlock.FACING) + ); + if (!level.getBlockState(dispenserPos) + .is(WBBlockTags.CONVERTABLE_TO_MUD)) { return this.behavior.dispense(source, stack); } else { if (!level.isClientSide()) { for (int i = 0; i < 5; i++) { - level.sendParticles(ParticleTypes.SPLASH, (double)sourcePos.getX() + level.random.nextDouble(), sourcePos.getY() + 1, (double)sourcePos.getZ() + level.random.nextDouble(), 1, 0.0D, 0.0D, 0.0D, 1.0D); + level.sendParticles( + ParticleTypes.SPLASH, + (double) sourcePos.getX() + level.random.nextDouble(), + sourcePos.getY() + 1, + (double) sourcePos.getZ() + level.random.nextDouble(), + 1, + 0.0D, + 0.0D, + 0.0D, + 1.0D + ); } } - level.playSound(null, sourcePos, SoundEvents.BOTTLE_EMPTY, SoundSource.BLOCKS, 1.0F, 1.0F); + level.playSound( + null, + sourcePos, + SoundEvents.BOTTLE_EMPTY, + SoundSource.BLOCKS, + 1.0F, + 1.0F + ); level.gameEvent(GameEvent.FLUID_PLACE, sourcePos); - level.setBlockAndUpdate(dispenserPos, WBBlocks.MUD.get().defaultBlockState()); + level.setBlockAndUpdate( + dispenserPos, WBBlocks.MUD.get().defaultBlockState() + ); return new ItemStack(Items.GLASS_BOTTLE); } } @@ -112,7 +160,7 @@ public class VanillaIntegration { } public static void addFlammable(Block block, int flameOdds, int burnOdds) { - ((FireBlockAccessor)Blocks.FIRE).callSetFlammable(block, flameOdds, burnOdds); + ((FireBlockAccessor) Blocks.FIRE).callSetFlammable(block, flameOdds, burnOdds); } public static void addCompostable(ItemLike item, float chance) { diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/DrippingFluid.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/DrippingFluid.java index 220902e..b26a601 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/DrippingFluid.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/DrippingFluid.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.blocks; +import java.util.Optional; + import com.cursedcauldron.wildbackport.common.registry.WBBlocks; import com.cursedcauldron.wildbackport.common.tag.WBBlockTags; import com.cursedcauldron.wildbackport.core.mixin.access.PointedDripstoneBlockAccessor; @@ -12,27 +14,39 @@ import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Fluids; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.Optional; - public record DrippingFluid(BlockPos pos, Fluid fluid, BlockState sourceState) { - public static void fillCauldron(BlockState state, ServerLevel world, BlockPos blockPos, CallbackInfo ci) { - Optional fluidAbove = getFluidAboveStalactite(world, blockPos, state); + public static void fillCauldron( + BlockState state, ServerLevel world, BlockPos blockPos, CallbackInfo ci + ) { + Optional fluidAbove + = getFluidAboveStalactite(world, blockPos, state); if (fluidAbove.isPresent()) { Fluid fluid = fluidAbove.get().fluid; - if (fluidAbove.get().sourceState().is(WBBlockTags.MUD) && fluid == Fluids.WATER) { - world.setBlockAndUpdate(fluidAbove.get().pos, Blocks.CLAY.defaultBlockState()); + if (fluidAbove.get().sourceState().is(WBBlockTags.MUD) + && fluid == Fluids.WATER) { + world.setBlockAndUpdate( + fluidAbove.get().pos, Blocks.CLAY.defaultBlockState() + ); world.levelEvent(1504, blockPos, 0); ci.cancel(); } } } - public static Optional getFluidAboveStalactite(Level level, BlockPos pos, BlockState state) { - return !PointedDripstoneBlockAccessor.callIsStalactite(state) ? Optional.empty() : PointedDripstoneBlockAccessor.callFindRootBlock(level, pos, state, 11).map(blockPos -> { - BlockPos position = blockPos.above(); - BlockState sourceState = level.getBlockState(position); - Fluid fluid = sourceState.is(WBBlockTags.MUD) && !level.dimensionType().ultraWarm() ? Fluids.WATER : level.getFluidState(position).getType(); - return new DrippingFluid(position, fluid, sourceState); - }); + public static Optional getFluidAboveStalactite( + Level level, BlockPos pos, BlockState state + ) { + return !PointedDripstoneBlockAccessor.callIsStalactite(state) + ? Optional.empty() + : PointedDripstoneBlockAccessor.callFindRootBlock(level, pos, state, 11) + .map(blockPos -> { + BlockPos position = blockPos.above(); + BlockState sourceState = level.getBlockState(position); + Fluid fluid = sourceState.is(WBBlockTags.MUD) + && !level.dimensionType().ultraWarm() + ? Fluids.WATER + : level.getFluidState(position).getType(); + return new DrippingFluid(position, fluid, sourceState); + }); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/FrogspawnBlock.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/FrogspawnBlock.java index 94ae05c..063a3e3 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/FrogspawnBlock.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/FrogspawnBlock.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.blocks; +import java.util.Random; + import com.cursedcauldron.wildbackport.client.registry.WBSoundEvents; import com.cursedcauldron.wildbackport.common.entities.Tadpole; import com.cursedcauldron.wildbackport.common.registry.entity.WBEntityTypes; @@ -22,19 +24,20 @@ import net.minecraft.world.level.material.Fluids; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; -import java.util.Random; - //<> public class FrogspawnBlock extends Block { - protected static final VoxelShape SHAPE = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 1.5D, 16.0D); + protected static final VoxelShape SHAPE + = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 1.5D, 16.0D); public FrogspawnBlock(Properties properties) { super(properties); } @Override - public VoxelShape getShape(BlockState state, BlockGetter getter, BlockPos pos, CollisionContext context) { + public VoxelShape getShape( + BlockState state, BlockGetter getter, BlockPos pos, CollisionContext context + ) { return SHAPE; } @@ -44,7 +47,9 @@ public class FrogspawnBlock extends Block { } @Override - public void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean notify) { + public void onPlace( + BlockState state, Level level, BlockPos pos, BlockState oldState, boolean notify + ) { level.scheduleTick(pos, this, hatchTime(level.getRandom())); } @@ -53,8 +58,19 @@ public class FrogspawnBlock extends Block { } @Override - public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor access, BlockPos pos, BlockPos neighborPos) { - return !this.canSurvive(state, access, pos) ? Blocks.AIR.defaultBlockState() : super.updateShape(state, direction, neighborState, access, pos, neighborPos); + public BlockState updateShape( + BlockState state, + Direction direction, + BlockState neighborState, + LevelAccessor access, + BlockPos pos, + BlockPos neighborPos + ) { + return !this.canSurvive(state, access, pos) + ? Blocks.AIR.defaultBlockState() + : super.updateShape( + state, direction, neighborState, access, pos, neighborPos + ); } @Override @@ -76,12 +92,15 @@ public class FrogspawnBlock extends Block { private static boolean mayPlaceOn(LevelReader reader, BlockPos pos) { FluidState fluidState = reader.getFluidState(pos); FluidState topFluidState = reader.getFluidState(pos.above()); - return fluidState.getType() == Fluids.WATER && topFluidState.getType() == Fluids.EMPTY; + return fluidState.getType() == Fluids.WATER + && topFluidState.getType() == Fluids.EMPTY; } private void onHatch(ServerLevel level, BlockPos pos, Random random) { this.hatch(level, pos); - level.playSound(null, pos, WBSoundEvents.BLOCK_FROGSPAWN_HATCH, SoundSource.BLOCKS, 1.0F, 1.0F); + level.playSound( + null, pos, WBSoundEvents.BLOCK_FROGSPAWN_HATCH, SoundSource.BLOCKS, 1.0F, 1.0F + ); this.createTadpole(level, pos, random); } @@ -95,10 +114,10 @@ public class FrogspawnBlock extends Block { for (int index = 1; index <= i; ++index) { Tadpole tadpole = WBEntityTypes.TADPOLE.get().create(level); if (tadpole != null) { - double x = (double)pos.getX() + this.getSpawnOffset(random); - double z = (double)pos.getZ() + this.getSpawnOffset(random); + double x = (double) pos.getX() + this.getSpawnOffset(random); + double z = (double) pos.getZ() + this.getSpawnOffset(random); int yaw = random.nextInt(1, 361); - tadpole.moveTo(x, (double)pos.getY() - 0.5, z, yaw, 0.0F); + tadpole.moveTo(x, (double) pos.getY() - 0.5, z, yaw, 0.0F); tadpole.setPersistenceRequired(); level.addFreshEntity(tadpole); } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/MangroveLeavesBlock.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/MangroveLeavesBlock.java index e641b32..92ed528 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/MangroveLeavesBlock.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/MangroveLeavesBlock.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.blocks; +import java.util.Random; + import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.BlockGetter; @@ -8,8 +10,6 @@ import net.minecraft.world.level.block.BonemealableBlock; import net.minecraft.world.level.block.LeavesBlock; import net.minecraft.world.level.block.state.BlockState; -import java.util.Random; - //<> public class MangroveLeavesBlock extends LeavesBlock implements BonemealableBlock { @@ -18,17 +18,21 @@ public class MangroveLeavesBlock extends LeavesBlock implements BonemealableBloc } @Override - public boolean isValidBonemealTarget(BlockGetter block, BlockPos pos, BlockState state, boolean flag) { + public boolean isValidBonemealTarget( + BlockGetter block, BlockPos pos, BlockState state, boolean flag + ) { return block.getBlockState(pos.below()).isAir(); } @Override - public boolean isBonemealSuccess(Level level, Random random, BlockPos pos, BlockState state) { + public boolean + isBonemealSuccess(Level level, Random random, BlockPos pos, BlockState state) { return true; } @Override - public void performBonemeal(ServerLevel level, Random random, BlockPos pos, BlockState state) { + public void + performBonemeal(ServerLevel level, Random random, BlockPos pos, BlockState state) { level.setBlock(pos.below(), MangrovePropaguleBlock.createPropagule(), 2); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/MangrovePropaguleBlock.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/MangrovePropaguleBlock.java index aa9db15..d0a38ea 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/MangrovePropaguleBlock.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/MangrovePropaguleBlock.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.blocks; +import java.util.Random; + import com.cursedcauldron.wildbackport.common.registry.WBBlocks; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -25,23 +27,32 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; import org.jetbrains.annotations.Nullable; -import java.util.Random; - //<> -public class MangrovePropaguleBlock extends SaplingBlock implements SimpleWaterloggedBlock { - private static final VoxelShape[] SHAPES = new VoxelShape[]{Block.box(7.0D, 13.0D, 7.0D, 9.0D, 16.0D, 9.0D), Block.box(7.0D, 10.0D, 7.0D, 9.0D, 16.0D, 9.0D), Block.box(7.0D, 7.0D, 7.0D, 9.0D, 16.0D, 9.0D), Block.box(7.0D, 3.0D, 7.0D, 9.0D, 16.0D, 9.0D), Block.box(7.0D, 0.0D, 7.0D, 9.0D, 16.0D, 9.0D)}; +public class MangrovePropaguleBlock + extends SaplingBlock implements SimpleWaterloggedBlock { + private static final VoxelShape[] SHAPES + = new VoxelShape[] { Block.box(7.0D, 13.0D, 7.0D, 9.0D, 16.0D, 9.0D), + Block.box(7.0D, 10.0D, 7.0D, 9.0D, 16.0D, 9.0D), + Block.box(7.0D, 7.0D, 7.0D, 9.0D, 16.0D, 9.0D), + Block.box(7.0D, 3.0D, 7.0D, 9.0D, 16.0D, 9.0D), + Block.box(7.0D, 0.0D, 7.0D, 9.0D, 16.0D, 9.0D) }; public static final IntegerProperty AGE = StateProperties.AGE_4; public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; public static final BooleanProperty HANGING = BlockStateProperties.HANGING; public MangrovePropaguleBlock(Properties properties) { super(new MangroveTreeGrower(0.85F), properties); - this.registerDefaultState(this.stateDefinition.any().setValue(STAGE, 0).setValue(AGE, 0).setValue(WATERLOGGED, false).setValue(HANGING, false)); + this.registerDefaultState(this.stateDefinition.any() + .setValue(STAGE, 0) + .setValue(AGE, 0) + .setValue(WATERLOGGED, false) + .setValue(HANGING, false)); } @Override - protected void createBlockStateDefinition(StateDefinition.Builder builder) { + protected void + createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(STAGE, AGE, WATERLOGGED, HANGING); } @@ -50,28 +61,47 @@ public class MangrovePropaguleBlock extends SaplingBlock implements SimpleWaterl return super.mayPlaceOn(state, block, pos) || state.is(Blocks.CLAY); } - @Override @Nullable @SuppressWarnings("ConstantConditions") + @Override + @Nullable + @SuppressWarnings("ConstantConditions") public BlockState getStateForPlacement(BlockPlaceContext ctx) { FluidState fluidState = ctx.getLevel().getFluidState(ctx.getClickedPos()); - return super.getStateForPlacement(ctx).setValue(WATERLOGGED, fluidState.getType() == Fluids.WATER).setValue(AGE, 4); + return super.getStateForPlacement(ctx) + .setValue(WATERLOGGED, fluidState.getType() == Fluids.WATER) + .setValue(AGE, 4); } @Override - public VoxelShape getShape(BlockState state, BlockGetter block, BlockPos pos, CollisionContext context) { + public VoxelShape getShape( + BlockState state, BlockGetter block, BlockPos pos, CollisionContext context + ) { Vec3 offset = state.getOffset(block, pos); - VoxelShape shape = !state.getValue(HANGING) ? SHAPES[4] : SHAPES[state.getValue(AGE)]; + VoxelShape shape + = !state.getValue(HANGING) ? SHAPES[4] : SHAPES[state.getValue(AGE)]; return shape.move(offset.x, offset.y, offset.z); } @Override public boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) { - return isHanging(state) ? level.getBlockState(pos.above()).is(WBBlocks.MANGROVE_LEAVES.get()) : super.canSurvive(state, level, pos); + return isHanging(state) + ? level.getBlockState(pos.above()).is(WBBlocks.MANGROVE_LEAVES.get()) + : super.canSurvive(state, level, pos); } @Override - public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor level, BlockPos pos, BlockPos newPos) { - if (state.getValue(WATERLOGGED)) level.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(level)); - return direction == Direction.UP && !state.canSurvive(level, pos) ? Blocks.AIR.defaultBlockState() : super.updateShape(state, direction, newState, level, pos, newPos); + public BlockState updateShape( + BlockState state, + Direction direction, + BlockState newState, + LevelAccessor level, + BlockPos pos, + BlockPos newPos + ) { + if (state.getValue(WATERLOGGED)) + level.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(level)); + return direction == Direction.UP && !state.canSurvive(level, pos) + ? Blocks.AIR.defaultBlockState() + : super.updateShape(state, direction, newState, level, pos, newPos); } @Override @@ -81,30 +111,39 @@ public class MangrovePropaguleBlock extends SaplingBlock implements SimpleWaterl @Override public FluidState getFluidState(BlockState state) { - return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); + return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) + : super.getFluidState(state); } @Override - public void randomTick(BlockState state, ServerLevel level, BlockPos pos, Random random) { + public void + randomTick(BlockState state, ServerLevel level, BlockPos pos, Random random) { if (!isHanging(state)) { - if (random.nextInt(7) == 0) this.advanceTree(level, pos, state, random); + if (random.nextInt(7) == 0) + this.advanceTree(level, pos, state, random); } else { - if (!ageAtMax(state)) level.setBlock(pos, state.cycle(AGE), 2); + if (!ageAtMax(state)) + level.setBlock(pos, state.cycle(AGE), 2); } } @Override - public boolean isValidBonemealTarget(BlockGetter block, BlockPos pos, BlockState state, boolean flag) { + public boolean isValidBonemealTarget( + BlockGetter block, BlockPos pos, BlockState state, boolean flag + ) { return !isHanging(state) || !ageAtMax(state); } @Override - public boolean isBonemealSuccess(Level level, Random random, BlockPos pos, BlockState state) { - return isHanging(state) ? !ageAtMax(state) : super.isBonemealSuccess(level, random, pos, state); + public boolean + isBonemealSuccess(Level level, Random random, BlockPos pos, BlockState state) { + return isHanging(state) ? !ageAtMax(state) + : super.isBonemealSuccess(level, random, pos, state); } @Override - public void performBonemeal(ServerLevel level, Random random, BlockPos pos, BlockState state) { + public void + performBonemeal(ServerLevel level, Random random, BlockPos pos, BlockState state) { if (isHanging(state) && !ageAtMax(state)) { level.setBlock(pos, state.cycle(AGE), 2); } else { @@ -125,6 +164,9 @@ public class MangrovePropaguleBlock extends SaplingBlock implements SimpleWaterl } public static BlockState createPropagule(int age) { - return WBBlocks.MANGROVE_PROPAGULE.get().defaultBlockState().setValue(HANGING, true).setValue(AGE, age); + return WBBlocks.MANGROVE_PROPAGULE.get() + .defaultBlockState() + .setValue(HANGING, true) + .setValue(AGE, age); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/MangroveRootsBlock.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/MangroveRootsBlock.java index 5a1a05a..e5bc09f 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/MangroveRootsBlock.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/MangroveRootsBlock.java @@ -21,32 +21,50 @@ public class MangroveRootsBlock extends Block implements SimpleWaterloggedBlock public MangroveRootsBlock(BlockBehaviour.Properties properties) { super(properties); - this.registerDefaultState(this.stateDefinition.any().setValue(WATERLOGGED, false)); + this.registerDefaultState(this.stateDefinition.any().setValue(WATERLOGGED, false) + ); } @Override - public boolean skipRendering(BlockState state, BlockState stateFrom, Direction direction) { - return stateFrom.is(WBBlocks.MANGROVE_ROOTS.get()) && direction.getAxis() == Direction.Axis.Y; + public boolean + skipRendering(BlockState state, BlockState stateFrom, Direction direction) { + return stateFrom.is(WBBlocks.MANGROVE_ROOTS.get()) + && direction.getAxis() == Direction.Axis.Y; } - @Override @Nullable @SuppressWarnings("ConstantConditions") + @Override + @Nullable + @SuppressWarnings("ConstantConditions") public BlockState getStateForPlacement(BlockPlaceContext ctx) { - return super.getStateForPlacement(ctx).setValue(WATERLOGGED, ctx.getLevel().getFluidState(ctx.getClickedPos()).getType() == Fluids.WATER); + return super.getStateForPlacement(ctx).setValue( + WATERLOGGED, + ctx.getLevel().getFluidState(ctx.getClickedPos()).getType() == Fluids.WATER + ); } @Override - public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor level, BlockPos pos, BlockPos newPos) { - if (state.getValue(WATERLOGGED)) level.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(level)); + public BlockState updateShape( + BlockState state, + Direction direction, + BlockState newState, + LevelAccessor level, + BlockPos pos, + BlockPos newPos + ) { + if (state.getValue(WATERLOGGED)) + level.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(level)); return super.updateShape(state, direction, newState, level, pos, newPos); } @Override public FluidState getFluidState(BlockState state) { - return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); + return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) + : super.getFluidState(state); } @Override - protected void createBlockStateDefinition(StateDefinition.Builder builder) { + protected void + createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(WATERLOGGED); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/MangroveTreeGrower.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/MangroveTreeGrower.java index 0744c8e..922044f 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/MangroveTreeGrower.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/MangroveTreeGrower.java @@ -1,13 +1,13 @@ package com.cursedcauldron.wildbackport.common.blocks; +import java.util.Random; + import com.cursedcauldron.wildbackport.common.registry.worldgen.WBWorldGeneration; import net.minecraft.core.Holder; import net.minecraft.world.level.block.grower.AbstractTreeGrower; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import org.jetbrains.annotations.Nullable; -import java.util.Random; - public class MangroveTreeGrower extends AbstractTreeGrower { private final float tallChance; @@ -15,8 +15,11 @@ public class MangroveTreeGrower extends AbstractTreeGrower { this.tallChance = tallChance; } - @Override @Nullable - protected Holder> getConfiguredFeature(Random random, boolean bees) { - return random.nextFloat() < this.tallChance ? WBWorldGeneration.TALL_MANGROVE : WBWorldGeneration.MANGROVE; + @Override + @Nullable + protected Holder> + getConfiguredFeature(Random random, boolean bees) { + return random.nextFloat() < this.tallChance ? WBWorldGeneration.TALL_MANGROVE + : WBWorldGeneration.MANGROVE; } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/MudBlock.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/MudBlock.java index db091d8..01f3b1f 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/MudBlock.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/MudBlock.java @@ -10,29 +10,40 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; public class MudBlock extends Block { - private static final VoxelShape SHAPE = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 14.0D, 16.0D); + private static final VoxelShape SHAPE + = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 14.0D, 16.0D); public MudBlock(Properties properties) { super(properties); } @Override - public VoxelShape getBlockSupportShape(BlockState state, BlockGetter getter, BlockPos pos) { + public VoxelShape + getBlockSupportShape(BlockState state, BlockGetter getter, BlockPos pos) { return Shapes.block(); } @Override - public VoxelShape getVisualShape(BlockState state, BlockGetter getter, BlockPos pos, CollisionContext context) { + public VoxelShape getVisualShape( + BlockState state, BlockGetter getter, BlockPos pos, CollisionContext context + ) { return Shapes.block(); } @Override - public VoxelShape getCollisionShape(BlockState state, BlockGetter getter, BlockPos pos, CollisionContext context) { + public VoxelShape getCollisionShape( + BlockState state, BlockGetter getter, BlockPos pos, CollisionContext context + ) { return SHAPE; } @Override - public boolean isPathfindable(BlockState state, BlockGetter getter, BlockPos pos, PathComputationType pathComputation) { + public boolean isPathfindable( + BlockState state, + BlockGetter getter, + BlockPos pos, + PathComputationType pathComputation + ) { return false; } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/SculkBlock.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/SculkBlock.java index 2dfb13f..5aa0ad7 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/SculkBlock.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/SculkBlock.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.blocks; +import java.util.Random; + import com.cursedcauldron.wildbackport.common.registry.WBBlocks; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; @@ -15,15 +17,20 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.material.Fluids; -import java.util.Random; - public class SculkBlock extends OreBlock implements SculkSpreadable { public SculkBlock(Properties properties) { super(properties); } @Override - public int spread(SculkSpreadManager.Cursor cursor, LevelAccessor level, BlockPos pos, Random random, SculkSpreadManager manager, boolean shouldConvert) { + public int spread( + SculkSpreadManager.Cursor cursor, + LevelAccessor level, + BlockPos pos, + Random random, + SculkSpreadManager manager, + boolean shouldConvert + ) { int charge = cursor.getCharge(); if (charge != 0 && random.nextInt(manager.getSpreadChance()) == 0) { BlockPos blockPos = cursor.getPos(); @@ -32,41 +39,66 @@ public class SculkBlock extends OreBlock implements SculkSpreadable { int chance = manager.getExtraBlockChance(); if (random.nextInt(chance) < charge) { BlockPos growthPos = blockPos.above(); - BlockState state = this.getExtraBlockState(level, growthPos, random, manager.isWorldGen()); + BlockState state = this.getExtraBlockState( + level, growthPos, random, manager.isWorldGen() + ); level.setBlock(growthPos, state, 3); - level.playSound(null, blockPos, state.getSoundType().getPlaceSound(), SoundSource.BLOCKS, 1.0F, 1.0F); + level.playSound( + null, + blockPos, + state.getSoundType().getPlaceSound(), + SoundSource.BLOCKS, + 1.0F, + 1.0F + ); } return Math.max(0, charge - chance); } else { - return random.nextInt(manager.getDecayChance()) != 0 ? charge : charge - (inRange ? 1 : getDecay(manager, blockPos, pos, charge)); + return random.nextInt(manager.getDecayChance()) != 0 + ? charge + : charge - (inRange ? 1 : getDecay(manager, blockPos, pos, charge)); } } else { return charge; } } - private static int getDecay(SculkSpreadManager manager, BlockPos source, BlockPos target, int charge) { + private static int + getDecay(SculkSpreadManager manager, BlockPos source, BlockPos target, int charge) { int maxDistance = manager.getMaxDistance(); - float range = Mth.square((float)Math.sqrt(source.distSqr(target)) - (float)maxDistance); + float range + = Mth.square((float) Math.sqrt(source.distSqr(target)) - (float) maxDistance); int distance = Mth.square(24 - maxDistance); - float spread = Math.min(1.0F, range / (float)distance); - return Math.max(1, (int)((float)charge * spread * 0.5F)); + float spread = Math.min(1.0F, range / (float) distance); + return Math.max(1, (int) ((float) charge * spread * 0.5F)); } - private BlockState getExtraBlockState(LevelAccessor level, BlockPos pos, Random random, boolean isWorldGen) { - BlockState state = random.nextInt(11) == 0 ? WBBlocks.SCULK_SHRIEKER.get().defaultBlockState().setValue(SculkShriekerBlock.CAN_SUMMON, isWorldGen) : Blocks.SCULK_SENSOR.defaultBlockState(); - return state.hasProperty(BlockStateProperties.WATERLOGGED) && !level.getFluidState(pos).isEmpty() ? state.setValue(BlockStateProperties.WATERLOGGED, true) : state; + private BlockState getExtraBlockState( + LevelAccessor level, BlockPos pos, Random random, boolean isWorldGen + ) { + BlockState state = random.nextInt(11) == 0 + ? WBBlocks.SCULK_SHRIEKER.get().defaultBlockState().setValue( + SculkShriekerBlock.CAN_SUMMON, isWorldGen + ) + : Blocks.SCULK_SENSOR.defaultBlockState(); + return state.hasProperty(BlockStateProperties.WATERLOGGED) + && !level.getFluidState(pos).isEmpty() + ? state.setValue(BlockStateProperties.WATERLOGGED, true) + : state; } private static boolean shouldNotDecay(LevelAccessor level, BlockPos pos) { BlockState state = level.getBlockState(pos.above()); - if (state.isAir() || state.is(Blocks.WATER) && state.getFluidState().is(Fluids.WATER)) { + if (state.isAir() + || state.is(Blocks.WATER) && state.getFluidState().is(Fluids.WATER)) { int chance = 0; - for (BlockPos position : BlockPos.betweenClosed(pos.offset(-4, 0, -4), pos.offset(4, 2, 4))) { + for (BlockPos position : + BlockPos.betweenClosed(pos.offset(-4, 0, -4), pos.offset(4, 2, 4))) { BlockState growth = level.getBlockState(position); - if (growth.is(Blocks.SCULK_SENSOR) || growth.is(WBBlocks.SCULK_SHRIEKER.get())) { + if (growth.is(Blocks.SCULK_SENSOR) + || growth.is(WBBlocks.SCULK_SHRIEKER.get())) { ++chance; } @@ -82,8 +114,11 @@ public class SculkBlock extends OreBlock implements SculkSpreadable { } @Override - public void spawnAfterBreak(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack) { - if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, stack) == 0) this.popExperience(level, pos, 1); + public void + spawnAfterBreak(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack) { + if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, stack) + == 0) + this.popExperience(level, pos, 1); } @Override diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/SculkCatalystBlock.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/SculkCatalystBlock.java index d71c4fd..91cf083 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/SculkCatalystBlock.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/SculkCatalystBlock.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.blocks; +import java.util.Random; + import com.cursedcauldron.wildbackport.client.registry.WBParticleTypes; import com.cursedcauldron.wildbackport.client.registry.WBSoundEvents; import com.cursedcauldron.wildbackport.common.blocks.entity.SculkCatalystBlockEntity; @@ -23,8 +25,6 @@ import net.minecraft.world.level.block.state.properties.BooleanProperty; import net.minecraft.world.level.gameevent.GameEventListener; import org.jetbrains.annotations.Nullable; -import java.util.Random; - //<> public class SculkCatalystBlock extends BaseEntityBlock { @@ -36,35 +36,63 @@ public class SculkCatalystBlock extends BaseEntityBlock { } @Override - protected void createBlockStateDefinition(StateDefinition.Builder builder) { + protected void + createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(BLOOM); } @Override public void tick(BlockState state, ServerLevel level, BlockPos pos, Random random) { - if (state.getValue(BLOOM)) level.setBlock(pos, state.setValue(BLOOM, false), 3); + if (state.getValue(BLOOM)) + level.setBlock(pos, state.setValue(BLOOM, false), 3); } - public static void bloom(ServerLevel level, BlockPos pos, BlockState state, Random random) { + public static void + bloom(ServerLevel level, BlockPos pos, BlockState state, Random random) { level.setBlock(pos, state.setValue(BLOOM, true), 3); level.scheduleTick(pos, state.getBlock(), 8); - level.sendParticles(WBParticleTypes.SCULK_SOUL.get(), (double)pos.getX() + 0.5D, (double)pos.getY() + 1.15D, (double)pos.getZ() + 0.5D, 2, 0.2D, 0.0D, 0.2D, 0.0D); - level.playSound(null, pos, WBSoundEvents.BLOCK_SCULK_CATALYST_BLOOM, SoundSource.BLOCKS, 2.0F, 0.6F + random.nextFloat() * 0.4F); + level.sendParticles( + WBParticleTypes.SCULK_SOUL.get(), + (double) pos.getX() + 0.5D, + (double) pos.getY() + 1.15D, + (double) pos.getZ() + 0.5D, + 2, + 0.2D, + 0.0D, + 0.2D, + 0.0D + ); + level.playSound( + null, + pos, + WBSoundEvents.BLOCK_SCULK_CATALYST_BLOOM, + SoundSource.BLOCKS, + 2.0F, + 0.6F + random.nextFloat() * 0.4F + ); } - @Nullable @Override + @Nullable + @Override public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { return new SculkCatalystBlockEntity(pos, state); } - @Nullable @Override + @Nullable + @Override public GameEventListener getListener(Level level, T type) { return type instanceof SculkCatalystBlockEntity catalyst ? catalyst : null; } - @Nullable @Override - public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType type) { - return level.isClientSide ? null : createTickerHelper(type, WBBlockEntities.SCULK_CATALYST.get(), SculkCatalystBlockEntity::tick); + @Nullable + @Override + public BlockEntityTicker + getTicker(Level level, BlockState state, BlockEntityType type) { + return level.isClientSide + ? null + : createTickerHelper( + type, WBBlockEntities.SCULK_CATALYST.get(), SculkCatalystBlockEntity::tick + ); } @Override @@ -73,7 +101,10 @@ public class SculkCatalystBlock extends BaseEntityBlock { } @Override - public void spawnAfterBreak(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack) { - if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, stack) == 0) this.popExperience(level, pos, 5); + public void + spawnAfterBreak(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack) { + if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, stack) + == 0) + this.popExperience(level, pos, 5); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/SculkShriekerBlock.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/SculkShriekerBlock.java index a3b0c5d..a619c93 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/SculkShriekerBlock.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/SculkShriekerBlock.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.blocks; +import java.util.Random; + import com.cursedcauldron.wildbackport.common.blocks.entity.SculkShriekerBlockEntity; import com.cursedcauldron.wildbackport.common.registry.WBBlockEntities; import net.minecraft.core.BlockPos; @@ -32,24 +34,28 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; import org.jetbrains.annotations.Nullable; -import java.util.Random; - //<> -public class SculkShriekerBlock extends BaseEntityBlock implements SimpleWaterloggedBlock { +public class SculkShriekerBlock + extends BaseEntityBlock implements SimpleWaterloggedBlock { public static final BooleanProperty SHRIEKING = StateProperties.SHRIEKING; public static final BooleanProperty CAN_SUMMON = StateProperties.CAN_SUMMON; public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; - private static final VoxelShape SHAPE = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D); + private static final VoxelShape SHAPE + = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D); public static final double TOP_Y = SHAPE.max(Direction.Axis.Y); public SculkShriekerBlock(Properties properties) { super(properties); - this.registerDefaultState(this.stateDefinition.any().setValue(SHRIEKING, false).setValue(WATERLOGGED, false).setValue(CAN_SUMMON, false)); + this.registerDefaultState(this.stateDefinition.any() + .setValue(SHRIEKING, false) + .setValue(WATERLOGGED, false) + .setValue(CAN_SUMMON, false)); } @Override - protected void createBlockStateDefinition(StateDefinition.Builder builder) { + protected void + createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(SHRIEKING, WATERLOGGED, CAN_SUMMON); } @@ -58,7 +64,8 @@ public class SculkShriekerBlock extends BaseEntityBlock implements SimpleWaterlo if (level instanceof ServerLevel server) { ServerPlayer player = SculkShriekerBlockEntity.tryGetPlayer(entity); if (player != null) { - server.getBlockEntity(pos, WBBlockEntities.SCULK_SHRIEKER.get()).ifPresent(shrieker -> shrieker.tryShriek(server, player)); + server.getBlockEntity(pos, WBBlockEntities.SCULK_SHRIEKER.get()) + .ifPresent(shrieker -> shrieker.tryShriek(server, player)); } } @@ -66,10 +73,13 @@ public class SculkShriekerBlock extends BaseEntityBlock implements SimpleWaterlo } @Override - public void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean moving) { + public void onRemove( + BlockState state, Level level, BlockPos pos, BlockState newState, boolean moving + ) { if (level instanceof ServerLevel server) { if (state.getValue(SHRIEKING) && !state.is(newState.getBlock())) { - server.getBlockEntity(pos, WBBlockEntities.SCULK_SHRIEKER.get()).ifPresent(shrieker -> shrieker.tryRespond(server)); + server.getBlockEntity(pos, WBBlockEntities.SCULK_SHRIEKER.get()) + .ifPresent(shrieker -> shrieker.tryRespond(server)); } } @@ -80,7 +90,8 @@ public class SculkShriekerBlock extends BaseEntityBlock implements SimpleWaterlo public void tick(BlockState state, ServerLevel level, BlockPos pos, Random random) { if (state.getValue(SHRIEKING)) { level.setBlock(pos, state.setValue(SHRIEKING, false), 3); - level.getBlockEntity(pos, WBBlockEntities.SCULK_SHRIEKER.get()).ifPresent(shrieker -> shrieker.tryRespond(level)); + level.getBlockEntity(pos, WBBlockEntities.SCULK_SHRIEKER.get()) + .ifPresent(shrieker -> shrieker.tryRespond(level)); } } @@ -90,12 +101,15 @@ public class SculkShriekerBlock extends BaseEntityBlock implements SimpleWaterlo } @Override - public VoxelShape getCollisionShape(BlockState state, BlockGetter getter, BlockPos pos, CollisionContext context) { + public VoxelShape getCollisionShape( + BlockState state, BlockGetter getter, BlockPos pos, CollisionContext context + ) { return SHAPE; } @Override - public VoxelShape getOcclusionShape(BlockState state, BlockGetter getter, BlockPos pos) { + public VoxelShape + getOcclusionShape(BlockState state, BlockGetter getter, BlockPos pos) { return SHAPE; } @@ -104,39 +118,67 @@ public class SculkShriekerBlock extends BaseEntityBlock implements SimpleWaterlo return true; } - @Nullable @Override + @Nullable + @Override public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { return new SculkShriekerBlockEntity(pos, state); } @Override - public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor level, BlockPos pos, BlockPos newPos) { - if (state.getValue(WATERLOGGED)) level.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(level)); + public BlockState updateShape( + BlockState state, + Direction direction, + BlockState newState, + LevelAccessor level, + BlockPos pos, + BlockPos newPos + ) { + if (state.getValue(WATERLOGGED)) + level.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(level)); return super.updateShape(state, direction, newState, level, pos, newPos); } - @Nullable @Override + @Nullable + @Override public BlockState getStateForPlacement(BlockPlaceContext context) { - return this.defaultBlockState().setValue(WATERLOGGED, context.getLevel().getFluidState(context.getClickedPos()).getType() == Fluids.WATER); + return this.defaultBlockState().setValue( + WATERLOGGED, + context.getLevel().getFluidState(context.getClickedPos()).getType() + == Fluids.WATER + ); } @Override public FluidState getFluidState(BlockState state) { - return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); + return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) + : super.getFluidState(state); } @Override - public void spawnAfterBreak(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack) { - if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, stack) == 0) this.popExperience(level, pos, 5); + public void + spawnAfterBreak(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack) { + if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, stack) + == 0) + this.popExperience(level, pos, 5); } - @Nullable @Override + @Nullable + @Override public GameEventListener getListener(Level level, T type) { - return type instanceof SculkShriekerBlockEntity shrieker ? shrieker.getListener() : null; + return type instanceof SculkShriekerBlockEntity shrieker ? shrieker.getListener() + : null; } - @Nullable @Override - public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType type) { - return !level.isClientSide ? createTickerHelper(type, WBBlockEntities.SCULK_SHRIEKER.get(), (levelIn, posIn, stateIn, shrieker) -> shrieker.getListener().tick(levelIn)) : null; + @Nullable + @Override + public BlockEntityTicker + getTicker(Level level, BlockState state, BlockEntityType type) { + return !level.isClientSide ? createTickerHelper( + type, + WBBlockEntities.SCULK_SHRIEKER.get(), + (levelIn, posIn, stateIn, shrieker + ) -> shrieker.getListener().tick(levelIn) + ) + : null; } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/SculkSpreadManager.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/SculkSpreadManager.java index d0afe95..482ed5c 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/SculkSpreadManager.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/SculkSpreadManager.java @@ -1,5 +1,14 @@ package com.cursedcauldron.wildbackport.common.blocks; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Random; +import java.util.Set; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.client.particle.SculkChargeParticleOptions; import com.cursedcauldron.wildbackport.client.registry.WBParticleTypes; @@ -36,15 +45,6 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Random; -import java.util.Set; -import java.util.function.Supplier; - public class SculkSpreadManager { final boolean isWorldGen; private final TagKey replaceableBlocks; @@ -54,7 +54,14 @@ public class SculkSpreadManager { private final int decayChance; private List cursors = new ArrayList<>(); - public SculkSpreadManager(boolean isWorldGen, TagKey replaceableBlocks, int extraBlockChance, int maxDistance, int spreadChance, int decayChance) { + public SculkSpreadManager( + boolean isWorldGen, + TagKey replaceableBlocks, + int extraBlockChance, + int maxDistance, + int spreadChance, + int decayChance + ) { this.isWorldGen = isWorldGen; this.replaceableBlocks = replaceableBlocks; this.extraBlockChance = extraBlockChance; @@ -68,7 +75,9 @@ public class SculkSpreadManager { } public static SculkSpreadManager createWorldGen() { - return new SculkSpreadManager(true, WBBlockTags.SCULK_REPLACEABLE_WORLD_GEN, 50, 1, 5, 10); + return new SculkSpreadManager( + true, WBBlockTags.SCULK_REPLACEABLE_WORLD_GEN, 50, 1, 5, 10 + ); } public TagKey getReplaceableBlocks() { @@ -102,7 +111,11 @@ public class SculkSpreadManager { public void readTag(CompoundTag tag) { if (tag.contains("cursors", 9)) { this.cursors.clear(); - List cursors = Cursor.CODEC.listOf().parse(new Dynamic<>(NbtOps.INSTANCE, tag.getList("cursors", 10))).resultOrPartial(WildBackport.LOGGER::error).orElseGet(ArrayList::new); + List cursors + = Cursor.CODEC.listOf() + .parse(new Dynamic<>(NbtOps.INSTANCE, tag.getList("cursors", 10))) + .resultOrPartial(WildBackport.LOGGER::error) + .orElseGet(ArrayList::new); int size = Math.min(cursors.size(), 32); for (int i = 0; i < size; i++) { @@ -112,9 +125,10 @@ public class SculkSpreadManager { } public void writeTag(CompoundTag tag) { - Cursor.CODEC.listOf().encodeStart(NbtOps.INSTANCE, this.cursors).resultOrPartial(WildBackport.LOGGER::error).ifPresent(value -> { - tag.put("cursors", value); - }); + Cursor.CODEC.listOf() + .encodeStart(NbtOps.INSTANCE, this.cursors) + .resultOrPartial(WildBackport.LOGGER::error) + .ifPresent(value -> { tag.put("cursors", value); }); } public void spread(BlockPos pos, int charge) { @@ -131,7 +145,8 @@ public class SculkSpreadManager { } } - public void tick(LevelAccessor level, BlockPos pos, Random random, boolean shouldConvert) { + public void + tick(LevelAccessor level, BlockPos pos, Random random, boolean shouldConvert) { Level instance = level instanceof Level side ? side : null; if (!this.cursors.isEmpty()) { List cursors = new ArrayList<>(); @@ -144,7 +159,11 @@ public class SculkSpreadManager { applySculkCharge(instance, cursor.getPos(), 0); } else { BlockPos position = cursor.getPos(); - positions.computeInt(position, (blockPos, charge) -> (charge == null ? 0 : charge) + cursor.charge); + positions.computeInt( + position, + (blockPos, + charge) -> (charge == null ? 0 : charge) + cursor.charge + ); Cursor target = cursorPositions.get(position); if (target == null) { cursorPositions.put(position, cursor); @@ -166,8 +185,9 @@ public class SculkSpreadManager { Cursor cursor = cursorPositions.get(position); Set directions = cursor == null ? null : cursor.getFacings(); if (exp > 0 && directions != null) { - int charge = (int)(Math.log1p(exp) / (double)2.3F) + 1; - int data = (charge << 6) + SculkVeinBlock.directionsToFlag(directions); + int charge = (int) (Math.log1p(exp) / (double) 2.3F) + 1; + int data + = (charge << 6) + SculkVeinBlock.directionsToFlag(directions); applySculkCharge(instance, cursor.getPos(), data); } } @@ -177,27 +197,60 @@ public class SculkSpreadManager { } public static class Cursor { - private static final ObjectArrayList OFFSETS = Util.make(new ObjectArrayList<>(18), positions -> { - BlockPos.betweenClosedStream(new BlockPos(-1, -1, -1), new BlockPos(1, 1, 1)).filter(pos -> { - return (pos.getX() == 0 || pos.getY() == 0 || pos.getZ() == 0) && pos != BlockPos.ZERO; - }).map(BlockPos::immutable).forEach(positions::add); - }); + private static final ObjectArrayList OFFSETS + = Util.make(new ObjectArrayList<>(18), positions -> { + BlockPos + .betweenClosedStream( + new BlockPos(-1, -1, -1), new BlockPos(1, 1, 1) + ) + .filter(pos -> { + return (pos.getX() == 0 || pos.getY() == 0 || pos.getZ() == 0) + && pos != BlockPos.ZERO; + }) + .map(BlockPos::immutable) + .forEach(positions::add); + }); private BlockPos pos; private int charge; private int updateDelay; private int decayDelay; @Nullable private Set facings; - private static final Codec> DIRECTION_SET = Direction.CODEC.listOf().xmap(directions -> Sets.newEnumSet(directions, Direction.class), Lists::newArrayList); + private static final Codec> DIRECTION_SET + = Direction.CODEC.listOf().xmap( + directions + -> Sets.newEnumSet(directions, Direction.class), + Lists::newArrayList + ); public static final Codec CODEC = RecordCodecBuilder.create(instance -> { - return instance.group(BlockPos.CODEC.fieldOf("pos").forGetter(Cursor::getPos), Codec.intRange(0, 1000).fieldOf("charge").orElse(0).forGetter(Cursor::getCharge), Codec.intRange(0, 1).fieldOf("decay_delay").orElse(1).forGetter(Cursor::getDecayDelay), Codec.intRange(0, Integer.MAX_VALUE).fieldOf("update_delay").orElse(0).forGetter(cursor -> { - return cursor.updateDelay; - }), DIRECTION_SET.optionalFieldOf("facings").forGetter(cursor -> { - return Optional.ofNullable(cursor.getFacings()); - })).apply(instance, Cursor::new); + return instance + .group( + BlockPos.CODEC.fieldOf("pos").forGetter(Cursor::getPos), + Codec.intRange(0, 1000).fieldOf("charge").orElse(0).forGetter( + Cursor::getCharge + ), + Codec.intRange(0, 1) + .fieldOf("decay_delay") + .orElse(1) + .forGetter(Cursor::getDecayDelay), + Codec.intRange(0, Integer.MAX_VALUE) + .fieldOf("update_delay") + .orElse(0) + .forGetter(cursor -> { return cursor.updateDelay; }), + DIRECTION_SET.optionalFieldOf("facings").forGetter(cursor -> { + return Optional.ofNullable(cursor.getFacings()); + }) + ) + .apply(instance, Cursor::new); }); - private Cursor(BlockPos pos, int charge, int decayDelay, int updateDelay, Optional> facings) { + private Cursor( + BlockPos pos, + int charge, + int decayDelay, + int updateDelay, + Optional> facings + ) { this.pos = pos; this.charge = charge; this.decayDelay = decayDelay; @@ -238,31 +291,59 @@ public class SculkSpreadManager { } } - public void spread(LevelAccessor level, BlockPos pos, Random random, SculkSpreadManager spreadManager, boolean shouldConvert) { + public void spread( + LevelAccessor level, + BlockPos pos, + Random random, + SculkSpreadManager spreadManager, + boolean shouldConvert + ) { if (this.canSpread(level, pos, spreadManager.isWorldGen)) { if (this.updateDelay > 0) { --this.updateDelay; } else { BlockState state = level.getBlockState(this.pos); SculkSpreadable spreadable = getSpreadable(state); - if (shouldConvert && spreadable.spread(level, this.pos, state, this.facings, spreadManager.isWorldGen())) { + if (shouldConvert + && spreadable.spread( + level, + this.pos, + state, + this.facings, + spreadManager.isWorldGen() + )) { if (spreadable.shouldConvertToSpreadable()) { state = level.getBlockState(this.pos); spreadable = getSpreadable(state); } - level.playSound(null, this.pos, WBSoundEvents.BLOCK_SCULK_BREAK, SoundSource.BLOCKS, 1.0F, 1.0F); + level.playSound( + null, + this.pos, + WBSoundEvents.BLOCK_SCULK_BREAK, + SoundSource.BLOCKS, + 1.0F, + 1.0F + ); } - this.charge = spreadable.spread(this, level, pos, random, spreadManager, shouldConvert); + this.charge = spreadable.spread( + this, level, pos, random, spreadManager, shouldConvert + ); if (this.charge <= 0) { spreadable.spreadAtSamePosition(level, state, this.pos, random); } else { BlockPos target = getSpreadPos(level, this.pos, random); if (target != null) { - spreadable.spreadAtSamePosition(level, state, this.pos, random); + spreadable.spreadAtSamePosition( + level, state, this.pos, random + ); this.pos = target.immutable(); - if (spreadManager.isWorldGen() && !this.pos.closerThan(new Vec3i(pos.getX(), this.pos.getY(), pos.getZ()), 15.0D)) { + if (spreadManager.isWorldGen() + && !this.pos.closerThan( + new Vec3i(pos.getX(), this.pos.getY(), pos.getZ()), + 15.0D + )) { this.charge = 0; return; } @@ -288,7 +369,9 @@ public class SculkSpreadManager { } private static SculkSpreadable getSpreadable(BlockState state) { - return state.getBlock() instanceof SculkSpreadable spreadable ? spreadable : SculkSpreadable.DEFAULT; + return state.getBlock() instanceof SculkSpreadable spreadable + ? spreadable + : SculkSpreadable.DEFAULT; } private static List shuffleOffsets(Random random) { @@ -296,14 +379,16 @@ public class SculkSpreadManager { } @Nullable - private static BlockPos getSpreadPos(LevelAccessor level, BlockPos pos, Random random) { + private static BlockPos + getSpreadPos(LevelAccessor level, BlockPos pos, Random random) { BlockPos.MutableBlockPos target = pos.mutable(); BlockPos.MutableBlockPos source = pos.mutable(); for (Vec3i offset : shuffleOffsets(random)) { source.setWithOffset(pos, offset); BlockState state = level.getBlockState(source); - if (state.getBlock() instanceof SculkSpreadable && canSpread(level, pos, source)) { + if (state.getBlock() instanceof SculkSpreadable + && canSpread(level, pos, source)) { target.set(source); if (SculkVeinBlock.veinCoversSculkReplaceable(level, state, source)) { break; @@ -314,66 +399,128 @@ public class SculkSpreadManager { return target.equals(pos) ? null : target; } - private static boolean canSpread(LevelAccessor level, BlockPos source, BlockPos target) { + private static boolean + canSpread(LevelAccessor level, BlockPos source, BlockPos target) { if (source.distManhattan(target) == 1) { return true; } else { BlockPos pos = target.subtract(target); - Direction xAxis = Direction.fromAxisAndDirection(Direction.Axis.X, pos.getX() < 0 ? Direction.AxisDirection.NEGATIVE : Direction.AxisDirection.POSITIVE); - Direction yAxis = Direction.fromAxisAndDirection(Direction.Axis.Y, pos.getY() < 0 ? Direction.AxisDirection.NEGATIVE : Direction.AxisDirection.POSITIVE); - Direction zAxis = Direction.fromAxisAndDirection(Direction.Axis.Z, pos.getZ() < 0 ? Direction.AxisDirection.NEGATIVE : Direction.AxisDirection.POSITIVE); + Direction xAxis = Direction.fromAxisAndDirection( + Direction.Axis.X, + pos.getX() < 0 ? Direction.AxisDirection.NEGATIVE + : Direction.AxisDirection.POSITIVE + ); + Direction yAxis = Direction.fromAxisAndDirection( + Direction.Axis.Y, + pos.getY() < 0 ? Direction.AxisDirection.NEGATIVE + : Direction.AxisDirection.POSITIVE + ); + Direction zAxis = Direction.fromAxisAndDirection( + Direction.Axis.Z, + pos.getZ() < 0 ? Direction.AxisDirection.NEGATIVE + : Direction.AxisDirection.POSITIVE + ); if (pos.getX() == 0) { - return canSpread(level, source, yAxis) || canSpread(level, source, zAxis); + return canSpread(level, source, yAxis) + || canSpread(level, source, zAxis); } else if (pos.getY() == 0) { - return canSpread(level, source, xAxis) || canSpread(level, source, zAxis); + return canSpread(level, source, xAxis) + || canSpread(level, source, zAxis); } else { - return canSpread(level, source, xAxis) || canSpread(level, source, yAxis); + return canSpread(level, source, xAxis) + || canSpread(level, source, yAxis); } } } - private static boolean canSpread(LevelAccessor level, BlockPos pos, Direction direction) { + private static boolean + canSpread(LevelAccessor level, BlockPos pos, Direction direction) { BlockPos facing = pos.relative(direction); - return !level.getBlockState(facing).isFaceSturdy(level, facing, direction.getOpposite()); + return !level.getBlockState(facing).isFaceSturdy( + level, facing, direction.getOpposite() + ); } } public static void applySculkCharge(Level level, BlockPos pos, int data) { - if (level == null) return; + if (level == null) + return; Random random = level.getRandom(); - ClientLevel client = level.isClientSide() && level instanceof ClientLevel side ? side : null; + ClientLevel client + = level.isClientSide() && level instanceof ClientLevel side ? side : null; ServerLevel server = level instanceof ServerLevel side ? side : null; int charge = data >> 6; if (charge > 0) { - if (random.nextFloat() < (float)charge * 0.2F) { - float volume = 0.15F + 0.05F * (float)charge * (float)charge * random.nextFloat(); - float pitch = 0.4F * (float)charge - 0.2F * random.nextFloat(); - if (client != null) client.playLocalSound(pos, WBSoundEvents.BLOCK_SCULK_CHARGE, SoundSource.BLOCKS, volume, pitch, false); + if (random.nextFloat() < (float) charge * 0.2F) { + float volume = 0.15F + + 0.05F * (float) charge * (float) charge * random.nextFloat(); + float pitch = 0.4F * (float) charge - 0.2F * random.nextFloat(); + if (client != null) + client.playLocalSound( + pos, + WBSoundEvents.BLOCK_SCULK_CHARGE, + SoundSource.BLOCKS, + volume, + pitch, + false + ); } - int facings = (byte)(data & 63); + int facings = (byte) (data & 63); UniformInt spread = UniformInt.of(0, charge); Supplier velocities = () -> { - return new Vec3(Mth.nextDouble(random, -0.005D, 0.005D), Mth.nextDouble(random, -0.005D, 0.005D), Mth.nextDouble(random, -0.005D, 0.005D)); + return new Vec3( + Mth.nextDouble(random, -0.005D, 0.005D), + Mth.nextDouble(random, -0.005D, 0.005D), + Mth.nextDouble(random, -0.005D, 0.005D) + ); }; if (facings == 0) { for (Direction direction : Direction.values()) { - float roll = direction == Direction.DOWN ? (float)Math.PI : 0.0F; - double offset = direction == Direction.UP || direction == Direction.DOWN ? 0.32D : 0.57D; - ParticleUtils.spawnParticles(level, pos, new SculkChargeParticleOptions(roll), spread, direction, velocities, offset); + float roll = direction == Direction.DOWN ? (float) Math.PI : 0.0F; + double offset + = direction == Direction.UP || direction == Direction.DOWN + ? 0.32D + : 0.57D; + ParticleUtils.spawnParticles( + level, + pos, + new SculkChargeParticleOptions(roll), + spread, + direction, + velocities, + offset + ); } } else { - for (Direction direction : DirectionUtils.unpack((byte)data)) { - float roll = direction == Direction.UP ? (float)Math.PI : 0.0F; - ParticleUtils.spawnParticles(level, pos, new SculkChargeParticleOptions(roll), spread, direction, velocities, 0.35D); + for (Direction direction : DirectionUtils.unpack((byte) data)) { + float roll = direction == Direction.UP ? (float) Math.PI : 0.0F; + ParticleUtils.spawnParticles( + level, + pos, + new SculkChargeParticleOptions(roll), + spread, + direction, + velocities, + 0.35D + ); } } } else { - if (client != null) client.playLocalSound(pos, WBSoundEvents.BLOCK_SCULK_CHARGE, SoundSource.BLOCKS, 1.0F, 1.0F, false); - boolean fullBlock = level.getBlockState(pos).isCollisionShapeFullBlock(level, pos); + if (client != null) + client.playLocalSound( + pos, + WBSoundEvents.BLOCK_SCULK_CHARGE, + SoundSource.BLOCKS, + 1.0F, + 1.0F, + false + ); + boolean fullBlock + = level.getBlockState(pos).isCollisionShapeFullBlock(level, pos); int tries = fullBlock ? 40 : 20; float spread = fullBlock ? 0.45F : 0.25F; @@ -381,7 +528,18 @@ public class SculkSpreadManager { float x = 2.0F * random.nextFloat() - 1.0F; float y = 2.0F * random.nextFloat() - 1.0F; float z = 2.0F * random.nextFloat() - 1.0F; - if (server != null) server.sendParticles(WBParticleTypes.SCULK_CHARGE_POP.get(), (double)pos.getX() + 0.5D + (double)(x * spread), (double)pos.getY() + 0.5D + (double)(y * spread), (double)pos.getZ() + 0.5D + (double)(z * spread), 1, x * 0.07F, y * 0.07F, z * 0.07F, 0.0D); + if (server != null) + server.sendParticles( + WBParticleTypes.SCULK_CHARGE_POP.get(), + (double) pos.getX() + 0.5D + (double) (x * spread), + (double) pos.getY() + 0.5D + (double) (y * spread), + (double) pos.getZ() + 0.5D + (double) (z * spread), + 1, + x * 0.07F, + y * 0.07F, + z * 0.07F, + 0.0D + ); } } } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/SculkSpreadable.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/SculkSpreadable.java index 3544c91..df4089c 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/SculkSpreadable.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/SculkSpreadable.java @@ -1,5 +1,8 @@ package com.cursedcauldron.wildbackport.common.blocks; +import java.util.Collection; +import java.util.Random; + import com.cursedcauldron.wildbackport.common.registry.WBBlocks; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -8,24 +11,40 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluids; import org.jetbrains.annotations.Nullable; -import java.util.Collection; -import java.util.Random; - public interface SculkSpreadable { SculkSpreadable DEFAULT = new SculkSpreadable() { @Override - public boolean spread(LevelAccessor level, BlockPos pos, BlockState state, @Nullable Collection directions, boolean postProcess) { + public boolean spread( + LevelAccessor level, + BlockPos pos, + BlockState state, + @Nullable Collection directions, + boolean postProcess + ) { if (directions == null) { - return ((SculkVeinBlock)WBBlocks.SCULK_VEIN.get()).getSamePositionOnlyGrower().grow(level.getBlockState(pos), level, pos, postProcess) > 0L; - } else if(!directions.isEmpty()) { - return (state.isAir() || state.getFluidState().is(Fluids.WATER)) && SculkVeinBlock.place(level, pos, state, directions); + return ((SculkVeinBlock) WBBlocks.SCULK_VEIN.get()) + .getSamePositionOnlyGrower() + .grow(level.getBlockState(pos), level, pos, postProcess) + > 0L; + } else if (!directions.isEmpty()) { + return (state.isAir() || state.getFluidState().is(Fluids.WATER)) + && SculkVeinBlock.place(level, pos, state, directions); } else { - return SculkSpreadable.super.spread(level, pos, state, directions, postProcess); + return SculkSpreadable.super.spread( + level, pos, state, directions, postProcess + ); } } @Override - public int spread(SculkSpreadManager.Cursor cursor, LevelAccessor level, BlockPos pos, Random random, SculkSpreadManager spreadManager, boolean shouldConvert) { + public int spread( + SculkSpreadManager.Cursor cursor, + LevelAccessor level, + BlockPos pos, + Random random, + SculkSpreadManager spreadManager, + boolean shouldConvert + ) { return cursor.getDecayDelay() > 0 ? cursor.getCharge() : 0; } @@ -39,10 +58,21 @@ public interface SculkSpreadable { return 1; } - default void spreadAtSamePosition(LevelAccessor level, BlockState state, BlockPos pos, Random random) {} + default void spreadAtSamePosition( + LevelAccessor level, BlockState state, BlockPos pos, Random random + ) {} - default boolean spread(LevelAccessor level, BlockPos pos, BlockState state, @Nullable Collection directions, boolean postProcess) { - return ((SculkVeinBlock)WBBlocks.SCULK_VEIN.get()).getAllGrowTypeGrower().grow(state, level, pos, postProcess) > 0L; + default boolean spread( + LevelAccessor level, + BlockPos pos, + BlockState state, + @Nullable Collection directions, + boolean postProcess + ) { + return ((SculkVeinBlock) WBBlocks.SCULK_VEIN.get()) + .getAllGrowTypeGrower() + .grow(state, level, pos, postProcess) + > 0L; } default boolean shouldConvertToSpreadable() { @@ -53,5 +83,12 @@ public interface SculkSpreadable { return 1; } - int spread(SculkSpreadManager.Cursor cursor, LevelAccessor level, BlockPos pos, Random random, SculkSpreadManager manager, boolean shouldConvert); + int spread( + SculkSpreadManager.Cursor cursor, + LevelAccessor level, + BlockPos pos, + Random random, + SculkSpreadManager manager, + boolean shouldConvert + ); } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/SculkVeinBlock.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/SculkVeinBlock.java index 915fa44..8f330b3 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/SculkVeinBlock.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/SculkVeinBlock.java @@ -1,10 +1,15 @@ package com.cursedcauldron.wildbackport.common.blocks; +import java.util.Collection; +import java.util.EnumSet; +import java.util.Random; +import java.util.Set; + import com.cursedcauldron.wildbackport.client.registry.WBSoundEvents; -import com.cursedcauldron.wildbackport.common.worldgen.VeinGrower; import com.cursedcauldron.wildbackport.common.registry.WBBlocks; import com.cursedcauldron.wildbackport.common.tag.WBBlockTags; import com.cursedcauldron.wildbackport.common.utils.DirectionUtils; +import com.cursedcauldron.wildbackport.common.worldgen.VeinGrower; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; @@ -26,17 +31,15 @@ import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.Fluids; import net.minecraft.world.level.material.PushReaction; -import java.util.Collection; -import java.util.EnumSet; -import java.util.Random; -import java.util.Set; - //<> -public class SculkVeinBlock extends MultifaceBlock implements SculkSpreadable, SimpleWaterloggedBlock { +public class SculkVeinBlock + extends MultifaceBlock implements SculkSpreadable, SimpleWaterloggedBlock { private static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; - public final VeinGrower allGrowTypeGrower = new VeinGrower(new SculkVeinGrowChecker(VeinGrower.GROW_TYPES)); - private final VeinGrower samePositionOnlyGrower = new VeinGrower(new SculkVeinGrowChecker(VeinGrower.GrowType.SAME_POSITION)); + public final VeinGrower allGrowTypeGrower + = new VeinGrower(new SculkVeinGrowChecker(VeinGrower.GROW_TYPES)); + private final VeinGrower samePositionOnlyGrower + = new VeinGrower(new SculkVeinGrowChecker(VeinGrower.GrowType.SAME_POSITION)); public SculkVeinBlock(Properties properties) { super(properties); @@ -47,12 +50,16 @@ public class SculkVeinBlock extends MultifaceBlock implements SculkSpreadable, S return this.allGrowTypeGrower; } - public VeinGrower getSamePositionOnlyGrower() { return this.samePositionOnlyGrower; } - public static boolean place(LevelAccessor level, BlockPos pos, BlockState state, Collection directions) { + public static boolean place( + LevelAccessor level, + BlockPos pos, + BlockState state, + Collection directions + ) { boolean canPlace = false; BlockState veinState = WBBlocks.SCULK_VEIN.get().defaultBlockState(); @@ -77,11 +84,15 @@ public class SculkVeinBlock extends MultifaceBlock implements SculkSpreadable, S } @Override - public void spreadAtSamePosition(LevelAccessor level, BlockState state, BlockPos pos, Random random) { + public void spreadAtSamePosition( + LevelAccessor level, BlockState state, BlockPos pos, Random random + ) { if (state.is(this)) { for (Direction direction : DIRECTIONS) { BooleanProperty property = getFaceProperty(direction); - if (state.getValue(property) && level.getBlockState(pos.relative(direction)).is(WBBlocks.SCULK.get())) { + if (state.getValue(property) + && level.getBlockState(pos.relative(direction)) + .is(WBBlocks.SCULK.get())) { state = state.setValue(property, false); } } @@ -97,15 +108,27 @@ public class SculkVeinBlock extends MultifaceBlock implements SculkSpreadable, S } @Override - public int spread(SculkSpreadManager.Cursor cursor, LevelAccessor level, BlockPos pos, Random random, SculkSpreadManager spreadManager, boolean shouldConvert) { - if (shouldConvert && this.convertToBlock(spreadManager, level, cursor.getPos(), random)) { + public int spread( + SculkSpreadManager.Cursor cursor, + LevelAccessor level, + BlockPos pos, + Random random, + SculkSpreadManager spreadManager, + boolean shouldConvert + ) { + if (shouldConvert + && this.convertToBlock(spreadManager, level, cursor.getPos(), random)) { return cursor.getCharge() - 1; } else { - return random.nextInt(spreadManager.getSpreadChance()) == 0 ? Mth.floor((float)cursor.getCharge() * 0.5F) : cursor.getCharge(); + return random.nextInt(spreadManager.getSpreadChance()) == 0 + ? Mth.floor((float) cursor.getCharge() * 0.5F) + : cursor.getCharge(); } } - private boolean convertToBlock(SculkSpreadManager spreadManager, LevelAccessor level, BlockPos pos, Random random) { + private boolean convertToBlock( + SculkSpreadManager spreadManager, LevelAccessor level, BlockPos pos, Random random + ) { BlockState state = level.getBlockState(pos); TagKey replaceable = spreadManager.getReplaceableBlocks(); @@ -116,9 +139,19 @@ public class SculkVeinBlock extends MultifaceBlock implements SculkSpreadable, S if (blockState.is(replaceable)) { BlockState sculk = WBBlocks.SCULK.get().defaultBlockState(); level.setBlock(blockPos, sculk, 3); - if (level instanceof ServerLevel server) Block.pushEntitiesUp(blockState, sculk, server, pos); - level.playSound(null, blockPos, WBSoundEvents.BLOCK_SCULK_SPREAD, SoundSource.BLOCKS, 1.0F, 1.0F); - this.allGrowTypeGrower.grow(sculk, level, blockPos, spreadManager.isWorldGen()); + if (level instanceof ServerLevel server) + Block.pushEntitiesUp(blockState, sculk, server, pos); + level.playSound( + null, + blockPos, + WBSoundEvents.BLOCK_SCULK_SPREAD, + SoundSource.BLOCKS, + 1.0F, + 1.0F + ); + this.allGrowTypeGrower.grow( + sculk, level, blockPos, spreadManager.isWorldGen() + ); Direction opposite = direction.getOpposite(); for (Direction towards : DIRECTIONS) { @@ -126,7 +159,9 @@ public class SculkVeinBlock extends MultifaceBlock implements SculkSpreadable, S BlockPos targetPos = blockPos.relative(towards); BlockState targetState = level.getBlockState(targetPos); if (targetState.is(this)) { - this.spreadAtSamePosition(level, targetState, targetPos, random); + this.spreadAtSamePosition( + level, targetState, targetPos, random + ); } } } @@ -139,10 +174,13 @@ public class SculkVeinBlock extends MultifaceBlock implements SculkSpreadable, S return false; } - public static boolean veinCoversSculkReplaceable(LevelAccessor level, BlockState state, BlockPos pos) { + public static boolean + veinCoversSculkReplaceable(LevelAccessor level, BlockState state, BlockPos pos) { if (state.is(WBBlocks.SCULK_VEIN.get())) { for (Direction direction : DIRECTIONS) { - if (hasFace(state, direction) && level.getBlockState(pos.relative(direction)).is(WBBlockTags.SCULK_REPLACEABLE)) { + if (hasFace(state, direction) + && level.getBlockState(pos.relative(direction)) + .is(WBBlockTags.SCULK_REPLACEABLE)) { return true; } } @@ -151,8 +189,11 @@ public class SculkVeinBlock extends MultifaceBlock implements SculkSpreadable, S return false; } - public boolean canGrowWithDirection(BlockGetter getter, BlockState state, BlockPos pos, Direction direction) { - if (this.isFaceSupported(direction) && (!state.is(this) || !hasFace(state, direction))) { + public boolean canGrowWithDirection( + BlockGetter getter, BlockState state, BlockPos pos, Direction direction + ) { + if (this.isFaceSupported(direction) + && (!state.is(this) || !hasFace(state, direction))) { BlockPos blockPos = pos.relative(direction); return canGrowOn(getter, direction, blockPos, getter.getBlockState(blockPos)); } else { @@ -161,27 +202,39 @@ public class SculkVeinBlock extends MultifaceBlock implements SculkSpreadable, S } @Override - public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { + public BlockState updateShape( + BlockState state, + Direction direction, + BlockState neighborState, + LevelAccessor world, + BlockPos pos, + BlockPos neighborPos + ) { if (state.getValue(WATERLOGGED)) { world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); } - return super.updateShape(state, direction, neighborState, world, pos, neighborPos); + return super.updateShape( + state, direction, neighborState, world, pos, neighborPos + ); } @Override - protected void createBlockStateDefinition(StateDefinition.Builder builder) { + protected void + createBlockStateDefinition(StateDefinition.Builder builder) { super.createBlockStateDefinition(builder); builder.add(WATERLOGGED); } @Override public boolean canBeReplaced(BlockState state, BlockPlaceContext context) { - return !context.getItemInHand().is(WBBlocks.SCULK_VEIN.get().asItem()) || super.canBeReplaced(state, context); + return !context.getItemInHand().is(WBBlocks.SCULK_VEIN.get().asItem()) + || super.canBeReplaced(state, context); } @Override public FluidState getFluidState(BlockState state) { - return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); + return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) + : super.getFluidState(state); } @Override @@ -193,7 +246,7 @@ public class SculkVeinBlock extends MultifaceBlock implements SculkSpreadable, S byte flag = 0; for (Direction direction : directions) { - flag = (byte)(flag | 1 << direction.ordinal()); + flag = (byte) (flag | 1 << direction.ordinal()); } return flag; @@ -215,8 +268,14 @@ public class SculkVeinBlock extends MultifaceBlock implements SculkSpreadable, S } } - public static boolean canGrowOn(BlockGetter getter, Direction direction, BlockPos pos, BlockState state) { - return Block.isFaceFull(state.getBlockSupportShape(getter, pos), direction.getOpposite()) || Block.isFaceFull(state.getCollisionShape(getter, pos), direction.getOpposite()); + public static boolean + canGrowOn(BlockGetter getter, Direction direction, BlockPos pos, BlockState state) { + return Block.isFaceFull( + state.getBlockSupportShape(getter, pos), direction.getOpposite() + ) + || Block.isFaceFull( + state.getCollisionShape(getter, pos), direction.getOpposite() + ); } public static boolean hasFace(BlockState state, Direction direction) { @@ -233,21 +292,32 @@ public class SculkVeinBlock extends MultifaceBlock implements SculkSpreadable, S } @Override - public boolean canGrow(BlockGetter getter, BlockPos pos, BlockPos growPos, Direction direction, BlockState state) { + public boolean canGrow( + BlockGetter getter, + BlockPos pos, + BlockPos growPos, + Direction direction, + BlockState state + ) { BlockPos blockPos; BlockState blockState = getter.getBlockState(growPos.relative(direction)); - boolean flag = blockState.is(WBBlocks.SCULK.get()) || blockState.is(WBBlocks.SCULK_CATALYST.get()) || blockState.is(Blocks.MOVING_PISTON); + boolean flag = blockState.is(WBBlocks.SCULK.get()) + || blockState.is(WBBlocks.SCULK_CATALYST.get()) + || blockState.is(Blocks.MOVING_PISTON); if (flag) { return false; } - if (pos.distManhattan(growPos) == 2 && getter.getBlockState(blockPos = pos.relative(direction.getOpposite())).isFaceSturdy(getter, blockPos, direction)) { + if (pos.distManhattan(growPos) == 2 + && getter.getBlockState(blockPos = pos.relative(direction.getOpposite())) + .isFaceSturdy(getter, blockPos, direction)) { return false; } FluidState fluidState = state.getFluidState(); if (!fluidState.isEmpty() && !fluidState.is(Fluids.WATER)) { return false; } - return state.getMaterial().isReplaceable() || super.canGrow(getter, pos, growPos, direction, state); + return state.getMaterial().isReplaceable() + || super.canGrow(getter, pos, growPos, direction, state); } @Override diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/StateProperties.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/StateProperties.java index 6b39cc8..a0373d0 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/StateProperties.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/StateProperties.java @@ -9,21 +9,25 @@ import net.minecraft.world.level.block.state.properties.IntegerProperty; public class StateProperties { // Block Properties - public static final BooleanProperty SHRIEKING = BooleanProperty.create("shrieking"); - public static final BooleanProperty CAN_SUMMON = BooleanProperty.create("can_summon"); - public static final BooleanProperty BLOOM = BooleanProperty.create("bloom"); - public static final IntegerProperty AGE_4 = IntegerProperty.create("age", 0, 4); + public static final BooleanProperty SHRIEKING = BooleanProperty.create("shrieking"); + public static final BooleanProperty CAN_SUMMON = BooleanProperty.create("can_summon"); + public static final BooleanProperty BLOOM = BooleanProperty.create("bloom"); + public static final IntegerProperty AGE_4 = IntegerProperty.create("age", 0, 4); // Block values - public static boolean always(BlockState state, BlockGetter getter, BlockPos pos, EntityType type) { + public static boolean + always(BlockState state, BlockGetter getter, BlockPos pos, EntityType type) { return true; } - public static boolean never(BlockState state, BlockGetter getter, BlockPos pos, EntityType type) { + public static boolean + never(BlockState state, BlockGetter getter, BlockPos pos, EntityType type) { return false; } - public static boolean ocelotOrParrot(BlockState state, BlockGetter getter, BlockPos pos, EntityType entity) { + public static boolean ocelotOrParrot( + BlockState state, BlockGetter getter, BlockPos pos, EntityType entity + ) { return entity == EntityType.OCELOT || entity == EntityType.PARROT; } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/entity/SculkCatalystBlockEntity.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/entity/SculkCatalystBlockEntity.java index 1422a37..f43e698 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/entity/SculkCatalystBlockEntity.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/entity/SculkCatalystBlockEntity.java @@ -27,7 +27,8 @@ import org.jetbrains.annotations.Nullable; //<> public class SculkCatalystBlockEntity extends BlockEntity implements GameEventListener { - private final BlockPositionSource positionSource = new BlockPositionSource(this.worldPosition); + private final BlockPositionSource positionSource + = new BlockPositionSource(this.worldPosition); private final SculkSpreadManager spreadManager = SculkSpreadManager.create(); public SculkCatalystBlockEntity(BlockPos pos, BlockState state) { @@ -45,23 +46,39 @@ public class SculkCatalystBlockEntity extends BlockEntity implements GameEventLi } @Override - public boolean handleGameEvent(Level level, GameEvent event, @Nullable Entity entity, BlockPos pos) { + public boolean + handleGameEvent(Level level, GameEvent event, @Nullable Entity entity, BlockPos pos) { if (!this.isRemoved()) { if (event == WBGameEvents.ENTITY_DIE.get()) { - if (entity instanceof LivingEntity living && living instanceof EntityExperience mob) { + if (entity instanceof LivingEntity living + && living instanceof EntityExperience mob) { if (!mob.isExpDropDisabled()) { int charge = mob.getExpToDrop(); if (!living.isBaby() && charge > 0) { - this.spreadManager.spread(new BlockPos(PositionUtils.relative(PositionUtils.toVec(pos), Direction.UP, 0.5D)), charge); + this.spreadManager.spread( + new BlockPos(PositionUtils.relative( + PositionUtils.toVec(pos), Direction.UP, 0.5D + )), + charge + ); LivingEntity attacker = living.getLastHurtByMob(); if (attacker instanceof ServerPlayer player) { - DamageSource source = living.getLastDamageSource() == null ? DamageSource.playerAttack(player) : living.getLastDamageSource(); - WBCriteriaTriggers.KILL_MOB_NEAR_SCULK_CATALYST.trigger(player, entity, source); + DamageSource source = living.getLastDamageSource() == null + ? DamageSource.playerAttack(player) + : living.getLastDamageSource(); + WBCriteriaTriggers.KILL_MOB_NEAR_SCULK_CATALYST.trigger( + player, entity, source + ); } } mob.disableExpDrop(); - SculkCatalystBlock.bloom((ServerLevel) level, this.worldPosition, this.getBlockState(), level.getRandom()); + SculkCatalystBlock.bloom( + (ServerLevel) level, + this.worldPosition, + this.getBlockState(), + level.getRandom() + ); } return true; @@ -72,7 +89,8 @@ public class SculkCatalystBlockEntity extends BlockEntity implements GameEventLi return false; } - public static void tick(Level level, BlockPos pos, BlockState state, SculkCatalystBlockEntity catalyst) { + public static void + tick(Level level, BlockPos pos, BlockState state, SculkCatalystBlockEntity catalyst) { catalyst.spreadManager.tick(level, pos, level.getRandom(), true); } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/entity/SculkShriekerBlockEntity.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/entity/SculkShriekerBlockEntity.java index 397495b..7389c5e 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/entity/SculkShriekerBlockEntity.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/blocks/entity/SculkShriekerBlockEntity.java @@ -1,11 +1,13 @@ package com.cursedcauldron.wildbackport.common.blocks.entity; +import java.util.OptionalInt; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.client.particle.ShriekParticleOptions; import com.cursedcauldron.wildbackport.client.registry.WBSoundEvents; import com.cursedcauldron.wildbackport.common.blocks.SculkShriekerBlock; -import com.cursedcauldron.wildbackport.common.entities.warden.VibrationHandler; import com.cursedcauldron.wildbackport.common.entities.Warden; +import com.cursedcauldron.wildbackport.common.entities.warden.VibrationHandler; import com.cursedcauldron.wildbackport.common.entities.warden.WardenSpawnHelper; import com.cursedcauldron.wildbackport.common.entities.warden.WardenSpawnTracker; import com.cursedcauldron.wildbackport.common.registry.WBBlockEntities; @@ -38,19 +40,21 @@ import net.minecraft.world.level.gameevent.GameEventListener; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.Nullable; -import java.util.OptionalInt; - //<> -public class SculkShriekerBlockEntity extends BlockEntity implements VibrationHandler.VibrationConfig { - private static final Int2ObjectMap SOUND_BY_LEVEL = Util.make(new Int2ObjectOpenHashMap<>(), map -> { - map.put(1, WBSoundEvents.WARDEN_NEARBY_CLOSE); - map.put(2, WBSoundEvents.WARDEN_NEARBY_CLOSER); - map.put(3, WBSoundEvents.WARDEN_NEARBY_CLOSEST); - map.put(4, WBSoundEvents.WARDEN_LISTENING_ANGRY); - }); +public class SculkShriekerBlockEntity + extends BlockEntity implements VibrationHandler.VibrationConfig { + private static final Int2ObjectMap SOUND_BY_LEVEL + = Util.make(new Int2ObjectOpenHashMap<>(), map -> { + map.put(1, WBSoundEvents.WARDEN_NEARBY_CLOSE); + map.put(2, WBSoundEvents.WARDEN_NEARBY_CLOSER); + map.put(3, WBSoundEvents.WARDEN_NEARBY_CLOSEST); + map.put(4, WBSoundEvents.WARDEN_LISTENING_ANGRY); + }); private int warningLevel; - private VibrationHandler listener = new VibrationHandler(new BlockPositionSource(this.worldPosition), 8, this, null, 0.0F, 0); + private VibrationHandler listener = new VibrationHandler( + new BlockPositionSource(this.worldPosition), 8, this, null, 0.0F, 0 + ); public SculkShriekerBlockEntity(BlockPos pos, BlockState state) { super(WBBlockEntities.SCULK_SHRIEKER.get(), pos, state); @@ -68,7 +72,10 @@ public class SculkShriekerBlockEntity extends BlockEntity implements VibrationHa } if (tag.contains("listener", 10)) { - VibrationHandler.codec(this).parse(new Dynamic<>(NbtOps.INSTANCE, tag.getCompound("listener"))).resultOrPartial(WildBackport.LOGGER::error).ifPresent(listener -> this.listener = listener); + VibrationHandler.codec(this) + .parse(new Dynamic<>(NbtOps.INSTANCE, tag.getCompound("listener"))) + .resultOrPartial(WildBackport.LOGGER::error) + .ifPresent(listener -> this.listener = listener); } } @@ -76,7 +83,10 @@ public class SculkShriekerBlockEntity extends BlockEntity implements VibrationHa protected void saveAdditional(CompoundTag tag) { super.saveAdditional(tag); tag.putInt("warning_level", this.warningLevel); - VibrationHandler.codec(this).encodeStart(NbtOps.INSTANCE, this.listener).resultOrPartial(WildBackport.LOGGER::error).ifPresent(listener -> tag.put("listener", listener)); + VibrationHandler.codec(this) + .encodeStart(NbtOps.INSTANCE, this.listener) + .resultOrPartial(WildBackport.LOGGER::error) + .ifPresent(listener -> tag.put("listener", listener)); } @Override @@ -85,8 +95,16 @@ public class SculkShriekerBlockEntity extends BlockEntity implements VibrationHa } @Override - public boolean shouldListen(ServerLevel level, GameEventListener listener, BlockPos pos, GameEvent event, @Nullable Entity entity) { - return !this.isRemoved() && !this.getBlockState().getValue(SculkShriekerBlock.SHRIEKING) && tryGetPlayer(entity) != null; + public boolean shouldListen( + ServerLevel level, + GameEventListener listener, + BlockPos pos, + GameEvent event, + @Nullable Entity entity + ) { + return !this.isRemoved() + && !this.getBlockState().getValue(SculkShriekerBlock.SHRIEKING) + && tryGetPlayer(entity) != null; } @Nullable @@ -113,7 +131,15 @@ public class SculkShriekerBlockEntity extends BlockEntity implements VibrationHa } @Override - public void onSignalReceive(ServerLevel level, GameEventListener listener, BlockPos pos, GameEvent event, @Nullable Entity entity, @Nullable Entity source, float distance) { + public void onSignalReceive( + ServerLevel level, + GameEventListener listener, + BlockPos pos, + GameEvent event, + @Nullable Entity entity, + @Nullable Entity source, + float distance + ) { this.tryShriek(level, tryGetPlayer(source != null ? source : entity)); } @@ -130,7 +156,8 @@ public class SculkShriekerBlockEntity extends BlockEntity implements VibrationHa } private boolean tryToWarn(ServerLevel level, ServerPlayer player) { - OptionalInt warning = WardenSpawnTracker.tryWarn(level, this.getBlockPos(), player); + OptionalInt warning + = WardenSpawnTracker.tryWarn(level, this.getBlockPos(), player); warning.ifPresent(warningLevel -> this.warningLevel = warningLevel); return warning.isPresent(); } @@ -141,17 +168,38 @@ public class SculkShriekerBlockEntity extends BlockEntity implements VibrationHa level.setBlock(pos, state.setValue(SculkShriekerBlock.SHRIEKING, true), 2); level.scheduleTick(pos, state.getBlock(), 90); - level.playSound(null, pos.getX(), pos.getY(), pos.getZ(), WBSoundEvents.BLOCK_SCULK_SHRIEKER_SHRIEK, SoundSource.BLOCKS, 2.0F, 0.6F + level.random.nextFloat() * 0.4F); + level.playSound( + null, + pos.getX(), + pos.getY(), + pos.getZ(), + WBSoundEvents.BLOCK_SCULK_SHRIEKER_SHRIEK, + SoundSource.BLOCKS, + 2.0F, + 0.6F + level.random.nextFloat() * 0.4F + ); for (int i = 0; i < 10; i++) { int delay = i * 5; - level.sendParticles(new ShriekParticleOptions(delay), pos.getX() + 0.5D, pos.getY() + SculkShriekerBlock.TOP_Y, pos.getZ() + 0.5D, 1, 0.0D, 0.0D, 0.0D, 0.0D); + level.sendParticles( + new ShriekParticleOptions(delay), + pos.getX() + 0.5D, + pos.getY() + SculkShriekerBlock.TOP_Y, + pos.getZ() + 0.5D, + 1, + 0.0D, + 0.0D, + 0.0D, + 0.0D + ); } level.gameEvent(entity, WBGameEvents.SHRIEK.get(), pos); } private boolean canRespond(ServerLevel level) { - return this.getBlockState().getValue(SculkShriekerBlock.CAN_SUMMON) && level.getDifficulty() != Difficulty.PEACEFUL && level.getGameRules().getBoolean(WBGameRules.DO_WARDEN_SPAWNING); + return this.getBlockState().getValue(SculkShriekerBlock.CAN_SUMMON) + && level.getDifficulty() != Difficulty.PEACEFUL + && level.getGameRules().getBoolean(WBGameRules.DO_WARDEN_SPAWNING); } public void tryRespond(ServerLevel level) { @@ -160,7 +208,9 @@ public class SculkShriekerBlockEntity extends BlockEntity implements VibrationHa this.playWardenReplySound(); } - Warden.addDarknessToClosePlayers(level, Vec3.atCenterOf(this.getBlockPos()), null, 40); + Warden.addDarknessToClosePlayers( + level, Vec3.atCenterOf(this.getBlockPos()), null, 40 + ); } } @@ -176,7 +226,18 @@ public class SculkShriekerBlockEntity extends BlockEntity implements VibrationHa } private boolean trySummonWarden(ServerLevel level) { - return this.warningLevel >= 4 && WardenSpawnHelper.trySpawnMob(WBEntityTypes.WARDEN.get(), MobSpawnType.TRIGGERED, level, this.getBlockPos(), 20, 5, 6).isPresent(); + return this.warningLevel >= 4 + && WardenSpawnHelper + .trySpawnMob( + WBEntityTypes.WARDEN.get(), + MobSpawnType.TRIGGERED, + level, + this.getBlockPos(), + 20, + 5, + 6 + ) + .isPresent(); } @Override diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/effects/EffectFactor.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/effects/EffectFactor.java index da5b1fa..afa47f9 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/effects/EffectFactor.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/effects/EffectFactor.java @@ -1,15 +1,15 @@ package com.cursedcauldron.wildbackport.common.effects; +import java.util.Optional; +import java.util.function.Supplier; + import net.minecraft.network.protocol.Packet; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffectInstance; -import java.util.Optional; -import java.util.function.Supplier; - public interface EffectFactor { static EffectFactor of(MobEffect effect) { - return (EffectFactor)effect; + return (EffectFactor) effect; } MobEffect setFactorCalculationData(Supplier data); @@ -22,7 +22,7 @@ public interface EffectFactor { interface Instance { static Instance of(MobEffectInstance instance) { - return (Instance)instance; + return (Instance) instance; } void setFactorCalculationData(Optional data); @@ -32,7 +32,7 @@ public interface EffectFactor { interface Network { static Network of(Packet packet) { - return (Network)packet; + return (Network) packet; } FactorCalculationData getFactorCalculationData(); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/effects/FactorCalculationData.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/effects/FactorCalculationData.java index 04794ac..8205d31 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/effects/FactorCalculationData.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/effects/FactorCalculationData.java @@ -8,23 +8,34 @@ import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.entity.LivingEntity; public class FactorCalculationData { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> { - return instance.group(ExtraCodecs.NON_NEGATIVE_INT.fieldOf("padding_duration").forGetter(data -> { - return data.paddingDuration; - }), Codec.FLOAT.fieldOf("factor_start").orElse(0.0F).forGetter(data -> { - return data.factorStart; - }), Codec.FLOAT.fieldOf("factor_target").orElse(1.0F).forGetter(data -> { - return data.factorTarget; - }), Codec.FLOAT.fieldOf("factor_current").orElse(0.0F).forGetter(data -> { - return data.factorCurrent; - }), ExtraCodecs.NON_NEGATIVE_INT.fieldOf("effect_changed_timestamp").orElse(0).forGetter(data -> { - return data.effectChangedTimestamp; - }), Codec.FLOAT.fieldOf("factor_previous_frame").orElse(0.0F).forGetter(data -> { - return data.factorPreviousFrame; - }), Codec.BOOL.fieldOf("had_effect_last_tick").orElse(false).forGetter(data -> { - return data.hadEffectLastTick; - })).apply(instance, FactorCalculationData::new); - }); + public static final Codec CODEC = RecordCodecBuilder.create( + instance -> { + return instance + .group( + ExtraCodecs.NON_NEGATIVE_INT.fieldOf("padding_duration") + .forGetter(data -> { return data.paddingDuration; }), + Codec.FLOAT.fieldOf("factor_start").orElse(0.0F).forGetter(data -> { + return data.factorStart; + }), + Codec.FLOAT.fieldOf("factor_target").orElse(1.0F).forGetter(data -> { + return data.factorTarget; + }), + Codec.FLOAT.fieldOf("factor_current").orElse(0.0F).forGetter(data -> { + return data.factorCurrent; + }), + ExtraCodecs.NON_NEGATIVE_INT.fieldOf("effect_changed_timestamp") + .orElse(0) + .forGetter(data -> { return data.effectChangedTimestamp; }), + Codec.FLOAT.fieldOf("factor_previous_frame") + .orElse(0.0F) + .forGetter(data -> { return data.factorPreviousFrame; }), + Codec.BOOL.fieldOf("had_effect_last_tick") + .orElse(false) + .forGetter(data -> { return data.hadEffectLastTick; }) + ) + .apply(instance, FactorCalculationData::new); + } + ); private final int paddingDuration; private float factorStart; private float factorTarget; @@ -33,7 +44,15 @@ public class FactorCalculationData { private float factorPreviousFrame; private boolean hadEffectLastTick; - public FactorCalculationData(int paddingDuration, float factorStart, float factorTarget, float factorCurrent, int effectChangedTimestamp, float factorPreviousFrame, boolean hadEffectLastTick) { + public FactorCalculationData( + int paddingDuration, + float factorStart, + float factorTarget, + float factorCurrent, + int effectChangedTimestamp, + float factorPreviousFrame, + boolean hadEffectLastTick + ) { this.paddingDuration = paddingDuration; this.factorStart = factorStart; this.factorTarget = factorTarget; @@ -58,12 +77,18 @@ public class FactorCalculationData { this.factorTarget = inRange ? 1.0F : 0.0F; } - float delta = Mth.clamp(((float)this.effectChangedTimestamp - (float)instance.getDuration()) / (float)this.paddingDuration, 0.0F, 1.0F); + float delta = Mth.clamp( + ((float) this.effectChangedTimestamp - (float) instance.getDuration()) + / (float) this.paddingDuration, + 0.0F, + 1.0F + ); this.factorCurrent = Mth.lerp(delta, this.factorCurrent, this.factorTarget); } public float lerp(LivingEntity entity, float factor) { - if (entity.isRemoved()) this.factorPreviousFrame = this.factorCurrent; + if (entity.isRemoved()) + this.factorPreviousFrame = this.factorCurrent; return Mth.lerp(factor, this.factorPreviousFrame, this.factorCurrent); } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/Allay.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/Allay.java index 0234721..81cd0b6 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/Allay.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/Allay.java @@ -1,5 +1,9 @@ package com.cursedcauldron.wildbackport.common.entities; +import java.util.List; +import java.util.Optional; +import java.util.UUID; + import com.cursedcauldron.wildbackport.client.registry.WBSoundEvents; import com.cursedcauldron.wildbackport.common.entities.brain.AllayBrain; import com.cursedcauldron.wildbackport.common.registry.entity.WBMemoryModules; @@ -46,16 +50,48 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.Nullable; -import java.util.List; -import java.util.Optional; -import java.util.UUID; - //<> public class Allay extends PathfinderMob implements InventoryCarrier { - protected static final ImmutableList>> SENSORS = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.HURT_BY, SensorType.NEAREST_ITEMS); - protected static final ImmutableList> MEMORIES = ImmutableList.of(MemoryModuleType.PATH, MemoryModuleType.LOOK_TARGET, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.HURT_BY, MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, WBMemoryModules.LIKED_PLAYER.get(), WBMemoryModules.LIKED_NOTEBLOCK.get(), WBMemoryModules.LIKED_NOTEBLOCK_COOLDOWN_TICKS.get(), WBMemoryModules.ITEM_PICKUP_COOLDOWN_TICKS.get()); - public static final ImmutableList THROW_SOUND_PITCHES = ImmutableList.of(0.5625F, 0.625F, 0.75F, 0.9375F, 1.0F, 1.0F, 1.125F, 1.25F, 1.5F, 1.875F, 2.0F, 2.25F, 2.5F, 3.0F, 3.75F, 4.0F); + protected static final + ImmutableList>> SENSORS + = ImmutableList.of( + SensorType.NEAREST_LIVING_ENTITIES, + SensorType.NEAREST_PLAYERS, + SensorType.HURT_BY, + SensorType.NEAREST_ITEMS + ); + protected static final ImmutableList> MEMORIES = ImmutableList.of( + MemoryModuleType.PATH, + MemoryModuleType.LOOK_TARGET, + MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, + MemoryModuleType.WALK_TARGET, + MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, + MemoryModuleType.HURT_BY, + MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, + WBMemoryModules.LIKED_PLAYER.get(), + WBMemoryModules.LIKED_NOTEBLOCK.get(), + WBMemoryModules.LIKED_NOTEBLOCK_COOLDOWN_TICKS.get(), + WBMemoryModules.ITEM_PICKUP_COOLDOWN_TICKS.get() + ); + public static final ImmutableList THROW_SOUND_PITCHES = ImmutableList.of( + 0.5625F, + 0.625F, + 0.75F, + 0.9375F, + 1.0F, + 1.0F, + 1.125F, + 1.25F, + 1.5F, + 1.875F, + 2.0F, + 2.25F, + 2.5F, + 3.0F, + 3.75F, + 4.0F + ); private final SimpleContainer inventory = new SimpleContainer(1); private float holdingTicks; private float holdingTicksOld; @@ -76,13 +112,19 @@ public class Allay extends PathfinderMob implements InventoryCarrier { return AllayBrain.create(this.brainProvider().makeBrain(dynamic)); } - @Override @SuppressWarnings("unchecked") + @Override + @SuppressWarnings("unchecked") public Brain getBrain() { - return (Brain)super.getBrain(); + return (Brain) super.getBrain(); } public static AttributeSupplier.Builder createAttributes() { - return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 20.0D).add(Attributes.FLYING_SPEED, 0.1F).add(Attributes.MOVEMENT_SPEED, 0.1F).add(Attributes.ATTACK_DAMAGE, 2.0D).add(Attributes.FOLLOW_RANGE, 48.0D); + return Mob.createMobAttributes() + .add(Attributes.MAX_HEALTH, 20.0D) + .add(Attributes.FLYING_SPEED, 0.1F) + .add(Attributes.MOVEMENT_SPEED, 0.1F) + .add(Attributes.ATTACK_DAMAGE, 2.0D) + .add(Attributes.FOLLOW_RANGE, 48.0D); } @Override @@ -121,15 +163,18 @@ public class Allay extends PathfinderMob implements InventoryCarrier { } @Override - public boolean causeFallDamage(float fallDistance, float damageMultiplier, DamageSource source) { + public boolean + causeFallDamage(float fallDistance, float damageMultiplier, DamageSource source) { return false; } @Override public boolean hurt(DamageSource source, float amount) { if (source.getEntity() instanceof Player player) { - Optional likedPlayer = this.getBrain().getMemory(WBMemoryModules.LIKED_PLAYER.get()); - if (likedPlayer.isPresent() && player.getUUID().equals(likedPlayer.get())) return false; + Optional likedPlayer + = this.getBrain().getMemory(WBMemoryModules.LIKED_PLAYER.get()); + if (likedPlayer.isPresent() && player.getUUID().equals(likedPlayer.get())) + return false; } return super.hurt(source, amount); @@ -139,19 +184,26 @@ public class Allay extends PathfinderMob implements InventoryCarrier { protected void playStepSound(BlockPos pos, BlockState state) {} @Override - protected void checkFallDamage(double fallenDistance, boolean canLand, BlockState state, BlockPos pos) {} + protected void checkFallDamage( + double fallenDistance, boolean canLand, BlockState state, BlockPos pos + ) {} - @Override @Nullable + @Override + @Nullable protected SoundEvent getAmbientSound() { - return this.hasItemInSlot(EquipmentSlot.MAINHAND) ? WBSoundEvents.ALLAY_AMBIENT_WITH_ITEM : WBSoundEvents.ALLAY_AMBIENT_WITHOUT_ITEM; + return this.hasItemInSlot(EquipmentSlot.MAINHAND) + ? WBSoundEvents.ALLAY_AMBIENT_WITH_ITEM + : WBSoundEvents.ALLAY_AMBIENT_WITHOUT_ITEM; } - @Override @Nullable + @Override + @Nullable protected SoundEvent getHurtSound(DamageSource source) { return WBSoundEvents.ALLAY_HURT; } - @Override @Nullable + @Override + @Nullable protected SoundEvent getDeathSound() { return WBSoundEvents.ALLAY_DEATH; } @@ -164,16 +216,22 @@ public class Allay extends PathfinderMob implements InventoryCarrier { @Override protected void customServerAiStep() { this.level.getProfiler().push("allayBrain"); - this.getBrain().tick((ServerLevel)this.level, this); + this.getBrain().tick((ServerLevel) this.level, this); this.level.getProfiler().pop(); this.level.getProfiler().push("allayActivityUpdate"); AllayBrain.updateActivities(this); this.level.getProfiler().pop(); this.level.getProfiler().push("looting"); - if (!this.level.isClientSide && this.canPickUpLoot() && this.isAlive() && !this.dead && this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { - List items = this.level.getEntitiesOfClass(ItemEntity.class, this.getBoundingBox().inflate(1.0, 1.0, 1.0)); + if (!this.level.isClientSide && this.canPickUpLoot() && this.isAlive() + && !this.dead + && this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + List items = this.level.getEntitiesOfClass( + ItemEntity.class, this.getBoundingBox().inflate(1.0, 1.0, 1.0) + ); for (ItemEntity item : items) { - if (item.isRemoved() || item.getItem().isEmpty() || item.hasPickUpDelay() || !this.wantsToPickUp(item.getItem())) continue; + if (item.isRemoved() || item.getItem().isEmpty() || item.hasPickUpDelay() + || !this.wantsToPickUp(item.getItem())) + continue; this.pickUpItem(item); } } @@ -184,7 +242,8 @@ public class Allay extends PathfinderMob implements InventoryCarrier { @Override public void aiStep() { super.aiStep(); - if (!this.level.isClientSide && this.isAlive() && this.tickCount % 10 == 0) this.heal(1.0F); + if (!this.level.isClientSide && this.isAlive() && this.tickCount % 10 == 0) + this.heal(1.0F); } @Override @@ -215,7 +274,9 @@ public class Allay extends PathfinderMob implements InventoryCarrier { } private boolean isOnItemPickupCooldown() { - return this.getBrain().checkMemory(WBMemoryModules.ITEM_PICKUP_COOLDOWN_TICKS.get(), MemoryStatus.VALUE_PRESENT); + return this.getBrain().checkMemory( + WBMemoryModules.ITEM_PICKUP_COOLDOWN_TICKS.get(), MemoryStatus.VALUE_PRESENT + ); } @Override @@ -226,15 +287,33 @@ public class Allay extends PathfinderMob implements InventoryCarrier { ItemStack stack = playerStack.copy(); stack.setCount(1); this.setItemInHand(InteractionHand.MAIN_HAND, stack); - if (!player.getAbilities().instabuild) playerStack.shrink(1); - this.level.playSound(player, this, WBSoundEvents.ALLAY_ITEM_GIVEN, SoundSource.NEUTRAL, 2.0F, 1.0F); - this.getBrain().setMemory(WBMemoryModules.LIKED_PLAYER.get(), player.getUUID()); + if (!player.getAbilities().instabuild) + playerStack.shrink(1); + this.level.playSound( + player, + this, + WBSoundEvents.ALLAY_ITEM_GIVEN, + SoundSource.NEUTRAL, + 2.0F, + 1.0F + ); + this.getBrain().setMemory( + WBMemoryModules.LIKED_PLAYER.get(), player.getUUID() + ); return InteractionResult.SUCCESS; } else if (!allayStack.isEmpty() && hand == InteractionHand.MAIN_HAND && playerStack.isEmpty()) { this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY); - this.level.playSound(player, this, WBSoundEvents.ALLAY_ITEM_TAKEN, SoundSource.NEUTRAL, 2.0F, 1.0F); + this.level.playSound( + player, + this, + WBSoundEvents.ALLAY_ITEM_TAKEN, + SoundSource.NEUTRAL, + 2.0F, + 1.0F + ); this.swing(InteractionHand.MAIN_HAND); - for (ItemStack stack : this.getInventory().removeAllItems()) BehaviorUtils.throwItem(this, stack, this.position()); + for (ItemStack stack : this.getInventory().removeAllItems()) + BehaviorUtils.throwItem(this, stack, this.position()); this.getBrain().eraseMemory(WBMemoryModules.LIKED_PLAYER.get()); player.addItem(allayStack); return InteractionResult.SUCCESS; @@ -251,7 +330,8 @@ public class Allay extends PathfinderMob implements InventoryCarrier { @Override public boolean wantsToPickUp(ItemStack stack) { ItemStack heldItem = this.getItemInHand(InteractionHand.MAIN_HAND); - return !heldItem.isEmpty() && heldItem.sameItemStackIgnoreDurability(stack) && this.inventory.canAddItem(stack); + return !heldItem.isEmpty() && heldItem.sameItemStackIgnoreDurability(stack) + && this.inventory.canAddItem(stack); } @Override @@ -260,7 +340,8 @@ public class Allay extends PathfinderMob implements InventoryCarrier { if (this.wantsToPickUp(stack)) { SimpleContainer inventory = this.getInventory(); boolean canAdd = inventory.canAddItem(stack); - if (!canAdd) return; + if (!canAdd) + return; this.onItemPickup(itemEntity); this.take(itemEntity, stack.getCount()); @@ -285,7 +366,8 @@ public class Allay extends PathfinderMob implements InventoryCarrier { } public float getHoldingItemAnimationProgress(float animationProgress) { - return Mth.lerp(animationProgress, this.holdingTicksOld, this.holdingTicks) / 5.0F; + return Mth.lerp(animationProgress, this.holdingTicksOld, this.holdingTicks) + / 5.0F; } @Override diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/ChestBoat.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/ChestBoat.java index 0423f5d..8daf92d 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/ChestBoat.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/ChestBoat.java @@ -71,7 +71,8 @@ public class ChestBoat extends MangroveBoat implements Container, MenuProvider { super.addAdditionalSaveData(tag); if (this.lootTable != null) { tag.putString("LootTable", this.lootTable.toString()); - if (this.lootTableSeed != 0L) tag.putLong("LootTableSeed", this.lootTableSeed); + if (this.lootTableSeed != 0L) + tag.putLong("LootTableSeed", this.lootTableSeed); } else { ContainerHelper.saveAllItems(tag, this.stacks); } @@ -96,14 +97,16 @@ public class ChestBoat extends MangroveBoat implements Container, MenuProvider { Containers.dropContents(this.level, this, this); if (!this.level.isClientSide) { Entity entity = source.getDirectEntity(); - if (entity != null && entity.getType() == EntityType.PLAYER) PiglinAi.angerNearbyPiglins((Player)entity, true); + if (entity != null && entity.getType() == EntityType.PLAYER) + PiglinAi.angerNearbyPiglins((Player) entity, true); } } } @Override public void remove(Entity.RemovalReason reason) { - if (!this.level.isClientSide && reason.shouldDestroy()) Containers.dropContents(this.level, this, this); + if (!this.level.isClientSide && reason.shouldDestroy()) + Containers.dropContents(this.level, this, this); super.remove(reason); } @@ -131,7 +134,8 @@ public class ChestBoat extends MangroveBoat implements Container, MenuProvider { } } - @Override @SuppressWarnings("UnnecessaryDefault") + @Override + @SuppressWarnings("UnnecessaryDefault") public Item getDropItem() { return switch (this.getBoatType()) { case OAK -> WBItems.OAK_CHEST_BOAT.get(); @@ -211,30 +215,37 @@ public class ChestBoat extends MangroveBoat implements Container, MenuProvider { ChestBoat.this.setItem(slot, stack); return true; } - } : super.getSlot(slot); - } - - @Override - public void setChanged() {} - - @Override - public boolean stillValid(Player player) { - return !this.isRemoved() && this.position().closerThan(player.position(), 8.0D); - } - - @Override - public boolean isEmpty() { - for (ItemStack stack : this.stacks) if (!stack.isEmpty()) return false; - return true; - } - - @Override @Nullable - public AbstractContainerMenu createMenu(int i, Inventory inventory, Player player) { - if (this.lootTable == null || !player.isSpectator()) { - this.unpackLootTable(inventory.player); - return ChestMenu.threeRows(i, inventory, this); + } : + super.getSlot(slot); } - return null; - } -} \ No newline at end of file + @Override + public void setChanged() {} + + @Override + public boolean stillValid(Player player) { + return !this.isRemoved() + && this.position().closerThan(player.position(), 8.0D); + } + + @Override + public boolean isEmpty() { + for (ItemStack stack : this.stacks) + if (!stack.isEmpty()) + return false; + return true; + } + + @Override + @Nullable + public AbstractContainerMenu createMenu( + int i, Inventory inventory, Player player + ) { + if (this.lootTable == null || !player.isSpectator()) { + this.unpackLootTable(inventory.player); + return ChestMenu.threeRows(i, inventory, this); + } + + return null; + } + } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/Frog.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/Frog.java index 7209ca3..defa218 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/Frog.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/Frog.java @@ -1,9 +1,16 @@ package com.cursedcauldron.wildbackport.common.entities; +import java.util.Arrays; +import java.util.Comparator; +import java.util.Objects; +import java.util.Optional; +import java.util.OptionalInt; +import java.util.Random; + import com.cursedcauldron.wildbackport.client.animation.api.AnimationState; import com.cursedcauldron.wildbackport.client.registry.WBSoundEvents; -import com.cursedcauldron.wildbackport.common.entities.brain.FrogBrain; import com.cursedcauldron.wildbackport.common.entities.access.api.Poses; +import com.cursedcauldron.wildbackport.common.entities.brain.FrogBrain; import com.cursedcauldron.wildbackport.common.registry.entity.WBEntityTypes; import com.cursedcauldron.wildbackport.common.registry.entity.WBMemoryModules; import com.cursedcauldron.wildbackport.common.registry.entity.WBSensorTypes; @@ -66,21 +73,47 @@ import net.minecraft.world.level.pathfinder.PathFinder; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.Nullable; -import java.util.Arrays; -import java.util.Comparator; -import java.util.Objects; -import java.util.Optional; -import java.util.OptionalInt; -import java.util.Random; - //<> public class Frog extends Animal { public static final Ingredient FOOD = Ingredient.of(Items.SLIME_BALL); - protected static final ImmutableList>> SENSORS = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.HURT_BY, WBSensorTypes.FROG_ATTACKABLES.get(), WBSensorTypes.FROG_TEMPTATIONS.get(), WBSensorTypes.IS_IN_WATER.get()); - protected static final ImmutableList> MEMORIES = ImmutableList.of(MemoryModuleType.LOOK_TARGET, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.BREED_TARGET, MemoryModuleType.LONG_JUMP_COOLDOWN_TICKS, MemoryModuleType.LONG_JUMP_MID_JUMP, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.TEMPTING_PLAYER, MemoryModuleType.TEMPTATION_COOLDOWN_TICKS, MemoryModuleType.IS_TEMPTED, MemoryModuleType.HURT_BY, MemoryModuleType.HURT_BY_ENTITY, MemoryModuleType.NEAREST_ATTACKABLE, WBMemoryModules.IS_IN_WATER.get(), WBMemoryModules.IS_PREGNANT.get(), WBMemoryModules.UNREACHABLE_TONGUE_TARGETS.get()); - private static final EntityDataAccessor VARIANT = SynchedEntityData.defineId(Frog.class, EntityDataSerializers.INT); - private static final EntityDataAccessor TARGET = SynchedEntityData.defineId(Frog.class, EntityDataSerializers.OPTIONAL_UNSIGNED_INT); + protected static final + ImmutableList>> SENSORS + = ImmutableList.of( + SensorType.NEAREST_LIVING_ENTITIES, + SensorType.HURT_BY, + WBSensorTypes.FROG_ATTACKABLES.get(), + WBSensorTypes.FROG_TEMPTATIONS.get(), + WBSensorTypes.IS_IN_WATER.get() + ); + protected static final ImmutableList> MEMORIES + = ImmutableList.of( + MemoryModuleType.LOOK_TARGET, + MemoryModuleType.NEAREST_LIVING_ENTITIES, + MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, + MemoryModuleType.WALK_TARGET, + MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, + MemoryModuleType.PATH, + MemoryModuleType.BREED_TARGET, + MemoryModuleType.LONG_JUMP_COOLDOWN_TICKS, + MemoryModuleType.LONG_JUMP_MID_JUMP, + MemoryModuleType.ATTACK_TARGET, + MemoryModuleType.TEMPTING_PLAYER, + MemoryModuleType.TEMPTATION_COOLDOWN_TICKS, + MemoryModuleType.IS_TEMPTED, + MemoryModuleType.HURT_BY, + MemoryModuleType.HURT_BY_ENTITY, + MemoryModuleType.NEAREST_ATTACKABLE, + WBMemoryModules.IS_IN_WATER.get(), + WBMemoryModules.IS_PREGNANT.get(), + WBMemoryModules.UNREACHABLE_TONGUE_TARGETS.get() + ); + private static final EntityDataAccessor VARIANT + = SynchedEntityData.defineId(Frog.class, EntityDataSerializers.INT); + private static final EntityDataAccessor TARGET + = SynchedEntityData.defineId( + Frog.class, EntityDataSerializers.OPTIONAL_UNSIGNED_INT + ); public final AnimationState longJumpingAnimationState = new AnimationState(); public final AnimationState croakingAnimationState = new AnimationState(); public final AnimationState usingTongueAnimationState = new AnimationState(); @@ -107,9 +140,10 @@ public class Frog extends Animal { return FrogBrain.create(this.brainProvider().makeBrain(dynamic)); } - @Override @SuppressWarnings("unchecked") + @Override + @SuppressWarnings("unchecked") public Brain getBrain() { - return (Brain)super.getBrain(); + return (Brain) super.getBrain(); } @Override @@ -124,7 +158,11 @@ public class Frog extends Animal { } public Optional getFrogTarget() { - return this.entityData.get(TARGET).stream().mapToObj(this.level::getEntity).filter(Objects::nonNull).findFirst(); + return this.entityData.get(TARGET) + .stream() + .mapToObj(this.level::getEntity) + .filter(Objects::nonNull) + .findFirst(); } public void setFrogTarget(Entity entity) { @@ -167,17 +205,19 @@ public class Frog extends Animal { } private boolean shouldWalk() { - return this.onGround && this.getDeltaMovement().horizontalDistanceSqr() > 1.0E-6D && !this.isInWaterOrBubble(); + return this.onGround && this.getDeltaMovement().horizontalDistanceSqr() > 1.0E-6D + && !this.isInWaterOrBubble(); } private boolean shouldSwim() { - return this.getDeltaMovement().horizontalDistanceSqr() > 1.0E-6D && this.isInWaterOrBubble(); + return this.getDeltaMovement().horizontalDistanceSqr() > 1.0E-6D + && this.isInWaterOrBubble(); } @Override protected void customServerAiStep() { this.level.getProfiler().push("frogBrain"); - this.getBrain().tick((ServerLevel)this.level, this); + this.getBrain().tick((ServerLevel) this.level, this); this.level.getProfiler().pop(); this.level.getProfiler().push("frogActivityUpdate"); FrogBrain.updateActivities(this); @@ -238,10 +278,12 @@ public class Frog extends Animal { return this.getPose() == pose; } - @Nullable @Override + @Nullable + @Override public AgeableMob getBreedOffspring(ServerLevel level, AgeableMob mob) { Frog frog = WBEntityTypes.FROG.get().create(level); - if (frog != null) FrogBrain.coolDownLongJump(frog, level.getRandom()); + if (frog != null) + FrogBrain.coolDownLongJump(frog, level.getRandom()); return frog; } @@ -256,7 +298,8 @@ public class Frog extends Animal { @Override public void spawnChildFromBreeding(ServerLevel level, Animal partner) { ServerPlayer player = this.getLoveCause(); - if (player == null) player = partner.getLoveCause(); + if (player == null) + player = partner.getLoveCause(); if (player != null) { player.awardStat(Stats.ANIMALS_BRED); @@ -268,12 +311,25 @@ public class Frog extends Animal { this.resetLove(); partner.resetLove(); this.getBrain().setMemory(WBMemoryModules.IS_PREGNANT.get(), Unit.INSTANCE); - level.broadcastEntityEvent(this, (byte)18); - if (level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) level.addFreshEntity(new ExperienceOrb(level, this.getX(), this.getY(), this.getZ(), this.getRandom().nextInt(7) + 1)); + level.broadcastEntityEvent(this, (byte) 18); + if (level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) + level.addFreshEntity(new ExperienceOrb( + level, + this.getX(), + this.getY(), + this.getZ(), + this.getRandom().nextInt(7) + 1 + )); } @Override - public SpawnGroupData finalizeSpawn(ServerLevelAccessor accessor, DifficultyInstance difficulty, MobSpawnType spawnType, @Nullable SpawnGroupData groupData, @Nullable CompoundTag tag) { + public SpawnGroupData finalizeSpawn( + ServerLevelAccessor accessor, + DifficultyInstance difficulty, + MobSpawnType spawnType, + @Nullable SpawnGroupData groupData, + @Nullable CompoundTag tag + ) { Holder biome = accessor.getBiome(this.blockPosition()); if (biome.is(WBBiomeTags.SPAWNS_COLD_VARIANT_FROGS)) { this.setVariant(Variant.COLD); @@ -287,20 +343,26 @@ public class Frog extends Animal { } public static AttributeSupplier.Builder createAttributes() { - return Mob.createMobAttributes().add(Attributes.MOVEMENT_SPEED, 1.0D).add(Attributes.MAX_HEALTH, 10.0D).add(Attributes.ATTACK_DAMAGE, 10.0D); + return Mob.createMobAttributes() + .add(Attributes.MOVEMENT_SPEED, 1.0D) + .add(Attributes.MAX_HEALTH, 10.0D) + .add(Attributes.ATTACK_DAMAGE, 10.0D); } - @Nullable @Override + @Nullable + @Override protected SoundEvent getAmbientSound() { return WBSoundEvents.FROG_AMBIENT; } - @Nullable @Override + @Nullable + @Override protected SoundEvent getHurtSound(DamageSource source) { return WBSoundEvents.FROG_HURT; } - @Nullable @Override + @Nullable + @Override protected SoundEvent getDeathSound() { return WBSoundEvents.FROG_DEATH; } @@ -343,7 +405,8 @@ public class Frog extends Animal { } public static boolean isValidFrogFood(LivingEntity entity) { - return (!(entity instanceof Slime slime) || slime.getSize() == 1) && entity.getType().is(WBEntityTypeTags.FROG_FOOD); + return (!(entity instanceof Slime slime) || slime.getSize() == 1) + && entity.getType().is(WBEntityTypeTags.FROG_FOOD); } @Override @@ -356,14 +419,22 @@ public class Frog extends Animal { return FOOD.test(stack); } - public static boolean checkFrogSpawnRules(EntityType type, LevelAccessor accessor, MobSpawnType spawnType, BlockPos pos, Random random) { - return accessor.getBlockState(pos.below()).is(WBBlockTags.FROGS_SPAWNABLE_ON) && isBrightEnoughToSpawn(accessor, pos); + public static boolean checkFrogSpawnRules( + EntityType type, + LevelAccessor accessor, + MobSpawnType spawnType, + BlockPos pos, + Random random + ) { + return accessor.getBlockState(pos.below()).is(WBBlockTags.FROGS_SPAWNABLE_ON) + && isBrightEnoughToSpawn(accessor, pos); } class FrogLookController extends LookControl { FrogLookController(Mob mobEntity) { super(mobEntity); } + @Override protected boolean resetXRotOnTick() { return Frog.this.getFrogTarget().isEmpty(); @@ -371,7 +442,8 @@ public class Frog extends Animal { } static class FrogNodeEvaluator extends AmphibiousNodeEvaluator { - private final BlockPos.MutableBlockPos preferredBlock = new BlockPos.MutableBlockPos(); + private final BlockPos.MutableBlockPos preferredBlock + = new BlockPos.MutableBlockPos(); public FrogNodeEvaluator(boolean penalizeDeepWater) { super(penalizeDeepWater); @@ -381,7 +453,11 @@ public class Frog extends Animal { public BlockPathTypes getBlockPathType(BlockGetter getter, int x, int y, int z) { this.preferredBlock.set(x, y - 1, z); BlockState state = getter.getBlockState(this.preferredBlock); - return state.is(WBBlockTags.FROG_PREFER_JUMP_TO) ? BlockPathTypes.OPEN : FrogNodeEvaluator.getBlockPathTypeStatic(getter, this.preferredBlock.move(Direction.UP)); + return state.is(WBBlockTags.FROG_PREFER_JUMP_TO) + ? BlockPathTypes.OPEN + : FrogNodeEvaluator.getBlockPathTypeStatic( + getter, this.preferredBlock.move(Direction.UP) + ); } } @@ -389,6 +465,7 @@ public class Frog extends Animal { FrogPathNavigator(Frog frog, Level level) { super(frog, level); } + @Override protected PathFinder createPathFinder(int range) { this.nodeEvaluator = new FrogNodeEvaluator(true); @@ -411,7 +488,10 @@ public class Frog extends Animal { TEMPERATE(0, "temperate"), WARM(1, "warm"), COLD(2, "cold"); - private static final Variant[] VARIANTS = Arrays.stream(Variant.values()).sorted(Comparator.comparingInt(Variant::getId)).toArray(Variant[]::new); + private static final Variant[] VARIANTS + = Arrays.stream(Variant.values()) + .sorted(Comparator.comparingInt(Variant::getId)) + .toArray(Variant[] ::new); private final int id; private final String name; diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/MangroveBoat.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/MangroveBoat.java index 6a1c4c3..4c2ede2 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/MangroveBoat.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/MangroveBoat.java @@ -37,9 +37,12 @@ public class MangroveBoat extends Boat { this.setDamage(this.getDamage() + amount * 10.0F); this.markHurt(); this.gameEvent(GameEvent.ENTITY_DAMAGED, source.getEntity()); - boolean isCreativePlayer = source.getEntity() instanceof Player player && player.getAbilities().instabuild; + boolean isCreativePlayer = source.getEntity() instanceof Player player + && player.getAbilities().instabuild; if (isCreativePlayer || this.getDamage() > 40.0F) { - if (!isCreativePlayer && this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) this.dropItems(source); + if (!isCreativePlayer + && this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) + this.dropItems(source); this.discard(); } @@ -56,6 +59,8 @@ public class MangroveBoat extends Boat { @Override public Item getDropItem() { - return this.getBoatType() != BoatTypes.MANGROVE.get() ? super.getDropItem() : WBItems.MANGROVE_BOAT.get(); + return this.getBoatType() != BoatTypes.MANGROVE.get() + ? super.getDropItem() + : WBItems.MANGROVE_BOAT.get(); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/Tadpole.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/Tadpole.java index b7a73ad..c3e0eb0 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/Tadpole.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/Tadpole.java @@ -39,8 +39,20 @@ import org.jetbrains.annotations.Nullable; public class Tadpole extends AbstractFish { public static final int MAX_TADPOLE_AGE = Math.abs(-24000); private int age; - protected static final ImmutableList>> SENSORS = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.HURT_BY); - protected static final ImmutableList> MEMORIES = ImmutableList.of(MemoryModuleType.LOOK_TARGET, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.NEAREST_VISIBLE_ADULT); + protected static final ImmutableList>> + SENSORS = ImmutableList.of( + SensorType.NEAREST_LIVING_ENTITIES, + SensorType.NEAREST_PLAYERS, + SensorType.HURT_BY + ); + protected static final ImmutableList> MEMORIES = ImmutableList.of( + MemoryModuleType.LOOK_TARGET, + MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, + MemoryModuleType.WALK_TARGET, + MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, + MemoryModuleType.PATH, + MemoryModuleType.NEAREST_VISIBLE_ADULT + ); public Tadpole(EntityType type, Level level) { super(type, level); @@ -63,7 +75,8 @@ public class Tadpole extends AbstractFish { return TadpoleBrain.create(this.brainProvider().makeBrain(dynamic)); } - @Override @SuppressWarnings("unchecked") + @Override + @SuppressWarnings("unchecked") public Brain getBrain() { return (Brain) super.getBrain(); } @@ -76,7 +89,7 @@ public class Tadpole extends AbstractFish { @Override protected void customServerAiStep() { this.level.getProfiler().push("tadpoleBrain"); - this.getBrain().tick((ServerLevel)this.level, this); + this.getBrain().tick((ServerLevel) this.level, this); this.level.getProfiler().pop(); this.level.getProfiler().push("tadpoleActivityUpdate"); TadpoleBrain.updateActivities(this); @@ -85,13 +98,16 @@ public class Tadpole extends AbstractFish { } public static AttributeSupplier.Builder createAttributes() { - return Mob.createMobAttributes().add(Attributes.MOVEMENT_SPEED, 1.0D).add(Attributes.MAX_HEALTH, 6.0D); + return Mob.createMobAttributes() + .add(Attributes.MOVEMENT_SPEED, 1.0D) + .add(Attributes.MAX_HEALTH, 6.0D); } @Override public void aiStep() { super.aiStep(); - if (!this.level.isClientSide) this.setAge(this.age + 1); + if (!this.level.isClientSide) + this.setAge(this.age + 1); } @Override @@ -106,17 +122,20 @@ public class Tadpole extends AbstractFish { this.setAge(tag.getInt("Age")); } - @Override @Nullable + @Override + @Nullable protected SoundEvent getAmbientSound() { return null; } - @Override @Nullable + @Override + @Nullable protected SoundEvent getHurtSound(DamageSource source) { return WBSoundEvents.TADPOLE_HURT; } - @Override @Nullable + @Override + @Nullable protected SoundEvent getDeathSound() { return WBSoundEvents.TADPOLE_DEATH; } @@ -128,7 +147,8 @@ public class Tadpole extends AbstractFish { this.eatSlimeBall(player, stack); return InteractionResult.sidedSuccess(this.level.isClientSide()); } else { - return Bucketable.bucketMobPickup(player, hand, this).orElse(super.mobInteract(player, hand)); + return Bucketable.bucketMobPickup(player, hand, this) + .orElse(super.mobInteract(player, hand)); } } @@ -177,8 +197,16 @@ public class Tadpole extends AbstractFish { private void eatSlimeBall(Player player, ItemStack stack) { this.decrementItem(player, stack); - this.increaseAge((int)((float)(this.getTicksUntilGrowth() / 20) * 0.1F)); - this.level.addParticle(ParticleTypes.HAPPY_VILLAGER, this.getRandomX(1.0D), this.getRandomY() + 0.5D, this.getRandomZ(1.0D), 0.0D, 0.0D, 0.0D); + this.increaseAge((int) ((float) (this.getTicksUntilGrowth() / 20) * 0.1F)); + this.level.addParticle( + ParticleTypes.HAPPY_VILLAGER, + this.getRandomX(1.0D), + this.getRandomY() + 0.5D, + this.getRandomZ(1.0D), + 0.0D, + 0.0D, + 0.0D + ); } private void decrementItem(Player player, ItemStack stack) { @@ -197,16 +225,26 @@ public class Tadpole extends AbstractFish { private void setAge(int age) { this.age = age; - if (this.age >= MAX_TADPOLE_AGE) this.growUp(); + if (this.age >= MAX_TADPOLE_AGE) + this.growUp(); } private void growUp() { if (this.level instanceof ServerLevel server) { Frog frog = WBEntityTypes.FROG.get().create(this.level); - if (frog == null) return; + if (frog == null) + return; - frog.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); - frog.finalizeSpawn(server, this.level.getCurrentDifficultyAt(frog.blockPosition()), MobSpawnType.CONVERSION, null, null); + frog.moveTo( + this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot() + ); + frog.finalizeSpawn( + server, + this.level.getCurrentDifficultyAt(frog.blockPosition()), + MobSpawnType.CONVERSION, + null, + null + ); frog.setNoAi(this.isNoAi()); if (this.hasCustomName()) { frog.setCustomName(this.getCustomName()); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/Warden.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/Warden.java index c846233..98198a1 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/Warden.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/Warden.java @@ -1,5 +1,10 @@ package com.cursedcauldron.wildbackport.common.entities; +import java.util.Collections; +import java.util.Optional; +import java.util.Random; +import javax.annotation.Nullable; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.client.animation.api.AnimationState; import com.cursedcauldron.wildbackport.client.registry.WBSoundEvents; @@ -61,18 +66,14 @@ import net.minecraft.world.level.gameevent.GameEventListenerRegistrar; import net.minecraft.world.level.pathfinder.BlockPathTypes; import net.minecraft.world.phys.Vec3; -import javax.annotation.Nullable; -import java.util.Collections; -import java.util.Optional; -import java.util.Random; - //<> public class Warden extends Monster implements VibrationHandler.VibrationConfig { public static final byte PLAY_ATTACK_SOUND = 4; public static final byte EARS_TWITCH = 61; public static final byte SONIC_BOOM = 62; - private static final EntityDataAccessor ANGER = SynchedEntityData.defineId(Warden.class, EntityDataSerializers.INT); + private static final EntityDataAccessor ANGER + = SynchedEntityData.defineId(Warden.class, EntityDataSerializers.INT); private int tendrilPitchEnd; private int tendrilPitchStart; private int heartPitchEnd; @@ -85,11 +86,14 @@ public class Warden extends Monster implements VibrationHandler.VibrationConfig public AnimationState sonicBoomAnimationState = new AnimationState(); private final GameEventListenerRegistrar gameEventHandler; private final VibrationHandler listener; - private WardenAngerManager angerManager = new WardenAngerManager(this::isValidTarget, Collections.emptyList()); + private WardenAngerManager angerManager + = new WardenAngerManager(this::isValidTarget, Collections.emptyList()); public Warden(EntityType type, Level level) { super(type, level); - this.listener = new VibrationHandler(new MobPositionSource(this, this.getEyeHeight()), 16, this); + this.listener = new VibrationHandler( + new MobPositionSource(this, this.getEyeHeight()), 16, this + ); this.gameEventHandler = new GameEventListenerRegistrar(this.listener); this.xpReward = 5; this.getNavigation().setCanFloat(true); @@ -103,18 +107,24 @@ public class Warden extends Monster implements VibrationHandler.VibrationConfig @Override public Packet getAddEntityPacket() { - return new ClientboundAddEntityPacket(this, this.hasPose(Poses.EMERGING.get()) ? 1 : 0); + return new ClientboundAddEntityPacket( + this, this.hasPose(Poses.EMERGING.get()) ? 1 : 0 + ); } @Override public void recreateFromPacket(ClientboundAddEntityPacket packet) { super.recreateFromPacket(packet); - if (packet.getData() == 1) this.setPose(Poses.EMERGING.get()); + if (packet.getData() == 1) + this.setPose(Poses.EMERGING.get()); } @Override public boolean checkSpawnObstruction(LevelReader reader) { - return super.checkSpawnObstruction(reader) && reader.noCollision(this, this.getType().getDimensions().makeBoundingBox(this.position())); + return super.checkSpawnObstruction(reader) + && reader.noCollision( + this, this.getType().getDimensions().makeBoundingBox(this.position()) + ); } @Override @@ -124,7 +134,8 @@ public class Warden extends Monster implements VibrationHandler.VibrationConfig @Override public boolean isInvulnerableTo(DamageSource source) { - return this.isDiggingOrEmerging() && !source.isBypassInvul() || super.isInvulnerableTo(source); + return this.isDiggingOrEmerging() && !source.isBypassInvul() + || super.isInvulnerableTo(source); } private boolean isDiggingOrEmerging() { @@ -142,7 +153,12 @@ public class Warden extends Monster implements VibrationHandler.VibrationConfig } public static AttributeSupplier.Builder createAttributes() { - return Monster.createMonsterAttributes().add(Attributes.MAX_HEALTH, 500.0D).add(Attributes.MOVEMENT_SPEED, 0.3F).add(Attributes.KNOCKBACK_RESISTANCE, 1.0D).add(Attributes.ATTACK_KNOCKBACK, 1.5D).add(Attributes.ATTACK_DAMAGE, 30.0D); + return Monster.createMonsterAttributes() + .add(Attributes.MAX_HEALTH, 500.0D) + .add(Attributes.MOVEMENT_SPEED, 0.3F) + .add(Attributes.KNOCKBACK_RESISTANCE, 1.0D) + .add(Attributes.ATTACK_KNOCKBACK, 1.5D) + .add(Attributes.ATTACK_DAMAGE, 30.0D); } @Override @@ -158,7 +174,9 @@ public class Warden extends Monster implements VibrationHandler.VibrationConfig @Nullable @Override protected SoundEvent getAmbientSound() { - return !this.hasPose(Poses.ROARING.get()) && !this.isDiggingOrEmerging() ? this.getAngriness().getSound() : null; + return !this.hasPose(Poses.ROARING.get()) && !this.isDiggingOrEmerging() + ? this.getAngriness().getSound() + : null; } @Override @@ -178,7 +196,7 @@ public class Warden extends Monster implements VibrationHandler.VibrationConfig @Override public boolean doHurtTarget(Entity entity) { - this.level.broadcastEntityEvent(this, (byte)4); + this.level.broadcastEntityEvent(this, (byte) 4); this.playSound(WBSoundEvents.WARDEN_ATTACK_IMPACT, 10.0F, this.getVoicePitch()); SonicBoom.setCooldown(this, 40); return super.doHurtTarget(entity); @@ -212,7 +230,16 @@ public class Warden extends Monster implements VibrationHandler.VibrationConfig if (this.tickCount % this.getHeartRate() == 0) { this.heartPitchEnd = 10; if (!this.isSilent()) { - this.level.playLocalSound(this.getX(), this.getY(), this.getZ(), WBSoundEvents.WARDEN_HEARTBEAT, this.getSoundSource(), 5.0F, this.getVoicePitch(), false); + this.level.playLocalSound( + this.getX(), + this.getY(), + this.getZ(), + WBSoundEvents.WARDEN_HEARTBEAT, + this.getSoundSource(), + 5.0F, + this.getVoicePitch(), + false + ); } } @@ -238,7 +265,7 @@ public class Warden extends Monster implements VibrationHandler.VibrationConfig @Override protected void customServerAiStep() { - ServerLevel level = (ServerLevel)this.level; + ServerLevel level = (ServerLevel) this.level; level.getProfiler().push("wardenBrain"); this.getBrain().tick(level, this); this.level.getProfiler().pop(); @@ -270,27 +297,51 @@ public class Warden extends Monster implements VibrationHandler.VibrationConfig } private int getHeartRate() { - return 40 - Mth.floor(Mth.clamp((float)this.getAnger() / (float)Angriness.ANGRY.getThreshold(), 0.0F, 1.0F) * 30.0F); + return 40 + - Mth.floor( + Mth.clamp( + (float) this.getAnger() / (float) Angriness.ANGRY.getThreshold(), + 0.0F, + 1.0F + ) + * 30.0F + ); } public float getTendrilPitch(float tickDelta) { - return Mth.lerp(tickDelta, (float)this.tendrilPitchStart, (float)this.tendrilPitchEnd) / 10.0F; + return Mth.lerp( + tickDelta, (float) this.tendrilPitchStart, (float) this.tendrilPitchEnd + ) + / 10.0F; } public float getHeartPitch(float tickDelta) { - return Mth.lerp(tickDelta, (float)this.heartPitchStart, (float)this.heartPitchEnd) / 10.0F; + return Mth.lerp( + tickDelta, (float) this.heartPitchStart, (float) this.heartPitchEnd + ) + / 10.0F; } private void addDigParticles(AnimationState animationState) { - if ((float)animationState.runningTime() < 4500.0F) { + if ((float) animationState.runningTime() < 4500.0F) { Random random = this.getRandom(); BlockState state = this.getBlockStateOn(); if (state.getRenderShape() != RenderShape.INVISIBLE) { for (int i = 0; i < 30; i++) { - double x = this.getX() + (double)Mth.randomBetween(random, -0.7F, 0.7F); + double x + = this.getX() + (double) Mth.randomBetween(random, -0.7F, 0.7F); double y = this.getY(); - double z = this.getZ() + (double)Mth.randomBetween(random, -0.7F, 0.7F); - this.level.addParticle(new BlockParticleOption(ParticleTypes.BLOCK, state), x, y, z, 0.0D, 0.0D, 0.0D); + double z + = this.getZ() + (double) Mth.randomBetween(random, -0.7F, 0.7F); + this.level.addParticle( + new BlockParticleOption(ParticleTypes.BLOCK, state), + x, + y, + z, + 0.0D, + 0.0D, + 0.0D + ); } } } @@ -327,9 +378,10 @@ public class Warden extends Monster implements VibrationHandler.VibrationConfig return WardenBrain.makeBrain(this, dynamic); } - @Override @SuppressWarnings("unchecked") + @Override + @SuppressWarnings("unchecked") public Brain getBrain() { - return (Brain)super.getBrain(); + return (Brain) super.getBrain(); } @Override @@ -350,35 +402,53 @@ public class Warden extends Monster implements VibrationHandler.VibrationConfig public boolean isValidTarget(@Nullable Entity entity) { if (entity instanceof LivingEntity living) { - return this.level == entity.level && EntitySelector.NO_CREATIVE_OR_SPECTATOR.test(entity) && !this.isAlliedTo(entity) && living.getType() != EntityType.ARMOR_STAND && living.getType() != WBEntityTypes.WARDEN.get() && !living.isInvulnerable() && !living.isDeadOrDying() && this.level.getWorldBorder().isWithinBounds(living.getBoundingBox()); + return this.level == entity.level + && EntitySelector.NO_CREATIVE_OR_SPECTATOR.test(entity) + && !this.isAlliedTo(entity) && living.getType() != EntityType.ARMOR_STAND + && living.getType() != WBEntityTypes.WARDEN.get() + && !living.isInvulnerable() && !living.isDeadOrDying() + && this.level.getWorldBorder().isWithinBounds(living.getBoundingBox()); } return false; } - public static void addDarknessToClosePlayers(ServerLevel world, Vec3 pos, @Nullable Entity entity, int range) { - MobEffectInstance instance = new MobEffectInstance(WBMobEffects.DARKNESS.get(), 260, 0, false, false); - MobUtils.addEffectToPlayersWithinDistance(world, entity, pos, range, instance, 200); + public static void addDarknessToClosePlayers( + ServerLevel world, Vec3 pos, @Nullable Entity entity, int range + ) { + MobEffectInstance instance + = new MobEffectInstance(WBMobEffects.DARKNESS.get(), 260, 0, false, false); + MobUtils.addEffectToPlayersWithinDistance( + world, entity, pos, range, instance, 200 + ); } @Override public void addAdditionalSaveData(CompoundTag tag) { super.addAdditionalSaveData(tag); - WardenAngerManager.codec(this::isValidTarget).encodeStart(NbtOps.INSTANCE, this.angerManager).resultOrPartial(WildBackport.LOGGER::error).ifPresent(manager -> tag.put("anger", manager)); - + WardenAngerManager.codec(this::isValidTarget) + .encodeStart(NbtOps.INSTANCE, this.angerManager) + .resultOrPartial(WildBackport.LOGGER::error) + .ifPresent(manager -> tag.put("anger", manager)); } @Override public void readAdditionalSaveData(CompoundTag tag) { super.readAdditionalSaveData(tag); if (tag.contains("anger")) { - WardenAngerManager.codec(this::isValidTarget).parse(new Dynamic<>(NbtOps.INSTANCE, tag.get("anger"))).resultOrPartial(WildBackport.LOGGER::error).ifPresent(manager -> this.angerManager = manager); + WardenAngerManager.codec(this::isValidTarget) + .parse(new Dynamic<>(NbtOps.INSTANCE, tag.get("anger"))) + .resultOrPartial(WildBackport.LOGGER::error) + .ifPresent(manager -> this.angerManager = manager); this.updateAnger(); } } private void playListeningSound() { - if (!this.hasPose(Poses.ROARING.get())) this.playSound(this.getAngriness().getListeningSound(), 10.0F, this.getVoicePitch()); + if (!this.hasPose(Poses.ROARING.get())) + this.playSound( + this.getAngriness().getListeningSound(), 10.0F, this.getVoicePitch() + ); } public Angriness getAngriness() { @@ -400,18 +470,23 @@ public class Warden extends Monster implements VibrationHandler.VibrationConfig public void increaseAngerAt(Entity entity, int amount, boolean listening) { if (!this.isNoAi() && this.isValidTarget(entity)) { WardenBrain.resetDigCooldown(this); - boolean targetNotPlayer = !(this.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null) instanceof Player); + boolean targetNotPlayer + = !(this.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null) + instanceof Player); int anger = this.angerManager.increaseAngerAt(entity, amount); - if (entity instanceof Player && targetNotPlayer && Angriness.getForAnger(anger).isAngry()) { + if (entity instanceof Player && targetNotPlayer + && Angriness.getForAnger(anger).isAngry()) { this.getBrain().eraseMemory(MemoryModuleType.ATTACK_TARGET); } - if (listening) this.playListeningSound(); + if (listening) + this.playListeningSound(); } } public Optional getPrimeSuspect() { - return this.getAngriness().isAngry() ? this.angerManager.getPrimeSuspect() : Optional.empty(); + return this.getAngriness().isAngry() ? this.angerManager.getPrimeSuspect() + : Optional.empty(); } @Nullable @@ -427,11 +502,23 @@ public class Warden extends Monster implements VibrationHandler.VibrationConfig @Nullable @Override - public SpawnGroupData finalizeSpawn(ServerLevelAccessor level, DifficultyInstance instance, MobSpawnType spawn, @Nullable SpawnGroupData data, @Nullable CompoundTag tag) { - this.getBrain().setMemoryWithExpiry(WBMemoryModules.DIG_COOLDOWN.get(), Unit.INSTANCE, 1200L); + public SpawnGroupData finalizeSpawn( + ServerLevelAccessor level, + DifficultyInstance instance, + MobSpawnType spawn, + @Nullable SpawnGroupData data, + @Nullable CompoundTag tag + ) { + this.getBrain().setMemoryWithExpiry( + WBMemoryModules.DIG_COOLDOWN.get(), Unit.INSTANCE, 1200L + ); if (spawn == MobSpawnType.TRIGGERED) { this.setPose(Poses.EMERGING.get()); - this.getBrain().setMemoryWithExpiry(WBMemoryModules.IS_EMERGING.get(), Unit.INSTANCE, WardenBrain.EMERGE_DURATION); + this.getBrain().setMemoryWithExpiry( + WBMemoryModules.IS_EMERGING.get(), + Unit.INSTANCE, + WardenBrain.EMERGE_DURATION + ); this.playSound(WBSoundEvents.WARDEN_AGITATED, 5.0F, 1.0F); } @@ -444,8 +531,10 @@ public class Warden extends Monster implements VibrationHandler.VibrationConfig if (!this.level.isClientSide && !this.isNoAi() && !this.isDiggingOrEmerging()) { Entity entity = source.getEntity(); this.increaseAngerAt(entity, Angriness.ANGRY.getThreshold() + 20, false); - if (this.brain.getMemory(MemoryModuleType.ATTACK_TARGET).isEmpty() && entity instanceof LivingEntity living) { - if (!(source instanceof IndirectEntityDamageSource) || this.closerThan(living, 5.0D)) { + if (this.brain.getMemory(MemoryModuleType.ATTACK_TARGET).isEmpty() + && entity instanceof LivingEntity living) { + if (!(source instanceof IndirectEntityDamageSource) + || this.closerThan(living, 5.0D)) { this.updateAttackTarget(living); } } @@ -464,7 +553,8 @@ public class Warden extends Monster implements VibrationHandler.VibrationConfig @Override public EntityDimensions getDimensions(Pose pose) { EntityDimensions dimensions = super.getDimensions(pose); - return this.isDiggingOrEmerging() ? EntityDimensions.fixed(dimensions.width, 1.0F) : dimensions; + return this.isDiggingOrEmerging() ? EntityDimensions.fixed(dimensions.width, 1.0F) + : dimensions; } @Override @@ -474,8 +564,11 @@ public class Warden extends Monster implements VibrationHandler.VibrationConfig @Override protected void doPush(Entity entity) { - if (!this.isNoAi() && !this.getBrain().hasMemoryValue(WBMemoryModules.TOUCH_COOLDOWN.get())) { - this.getBrain().setMemoryWithExpiry(WBMemoryModules.TOUCH_COOLDOWN.get(), Unit.INSTANCE, 20L); + if (!this.isNoAi() + && !this.getBrain().hasMemoryValue(WBMemoryModules.TOUCH_COOLDOWN.get())) { + this.getBrain().setMemoryWithExpiry( + WBMemoryModules.TOUCH_COOLDOWN.get(), Unit.INSTANCE, 20L + ); this.increaseAngerAt(entity); WardenBrain.lookAtDisturbance(this, entity.blockPosition()); } @@ -484,8 +577,17 @@ public class Warden extends Monster implements VibrationHandler.VibrationConfig } @Override - public boolean shouldListen(ServerLevel level, GameEventListener listener, BlockPos pos, GameEvent event, @Nullable Entity entity) { - if (!this.isNoAi() && !this.isDeadOrDying() && !this.getBrain().hasMemoryValue(WBMemoryModules.VIBRATION_COOLDOWN.get()) && !this.isDiggingOrEmerging() && level.getWorldBorder().isWithinBounds(pos) && !this.isRemoved() && this.level == level) { + public boolean shouldListen( + ServerLevel level, + GameEventListener listener, + BlockPos pos, + GameEvent event, + @Nullable Entity entity + ) { + if (!this.isNoAi() && !this.isDeadOrDying() + && !this.getBrain().hasMemoryValue(WBMemoryModules.VIBRATION_COOLDOWN.get()) + && !this.isDiggingOrEmerging() && level.getWorldBorder().isWithinBounds(pos) + && !this.isRemoved() && this.level == level) { if (entity instanceof LivingEntity living) { return this.isValidTarget(living); } @@ -497,15 +599,29 @@ public class Warden extends Monster implements VibrationHandler.VibrationConfig } @Override - public void onSignalReceive(ServerLevel level, GameEventListener listener, BlockPos pos, GameEvent event, @Nullable Entity entity, @Nullable Entity source, float distance) { + public void onSignalReceive( + ServerLevel level, + GameEventListener listener, + BlockPos pos, + GameEvent event, + @Nullable Entity entity, + @Nullable Entity source, + float distance + ) { if (!this.isDeadOrDying()) { - this.brain.setMemoryWithExpiry(WBMemoryModules.VIBRATION_COOLDOWN.get(), Unit.INSTANCE, 40L); - level.broadcastEntityEvent(this, (byte)61); - this.playSound(WBSoundEvents.WARDEN_TENDRIL_CLICKS, 5.0F, this.getVoicePitch()); + this.brain.setMemoryWithExpiry( + WBMemoryModules.VIBRATION_COOLDOWN.get(), Unit.INSTANCE, 40L + ); + level.broadcastEntityEvent(this, (byte) 61); + this.playSound( + WBSoundEvents.WARDEN_TENDRIL_CLICKS, 5.0F, this.getVoicePitch() + ); BlockPos position = pos; if (source != null) { if (this.closerThan(source, 30.0D)) { - if (this.getBrain().hasMemoryValue(WBMemoryModules.RECENT_PROJECTILE.get())) { + if (this.getBrain().hasMemoryValue( + WBMemoryModules.RECENT_PROJECTILE.get() + )) { if (this.isValidTarget(source)) { position = source.blockPosition(); } @@ -516,14 +632,17 @@ public class Warden extends Monster implements VibrationHandler.VibrationConfig } } - this.getBrain().setMemoryWithExpiry(WBMemoryModules.RECENT_PROJECTILE.get(), Unit.INSTANCE, 100L); + this.getBrain().setMemoryWithExpiry( + WBMemoryModules.RECENT_PROJECTILE.get(), Unit.INSTANCE, 100L + ); } else { this.increaseAngerAt(entity); } if (!this.getAngriness().isAngry()) { Optional primeSuspect = this.angerManager.getPrimeSuspect(); - if (source != null || primeSuspect.isEmpty() || primeSuspect.get() == entity) { + if (source != null || primeSuspect.isEmpty() + || primeSuspect.get() == entity) { WardenBrain.lookAtDisturbance(this, position); } } @@ -540,6 +659,7 @@ public class Warden extends Monster implements VibrationHandler.VibrationConfig double x = entity.getX() - this.getX(); double y = entity.getY() - this.getY(); double z = entity.getZ() - this.getZ(); - return Mth.lengthSquared(x, z) < Mth.square(xzRange) && Mth.square(y) < Mth.square(yRange); + return Mth.lengthSquared(x, z) < Mth.square(xzRange) + && Mth.square(y) < Mth.square(yRange); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/access/Listener.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/access/Listener.java index ecd36f7..4f9c4dc 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/access/Listener.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/access/Listener.java @@ -1,18 +1,18 @@ package com.cursedcauldron.wildbackport.common.entities.access; +import java.util.function.BiConsumer; +import javax.annotation.Nullable; + import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; import net.minecraft.world.level.entity.LevelCallback; import net.minecraft.world.level.gameevent.GameEventListener; import net.minecraft.world.level.gameevent.GameEventListenerRegistrar; -import javax.annotation.Nullable; -import java.util.function.BiConsumer; - public class Listener { public interface Instance { static Instance of(GameEventListenerRegistrar instance) { - return (Instance)instance; + return (Instance) instance; } void onPosCallback(Level level); @@ -27,15 +27,16 @@ public class Listener { return MobInstance.class.cast(entity); } - default void updateEventHandler(BiConsumer callback) { - } + default void + updateEventHandler(BiConsumer callback) {} } public interface Callback extends LevelCallback { @SuppressWarnings("unchecked") static Callback of(T entity) { - return (Callback)entity; + return (Callback) entity; } + void onSectionChange(T entry); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/access/Recovery.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/access/Recovery.java index 1569d8e..724534d 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/access/Recovery.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/access/Recovery.java @@ -1,13 +1,13 @@ package com.cursedcauldron.wildbackport.common.entities.access; +import java.util.Optional; + import net.minecraft.core.GlobalPos; import net.minecraft.world.entity.player.Player; -import java.util.Optional; - public interface Recovery { static Recovery of(Player player) { - return (Recovery)player; + return (Recovery) player; } Optional getLastDeathLocation(); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/access/Vibration.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/access/Vibration.java index 8758311..40f630e 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/access/Vibration.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/access/Vibration.java @@ -1,5 +1,8 @@ package com.cursedcauldron.wildbackport.common.entities.access; +import java.util.Optional; +import java.util.UUID; + import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; @@ -7,12 +10,14 @@ import net.minecraft.world.entity.projectile.Projectile; import net.minecraft.world.level.gameevent.vibrations.VibrationListener; import org.jetbrains.annotations.Nullable; -import java.util.Optional; -import java.util.UUID; - -public record Vibration(@Nullable UUID uuid, @Nullable UUID sourceUuid, @Nullable Entity entity) { +public record +Vibration(@Nullable UUID uuid, @Nullable UUID sourceUuid, @Nullable Entity entity) { public Vibration(@Nullable Entity entity) { - this(entity == null ? null : entity.getUUID(), Vibration.getOwnerUuid(entity), entity); + this( + entity == null ? null : entity.getUUID(), + Vibration.getOwnerUuid(entity), + entity + ); } @Nullable @@ -25,16 +30,21 @@ public record Vibration(@Nullable UUID uuid, @Nullable UUID sourceUuid, @Nullabl } public Optional getEntity(ServerLevel level) { - return Optional.ofNullable(this.entity).or(() -> Optional.ofNullable(this.uuid).map(level::getEntity)); + return Optional.ofNullable(this.entity) + .or(() -> Optional.ofNullable(this.uuid).map(level::getEntity)); } public Optional getOwner(ServerLevel level) { - return Optional.ofNullable(this.entity).filter(entity -> entity instanceof Projectile).map(entity -> (Projectile)entity).map(Projectile::getOwner).or(() -> Optional.ofNullable(this.sourceUuid).map(level::getEntity)); + return Optional.ofNullable(this.entity) + .filter(entity -> entity instanceof Projectile) + .map(entity -> (Projectile) entity) + .map(Projectile::getOwner) + .or(() -> Optional.ofNullable(this.sourceUuid).map(level::getEntity)); } public interface Instance { static Instance of(VibrationListener listener) { - return (Instance)listener; + return (Instance) listener; } void setPos(BlockPos pos); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/access/WardenTracker.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/access/WardenTracker.java index 6fa26ca..09454a5 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/access/WardenTracker.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/access/WardenTracker.java @@ -11,6 +11,6 @@ public interface WardenTracker { } static WardenTracker of(Player player) { - return (WardenTracker)player; + return (WardenTracker) player; } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/AllayBrain.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/AllayBrain.java index e7fb607..b74457c 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/AllayBrain.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/AllayBrain.java @@ -1,5 +1,8 @@ package com.cursedcauldron.wildbackport.common.entities.brain; +import java.util.Optional; +import java.util.UUID; + import com.cursedcauldron.wildbackport.common.entities.Allay; import com.cursedcauldron.wildbackport.common.entities.brain.allay.FlyingRandomStroll; import com.cursedcauldron.wildbackport.common.entities.brain.allay.GiveInventoryToLookTarget; @@ -33,9 +36,6 @@ import net.minecraft.world.entity.schedule.Activity; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; -import java.util.Optional; -import java.util.UUID; - //<> public class AllayBrain { @@ -49,15 +49,54 @@ public class AllayBrain { } private static void addCoreActivities(Brain brain) { - brain.addActivity(Activity.CORE, 0, ImmutableList.of(new Swim(0.8F), new AnimalPanic(2.5F), new LookAtTargetSink(45, 90), new MoveToTargetSink(), new CountDownCooldownTicks(WBMemoryModules.LIKED_NOTEBLOCK_COOLDOWN_TICKS.get()), new CountDownCooldownTicks(WBMemoryModules.ITEM_PICKUP_COOLDOWN_TICKS.get()))); + brain.addActivity( + Activity.CORE, + 0, + ImmutableList.of( + new Swim(0.8F), + new AnimalPanic(2.5F), + new LookAtTargetSink(45, 90), + new MoveToTargetSink(), + new CountDownCooldownTicks( + WBMemoryModules.LIKED_NOTEBLOCK_COOLDOWN_TICKS.get() + ), + new CountDownCooldownTicks(WBMemoryModules.ITEM_PICKUP_COOLDOWN_TICKS.get( + )) + ) + ); } private static void addIdleActivities(Brain brain) { - brain.addActivityWithConditions(Activity.IDLE, ImmutableList.of(Pair.of(0, new GoToWantedItem<>(entity -> { - return true; - }, 1.75F, true, 32)), Pair.of(1, new GiveInventoryToLookTarget<>(AllayBrain::getLookTarget, 2.25F)), Pair.of(2, new StayCloseToTarget<>(AllayBrain::getLookTarget, 4, 16, 2.25F)), Pair.of(3, new RunSometimes<>(new SetEntityLookTarget(entity -> { - return true; - }, 6.0F), UniformInt.of(30, 60))), Pair.of(4, new RunOne<>(ImmutableList.of(Pair.of(new FlyingRandomStroll(1.0F), 2), Pair.of(new SetWalkTargetFromLookTarget(1.0F, 3), 2), Pair.of(new DoNothing(30, 60), 1))))), ImmutableSet.of()); + brain.addActivityWithConditions( + Activity.IDLE, + ImmutableList.of( + Pair.of( + 0, new GoToWantedItem<>(entity -> { return true; }, 1.75F, true, 32) + ), + Pair.of( + 1, new GiveInventoryToLookTarget<>(AllayBrain::getLookTarget, 2.25F) + ), + Pair.of( + 2, new StayCloseToTarget<>(AllayBrain::getLookTarget, 4, 16, 2.25F) + ), + Pair.of( + 3, + new RunSometimes<>( + new SetEntityLookTarget(entity -> { return true; }, 6.0F), + UniformInt.of(30, 60) + ) + ), + Pair.of( + 4, + new RunOne<>(ImmutableList.of( + Pair.of(new FlyingRandomStroll(1.0F), 2), + Pair.of(new SetWalkTargetFromLookTarget(1.0F, 3), 2), + Pair.of(new DoNothing(30, 60), 1) + )) + ) + ), + ImmutableSet.of() + ); } public static void updateActivities(Allay allay) { @@ -67,7 +106,8 @@ public class AllayBrain { public static void rememberNoteBlock(LivingEntity entity, BlockPos pos) { Brain brain = entity.getBrain(); GlobalPos globalPos = GlobalPos.of(entity.getLevel().dimension(), pos); - Optional noteblock = brain.getMemory(WBMemoryModules.LIKED_NOTEBLOCK.get()); + Optional noteblock + = brain.getMemory(WBMemoryModules.LIKED_NOTEBLOCK.get()); if (noteblock.isEmpty()) { brain.setMemory(WBMemoryModules.LIKED_NOTEBLOCK.get(), globalPos); brain.setMemory(WBMemoryModules.LIKED_NOTEBLOCK_COOLDOWN_TICKS.get(), 600); @@ -78,20 +118,26 @@ public class AllayBrain { private static Optional getLookTarget(LivingEntity entity) { Brain brain = entity.getBrain(); - Optional likedNoteBlock = brain.getMemory(WBMemoryModules.LIKED_NOTEBLOCK.get()); + Optional likedNoteBlock + = brain.getMemory(WBMemoryModules.LIKED_NOTEBLOCK.get()); if (likedNoteBlock.isPresent()) { GlobalPos pos = likedNoteBlock.get(); - if (shouldGoTowardsNoteBlock(entity, brain, pos)) return Optional.of(new BlockPosTracker(pos.pos().above())); + if (shouldGoTowardsNoteBlock(entity, brain, pos)) + return Optional.of(new BlockPosTracker(pos.pos().above())); brain.eraseMemory(WBMemoryModules.LIKED_NOTEBLOCK.get()); } return getLikedLookTarget(entity); } - private static boolean shouldGoTowardsNoteBlock(LivingEntity entity, Brain brain, GlobalPos pos) { - Optional cooldownTicks = brain.getMemory(WBMemoryModules.LIKED_NOTEBLOCK_COOLDOWN_TICKS.get()); + private static boolean + shouldGoTowardsNoteBlock(LivingEntity entity, Brain brain, GlobalPos pos) { + Optional cooldownTicks + = brain.getMemory(WBMemoryModules.LIKED_NOTEBLOCK_COOLDOWN_TICKS.get()); Level level = entity.getLevel(); - return level.dimension() == pos.dimension() && level.getBlockState(pos.pos()).is(Blocks.NOTE_BLOCK) && cooldownTicks.isPresent(); + return level.dimension() == pos.dimension() + && level.getBlockState(pos.pos()).is(Blocks.NOTE_BLOCK) + && cooldownTicks.isPresent(); } private static Optional getLikedLookTarget(LivingEntity entity) { @@ -101,10 +147,13 @@ public class AllayBrain { public static Optional getLikedPlayer(LivingEntity entity) { Level level = entity.getLevel(); if (!level.isClientSide && level instanceof ServerLevel server) { - Optional likedPlayer = entity.getBrain().getMemory(WBMemoryModules.LIKED_PLAYER.get()); + Optional likedPlayer + = entity.getBrain().getMemory(WBMemoryModules.LIKED_PLAYER.get()); if (likedPlayer.isPresent()) { if (server.getEntity(likedPlayer.get()) instanceof ServerPlayer player) { - if ((player.gameMode.isSurvival() || player.gameMode.isCreative()) && player.closerThan(entity, 64.0D)) return Optional.of(player); + if ((player.gameMode.isSurvival() || player.gameMode.isCreative()) + && player.closerThan(entity, 64.0D)) + return Optional.of(player); } return Optional.empty(); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/FrogBrain.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/FrogBrain.java index 69610e6..8a62753 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/FrogBrain.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/FrogBrain.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.entities.brain; +import java.util.Random; + import com.cursedcauldron.wildbackport.client.registry.WBSoundEvents; import com.cursedcauldron.wildbackport.common.entities.Frog; import com.cursedcauldron.wildbackport.common.entities.brain.frog.BiasedLongJumpTask; @@ -45,13 +47,14 @@ import net.minecraft.world.entity.schedule.Activity; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.block.Blocks; -import java.util.Random; - public class FrogBrain { private static final UniformInt LONG_JUMP_COOLDOWN_RANGE = UniformInt.of(100, 140); public static void coolDownLongJump(Frog frog, Random random) { - frog.getBrain().setMemory(MemoryModuleType.LONG_JUMP_COOLDOWN_TICKS, LONG_JUMP_COOLDOWN_RANGE.sample(random)); + frog.getBrain().setMemory( + MemoryModuleType.LONG_JUMP_COOLDOWN_TICKS, + LONG_JUMP_COOLDOWN_RANGE.sample(random) + ); } public static Brain create(Brain brain) { @@ -68,27 +71,200 @@ public class FrogBrain { } private static void addCoreActivities(Brain brain) { - brain.addActivity(Activity.CORE, 0, ImmutableList.of(new AnimalPanic(2.0F), new LookAtTargetSink(45, 90), new MoveToTargetSink(), new CountDownCooldownTicks(MemoryModuleType.TEMPTATION_COOLDOWN_TICKS), new CountDownCooldownTicks(MemoryModuleType.LONG_JUMP_COOLDOWN_TICKS))); + brain.addActivity( + Activity.CORE, + 0, + ImmutableList.of( + new AnimalPanic(2.0F), + new LookAtTargetSink(45, 90), + new MoveToTargetSink(), + new CountDownCooldownTicks(MemoryModuleType.TEMPTATION_COOLDOWN_TICKS), + new CountDownCooldownTicks(MemoryModuleType.LONG_JUMP_COOLDOWN_TICKS) + ) + ); } private static void addIdleActivities(Brain brain) { - brain.addActivityWithConditions(Activity.IDLE, ImmutableList.of(Pair.of(0, new RunSometimes(new SetEntityLookTarget(EntityType.PLAYER, 6.0F), UniformInt.of(30, 60))), Pair.of(0, new AnimalMakeLove(WBEntityTypes.FROG.get(), 1.0F)), Pair.of(1, new FollowTemptation(entity -> 1.25F)), Pair.of(2, new StartAttacking<>(FrogBrain::isNotBreeding, frog -> frog.getBrain().getMemory(MemoryModuleType.NEAREST_ATTACKABLE))), Pair.of(3, new WalkTowardsLand(6, 1.0F)), Pair.of(4, new RunOne<>(ImmutableMap.of(MemoryModuleType.WALK_TARGET, MemoryStatus.VALUE_ABSENT), ImmutableList.of(Pair.of(new RandomStroll(1.0F), 1), Pair.of(new SetWalkTargetFromLookTarget(1.0F, 3), 1), Pair.of(new Croak(), 3), Pair.of(new RunIf<>(Entity::isOnGround, new DoNothing(5, 20)), 2))))), ImmutableSet.of(Pair.of(MemoryModuleType.LONG_JUMP_MID_JUMP, MemoryStatus.VALUE_ABSENT), Pair.of(WBMemoryModules.IS_IN_WATER.get(), MemoryStatus.VALUE_ABSENT))); + brain.addActivityWithConditions( + Activity.IDLE, + ImmutableList.of( + Pair.of( + 0, + new RunSometimes( + new SetEntityLookTarget(EntityType.PLAYER, 6.0F), + UniformInt.of(30, 60) + ) + ), + Pair.of(0, new AnimalMakeLove(WBEntityTypes.FROG.get(), 1.0F)), + Pair.of(1, new FollowTemptation(entity -> 1.25F)), + Pair.of( + 2, + new StartAttacking<>( + FrogBrain::isNotBreeding, + frog + -> frog.getBrain().getMemory(MemoryModuleType.NEAREST_ATTACKABLE) + ) + ), + Pair.of(3, new WalkTowardsLand(6, 1.0F)), + Pair.of( + 4, + new RunOne<>( + ImmutableMap + .of(MemoryModuleType.WALK_TARGET, MemoryStatus.VALUE_ABSENT), + ImmutableList.of( + Pair.of(new RandomStroll(1.0F), 1), + Pair.of(new SetWalkTargetFromLookTarget(1.0F, 3), 1), + Pair.of(new Croak(), 3), + Pair.of( + new RunIf<>(Entity::isOnGround, new DoNothing(5, 20)), 2 + ) + ) + ) + ) + ), + ImmutableSet.of( + Pair.of(MemoryModuleType.LONG_JUMP_MID_JUMP, MemoryStatus.VALUE_ABSENT), + Pair.of(WBMemoryModules.IS_IN_WATER.get(), MemoryStatus.VALUE_ABSENT) + ) + ); } private static void addSwimActivities(Brain brain) { - brain.addActivityWithConditions(WBActivities.SWIM.get(), ImmutableList.of(Pair.of(0, new RunSometimes(new SetEntityLookTarget(EntityType.PLAYER, 6.0F), UniformInt.of(30, 60))), Pair.of(1, new FollowTemptation(entity -> 1.25F)), Pair.of(2, new StartAttacking<>(FrogBrain::isNotBreeding, frog -> frog.getBrain().getMemory(MemoryModuleType.NEAREST_ATTACKABLE))), Pair.of(3, new WalkTowardsLand(8, 1.5F)), Pair.of(5, new GateBehavior<>(ImmutableMap.of(MemoryModuleType.WALK_TARGET, MemoryStatus.VALUE_ABSENT), ImmutableSet.of(), GateBehavior.OrderPolicy.ORDERED, GateBehavior.RunningPolicy.TRY_ALL, ImmutableList.of(Pair.of(new RandomStroll(0.75F), 1), Pair.of(new RandomStroll(1.0F, true), 1), Pair.of(new SetWalkTargetFromLookTarget(1.0F, 3), 1), Pair.of(new RunIf<>(Entity::isInWaterOrBubble, new DoNothing(30, 60)), 5))))), ImmutableSet.of(Pair.of(MemoryModuleType.LONG_JUMP_MID_JUMP, MemoryStatus.VALUE_ABSENT), Pair.of(WBMemoryModules.IS_IN_WATER.get(), MemoryStatus.VALUE_PRESENT))); + brain.addActivityWithConditions( + WBActivities.SWIM.get(), + ImmutableList.of( + Pair.of( + 0, + new RunSometimes( + new SetEntityLookTarget(EntityType.PLAYER, 6.0F), + UniformInt.of(30, 60) + ) + ), + Pair.of(1, new FollowTemptation(entity -> 1.25F)), + Pair.of( + 2, + new StartAttacking<>( + FrogBrain::isNotBreeding, + frog + -> frog.getBrain().getMemory(MemoryModuleType.NEAREST_ATTACKABLE) + ) + ), + Pair.of(3, new WalkTowardsLand(8, 1.5F)), + Pair.of( + 5, + new GateBehavior<>( + ImmutableMap + .of(MemoryModuleType.WALK_TARGET, MemoryStatus.VALUE_ABSENT), + ImmutableSet.of(), + GateBehavior.OrderPolicy.ORDERED, + GateBehavior.RunningPolicy.TRY_ALL, + ImmutableList.of( + Pair.of(new RandomStroll(0.75F), 1), + Pair.of(new RandomStroll(1.0F, true), 1), + Pair.of(new SetWalkTargetFromLookTarget(1.0F, 3), 1), + Pair + .of(new RunIf<>( + Entity::isInWaterOrBubble, new DoNothing(30, 60) + ), + 5) + ) + ) + ) + ), + ImmutableSet.of( + Pair.of(MemoryModuleType.LONG_JUMP_MID_JUMP, MemoryStatus.VALUE_ABSENT), + Pair.of(WBMemoryModules.IS_IN_WATER.get(), MemoryStatus.VALUE_PRESENT) + ) + ); } private static void addLaySpawnActivities(Brain brain) { - brain.addActivityWithConditions(WBActivities.LAY_SPAWN.get(), ImmutableList.of(Pair.of(0, new RunSometimes(new SetEntityLookTarget(EntityType.PLAYER, 6.0F), UniformInt.of(30, 60))), Pair.of(1, new StartAttacking<>(FrogBrain::isNotBreeding, frog -> frog.getBrain().getMemory(MemoryModuleType.NEAREST_ATTACKABLE))), Pair.of(2, new WalkTowardsWater(8, 1.0F)), Pair.of(3, new LayFrogSpawn(WBBlocks.FROGSPAWN.get(), WBMemoryModules.IS_PREGNANT.get())), Pair.of(4, new RunOne<>(ImmutableList.of(Pair.of(new RandomStroll(1.0F), 2), Pair.of(new SetWalkTargetFromLookTarget(1.0F, 3), 1), Pair.of(new Croak(), 2), Pair.of(new RunIf<>(Entity::isOnGround, new DoNothing(5, 20)), 1))))), ImmutableSet.of(Pair.of(MemoryModuleType.LONG_JUMP_MID_JUMP, MemoryStatus.VALUE_ABSENT), Pair.of(WBMemoryModules.IS_PREGNANT.get(), MemoryStatus.VALUE_PRESENT))); + brain.addActivityWithConditions( + WBActivities.LAY_SPAWN.get(), + ImmutableList.of( + Pair.of( + 0, + new RunSometimes( + new SetEntityLookTarget(EntityType.PLAYER, 6.0F), + UniformInt.of(30, 60) + ) + ), + Pair.of( + 1, + new StartAttacking<>( + FrogBrain::isNotBreeding, + frog + -> frog.getBrain().getMemory(MemoryModuleType.NEAREST_ATTACKABLE) + ) + ), + Pair.of(2, new WalkTowardsWater(8, 1.0F)), + Pair.of( + 3, + new LayFrogSpawn( + WBBlocks.FROGSPAWN.get(), WBMemoryModules.IS_PREGNANT.get() + ) + ), + Pair.of( + 4, + new RunOne<>(ImmutableList.of( + Pair.of(new RandomStroll(1.0F), 2), + Pair.of(new SetWalkTargetFromLookTarget(1.0F, 3), 1), + Pair.of(new Croak(), 2), + Pair.of(new RunIf<>(Entity::isOnGround, new DoNothing(5, 20)), 1) + )) + ) + ), + ImmutableSet.of( + Pair.of(MemoryModuleType.LONG_JUMP_MID_JUMP, MemoryStatus.VALUE_ABSENT), + Pair.of(WBMemoryModules.IS_PREGNANT.get(), MemoryStatus.VALUE_PRESENT) + ) + ); } private static void addLongJumpActivities(Brain brain) { - brain.addActivityWithConditions(Activity.LONG_JUMP, ImmutableList.of(Pair.of(0, new LongJumpMidJump(LONG_JUMP_COOLDOWN_RANGE, WBSoundEvents.FROG_STEP)), Pair.of(1, new BiasedLongJumpTask<>(LONG_JUMP_COOLDOWN_RANGE, 2, 4, 1.5F, frog -> WBSoundEvents.FROG_LONG_JUMP, WBBlockTags.FROG_PREFER_JUMP_TO, 0.5F, state -> state.is(Blocks.LILY_PAD)))), ImmutableSet.of(Pair.of(MemoryModuleType.TEMPTING_PLAYER, MemoryStatus.VALUE_ABSENT), Pair.of(MemoryModuleType.BREED_TARGET, MemoryStatus.VALUE_ABSENT), Pair.of(MemoryModuleType.LONG_JUMP_COOLDOWN_TICKS, MemoryStatus.VALUE_ABSENT), Pair.of(WBMemoryModules.IS_IN_WATER.get(), MemoryStatus.VALUE_ABSENT))); + brain.addActivityWithConditions( + Activity.LONG_JUMP, + ImmutableList.of( + Pair.of( + 0, + new LongJumpMidJump(LONG_JUMP_COOLDOWN_RANGE, WBSoundEvents.FROG_STEP) + ), + Pair.of( + 1, + new BiasedLongJumpTask<>( + LONG_JUMP_COOLDOWN_RANGE, + 2, + 4, + 1.5F, + frog + -> WBSoundEvents.FROG_LONG_JUMP, + WBBlockTags.FROG_PREFER_JUMP_TO, + 0.5F, + state -> state.is(Blocks.LILY_PAD) + ) + ) + ), + ImmutableSet.of( + Pair.of(MemoryModuleType.TEMPTING_PLAYER, MemoryStatus.VALUE_ABSENT), + Pair.of(MemoryModuleType.BREED_TARGET, MemoryStatus.VALUE_ABSENT), + Pair.of( + MemoryModuleType.LONG_JUMP_COOLDOWN_TICKS, MemoryStatus.VALUE_ABSENT + ), + Pair.of(WBMemoryModules.IS_IN_WATER.get(), MemoryStatus.VALUE_ABSENT) + ) + ); } private static void addTongueActivities(Brain brain) { - brain.addActivityAndRemoveMemoryWhenStopped(WBActivities.TONGUE.get(), 0, ImmutableList.of(new StopAttackingIfTargetInvalid<>(), new FrogEat(WBSoundEvents.FROG_TONGUE, WBSoundEvents.FROG_EAT)), MemoryModuleType.ATTACK_TARGET); + brain.addActivityAndRemoveMemoryWhenStopped( + WBActivities.TONGUE.get(), + 0, + ImmutableList.of( + new StopAttackingIfTargetInvalid<>(), + new FrogEat(WBSoundEvents.FROG_TONGUE, WBSoundEvents.FROG_EAT) + ), + MemoryModuleType.ATTACK_TARGET + ); } private static boolean isNotBreeding(Frog frog) { @@ -96,7 +272,13 @@ public class FrogBrain { } public static void updateActivities(Frog frog) { - frog.getBrain().setActiveActivityToFirstValid(ImmutableList.of(WBActivities.TONGUE.get(), WBActivities.LAY_SPAWN.get(), Activity.LONG_JUMP, WBActivities.SWIM.get(), Activity.IDLE)); + frog.getBrain().setActiveActivityToFirstValid(ImmutableList.of( + WBActivities.TONGUE.get(), + WBActivities.LAY_SPAWN.get(), + Activity.LONG_JUMP, + WBActivities.SWIM.get(), + Activity.IDLE + )); } public static Ingredient getTemptItems() { diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/TadpoleBrain.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/TadpoleBrain.java index 1e43d35..b96ae57 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/TadpoleBrain.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/TadpoleBrain.java @@ -38,11 +38,52 @@ public class TadpoleBrain { } private static void addCoreActivities(Brain brain) { - brain.addActivity(Activity.CORE, 0, ImmutableList.of(new AnimalPanic(2.0f), new LookAtTargetSink(45, 90), new MoveToTargetSink(), new CountDownCooldownTicks(MemoryModuleType.TEMPTATION_COOLDOWN_TICKS))); + brain.addActivity( + Activity.CORE, + 0, + ImmutableList.of( + new AnimalPanic(2.0f), + new LookAtTargetSink(45, 90), + new MoveToTargetSink(), + new CountDownCooldownTicks(MemoryModuleType.TEMPTATION_COOLDOWN_TICKS) + ) + ); } private static void addIdleActivities(Brain brain) { - brain.addActivity(Activity.IDLE, ImmutableList.of(Pair.of(0, new RunSometimes(new SetEntityLookTarget(EntityType.PLAYER, 6.0f), UniformInt.of(30, 60))), Pair.of(3, new TryFindWater(6, 0.15f)), Pair.of(4, new GateBehavior<>(ImmutableMap.of(MemoryModuleType.WALK_TARGET, MemoryStatus.VALUE_ABSENT), ImmutableSet.of(), GateBehavior.OrderPolicy.ORDERED, GateBehavior.RunningPolicy.TRY_ALL, ImmutableList.of(Pair.of(new RandomSwim(0.5F), 2), Pair.of(new RandomStroll(0.15F), 2), Pair.of(new SetWalkTargetFromLookTarget(0.5f, 3), 3), Pair.of(new RunIf<>(Entity::isInWaterOrBubble, new DoNothing(30, 60)), 5)))))); + brain.addActivity( + Activity.IDLE, + ImmutableList.of( + Pair.of( + 0, + new RunSometimes( + new SetEntityLookTarget(EntityType.PLAYER, 6.0f), + UniformInt.of(30, 60) + ) + ), + Pair.of(3, new TryFindWater(6, 0.15f)), + Pair.of( + 4, + new GateBehavior<>( + ImmutableMap + .of(MemoryModuleType.WALK_TARGET, MemoryStatus.VALUE_ABSENT), + ImmutableSet.of(), + GateBehavior.OrderPolicy.ORDERED, + GateBehavior.RunningPolicy.TRY_ALL, + ImmutableList.of( + Pair.of(new RandomSwim(0.5F), 2), + Pair.of(new RandomStroll(0.15F), 2), + Pair.of(new SetWalkTargetFromLookTarget(0.5f, 3), 3), + Pair + .of(new RunIf<>( + Entity::isInWaterOrBubble, new DoNothing(30, 60) + ), + 5) + ) + ) + ) + ) + ); } public static void updateActivities(Tadpole tadpole) { diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/WardenBrain.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/WardenBrain.java index 8e3d1a1..6f6d2e3 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/WardenBrain.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/WardenBrain.java @@ -1,13 +1,15 @@ package com.cursedcauldron.wildbackport.common.entities.brain; +import java.util.List; + import com.cursedcauldron.wildbackport.common.entities.Warden; import com.cursedcauldron.wildbackport.common.entities.brain.warden.Digging; import com.cursedcauldron.wildbackport.common.entities.brain.warden.Dismount; import com.cursedcauldron.wildbackport.common.entities.brain.warden.Emerging; +import com.cursedcauldron.wildbackport.common.entities.brain.warden.FindRoarTarget; import com.cursedcauldron.wildbackport.common.entities.brain.warden.ForgetAttackTarget; import com.cursedcauldron.wildbackport.common.entities.brain.warden.GoToTargetLocation; import com.cursedcauldron.wildbackport.common.entities.brain.warden.Roar; -import com.cursedcauldron.wildbackport.common.entities.brain.warden.FindRoarTarget; import com.cursedcauldron.wildbackport.common.entities.brain.warden.SetWardenLookTarget; import com.cursedcauldron.wildbackport.common.entities.brain.warden.Sniffing; import com.cursedcauldron.wildbackport.common.entities.brain.warden.SonicBoom; @@ -44,8 +46,6 @@ import net.minecraft.world.entity.ai.sensing.Sensor; import net.minecraft.world.entity.ai.sensing.SensorType; import net.minecraft.world.entity.schedule.Activity; -import java.util.List; - //<> public class WardenBrain { @@ -53,16 +53,55 @@ public class WardenBrain { public static final int EMERGE_DURATION = Mth.ceil(133.59999F); public static final int ROAR_DURATION = Mth.ceil(84.0F); private static final int SNIFFING_DURATION = Mth.ceil(83.2F); - private static final List>> SENSOR_TYPES = List.of(SensorType.NEAREST_PLAYERS, WBSensorTypes.WARDEN_ENTITY_SENSOR.get()); - private static final List> MEMORY_TYPES = List.of(MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_NEMESIS, MemoryModuleType.LOOK_TARGET, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.NEAREST_ATTACKABLE, WBMemoryModules.ROAR_TARGET.get(), WBMemoryModules.DISTURBANCE_LOCATION.get(), WBMemoryModules.RECENT_PROJECTILE.get(), WBMemoryModules.IS_SNIFFING.get(), WBMemoryModules.IS_EMERGING.get(), WBMemoryModules.ROAR_SOUND_DELAY.get(), WBMemoryModules.DIG_COOLDOWN.get(), WBMemoryModules.ROAR_SOUND_COOLDOWN.get(), WBMemoryModules.SNIFF_COOLDOWN.get(), WBMemoryModules.TOUCH_COOLDOWN.get(), WBMemoryModules.VIBRATION_COOLDOWN.get(), WBMemoryModules.SONIC_BOOM_COOLDOWN.get(), WBMemoryModules.SONIC_BOOM_SOUND_COOLDOWN.get(), WBMemoryModules.SONIC_BOOM_SOUND_DELAY.get()); - private static final Behavior DIG_COOLDOWN_SETTER = new Behavior<>(ImmutableMap.of(WBMemoryModules.DIG_COOLDOWN.get(), MemoryStatus.REGISTERED)) { - @Override protected void start(ServerLevel level, Warden warden, long time) { + private static final List>> SENSOR_TYPES + = List.of(SensorType.NEAREST_PLAYERS, WBSensorTypes.WARDEN_ENTITY_SENSOR.get()); + private static final List> MEMORY_TYPES = List.of( + MemoryModuleType.NEAREST_LIVING_ENTITIES, + MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, + MemoryModuleType.NEAREST_VISIBLE_PLAYER, + MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, + MemoryModuleType.NEAREST_VISIBLE_NEMESIS, + MemoryModuleType.LOOK_TARGET, + MemoryModuleType.WALK_TARGET, + MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, + MemoryModuleType.PATH, + MemoryModuleType.ATTACK_TARGET, + MemoryModuleType.ATTACK_COOLING_DOWN, + MemoryModuleType.NEAREST_ATTACKABLE, + WBMemoryModules.ROAR_TARGET.get(), + WBMemoryModules.DISTURBANCE_LOCATION.get(), + WBMemoryModules.RECENT_PROJECTILE.get(), + WBMemoryModules.IS_SNIFFING.get(), + WBMemoryModules.IS_EMERGING.get(), + WBMemoryModules.ROAR_SOUND_DELAY.get(), + WBMemoryModules.DIG_COOLDOWN.get(), + WBMemoryModules.ROAR_SOUND_COOLDOWN.get(), + WBMemoryModules.SNIFF_COOLDOWN.get(), + WBMemoryModules.TOUCH_COOLDOWN.get(), + WBMemoryModules.VIBRATION_COOLDOWN.get(), + WBMemoryModules.SONIC_BOOM_COOLDOWN.get(), + WBMemoryModules.SONIC_BOOM_SOUND_COOLDOWN.get(), + WBMemoryModules.SONIC_BOOM_SOUND_DELAY.get() + ); + private static final Behavior DIG_COOLDOWN_SETTER = new Behavior<>( + ImmutableMap.of(WBMemoryModules.DIG_COOLDOWN.get(), MemoryStatus.REGISTERED) + ) { + @Override + protected void start(ServerLevel level, Warden warden, long time) { resetDigCooldown(warden); } }; public static void updateActivities(Warden warden) { - warden.getBrain().setActiveActivityToFirstValid(ImmutableList.of(WBActivities.EMERGE.get(), WBActivities.DIG.get(), WBActivities.ROAR.get(), Activity.FIGHT, WBActivities.INVESTIGATE.get(), WBActivities.SNIFF.get(), Activity.IDLE)); + warden.getBrain().setActiveActivityToFirstValid(ImmutableList.of( + WBActivities.EMERGE.get(), + WBActivities.DIG.get(), + WBActivities.ROAR.get(), + Activity.FIGHT, + WBActivities.INVESTIGATE.get(), + WBActivities.SNIFF.get(), + Activity.IDLE + )); } public static Brain makeBrain(Warden warden, Dynamic dynamic) { @@ -83,58 +122,155 @@ public class WardenBrain { } private static void initCoreActivity(Brain brain) { - brain.addActivity(Activity.CORE, 0, ImmutableList.of(new Swim(0.8F), new SetWardenLookTarget(), new LookAtTargetSink(45, 90), new MoveToTargetSink())); + brain.addActivity( + Activity.CORE, + 0, + ImmutableList.of( + new Swim(0.8F), + new SetWardenLookTarget(), + new LookAtTargetSink(45, 90), + new MoveToTargetSink() + ) + ); } private static void initEmergeActivity(Brain brain) { - brain.addActivityAndRemoveMemoryWhenStopped(WBActivities.EMERGE.get(), 5, ImmutableList.of(new Emerging<>(EMERGE_DURATION)), WBMemoryModules.IS_EMERGING.get()); + brain.addActivityAndRemoveMemoryWhenStopped( + WBActivities.EMERGE.get(), + 5, + ImmutableList.of(new Emerging<>(EMERGE_DURATION)), + WBMemoryModules.IS_EMERGING.get() + ); } private static void initDiggingActivity(Brain brain) { - brain.addActivityWithConditions(WBActivities.DIG.get(), ImmutableList.of(Pair.of(0, new Dismount()), Pair.of(1, new Digging<>(DIGGING_DURATION))), ImmutableSet.of(Pair.of(WBMemoryModules.ROAR_TARGET.get(), MemoryStatus.VALUE_ABSENT), Pair.of(WBMemoryModules.DIG_COOLDOWN.get(), MemoryStatus.VALUE_ABSENT))); + brain.addActivityWithConditions( + WBActivities.DIG.get(), + ImmutableList.of( + Pair.of(0, new Dismount()), Pair.of(1, new Digging<>(DIGGING_DURATION)) + ), + ImmutableSet.of( + Pair.of(WBMemoryModules.ROAR_TARGET.get(), MemoryStatus.VALUE_ABSENT), + Pair.of(WBMemoryModules.DIG_COOLDOWN.get(), MemoryStatus.VALUE_ABSENT) + ) + ); } private static void initIdleActivity(Brain brain) { - brain.addActivity(Activity.IDLE, 10, ImmutableList.of(new FindRoarTarget<>(Warden::getPrimeSuspect), new TryToSniff(), new RunOne<>(ImmutableMap.of(WBMemoryModules.IS_SNIFFING.get(), MemoryStatus.VALUE_ABSENT), ImmutableList.of(Pair.of(new RandomStroll(0.5F), 2), Pair.of(new DoNothing(30, 60), 1))))); + brain.addActivity( + Activity.IDLE, + 10, + ImmutableList.of( + new FindRoarTarget<>(Warden::getPrimeSuspect), + new TryToSniff(), + new RunOne<>( + ImmutableMap.of( + WBMemoryModules.IS_SNIFFING.get(), MemoryStatus.VALUE_ABSENT + ), + ImmutableList.of( + Pair.of(new RandomStroll(0.5F), 2), + Pair.of(new DoNothing(30, 60), 1) + ) + ) + ) + ); } private static void initInvestigateActivity(Brain brain) { - brain.addActivityAndRemoveMemoryWhenStopped(WBActivities.INVESTIGATE.get(), 5, ImmutableList.of(new FindRoarTarget<>(Warden::getPrimeSuspect), new GoToTargetLocation<>(WBMemoryModules.DISTURBANCE_LOCATION.get(), 2, 0.7F)), WBMemoryModules.DISTURBANCE_LOCATION.get()); + brain.addActivityAndRemoveMemoryWhenStopped( + WBActivities.INVESTIGATE.get(), + 5, + ImmutableList.of( + new FindRoarTarget<>(Warden::getPrimeSuspect), + new GoToTargetLocation<>( + WBMemoryModules.DISTURBANCE_LOCATION.get(), 2, 0.7F + ) + ), + WBMemoryModules.DISTURBANCE_LOCATION.get() + ); } private static void initSniffingActivity(Brain brain) { - brain.addActivityAndRemoveMemoryWhenStopped(WBActivities.SNIFF.get(), 5, ImmutableList.of(new FindRoarTarget<>(Warden::getPrimeSuspect), new Sniffing<>(SNIFFING_DURATION)), WBMemoryModules.IS_SNIFFING.get()); + brain.addActivityAndRemoveMemoryWhenStopped( + WBActivities.SNIFF.get(), + 5, + ImmutableList.of( + new FindRoarTarget<>(Warden::getPrimeSuspect), + new Sniffing<>(SNIFFING_DURATION) + ), + WBMemoryModules.IS_SNIFFING.get() + ); } private static void initRoarActivity(Brain brain) { - brain.addActivityAndRemoveMemoryWhenStopped(WBActivities.ROAR.get(), 10, ImmutableList.of(new Roar()), WBMemoryModules.ROAR_TARGET.get()); + brain.addActivityAndRemoveMemoryWhenStopped( + WBActivities.ROAR.get(), + 10, + ImmutableList.of(new Roar()), + WBMemoryModules.ROAR_TARGET.get() + ); } private static void initFightActivity(Warden warden, Brain brain) { - brain.addActivityAndRemoveMemoryWhenStopped(Activity.FIGHT, 10, ImmutableList.of(DIG_COOLDOWN_SETTER, new ForgetAttackTarget<>(entity -> !warden.getAngriness().isAngry() || !warden.isValidTarget(entity), WardenBrain::removeDeadSuspect, false), new SetEntityLookTarget(entity -> isTargeting(warden, entity), (float)warden.getAttributeValue(Attributes.FOLLOW_RANGE)), new SetWalkTargetFromAttackTargetIfTargetOutOfReach(1.2F), new SonicBoom(), new MeleeAttack(18)), MemoryModuleType.ATTACK_TARGET); + brain.addActivityAndRemoveMemoryWhenStopped( + Activity.FIGHT, + 10, + ImmutableList.of( + DIG_COOLDOWN_SETTER, + new ForgetAttackTarget<>( + entity + -> !warden.getAngriness().isAngry() || !warden.isValidTarget(entity), + WardenBrain::removeDeadSuspect, + false + ), + new SetEntityLookTarget( + entity + -> isTargeting(warden, entity), + (float) warden.getAttributeValue(Attributes.FOLLOW_RANGE) + ), + new SetWalkTargetFromAttackTargetIfTargetOutOfReach(1.2F), + new SonicBoom(), + new MeleeAttack(18) + ), + MemoryModuleType.ATTACK_TARGET + ); } private static boolean isTargeting(Warden warden, LivingEntity entity) { - return warden.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).filter(target -> target == entity).isPresent(); + return warden.getBrain() + .getMemory(MemoryModuleType.ATTACK_TARGET) + .filter(target -> target == entity) + .isPresent(); } private static void removeDeadSuspect(Warden warden, LivingEntity suspect) { - if (!warden.isValidTarget(suspect)) warden.removeSuspect(suspect); + if (!warden.isValidTarget(suspect)) + warden.removeSuspect(suspect); resetDigCooldown(warden); } public static void resetDigCooldown(LivingEntity warden) { if (warden.getBrain().hasMemoryValue(WBMemoryModules.DIG_COOLDOWN.get())) { - warden.getBrain().setMemoryWithExpiry(WBMemoryModules.DIG_COOLDOWN.get(), Unit.INSTANCE, 1200L); + warden.getBrain().setMemoryWithExpiry( + WBMemoryModules.DIG_COOLDOWN.get(), Unit.INSTANCE, 1200L + ); } } public static void lookAtDisturbance(Warden warden, BlockPos pos) { - if (warden.level.getWorldBorder().isWithinBounds(pos) && warden.getPrimeSuspect().isEmpty() && warden.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).isEmpty()) { + if (warden.level.getWorldBorder().isWithinBounds(pos) + && warden.getPrimeSuspect().isEmpty() + && warden.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).isEmpty()) { resetDigCooldown(warden); - warden.getBrain().setMemoryWithExpiry(WBMemoryModules.SNIFF_COOLDOWN.get(), Unit.INSTANCE, 100L); - warden.getBrain().setMemoryWithExpiry(MemoryModuleType.LOOK_TARGET, new BlockPosTracker(pos), 100L); - warden.getBrain().setMemoryWithExpiry(WBMemoryModules.DISTURBANCE_LOCATION.get(), pos, 100L); + warden.getBrain().setMemoryWithExpiry( + WBMemoryModules.SNIFF_COOLDOWN.get(), Unit.INSTANCE, 100L + ); + warden.getBrain().setMemoryWithExpiry( + MemoryModuleType.LOOK_TARGET, new BlockPosTracker(pos), 100L + ); + warden.getBrain().setMemoryWithExpiry( + WBMemoryModules.DISTURBANCE_LOCATION.get(), pos, 100L + ); warden.getBrain().eraseMemory(MemoryModuleType.WALK_TARGET); } } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/allay/FlyingRandomStroll.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/allay/FlyingRandomStroll.java index b3f8877..f5aa1ec 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/allay/FlyingRandomStroll.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/allay/FlyingRandomStroll.java @@ -11,9 +11,18 @@ public class FlyingRandomStroll extends RandomStroll { super(distance, true); } - @Override @Nullable + @Override + @Nullable protected Vec3 getTargetPos(PathfinderMob mob) { Vec3 vector = mob.getViewVector(0.0F); - return AirAndWaterRandomPos.getPos(mob, this.maxHorizontalDistance, this.maxVerticalDistance, -2, vector.x, vector.z, (float)Math.PI / 2.0F); + return AirAndWaterRandomPos.getPos( + mob, + this.maxHorizontalDistance, + this.maxVerticalDistance, + -2, + vector.x, + vector.z, + (float) Math.PI / 2.0F + ); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/allay/GiveInventoryToLookTarget.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/allay/GiveInventoryToLookTarget.java index 5ab9505..ae92236 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/allay/GiveInventoryToLookTarget.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/allay/GiveInventoryToLookTarget.java @@ -1,5 +1,8 @@ package com.cursedcauldron.wildbackport.common.entities.brain.allay; +import java.util.Optional; +import java.util.function.Function; + import com.cursedcauldron.wildbackport.client.registry.WBSoundEvents; import com.cursedcauldron.wildbackport.common.entities.Allay; import com.cursedcauldron.wildbackport.common.entities.brain.AllayBrain; @@ -21,17 +24,24 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; -import java.util.Optional; -import java.util.function.Function; - //<> -public class GiveInventoryToLookTarget extends Behavior { +public class GiveInventoryToLookTarget + extends Behavior { private final Function> lookTarget; private final float speed; - public GiveInventoryToLookTarget(Function> lookTarget, float speed) { - super(ImmutableMap.of(MemoryModuleType.LOOK_TARGET, MemoryStatus.REGISTERED, MemoryModuleType.WALK_TARGET, MemoryStatus.REGISTERED, WBMemoryModules.ITEM_PICKUP_COOLDOWN_TICKS.get(), MemoryStatus.REGISTERED)); + public GiveInventoryToLookTarget( + Function> lookTarget, float speed + ) { + super(ImmutableMap.of( + MemoryModuleType.LOOK_TARGET, + MemoryStatus.REGISTERED, + MemoryModuleType.WALK_TARGET, + MemoryStatus.REGISTERED, + WBMemoryModules.ITEM_PICKUP_COOLDOWN_TICKS.get(), + MemoryStatus.REGISTERED + )); this.lookTarget = lookTarget; this.speed = speed; } @@ -48,7 +58,9 @@ public class GiveInventoryToLookTarget MobUtils.walkTowards(entity, target, this.speed, 3)); + this.lookTarget.apply(entity).ifPresent( + target -> MobUtils.walkTowards(entity, target, this.speed, 3) + ); } @Override @@ -56,28 +68,35 @@ public class GiveInventoryToLookTarget lookTarget = this.lookTarget.apply(entity); if (lookTarget.isPresent()) { PositionTracker target = lookTarget.get(); - double distance = target.currentPosition().distanceTo(entity.getEyePosition()); + double distance + = target.currentPosition().distanceTo(entity.getEyePosition()); if (distance < 3.0D) { ItemStack stack = entity.getInventory().removeItem(0, 1); if (!stack.isEmpty()) { playThrowSound(entity, stack, offsetTarget(target)); if (entity instanceof Allay allay) { - AllayBrain.getLikedPlayer(allay).ifPresent(player -> this.triggerCriteria(target, stack, player)); + AllayBrain.getLikedPlayer(allay).ifPresent( + player -> this.triggerCriteria(target, stack, player) + ); } - entity.getBrain().setMemory(WBMemoryModules.ITEM_PICKUP_COOLDOWN_TICKS.get(), 60); + entity.getBrain().setMemory( + WBMemoryModules.ITEM_PICKUP_COOLDOWN_TICKS.get(), 60 + ); } } } } - private void triggerCriteria(PositionTracker target, ItemStack stack, ServerPlayer player) { + private void + triggerCriteria(PositionTracker target, ItemStack stack, ServerPlayer player) { BlockPos pos = target.currentBlockPosition().below(); -// WBCriteriaTriggers.ALLAY_DROP_ITEM_ON_BLOCK.trigger(player, pos, stack); + // WBCriteriaTriggers.ALLAY_DROP_ITEM_ON_BLOCK.trigger(player, pos, stack); } private boolean hasItemAndTarget(E entity) { - return !entity.getInventory().isEmpty() && this.lookTarget.apply(entity).isPresent(); + return !entity.getInventory().isEmpty() + && this.lookTarget.apply(entity).isPresent(); } private static Vec3 offsetTarget(PositionTracker tracker) { @@ -90,7 +109,14 @@ public class GiveInventoryToLookTarget extends Behavior { private final Function> lookTarget; private final int completitionRange; private final int searchRange; private final float speed; - public StayCloseToTarget(Function> lookTarget, int completitionRange, int searchRange, float speed) { + public StayCloseToTarget( + Function> lookTarget, + int completitionRange, + int searchRange, + float speed + ) { super(ImmutableMap.of(MemoryModuleType.WALK_TARGET, MemoryStatus.VALUE_ABSENT)); this.lookTarget = lookTarget; this.completitionRange = completitionRange; @@ -29,11 +34,19 @@ public class StayCloseToTarget extends Behavior { @Override protected boolean checkExtraStartConditions(ServerLevel level, E entity) { Optional tracker = this.lookTarget.apply(entity); - return tracker.isPresent() && !entity.position().closerThan(tracker.get().currentPosition(), this.searchRange); + return tracker.isPresent() + && !entity.position().closerThan( + tracker.get().currentPosition(), this.searchRange + ); } @Override protected void start(ServerLevel level, E entity, long time) { - MobUtils.walkTowards(entity, this.lookTarget.apply(entity).get(), this.speed, this.completitionRange); + MobUtils.walkTowards( + entity, + this.lookTarget.apply(entity).get(), + this.speed, + this.completitionRange + ); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/BiasedLongJumpTask.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/BiasedLongJumpTask.java index 2f9cdb8..5bcec3f 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/BiasedLongJumpTask.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/BiasedLongJumpTask.java @@ -1,5 +1,11 @@ package com.cursedcauldron.wildbackport.common.entities.brain.frog; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.function.Function; +import java.util.function.Predicate; + import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; @@ -10,19 +16,22 @@ import net.minecraft.world.entity.Mob; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.function.Function; -import java.util.function.Predicate; - public class BiasedLongJumpTask extends FrogJumpToRandomPos { private final TagKey preferredBlocks; private final float chance; private final List targetCandidates = new ArrayList<>(); private boolean priorityOnPreferred; - public BiasedLongJumpTask(UniformInt cooldown, int yRange, int xzRange, float range, Function landingSound, TagKey preferredBlocks, float chance, Predicate landingBlocks) { + public BiasedLongJumpTask( + UniformInt cooldown, + int yRange, + int xzRange, + float range, + Function landingSound, + TagKey preferredBlocks, + float chance, + Predicate landingBlocks + ) { super(cooldown, yRange, xzRange, range, landingSound, landingBlocks); this.preferredBlocks = preferredBlocks; this.chance = chance; @@ -46,7 +55,11 @@ public class BiasedLongJumpTask extends FrogJumpToRandomPos { Optional jumpTarget = super.jumpTarget(level); if (jumpTarget.isPresent()) { FrogJumpToRandomPos.Target target = jumpTarget.get(); - if (level.getBlockState(mutable.setWithOffset(target.getPos(), Direction.DOWN)).is(this.preferredBlocks)) { + if (level + .getBlockState( + mutable.setWithOffset(target.getPos(), Direction.DOWN) + ) + .is(this.preferredBlocks)) { return jumpTarget; } @@ -54,7 +67,9 @@ public class BiasedLongJumpTask extends FrogJumpToRandomPos { } } - return !this.targetCandidates.isEmpty() ? Optional.of(this.targetCandidates.remove(0)) : Optional.empty(); + return !this.targetCandidates.isEmpty() + ? Optional.of(this.targetCandidates.remove(0)) + : Optional.empty(); } } @@ -64,6 +79,7 @@ public class BiasedLongJumpTask extends FrogJumpToRandomPos { } private boolean cantLandInFluid(ServerLevel level, BlockPos pos) { - return level.getFluidState(pos).isEmpty() && level.getFluidState(pos.below()).isEmpty(); + return level.getFluidState(pos).isEmpty() + && level.getFluidState(pos.below()).isEmpty(); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/Croak.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/Croak.java index 687e04e..93fa266 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/Croak.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/Croak.java @@ -13,7 +13,9 @@ public class Croak extends Behavior { private int ticks; public Croak() { - super(ImmutableMap.of(MemoryModuleType.WALK_TARGET, MemoryStatus.VALUE_ABSENT), 100); + super( + ImmutableMap.of(MemoryModuleType.WALK_TARGET, MemoryStatus.VALUE_ABSENT), 100 + ); } @Override @@ -28,7 +30,6 @@ public class Croak extends Behavior { @Override protected void start(ServerLevel level, Frog frog, long time) { - if (!frog.isInWaterOrBubble() && !frog.isInLava()) { frog.setPose(Poses.CROAKING.get()); this.ticks = 0; diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/FrogAttackablesSensor.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/FrogAttackablesSensor.java index 898f52a..52b867e 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/FrogAttackablesSensor.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/FrogAttackablesSensor.java @@ -1,5 +1,9 @@ package com.cursedcauldron.wildbackport.common.entities.brain.frog; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + import com.cursedcauldron.wildbackport.common.entities.Frog; import com.cursedcauldron.wildbackport.common.registry.entity.WBMemoryModules; import net.minecraft.world.entity.LivingEntity; @@ -7,20 +11,21 @@ import net.minecraft.world.entity.ai.memory.MemoryModuleType; import net.minecraft.world.entity.ai.sensing.NearestVisibleLivingEntitySensor; import net.minecraft.world.entity.ai.sensing.Sensor; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - //<> public class FrogAttackablesSensor extends NearestVisibleLivingEntitySensor { @Override protected boolean isMatchingEntity(LivingEntity entity, LivingEntity target) { - return !entity.getBrain().hasMemoryValue(MemoryModuleType.HAS_HUNTING_COOLDOWN) && Sensor.isEntityAttackable(entity, target) && Frog.isValidFrogFood(target) && !this.cantReachTarget(entity, target) && target.closerThan(entity, 10.0D); + return !entity.getBrain().hasMemoryValue(MemoryModuleType.HAS_HUNTING_COOLDOWN) + && Sensor.isEntityAttackable(entity, target) && Frog.isValidFrogFood(target) + && !this.cantReachTarget(entity, target) && target.closerThan(entity, 10.0D); } private boolean cantReachTarget(LivingEntity entity, LivingEntity target) { - List targets = entity.getBrain().getMemory(WBMemoryModules.UNREACHABLE_TONGUE_TARGETS.get()).orElseGet(ArrayList::new); + List targets + = entity.getBrain() + .getMemory(WBMemoryModules.UNREACHABLE_TONGUE_TARGETS.get()) + .orElseGet(ArrayList::new); return targets.contains(target.getUUID()); } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/FrogEat.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/FrogEat.java index f7aec6b..a374a46 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/FrogEat.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/FrogEat.java @@ -1,5 +1,10 @@ package com.cursedcauldron.wildbackport.common.entities.brain.frog; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.UUID; + import com.cursedcauldron.wildbackport.common.entities.Frog; import com.cursedcauldron.wildbackport.common.entities.access.api.Poses; import com.cursedcauldron.wildbackport.common.registry.WBBlocks; @@ -21,11 +26,6 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.pathfinder.Path; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.UUID; - //<> public class FrogEat extends Behavior { @@ -36,34 +36,50 @@ public class FrogEat extends Behavior { private Phase phase = Phase.DONE; public FrogEat(SoundEvent tongueSound, SoundEvent eatSound) { - super(ImmutableMap.of(MemoryModuleType.WALK_TARGET, MemoryStatus.VALUE_ABSENT, MemoryModuleType.LOOK_TARGET, MemoryStatus.REGISTERED, MemoryModuleType.ATTACK_TARGET, MemoryStatus.VALUE_PRESENT), 100); + super( + ImmutableMap.of( + MemoryModuleType.WALK_TARGET, + MemoryStatus.VALUE_ABSENT, + MemoryModuleType.LOOK_TARGET, + MemoryStatus.REGISTERED, + MemoryModuleType.ATTACK_TARGET, + MemoryStatus.VALUE_PRESENT + ), + 100 + ); this.tongueSound = tongueSound; this.eatSound = eatSound; } @Override protected boolean checkExtraStartConditions(ServerLevel level, Frog frog) { - LivingEntity target = frog.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).get(); + LivingEntity target + = frog.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).get(); boolean flag = this.canMoveToTarget(frog, target); if (!flag) { frog.getBrain().eraseMemory(MemoryModuleType.ATTACK_TARGET); this.cantReachTarget(frog, target); } - return flag && frog.getPose() != Poses.CROAKING.get() && Frog.isValidFrogFood(target); + return flag && frog.getPose() != Poses.CROAKING.get() + && Frog.isValidFrogFood(target); } @Override protected boolean canStillUse(ServerLevel level, Frog frog, long time) { - return frog.getBrain().hasMemoryValue(MemoryModuleType.ATTACK_TARGET) && this.phase != Phase.DONE; + return frog.getBrain().hasMemoryValue(MemoryModuleType.ATTACK_TARGET) + && this.phase != Phase.DONE; } @Override protected void start(ServerLevel level, Frog frog, long time) { - LivingEntity entity = frog.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).get(); + LivingEntity entity + = frog.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).get(); BehaviorUtils.lookAtEntity(frog, entity); frog.setFrogTarget(entity); - frog.getBrain().setMemory(MemoryModuleType.WALK_TARGET, new WalkTarget(entity.position(), 2.0F, 0)); + frog.getBrain().setMemory( + MemoryModuleType.WALK_TARGET, new WalkTarget(entity.position(), 2.0F, 0) + ); this.moveToTargetTick = 10; this.phase = Phase.MOVE_TO_TARGET; } @@ -109,54 +125,64 @@ public class FrogEat extends Behavior { frog.setFrogTarget(target); switch (this.phase) { case MOVE_TO_TARGET: - if (target.distanceTo(frog) < 1.75F) { - level.playSound(null, frog, this.tongueSound, SoundSource.NEUTRAL, 2.0F, 1.0F); - frog.setPose(Poses.USING_TONGUE.get()); - target.setDeltaMovement(target.position().vectorTo(frog.position()).normalize().scale(0.75D)); - this.eatTick = 0; - this.phase = Phase.CATCH_ANIMATION; - } else if (this.moveToTargetTick <= 0) { - frog.getBrain().setMemory(MemoryModuleType.WALK_TARGET, new WalkTarget(target.position(), 2.0F, 0)); - this.moveToTargetTick = 10; - } else { - --this.moveToTargetTick; - } - break; - case CATCH_ANIMATION: - if (this.eatTick++ >= 6) { - this.phase = Phase.EAT_ANIMATION; - this.eat(level, frog); - } - break; - case EAT_ANIMATION: - if (this.eatTick >= 10) { - this.phase = Phase.DONE; - } else { - ++this.eatTick; - } - case DONE: + if (target.distanceTo(frog) < 1.75F) { + level.playSound( + null, frog, this.tongueSound, SoundSource.NEUTRAL, 2.0F, 1.0F + ); + frog.setPose(Poses.USING_TONGUE.get()); + target.setDeltaMovement(target.position() + .vectorTo(frog.position()) + .normalize() + .scale(0.75D)); + this.eatTick = 0; + this.phase = Phase.CATCH_ANIMATION; + } else if (this.moveToTargetTick <= 0) { + frog.getBrain().setMemory( + MemoryModuleType.WALK_TARGET, + new WalkTarget(target.position(), 2.0F, 0) + ); + this.moveToTargetTick = 10; + } else { + --this.moveToTargetTick; + } + break; + case CATCH_ANIMATION: + if (this.eatTick++ >= 6) { + this.phase = Phase.EAT_ANIMATION; + this.eat(level, frog); + } + break; + case EAT_ANIMATION: + if (this.eatTick >= 10) { + this.phase = Phase.DONE; + } else { + ++this.eatTick; + } + case DONE: + } } - } - private boolean canMoveToTarget(Frog frog, LivingEntity entity) { - Path path = frog.getNavigation().createPath(entity, 0); - return path != null && path.getDistToTarget() < 1.75F; - } + private boolean canMoveToTarget(Frog frog, LivingEntity entity) { + Path path = frog.getNavigation().createPath(entity, 0); + return path != null && path.getDistToTarget() < 1.75F; + } - private void cantReachTarget(Frog frog, LivingEntity entity) { - List targets = frog.getBrain().getMemory(WBMemoryModules.UNREACHABLE_TONGUE_TARGETS.get()).orElseGet(ArrayList::new); - boolean notTargeting = !targets.contains(entity.getUUID()); - if (targets.size() == 5 && notTargeting) targets.remove(0); + private void cantReachTarget(Frog frog, LivingEntity entity) { + List targets + = frog.getBrain() + .getMemory(WBMemoryModules.UNREACHABLE_TONGUE_TARGETS.get()) + .orElseGet(ArrayList::new); + boolean notTargeting = !targets.contains(entity.getUUID()); + if (targets.size() == 5 && notTargeting) + targets.remove(0); - if (notTargeting) targets.add(entity.getUUID()); + if (notTargeting) + targets.add(entity.getUUID()); - frog.getBrain().setMemoryWithExpiry(WBMemoryModules.UNREACHABLE_TONGUE_TARGETS.get(), targets, 100L); - } + frog.getBrain().setMemoryWithExpiry( + WBMemoryModules.UNREACHABLE_TONGUE_TARGETS.get(), targets, 100L + ); + } - enum Phase { - MOVE_TO_TARGET, - CATCH_ANIMATION, - EAT_ANIMATION, - DONE - } -} \ No newline at end of file + enum Phase { MOVE_TO_TARGET, CATCH_ANIMATION, EAT_ANIMATION, DONE } + } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/FrogJumpToRandomPos.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/FrogJumpToRandomPos.java index d9df1f7..4e08d4b 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/FrogJumpToRandomPos.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/FrogJumpToRandomPos.java @@ -1,5 +1,12 @@ package com.cursedcauldron.wildbackport.common.entities.brain.frog; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.stream.Collectors; + import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import net.minecraft.core.BlockPos; @@ -26,13 +33,6 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.Nullable; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.stream.Collectors; - public class FrogJumpToRandomPos extends Behavior { private static final List ANGLES = Lists.newArrayList(65, 70, 75, 80); private final UniformInt cooldown; @@ -48,8 +48,25 @@ public class FrogJumpToRandomPos extends Behavior { private final Function landingSound; private final Predicate landingBlocks; - public FrogJumpToRandomPos(UniformInt cooldown, int yRange, int xzRange, float range, Function landingSound, Predicate landingBlocks) { - super(ImmutableMap.of(MemoryModuleType.LOOK_TARGET, MemoryStatus.REGISTERED, MemoryModuleType.LONG_JUMP_COOLDOWN_TICKS, MemoryStatus.VALUE_ABSENT, MemoryModuleType.LONG_JUMP_MID_JUMP, MemoryStatus.VALUE_ABSENT), 200); + public FrogJumpToRandomPos( + UniformInt cooldown, + int yRange, + int xzRange, + float range, + Function landingSound, + Predicate landingBlocks + ) { + super( + ImmutableMap.of( + MemoryModuleType.LOOK_TARGET, + MemoryStatus.REGISTERED, + MemoryModuleType.LONG_JUMP_COOLDOWN_TICKS, + MemoryStatus.VALUE_ABSENT, + MemoryModuleType.LONG_JUMP_MID_JUMP, + MemoryStatus.VALUE_ABSENT + ), + 200 + ); this.cooldown = cooldown; this.yRange = yRange; this.xzRange = xzRange; @@ -60,16 +77,30 @@ public class FrogJumpToRandomPos extends Behavior { @Override protected boolean checkExtraStartConditions(ServerLevel level, Mob entity) { - boolean canUse = entity.isOnGround() && !entity.isInWater() && !entity.isInLava() && !level.getBlockState(entity.blockPosition()).is(Blocks.HONEY_BLOCK); - if (!canUse) entity.getBrain().setMemory(MemoryModuleType.LONG_JUMP_COOLDOWN_TICKS, this.cooldown.sample(level.random) / 2); + boolean canUse = entity.isOnGround() && !entity.isInWater() && !entity.isInLava() + && !level.getBlockState(entity.blockPosition()).is(Blocks.HONEY_BLOCK); + if (!canUse) + entity.getBrain().setMemory( + MemoryModuleType.LONG_JUMP_COOLDOWN_TICKS, + this.cooldown.sample(level.random) / 2 + ); return canUse; } @Override protected boolean canStillUse(ServerLevel level, Mob entity, long time) { - boolean canUse = this.lastPos.isPresent() && this.lastPos.get().equals(entity.position()) && this.tries > 0 && !entity.isInWaterOrBubble() && (this.lastTarget != null || !this.targets.isEmpty()); - if (!canUse && entity.getBrain().getMemory(MemoryModuleType.LONG_JUMP_MID_JUMP).isEmpty()) { - entity.getBrain().setMemory(MemoryModuleType.LONG_JUMP_COOLDOWN_TICKS, this.cooldown.sample(level.random) / 2); + boolean canUse = this.lastPos.isPresent() + && this.lastPos.get().equals(entity.position()) && this.tries > 0 + && !entity.isInWaterOrBubble() + && (this.lastTarget != null || !this.targets.isEmpty()); + if (!canUse + && entity.getBrain() + .getMemory(MemoryModuleType.LONG_JUMP_MID_JUMP) + .isEmpty()) { + entity.getBrain().setMemory( + MemoryModuleType.LONG_JUMP_COOLDOWN_TICKS, + this.cooldown.sample(level.random) / 2 + ); entity.getBrain().eraseMemory(MemoryModuleType.LOOK_TARGET); } @@ -85,7 +116,22 @@ public class FrogJumpToRandomPos extends Behavior { int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); - this.targets = BlockPos.betweenClosedStream(x - this.xzRange, y - this.yRange, z - this.xzRange, x + this.xzRange, y + this.yRange, z + this.xzRange).filter(position -> !position.equals(pos)).map(position -> new Target(position.immutable(), Mth.ceil(pos.distSqr(position)))).collect(Collectors.toCollection(Lists::newArrayList)); + this.targets + = BlockPos + .betweenClosedStream( + x - this.xzRange, + y - this.yRange, + z - this.xzRange, + x + this.xzRange, + y + this.yRange, + z + this.xzRange + ) + .filter(position -> !position.equals(pos)) + .map( + position + -> new Target(position.immutable(), Mth.ceil(pos.distSqr(position))) + ) + .collect(Collectors.toCollection(Lists::newArrayList)); } @Override @@ -98,7 +144,14 @@ public class FrogJumpToRandomPos extends Behavior { double height = length + entity.getJumpBoostPower(); entity.setDeltaMovement(this.lastTarget.scale(height / length)); entity.getBrain().setMemory(MemoryModuleType.LONG_JUMP_MID_JUMP, true); - level.playSound(null, entity, this.landingSound.apply(entity), SoundSource.NEUTRAL, 1.0F, 1.0F); + level.playSound( + null, + entity, + this.landingSound.apply(entity), + SoundSource.NEUTRAL, + 1.0F, + 1.0F + ); } } else { --this.tries; @@ -110,20 +163,26 @@ public class FrogJumpToRandomPos extends Behavior { while (true) { if (!this.targets.isEmpty()) { Optional jumpTarget = this.jumpTarget(level); - if (jumpTarget.isEmpty()) continue; + if (jumpTarget.isEmpty()) + continue; Target target = jumpTarget.get(); BlockPos pos = target.getPos(); - if (!canLandOn(level, entity, pos)) continue; + if (!canLandOn(level, entity, pos)) + continue; Vec3 center = Vec3.atCenterOf(pos); Vec3 lastTarget = this.getRammingVelocity(entity, center); - if (lastTarget == null) continue; + if (lastTarget == null) + continue; - entity.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, new BlockPosTracker(pos)); + entity.getBrain().setMemory( + MemoryModuleType.LOOK_TARGET, new BlockPosTracker(pos) + ); PathNavigation navigation = entity.getNavigation(); Path path = navigation.createPath(pos, 0, 8); - if (path != null && path.canReach()) continue; + if (path != null && path.canReach()) + continue; this.lastTarget = lastTarget; this.targetTime = time; @@ -135,7 +194,8 @@ public class FrogJumpToRandomPos extends Behavior { } protected Optional jumpTarget(ServerLevel level) { - Optional target = WeightedRandom.getRandomItem(level.random, this.targets); + Optional target + = WeightedRandom.getRandomItem(level.random, this.targets); target.ifPresent(this.targets::remove); return target; } @@ -149,7 +209,10 @@ public class FrogJumpToRandomPos extends Behavior { } else if (!entity.getNavigation().isStableDestination(pos) && !this.landingBlocks.test(level.getBlockState(pos.below()))) { return false; } else { - return entity.getPathfindingMalus(WalkNodeEvaluator.getBlockPathTypeStatic(entity.level, pos.mutable())) == 0.0F; + return entity.getPathfindingMalus(WalkNodeEvaluator.getBlockPathTypeStatic( + entity.level, pos.mutable() + )) + == 0.0F; } } @@ -160,7 +223,8 @@ public class FrogJumpToRandomPos extends Behavior { for (int angle : angles) { Vec3 velocity = this.getRammingVelocity(entity, pos, angle); - if (velocity != null) return velocity; + if (velocity != null) + return velocity; } return null; @@ -169,10 +233,12 @@ public class FrogJumpToRandomPos extends Behavior { @Nullable private Vec3 getRammingVelocity(Mob entity, Vec3 pos, int angle) { Vec3 position = entity.position(); - Vec3 scale = new Vec3(pos.x - position.x, 0.0, pos.z - position.z).normalize().scale(0.5D); + Vec3 scale = new Vec3(pos.x - position.x, 0.0, pos.z - position.z) + .normalize() + .scale(0.5D); pos = pos.subtract(scale); Vec3 distance = pos.subtract(position); - float maxAngle = (float)angle * (float)Math.PI / 180.0F; + float maxAngle = (float) angle * (float) Math.PI / 180.0F; double xzRange = Math.atan2(distance.z, distance.x); double yRange = distance.subtract(0.0D, distance.y, 0.0D).lengthSqr(); double yRadius = Math.sqrt(yRange); @@ -187,7 +253,7 @@ public class FrogJumpToRandomPos extends Behavior { return null; } else { double range = Math.sqrt(jumpHeight); - if (range > (double)this.maxRange) { + if (range > (double) this.maxRange) { return null; } else { double xzDistance = range * xzMax; @@ -195,21 +261,25 @@ public class FrogJumpToRandomPos extends Behavior { int radius = Mth.ceil(yRadius / xzDistance) * 2; double index = 0.0; Vec3 source = null; - + for (int j = 0; j < radius - 1; ++j) { - index += yRadius / (double)radius; + index += yRadius / (double) radius; double x = index * xOffset; - double y = yMax / xzMax * index - Math.pow(index, 2.0) * 0.08 / (2.0 * jumpHeight * Math.pow(xzMax, 2.0)); + double y = yMax / xzMax * index + - Math.pow(index, 2.0) * 0.08 + / (2.0 * jumpHeight * Math.pow(xzMax, 2.0)); double z = index * zOffset; - Vec3 target = new Vec3(position.x + x, position.y + y, position.z + z); + Vec3 target + = new Vec3(position.x + x, position.y + y, position.z + z); if (source != null && !this.canReach(entity, source, target)) { return null; } - + source = target; } - - return new Vec3(xzDistance * xOffset, yDistance, xzDistance * zOffset).scale(0.95F); + + return new Vec3(xzDistance * xOffset, yDistance, xzDistance * zOffset) + .scale(0.95F); } } } @@ -222,7 +292,8 @@ public class FrogJumpToRandomPos extends Behavior { Vec3 normal = distance.normalize(); Vec3 vector = source; for (int i = 0; i < height; ++i) { - vector = i == height - 1 ? target : vector.add(normal.scale(size * (double)0.9F)); + vector = i == height - 1 ? target + : vector.add(normal.scale(size * (double) 0.9F)); AABB box = dimensions.makeBoundingBox(vector); if (!entity.level.noCollision(entity, box)) { return false; diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/IsInWaterSensor.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/IsInWaterSensor.java index fdc7975..c22a276 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/IsInWaterSensor.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/IsInWaterSensor.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.entities.brain.frog; +import java.util.Set; + import com.cursedcauldron.wildbackport.common.registry.entity.WBMemoryModules; import com.google.common.collect.ImmutableSet; import net.minecraft.server.level.ServerLevel; @@ -8,10 +10,7 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.memory.MemoryModuleType; import net.minecraft.world.entity.ai.sensing.Sensor; -import java.util.Set; - public class IsInWaterSensor extends Sensor { - @Override public Set> requires() { return ImmutableSet.of(WBMemoryModules.IS_IN_WATER.get()); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/LayFrogSpawn.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/LayFrogSpawn.java index 09dd371..bba7e33 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/LayFrogSpawn.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/LayFrogSpawn.java @@ -19,7 +19,14 @@ public class LayFrogSpawn extends Behavior { private final MemoryModuleType triggerMemory; public LayFrogSpawn(Block block, MemoryModuleType triggerMemory) { - super(ImmutableMap.of(MemoryModuleType.ATTACK_TARGET, MemoryStatus.VALUE_ABSENT, MemoryModuleType.WALK_TARGET, MemoryStatus.VALUE_PRESENT, WBMemoryModules.IS_PREGNANT.get(), MemoryStatus.VALUE_PRESENT)); + super(ImmutableMap.of( + MemoryModuleType.ATTACK_TARGET, + MemoryStatus.VALUE_ABSENT, + MemoryModuleType.WALK_TARGET, + MemoryStatus.VALUE_PRESENT, + WBMemoryModules.IS_PREGNANT.get(), + MemoryStatus.VALUE_PRESENT + )); this.frogSpawn = block; this.triggerMemory = triggerMemory; } @@ -35,9 +42,17 @@ public class LayFrogSpawn extends Behavior { for (Direction direction : Direction.Plane.HORIZONTAL) { BlockPos offset = blockPos.relative(direction); BlockPos above = offset.above(); - if (level.getBlockState(offset).is(Blocks.WATER) && level.getBlockState(above).isAir()) { + if (level.getBlockState(offset).is(Blocks.WATER) + && level.getBlockState(above).isAir()) { level.setBlock(above, this.frogSpawn.defaultBlockState(), 3); - level.playSound(null, frog, WBSoundEvents.FROG_LAY_SPAWN, SoundSource.BLOCKS, 1.0F, 1.0F); + level.playSound( + null, + frog, + WBSoundEvents.FROG_LAY_SPAWN, + SoundSource.BLOCKS, + 1.0F, + 1.0F + ); frog.getBrain().eraseMemory(this.triggerMemory); return; } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/WalkTowardsLand.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/WalkTowardsLand.java index be8198c..444c302 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/WalkTowardsLand.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/WalkTowardsLand.java @@ -20,7 +20,14 @@ public class WalkTowardsLand extends Behavior { private long nextStartTime; public WalkTowardsLand(int distance, float speedModifier) { - super(ImmutableMap.of(MemoryModuleType.ATTACK_TARGET, MemoryStatus.VALUE_ABSENT, MemoryModuleType.WALK_TARGET, MemoryStatus.VALUE_ABSENT, MemoryModuleType.LOOK_TARGET, MemoryStatus.REGISTERED)); + super(ImmutableMap.of( + MemoryModuleType.ATTACK_TARGET, + MemoryStatus.VALUE_ABSENT, + MemoryModuleType.WALK_TARGET, + MemoryStatus.VALUE_ABSENT, + MemoryModuleType.LOOK_TARGET, + MemoryStatus.REGISTERED + )); this.distance = distance; this.speedModifier = speedModifier; } @@ -42,13 +49,21 @@ public class WalkTowardsLand extends Behavior { BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos(); CollisionContext context = CollisionContext.of(entity); - for (BlockPos position : BlockPos.withinManhattan(pos, this.distance, this.distance, this.distance)) { + for (BlockPos position : BlockPos.withinManhattan( + pos, this.distance, this.distance, this.distance + )) { if (position.getX() != pos.getX() || position.getZ() != pos.getZ()) { BlockState state = level.getBlockState(position); - BlockState landState = level.getBlockState(mutable.setWithOffset(position, Direction.DOWN)); - if (!state.is(Blocks.WATER) && level.getFluidState(position).isEmpty() && state.getCollisionShape(level, position, context).isEmpty() && landState.isFaceSturdy(level, mutable, Direction.UP)) { + BlockState landState = level.getBlockState( + mutable.setWithOffset(position, Direction.DOWN) + ); + if (!state.is(Blocks.WATER) && level.getFluidState(position).isEmpty() + && state.getCollisionShape(level, position, context).isEmpty() + && landState.isFaceSturdy(level, mutable, Direction.UP)) { this.nextStartTime = time + 60L; - BehaviorUtils.setWalkAndLookTargetMemories(entity, position.immutable(), this.speedModifier, 1); + BehaviorUtils.setWalkAndLookTargetMemories( + entity, position.immutable(), this.speedModifier, 1 + ); return; } } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/WalkTowardsWater.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/WalkTowardsWater.java index 3d7754a..0eb9dda 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/WalkTowardsWater.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/frog/WalkTowardsWater.java @@ -21,7 +21,14 @@ public class WalkTowardsWater extends Behavior { private long nextStartTime; public WalkTowardsWater(int distance, float speedModifier) { - super(ImmutableMap.of(MemoryModuleType.ATTACK_TARGET, MemoryStatus.VALUE_ABSENT, MemoryModuleType.WALK_TARGET, MemoryStatus.VALUE_ABSENT, MemoryModuleType.LOOK_TARGET, MemoryStatus.REGISTERED)); + super(ImmutableMap.of( + MemoryModuleType.ATTACK_TARGET, + MemoryStatus.VALUE_ABSENT, + MemoryModuleType.WALK_TARGET, + MemoryStatus.VALUE_ABSENT, + MemoryModuleType.LOOK_TARGET, + MemoryStatus.REGISTERED + )); this.distance = distance; this.speedModifier = speedModifier; } @@ -43,13 +50,29 @@ public class WalkTowardsWater extends Behavior { BlockPos pos = entity.blockPosition(); BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos(); - for (BlockPos position : BlockPos.withinManhattan(pos, this.distance, this.distance, this.distance)) { - if (position.getX() != pos.getX() || position.getZ() != pos.getZ() && level.getBlockState(position).getCollisionShape(level, position, context).isEmpty() && level.getBlockState(mutable.setWithOffset(position, Direction.DOWN)).getCollisionShape(level, position, context).isEmpty()) { + for (BlockPos position : BlockPos.withinManhattan( + pos, this.distance, this.distance, this.distance + )) { + if (position.getX() != pos.getX() + || position.getZ() != pos.getZ() + && level.getBlockState(position) + .getCollisionShape(level, position, context) + .isEmpty() + && level + .getBlockState( + mutable.setWithOffset(position, Direction.DOWN) + ) + .getCollisionShape(level, position, context) + .isEmpty()) { for (Direction direction : Direction.Plane.HORIZONTAL) { mutable.setWithOffset(position, direction); - if (level.getBlockState(mutable).isAir() && level.getBlockState(mutable.move(Direction.DOWN)).is(Blocks.WATER)) { + if (level.getBlockState(mutable).isAir() + && level.getBlockState(mutable.move(Direction.DOWN)) + .is(Blocks.WATER)) { this.nextStartTime = time + 40L; - BehaviorUtils.setWalkAndLookTargetMemories(entity, position, this.speedModifier, 0); + BehaviorUtils.setWalkAndLookTargetMemories( + entity, position, this.speedModifier, 0 + ); return; } } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/Digging.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/Digging.java index 53bfdd2..1a3a4dd 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/Digging.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/Digging.java @@ -1,8 +1,8 @@ package com.cursedcauldron.wildbackport.common.entities.brain.warden; import com.cursedcauldron.wildbackport.client.registry.WBSoundEvents; -import com.cursedcauldron.wildbackport.common.entities.access.api.Poses; import com.cursedcauldron.wildbackport.common.entities.Warden; +import com.cursedcauldron.wildbackport.common.entities.access.api.Poses; import com.google.common.collect.ImmutableMap; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; @@ -14,7 +14,15 @@ import net.minecraft.world.entity.ai.memory.MemoryStatus; public class Digging extends Behavior { public Digging(int duration) { - super(ImmutableMap.of(MemoryModuleType.ATTACK_TARGET, MemoryStatus.VALUE_ABSENT, MemoryModuleType.WALK_TARGET, MemoryStatus.VALUE_ABSENT), duration); + super( + ImmutableMap.of( + MemoryModuleType.ATTACK_TARGET, + MemoryStatus.VALUE_ABSENT, + MemoryModuleType.WALK_TARGET, + MemoryStatus.VALUE_ABSENT + ), + duration + ); } @Override diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/Emerging.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/Emerging.java index 5aaaf70..529090d 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/Emerging.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/Emerging.java @@ -1,8 +1,8 @@ package com.cursedcauldron.wildbackport.common.entities.brain.warden; import com.cursedcauldron.wildbackport.client.registry.WBSoundEvents; -import com.cursedcauldron.wildbackport.common.entities.access.api.Poses; import com.cursedcauldron.wildbackport.common.entities.Warden; +import com.cursedcauldron.wildbackport.common.entities.access.api.Poses; import com.cursedcauldron.wildbackport.common.registry.entity.WBMemoryModules; import com.google.common.collect.ImmutableMap; import net.minecraft.server.level.ServerLevel; @@ -15,7 +15,17 @@ import net.minecraft.world.entity.ai.memory.MemoryStatus; public class Emerging extends Behavior { public Emerging(int duration) { - super(ImmutableMap.of(WBMemoryModules.IS_EMERGING.get(), MemoryStatus.VALUE_PRESENT, MemoryModuleType.WALK_TARGET, MemoryStatus.VALUE_ABSENT, MemoryModuleType.LOOK_TARGET, MemoryStatus.REGISTERED), duration); + super( + ImmutableMap.of( + WBMemoryModules.IS_EMERGING.get(), + MemoryStatus.VALUE_PRESENT, + MemoryModuleType.WALK_TARGET, + MemoryStatus.VALUE_ABSENT, + MemoryModuleType.LOOK_TARGET, + MemoryStatus.REGISTERED + ), + duration + ); } @Override diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/FindRoarTarget.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/FindRoarTarget.java index e06a658..ba49ffd 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/FindRoarTarget.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/FindRoarTarget.java @@ -1,5 +1,8 @@ package com.cursedcauldron.wildbackport.common.entities.brain.warden; +import java.util.Optional; +import java.util.function.Function; + import com.cursedcauldron.wildbackport.common.entities.Warden; import com.cursedcauldron.wildbackport.common.registry.entity.WBMemoryModules; import com.google.common.collect.ImmutableMap; @@ -9,14 +12,18 @@ import net.minecraft.world.entity.ai.behavior.Behavior; import net.minecraft.world.entity.ai.memory.MemoryModuleType; import net.minecraft.world.entity.ai.memory.MemoryStatus; -import java.util.Optional; -import java.util.function.Function; - public class FindRoarTarget extends Behavior { private final Function> targetFinder; public FindRoarTarget(Function> targetFinder) { - super(ImmutableMap.of(WBMemoryModules.ROAR_TARGET.get(), MemoryStatus.VALUE_ABSENT, MemoryModuleType.ATTACK_TARGET, MemoryStatus.VALUE_ABSENT, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryStatus.REGISTERED)); + super(ImmutableMap.of( + WBMemoryModules.ROAR_TARGET.get(), + MemoryStatus.VALUE_ABSENT, + MemoryModuleType.ATTACK_TARGET, + MemoryStatus.VALUE_ABSENT, + MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, + MemoryStatus.REGISTERED + )); this.targetFinder = targetFinder; } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/ForgetAttackTarget.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/ForgetAttackTarget.java index c2894df..0d132e2 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/ForgetAttackTarget.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/ForgetAttackTarget.java @@ -1,5 +1,9 @@ package com.cursedcauldron.wildbackport.common.entities.brain.warden; +import java.util.Optional; +import java.util.function.BiConsumer; +import java.util.function.Predicate; + import com.google.common.collect.ImmutableMap; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.LivingEntity; @@ -8,17 +12,22 @@ import net.minecraft.world.entity.ai.behavior.Behavior; import net.minecraft.world.entity.ai.memory.MemoryModuleType; import net.minecraft.world.entity.ai.memory.MemoryStatus; -import java.util.Optional; -import java.util.function.BiConsumer; -import java.util.function.Predicate; - public class ForgetAttackTarget extends Behavior { private final Predicate alternativeCondition; private final BiConsumer forgetCallback; private final boolean shouldForgetIfTargetUnreachable; - public ForgetAttackTarget(Predicate alternativeCondition, BiConsumer forgetCallback, boolean shouldForgetIfTargetUnreachable) { - super(ImmutableMap.of(MemoryModuleType.ATTACK_TARGET, MemoryStatus.VALUE_PRESENT, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryStatus.REGISTERED)); + public ForgetAttackTarget( + Predicate alternativeCondition, + BiConsumer forgetCallback, + boolean shouldForgetIfTargetUnreachable + ) { + super(ImmutableMap.of( + MemoryModuleType.ATTACK_TARGET, + MemoryStatus.VALUE_PRESENT, + MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, + MemoryStatus.REGISTERED + )); this.alternativeCondition = alternativeCondition; this.forgetCallback = forgetCallback; this.shouldForgetIfTargetUnreachable = shouldForgetIfTargetUnreachable; @@ -49,12 +58,14 @@ public class ForgetAttackTarget extends Behavior { } private static boolean cannotReachTarget(E entity) { - Optional time = entity.getBrain().getMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); + Optional time + = entity.getBrain().getMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); return time.isPresent() && entity.level.getGameTime() - time.get() > 200L; } private boolean isAttackTargetDead(E entity) { - Optional target = entity.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET); + Optional target + = entity.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET); return target.isPresent() && !target.get().isAlive(); } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/GoToTargetLocation.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/GoToTargetLocation.java index f5994ad..5d0d9de 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/GoToTargetLocation.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/GoToTargetLocation.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.entities.brain.warden; +import java.util.Random; + import com.google.common.collect.ImmutableMap; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; @@ -9,15 +11,26 @@ import net.minecraft.world.entity.ai.behavior.BehaviorUtils; import net.minecraft.world.entity.ai.memory.MemoryModuleType; import net.minecraft.world.entity.ai.memory.MemoryStatus; -import java.util.Random; - public class GoToTargetLocation extends Behavior { private final MemoryModuleType locationMemory; private final int closeEnoughDistance; private final float speedModifier; - public GoToTargetLocation(MemoryModuleType locationMemory, int closeEnoughDistance, float speedModifier) { - super(ImmutableMap.of(locationMemory, MemoryStatus.VALUE_PRESENT, MemoryModuleType.ATTACK_TARGET, MemoryStatus.VALUE_ABSENT, MemoryModuleType.WALK_TARGET, MemoryStatus.VALUE_ABSENT, MemoryModuleType.LOOK_TARGET, MemoryStatus.REGISTERED)); + public GoToTargetLocation( + MemoryModuleType locationMemory, + int closeEnoughDistance, + float speedModifier + ) { + super(ImmutableMap.of( + locationMemory, + MemoryStatus.VALUE_PRESENT, + MemoryModuleType.ATTACK_TARGET, + MemoryStatus.VALUE_ABSENT, + MemoryModuleType.WALK_TARGET, + MemoryStatus.VALUE_ABSENT, + MemoryModuleType.LOOK_TARGET, + MemoryStatus.REGISTERED + )); this.locationMemory = locationMemory; this.closeEnoughDistance = closeEnoughDistance; this.speedModifier = speedModifier; @@ -26,8 +39,15 @@ public class GoToTargetLocation extends Behavior { @Override protected void start(ServerLevel level, E entity, long time) { BlockPos pos = this.getTargetLocation(entity); - boolean inRange = pos.closerThan(entity.blockPosition(), this.closeEnoughDistance); - if (!inRange) BehaviorUtils.setWalkAndLookTargetMemories(entity, getNearbyPos(entity, pos), this.speedModifier, this.closeEnoughDistance); + boolean inRange + = pos.closerThan(entity.blockPosition(), this.closeEnoughDistance); + if (!inRange) + BehaviorUtils.setWalkAndLookTargetMemories( + entity, + getNearbyPos(entity, pos), + this.speedModifier, + this.closeEnoughDistance + ); } private static BlockPos getNearbyPos(Mob mob, BlockPos pos) { diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/NearestLivingEntitySensor.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/NearestLivingEntitySensor.java index e9178d2..f5529a1 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/NearestLivingEntitySensor.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/NearestLivingEntitySensor.java @@ -1,5 +1,9 @@ package com.cursedcauldron.wildbackport.common.entities.brain.warden; +import java.util.Comparator; +import java.util.List; +import java.util.Set; + import com.google.common.collect.ImmutableSet; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.LivingEntity; @@ -8,20 +12,25 @@ import net.minecraft.world.entity.ai.memory.NearestVisibleLivingEntities; import net.minecraft.world.entity.ai.sensing.Sensor; import net.minecraft.world.phys.AABB; -import java.util.Comparator; -import java.util.List; -import java.util.Set; - //<> public class NearestLivingEntitySensor extends Sensor { @Override protected void doTick(ServerLevel level, T entity) { - AABB box = entity.getBoundingBox().inflate(this.getHorizontalExpansion(), this.getHeightExpansion(), this.getHorizontalExpansion()); - List entities = level.getEntitiesOfClass(LivingEntity.class, box, target -> target != entity && target.isAlive()); + AABB box = entity.getBoundingBox().inflate( + this.getHorizontalExpansion(), + this.getHeightExpansion(), + this.getHorizontalExpansion() + ); + List entities = level.getEntitiesOfClass( + LivingEntity.class, box, target -> target != entity && target.isAlive() + ); entities.sort(Comparator.comparingDouble(entity::distanceToSqr)); entity.getBrain().setMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES, entities); - entity.getBrain().setMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, new NearestVisibleLivingEntities(entity, entities)); + entity.getBrain().setMemory( + MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, + new NearestVisibleLivingEntities(entity, entities) + ); } protected int getHorizontalExpansion() { @@ -34,6 +43,9 @@ public class NearestLivingEntitySensor extends Sensor @Override public Set> requires() { - return ImmutableSet.of(MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES); + return ImmutableSet.of( + MemoryModuleType.NEAREST_LIVING_ENTITIES, + MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES + ); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/Roar.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/Roar.java index d85eef2..6ac9bdf 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/Roar.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/Roar.java @@ -18,15 +18,30 @@ import net.minecraft.world.entity.ai.memory.MemoryStatus; public class Roar extends Behavior { public Roar() { - super(ImmutableMap.of(WBMemoryModules.ROAR_TARGET.get(), MemoryStatus.VALUE_PRESENT, MemoryModuleType.ATTACK_TARGET, MemoryStatus.VALUE_ABSENT, WBMemoryModules.ROAR_SOUND_COOLDOWN.get(), MemoryStatus.REGISTERED, WBMemoryModules.ROAR_SOUND_DELAY.get(), MemoryStatus.REGISTERED), WardenBrain.ROAR_DURATION); + super( + ImmutableMap.of( + WBMemoryModules.ROAR_TARGET.get(), + MemoryStatus.VALUE_PRESENT, + MemoryModuleType.ATTACK_TARGET, + MemoryStatus.VALUE_ABSENT, + WBMemoryModules.ROAR_SOUND_COOLDOWN.get(), + MemoryStatus.REGISTERED, + WBMemoryModules.ROAR_SOUND_DELAY.get(), + MemoryStatus.REGISTERED + ), + WardenBrain.ROAR_DURATION + ); } @Override protected void start(ServerLevel level, Warden warden, long time) { Brain brain = warden.getBrain(); - brain.setMemoryWithExpiry(WBMemoryModules.ROAR_SOUND_DELAY.get(), Unit.INSTANCE, 26L); + brain.setMemoryWithExpiry( + WBMemoryModules.ROAR_SOUND_DELAY.get(), Unit.INSTANCE, 26L + ); brain.eraseMemory(MemoryModuleType.WALK_TARGET); - LivingEntity target = warden.getBrain().getMemory(WBMemoryModules.ROAR_TARGET.get()).get(); + LivingEntity target + = warden.getBrain().getMemory(WBMemoryModules.ROAR_TARGET.get()).get(); BehaviorUtils.lookAtEntity(warden, target); warden.setPose(Poses.ROARING.get()); warden.increaseAngerAt(target, 20, false); @@ -39,16 +54,25 @@ public class Roar extends Behavior { @Override protected void tick(ServerLevel level, Warden warden, long time) { - if (!warden.getBrain().hasMemoryValue(WBMemoryModules.ROAR_SOUND_DELAY.get()) && !warden.getBrain().hasMemoryValue(WBMemoryModules.ROAR_SOUND_COOLDOWN.get())) { - warden.getBrain().setMemoryWithExpiry(WBMemoryModules.ROAR_SOUND_COOLDOWN.get(), Unit.INSTANCE, WardenBrain.ROAR_DURATION - 25); + if (!warden.getBrain().hasMemoryValue(WBMemoryModules.ROAR_SOUND_DELAY.get()) + && !warden.getBrain().hasMemoryValue(WBMemoryModules.ROAR_SOUND_COOLDOWN.get() + )) { + warden.getBrain().setMemoryWithExpiry( + WBMemoryModules.ROAR_SOUND_COOLDOWN.get(), + Unit.INSTANCE, + WardenBrain.ROAR_DURATION - 25 + ); warden.playSound(WBSoundEvents.WARDEN_ROAR, 3.0F, 1.0F); } } @Override protected void stop(ServerLevel level, Warden warden, long time) { - if (warden.hasPose(Poses.ROARING.get())) warden.setPose(Pose.STANDING); - warden.getBrain().getMemory(WBMemoryModules.ROAR_TARGET.get()).ifPresent(warden::updateAttackTarget); + if (warden.hasPose(Poses.ROARING.get())) + warden.setPose(Pose.STANDING); + warden.getBrain() + .getMemory(WBMemoryModules.ROAR_TARGET.get()) + .ifPresent(warden::updateAttackTarget); warden.getBrain().eraseMemory(WBMemoryModules.ROAR_TARGET.get()); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/SetWardenLookTarget.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/SetWardenLookTarget.java index 992d350..f90a7ca 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/SetWardenLookTarget.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/SetWardenLookTarget.java @@ -15,17 +15,35 @@ import net.minecraft.world.entity.ai.memory.MemoryStatus; public class SetWardenLookTarget extends Behavior { public SetWardenLookTarget() { - super(ImmutableMap.of(WBMemoryModules.DISTURBANCE_LOCATION.get(), MemoryStatus.REGISTERED, WBMemoryModules.ROAR_TARGET.get(), MemoryStatus.REGISTERED, MemoryModuleType.ATTACK_TARGET, MemoryStatus.VALUE_ABSENT)); + super(ImmutableMap.of( + WBMemoryModules.DISTURBANCE_LOCATION.get(), + MemoryStatus.REGISTERED, + WBMemoryModules.ROAR_TARGET.get(), + MemoryStatus.REGISTERED, + MemoryModuleType.ATTACK_TARGET, + MemoryStatus.VALUE_ABSENT + )); } @Override protected boolean checkExtraStartConditions(ServerLevel level, Warden warden) { - return warden.getBrain().hasMemoryValue(WBMemoryModules.DISTURBANCE_LOCATION.get()) || warden.getBrain().hasMemoryValue(WBMemoryModules.ROAR_TARGET.get()); + return warden.getBrain().hasMemoryValue(WBMemoryModules.DISTURBANCE_LOCATION.get() + ) + || warden.getBrain().hasMemoryValue(WBMemoryModules.ROAR_TARGET.get()); } @Override protected void start(ServerLevel level, Warden warden, long time) { - BlockPos pos = warden.getBrain().getMemory(WBMemoryModules.ROAR_TARGET.get()).map(Entity::blockPosition).or(() -> warden.getBrain().getMemory(WBMemoryModules.DISTURBANCE_LOCATION.get())).get(); - warden.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, new BlockPosTracker(pos)); + BlockPos pos = warden.getBrain() + .getMemory(WBMemoryModules.ROAR_TARGET.get()) + .map(Entity::blockPosition) + .or(() + -> warden.getBrain().getMemory( + WBMemoryModules.DISTURBANCE_LOCATION.get() + )) + .get(); + warden.getBrain().setMemory( + MemoryModuleType.LOOK_TARGET, new BlockPosTracker(pos) + ); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/Sniffing.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/Sniffing.java index 14d8d69..258dd8b 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/Sniffing.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/Sniffing.java @@ -1,8 +1,8 @@ package com.cursedcauldron.wildbackport.common.entities.brain.warden; import com.cursedcauldron.wildbackport.client.registry.WBSoundEvents; -import com.cursedcauldron.wildbackport.common.entities.access.api.Poses; import com.cursedcauldron.wildbackport.common.entities.Warden; +import com.cursedcauldron.wildbackport.common.entities.access.api.Poses; import com.cursedcauldron.wildbackport.common.entities.brain.WardenBrain; import com.cursedcauldron.wildbackport.common.registry.entity.WBMemoryModules; import com.google.common.collect.ImmutableMap; @@ -14,7 +14,25 @@ import net.minecraft.world.entity.ai.memory.MemoryStatus; public class Sniffing extends Behavior { public Sniffing(int duration) { - super(ImmutableMap.of(WBMemoryModules.IS_SNIFFING.get(), MemoryStatus.VALUE_PRESENT, MemoryModuleType.ATTACK_TARGET, MemoryStatus.VALUE_ABSENT, MemoryModuleType.WALK_TARGET, MemoryStatus.VALUE_ABSENT, MemoryModuleType.LOOK_TARGET, MemoryStatus.REGISTERED, MemoryModuleType.NEAREST_ATTACKABLE, MemoryStatus.REGISTERED, WBMemoryModules.DISTURBANCE_LOCATION.get(), MemoryStatus.REGISTERED, WBMemoryModules.SNIFF_COOLDOWN.get(), MemoryStatus.REGISTERED), duration); + super( + ImmutableMap.of( + WBMemoryModules.IS_SNIFFING.get(), + MemoryStatus.VALUE_PRESENT, + MemoryModuleType.ATTACK_TARGET, + MemoryStatus.VALUE_ABSENT, + MemoryModuleType.WALK_TARGET, + MemoryStatus.VALUE_ABSENT, + MemoryModuleType.LOOK_TARGET, + MemoryStatus.REGISTERED, + MemoryModuleType.NEAREST_ATTACKABLE, + MemoryStatus.REGISTERED, + WBMemoryModules.DISTURBANCE_LOCATION.get(), + MemoryStatus.REGISTERED, + WBMemoryModules.SNIFF_COOLDOWN.get(), + MemoryStatus.REGISTERED + ), + duration + ); } @Override @@ -34,14 +52,19 @@ public class Sniffing extends Behavior { } entity.getBrain().eraseMemory(WBMemoryModules.IS_SNIFFING.get()); - entity.getBrain().getMemory(MemoryModuleType.NEAREST_ATTACKABLE).filter(entity::isValidTarget).ifPresent(target -> { - if (entity.closerThan(target, 6.0D, 20.0D)) { - entity.increaseAngerAt(target); - } + entity.getBrain() + .getMemory(MemoryModuleType.NEAREST_ATTACKABLE) + .filter(entity::isValidTarget) + .ifPresent(target -> { + if (entity.closerThan(target, 6.0D, 20.0D)) { + entity.increaseAngerAt(target); + } - if (!entity.getBrain().hasMemoryValue(WBMemoryModules.DISTURBANCE_LOCATION.get())) { - WardenBrain.lookAtDisturbance(entity, target.blockPosition()); - } - }); + if (!entity.getBrain().hasMemoryValue( + WBMemoryModules.DISTURBANCE_LOCATION.get() + )) { + WardenBrain.lookAtDisturbance(entity, target.blockPosition()); + } + }); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/SonicBoom.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/SonicBoom.java index 9ec1a93..4e15d66 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/SonicBoom.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/SonicBoom.java @@ -26,12 +26,28 @@ public class SonicBoom extends Behavior { private static final int DURATION = Mth.ceil(60.0F); public SonicBoom() { - super(ImmutableMap.of(MemoryModuleType.ATTACK_TARGET, MemoryStatus.VALUE_PRESENT, WBMemoryModules.SONIC_BOOM_COOLDOWN.get(), MemoryStatus.VALUE_ABSENT, WBMemoryModules.SONIC_BOOM_SOUND_COOLDOWN.get(), MemoryStatus.REGISTERED, WBMemoryModules.SONIC_BOOM_SOUND_DELAY.get(), MemoryStatus.REGISTERED), DURATION); + super( + ImmutableMap.of( + MemoryModuleType.ATTACK_TARGET, + MemoryStatus.VALUE_PRESENT, + WBMemoryModules.SONIC_BOOM_COOLDOWN.get(), + MemoryStatus.VALUE_ABSENT, + WBMemoryModules.SONIC_BOOM_SOUND_COOLDOWN.get(), + MemoryStatus.REGISTERED, + WBMemoryModules.SONIC_BOOM_SOUND_DELAY.get(), + MemoryStatus.REGISTERED + ), + DURATION + ); } @Override protected boolean checkExtraStartConditions(ServerLevel level, Warden warden) { - return warden.closerThan(warden.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).get(), 15.0D, 20.0D); + return warden.closerThan( + warden.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).get(), + 15.0D, + 20.0D + ); } @Override @@ -41,33 +57,69 @@ public class SonicBoom extends Behavior { @Override protected void start(ServerLevel level, Warden warden, long time) { - warden.getBrain().setMemoryWithExpiry(MemoryModuleType.ATTACK_COOLING_DOWN, true, DURATION); - warden.getBrain().setMemoryWithExpiry(WBMemoryModules.SONIC_BOOM_SOUND_DELAY.get(), Unit.INSTANCE, SOUND_DELAY + 5); + warden.getBrain().setMemoryWithExpiry( + MemoryModuleType.ATTACK_COOLING_DOWN, true, DURATION + ); + warden.getBrain().setMemoryWithExpiry( + WBMemoryModules.SONIC_BOOM_SOUND_DELAY.get(), Unit.INSTANCE, SOUND_DELAY + 5 + ); level.broadcastEntityEvent(warden, Warden.SONIC_BOOM); warden.playSound(WBSoundEvents.WARDEN_SONIC_CHARGE, 3.0F, 1.0F); } @Override protected void tick(ServerLevel level, Warden warden, long time) { - warden.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).ifPresent(target -> warden.getLookControl().setLookAt(target.position())); - if (!warden.getBrain().hasMemoryValue(WBMemoryModules.SONIC_BOOM_SOUND_DELAY.get()) && !warden.getBrain().hasMemoryValue(WBMemoryModules.SONIC_BOOM_SOUND_COOLDOWN.get())) { - warden.getBrain().setMemoryWithExpiry(WBMemoryModules.SONIC_BOOM_SOUND_COOLDOWN.get(), Unit.INSTANCE, DURATION - SOUND_DELAY + 5); - warden.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).filter(warden::isValidTarget).filter(target -> warden.closerThan(target, 15.0D, 20.0D)).ifPresent(target -> { - Vec3 sourcePos = warden.position().add(0.0D, 1.6F, 0.0D); - Vec3 targetPos = target.getEyePosition().subtract(sourcePos); - Vec3 distance = targetPos.normalize(); + warden.getBrain() + .getMemory(MemoryModuleType.ATTACK_TARGET) + .ifPresent(target -> warden.getLookControl().setLookAt(target.position())); + if (!warden.getBrain().hasMemoryValue(WBMemoryModules.SONIC_BOOM_SOUND_DELAY.get() + ) + && !warden.getBrain().hasMemoryValue( + WBMemoryModules.SONIC_BOOM_SOUND_COOLDOWN.get() + )) { + warden.getBrain().setMemoryWithExpiry( + WBMemoryModules.SONIC_BOOM_SOUND_COOLDOWN.get(), + Unit.INSTANCE, + DURATION - SOUND_DELAY + 5 + ); + warden.getBrain() + .getMemory(MemoryModuleType.ATTACK_TARGET) + .filter(warden::isValidTarget) + .filter(target -> warden.closerThan(target, 15.0D, 20.0D)) + .ifPresent(target -> { + Vec3 sourcePos = warden.position().add(0.0D, 1.6F, 0.0D); + Vec3 targetPos = target.getEyePosition().subtract(sourcePos); + Vec3 distance = targetPos.normalize(); - for(int i = 1; i < Mth.floor(targetPos.length()) + 7; ++i) { - Vec3 charge = sourcePos.add(distance.scale(i)); - level.sendParticles(WBParticleTypes.SONIC_BOOM.get(), charge.x, charge.y, charge.z, 1, 0.0D, 0.0D, 0.0D, 0.0D); - } + for (int i = 1; i < Mth.floor(targetPos.length()) + 7; ++i) { + Vec3 charge = sourcePos.add(distance.scale(i)); + level.sendParticles( + WBParticleTypes.SONIC_BOOM.get(), + charge.x, + charge.y, + charge.z, + 1, + 0.0D, + 0.0D, + 0.0D, + 0.0D + ); + } - warden.playSound(WBSoundEvents.WARDEN_SONIC_BOOM, 3.0F, 1.0F); - target.hurt(sonicBoom(warden), 10.0F); - double yKnockback = 0.5D * (1.0D - target.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE)); - double xzKnockback = 2.5D * (1.0D - target.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE)); - target.push(distance.x() * xzKnockback, distance.y() * yKnockback, distance.z() * xzKnockback); - }); + warden.playSound(WBSoundEvents.WARDEN_SONIC_BOOM, 3.0F, 1.0F); + target.hurt(sonicBoom(warden), 10.0F); + double yKnockback = 0.5D + * (1.0D + - target.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE)); + double xzKnockback = 2.5D + * (1.0D + - target.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE)); + target.push( + distance.x() * xzKnockback, + distance.y() * yKnockback, + distance.z() * xzKnockback + ); + }); } } @@ -77,11 +129,15 @@ public class SonicBoom extends Behavior { } public static void setCooldown(LivingEntity entity, long cooldown) { - entity.getBrain().setMemoryWithExpiry(WBMemoryModules.SONIC_BOOM_COOLDOWN.get(), Unit.INSTANCE, cooldown); + entity.getBrain().setMemoryWithExpiry( + WBMemoryModules.SONIC_BOOM_COOLDOWN.get(), Unit.INSTANCE, cooldown + ); } @SuppressWarnings("ConstantConditions") public static DamageSource sonicBoom(Entity entity) { - return ((DamageSourceAccessor)new EntityDamageSource("sonic_boom", entity)).callBypassArmor().setMagic(); + return ((DamageSourceAccessor) new EntityDamageSource("sonic_boom", entity)) + .callBypassArmor() + .setMagic(); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/TryToSniff.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/TryToSniff.java index 78c7531..a26c320 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/TryToSniff.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/TryToSniff.java @@ -1,7 +1,7 @@ package com.cursedcauldron.wildbackport.common.entities.brain.warden; -import com.cursedcauldron.wildbackport.common.entities.access.api.Poses; import com.cursedcauldron.wildbackport.common.entities.Warden; +import com.cursedcauldron.wildbackport.common.entities.access.api.Poses; import com.cursedcauldron.wildbackport.common.registry.entity.WBMemoryModules; import com.google.common.collect.ImmutableMap; import net.minecraft.server.level.ServerLevel; @@ -16,13 +16,24 @@ public class TryToSniff extends Behavior { private static final IntProvider SNIFF_COOLDOWN = UniformInt.of(100, 200); public TryToSniff() { - super(ImmutableMap.of(WBMemoryModules.SNIFF_COOLDOWN.get(), MemoryStatus.VALUE_ABSENT, MemoryModuleType.NEAREST_ATTACKABLE, MemoryStatus.VALUE_PRESENT, WBMemoryModules.DISTURBANCE_LOCATION.get(), MemoryStatus.VALUE_ABSENT)); + super(ImmutableMap.of( + WBMemoryModules.SNIFF_COOLDOWN.get(), + MemoryStatus.VALUE_ABSENT, + MemoryModuleType.NEAREST_ATTACKABLE, + MemoryStatus.VALUE_PRESENT, + WBMemoryModules.DISTURBANCE_LOCATION.get(), + MemoryStatus.VALUE_ABSENT + )); } @Override protected void start(ServerLevel level, Warden warden, long time) { warden.getBrain().setMemory(WBMemoryModules.IS_SNIFFING.get(), Unit.INSTANCE); - warden.getBrain().setMemoryWithExpiry(WBMemoryModules.SNIFF_COOLDOWN.get(), Unit.INSTANCE, SNIFF_COOLDOWN.sample(level.getRandom())); + warden.getBrain().setMemoryWithExpiry( + WBMemoryModules.SNIFF_COOLDOWN.get(), + Unit.INSTANCE, + SNIFF_COOLDOWN.sample(level.getRandom()) + ); warden.getBrain().eraseMemory(MemoryModuleType.WALK_TARGET); warden.setPose(Poses.SNIFFING.get()); } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/WardenEntitySensor.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/WardenEntitySensor.java index 7583cbb..d019bf7 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/WardenEntitySensor.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/brain/warden/WardenEntitySensor.java @@ -1,5 +1,11 @@ package com.cursedcauldron.wildbackport.common.entities.brain.warden; +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.Set; +import java.util.function.Predicate; + import com.cursedcauldron.wildbackport.common.entities.Warden; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; @@ -8,26 +14,40 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.memory.MemoryModuleType; -import java.util.Collection; -import java.util.List; -import java.util.Optional; -import java.util.Set; -import java.util.function.Predicate; - public class WardenEntitySensor extends NearestLivingEntitySensor { @Override public Set> requires() { - return ImmutableSet.copyOf(Iterables.concat(super.requires(), List.of(MemoryModuleType.NEAREST_ATTACKABLE))); + return ImmutableSet.copyOf(Iterables.concat( + super.requires(), List.of(MemoryModuleType.NEAREST_ATTACKABLE) + )); } @Override protected void doTick(ServerLevel level, Warden warden) { super.doTick(level, warden); - findNearestTarget(warden, target -> target.getType() == EntityType.PLAYER).or(() -> findNearestTarget(warden, target -> target.getType() != EntityType.PLAYER)).ifPresentOrElse(target -> warden.getBrain().setMemory(MemoryModuleType.NEAREST_ATTACKABLE, target), () -> warden.getBrain().eraseMemory(MemoryModuleType.NEAREST_ATTACKABLE)); + findNearestTarget(warden, target -> target.getType() == EntityType.PLAYER) + .or(() + -> findNearestTarget( + warden, target -> target.getType() != EntityType.PLAYER + )) + .ifPresentOrElse( + target + -> warden.getBrain().setMemory( + MemoryModuleType.NEAREST_ATTACKABLE, target + ), + () -> warden.getBrain().eraseMemory(MemoryModuleType.NEAREST_ATTACKABLE) + ); } - private static Optional findNearestTarget(Warden warden, Predicate targetPredicate) { - return warden.getBrain().getMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES).stream().flatMap(Collection::stream).filter(warden::isValidTarget).filter(targetPredicate).findFirst(); + private static Optional + findNearestTarget(Warden warden, Predicate targetPredicate) { + return warden.getBrain() + .getMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES) + .stream() + .flatMap(Collection::stream) + .filter(warden::isValidTarget) + .filter(targetPredicate) + .findFirst(); } @Override diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/warden/Angriness.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/warden/Angriness.java index a6062db..8a47e9f 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/warden/Angriness.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/warden/Angriness.java @@ -1,11 +1,11 @@ package com.cursedcauldron.wildbackport.common.entities.warden; +import java.util.Arrays; + import com.cursedcauldron.wildbackport.client.registry.WBSoundEvents; import net.minecraft.Util; import net.minecraft.sounds.SoundEvent; -import java.util.Arrays; - //<> public enum Angriness { @@ -13,7 +13,10 @@ public enum Angriness { AGITATED(40, WBSoundEvents.WARDEN_AGITATED, WBSoundEvents.WARDEN_LISTENING_ANGRY), ANGRY(80, WBSoundEvents.WARDEN_ANGRY, WBSoundEvents.WARDEN_LISTENING_ANGRY); - private static final Angriness[] VALUES = Util.make(Angriness.values(), values -> Arrays.sort(values, (a, b) -> Integer.compare(b.threshold, a.threshold))); + private static final Angriness[] VALUES = Util.make( + Angriness.values(), + values -> Arrays.sort(values, (a, b) -> Integer.compare(b.threshold, a.threshold)) + ); private final int threshold; private final SoundEvent sound; private final SoundEvent listeningSound; diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/warden/MobPositionSource.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/warden/MobPositionSource.java index fa80bb9..8e08de9 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/warden/MobPositionSource.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/warden/MobPositionSource.java @@ -1,5 +1,9 @@ package com.cursedcauldron.wildbackport.common.entities.warden; +import java.util.Optional; +import java.util.UUID; +import java.util.function.Function; + import com.cursedcauldron.wildbackport.common.registry.WBPositionSources; import com.mojang.datafixers.util.Either; import com.mojang.serialization.Codec; @@ -13,12 +17,25 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.gameevent.PositionSource; import net.minecraft.world.level.gameevent.PositionSourceType; -import java.util.Optional; -import java.util.UUID; -import java.util.function.Function; - public class MobPositionSource implements PositionSource { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group((SerializableUUID.CODEC.fieldOf("source_entity")).forGetter(MobPositionSource::getUuid), (Codec.FLOAT.fieldOf("y_offset")).orElse(0.0f).forGetter(entityPositionSource -> entityPositionSource.yOffset)).apply(instance, (uUID, float_) -> new MobPositionSource(Either.right(Either.left(uUID)), float_.floatValue()))); + public static final Codec CODEC = RecordCodecBuilder.create( + instance + -> instance + .group( + (SerializableUUID.CODEC.fieldOf("source_entity")) + .forGetter(MobPositionSource::getUuid), + (Codec.FLOAT.fieldOf("y_offset")) + .orElse(0.0f) + .forGetter(entityPositionSource -> entityPositionSource.yOffset) + ) + .apply( + instance, + (uUID, float_) + -> new MobPositionSource( + Either.right(Either.left(uUID)), float_.floatValue() + ) + ) + ); private Either> source; final float yOffset; @@ -26,7 +43,9 @@ public class MobPositionSource implements PositionSource { this(Either.left(entity), yOffset); } - public MobPositionSource(Either> sourceEntityId, float yOffset) { + public MobPositionSource( + Either> sourceEntityId, float yOffset + ) { this.source = sourceEntityId; this.yOffset = yOffset; } @@ -36,21 +55,31 @@ public class MobPositionSource implements PositionSource { if (this.source.left().isEmpty()) { this.findEntityInWorld(world); } - return this.source.left().map(entity -> entity.blockPosition().offset(0.0, this.yOffset, 0.0)); + return this.source.left().map( + entity -> entity.blockPosition().offset(0.0, this.yOffset, 0.0) + ); } private void findEntityInWorld(Level world) { - this.source.map(Optional::of, either -> Optional.ofNullable(either.map(uuid -> { - Entity entity; - if (world instanceof ServerLevel serverLevel) { - entity = serverLevel.getEntity(uuid); - } else { - entity = null; - } - return entity; - }, world::getEntity))).ifPresent(entity -> { - this.source = Either.left(entity); - }); + this.source + .map( + Optional::of, + either + -> Optional.ofNullable(either.map( + uuid + -> { + Entity entity; + if (world instanceof ServerLevel serverLevel) { + entity = serverLevel.getEntity(uuid); + } else { + entity = null; + } + return entity; + }, + world::getEntity + )) + ) + .ifPresent(entity -> { this.source = Either.left(entity); }); } @Override @@ -59,9 +88,10 @@ public class MobPositionSource implements PositionSource { } private UUID getUuid() { - return this.source.map(Entity::getUUID, either -> either.map(Function.identity(), integer -> { - throw new RuntimeException("Unable to get entityId from uuid"); - })); + return this.source + .map(Entity::getUUID, either -> either.map(Function.identity(), integer -> { + throw new RuntimeException("Unable to get entityId from uuid"); + })); } int getEntityId() { @@ -73,7 +103,9 @@ public class MobPositionSource implements PositionSource { public static class Type implements PositionSourceType { @Override public MobPositionSource read(FriendlyByteBuf buf) { - return new MobPositionSource(Either.right(Either.right(buf.readVarInt())), buf.readFloat()); + return new MobPositionSource( + Either.right(Either.right(buf.readVarInt())), buf.readFloat() + ); } @Override diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/warden/VibrationHandler.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/warden/VibrationHandler.java index 0afcc2b..a1160d6 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/warden/VibrationHandler.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/warden/VibrationHandler.java @@ -1,5 +1,8 @@ package com.cursedcauldron.wildbackport.common.entities.warden; +import java.util.Optional; +import java.util.UUID; + import com.cursedcauldron.wildbackport.client.registry.WBCriteriaTriggers; import com.cursedcauldron.wildbackport.common.utils.PositionUtils; import com.mojang.serialization.Codec; @@ -27,38 +30,54 @@ import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.Nullable; -import java.util.Optional; -import java.util.UUID; - //<> public class VibrationHandler implements GameEventListener { protected final PositionSource source; protected final int range; protected final VibrationConfig config; - @Nullable protected Vibration event; + @Nullable + protected Vibration event; protected float distance; protected int delay; public static Codec codec(VibrationConfig config) { return RecordCodecBuilder.create(instance -> { - return instance.group(PositionSource.CODEC.fieldOf("source").forGetter(listener -> { - return listener.source; - }), ExtraCodecs.NON_NEGATIVE_INT.fieldOf("range").forGetter(listener -> { - return listener.range; - }), Vibration.CODEC.optionalFieldOf("event").forGetter(listener -> { - return Optional.ofNullable(listener.event); - }), Codec.floatRange(0.0F, Float.MAX_VALUE).fieldOf("event_distance").orElse(0.0F).forGetter(listener -> { - return listener.distance; - }), ExtraCodecs.NON_NEGATIVE_INT.fieldOf("event_delay").orElse(0).forGetter(listener -> { - return listener.delay; - })).apply(instance, (source, range, event, distance, delay) -> { - return new VibrationHandler(source, range, config, event.orElse(null), distance, delay); - }); + return instance + .group( + PositionSource.CODEC.fieldOf("source").forGetter(listener -> { + return listener.source; + }), + ExtraCodecs.NON_NEGATIVE_INT.fieldOf("range").forGetter(listener -> { + return listener.range; + }), + Vibration.CODEC.optionalFieldOf("event").forGetter(listener -> { + return Optional.ofNullable(listener.event); + }), + Codec.floatRange(0.0F, Float.MAX_VALUE) + .fieldOf("event_distance") + .orElse(0.0F) + .forGetter(listener -> { return listener.distance; }), + ExtraCodecs.NON_NEGATIVE_INT.fieldOf("event_delay") + .orElse(0) + .forGetter(listener -> { return listener.delay; }) + ) + .apply(instance, (source, range, event, distance, delay) -> { + return new VibrationHandler( + source, range, config, event.orElse(null), distance, delay + ); + }); }); } - public VibrationHandler(PositionSource source, int range, VibrationConfig config, @Nullable Vibration event, float distance, int delay) { + public VibrationHandler( + PositionSource source, + int range, + VibrationConfig config, + @Nullable Vibration event, + float distance, + int delay + ) { this.source = source; this.range = range; this.config = config; @@ -77,7 +96,15 @@ public class VibrationHandler implements GameEventListener { --this.delay; if (this.delay <= 0) { this.delay = 0; - this.config.onSignalReceive(server, this, new BlockPos(this.event.pos), this.event.event, this.event.getEntity(server).orElse(null), this.event.getProjectileOwner(server).orElse(null), this.distance); + this.config.onSignalReceive( + server, + this, + new BlockPos(this.event.pos), + this.event.event, + this.event.getEntity(server).orElse(null), + this.event.getProjectileOwner(server).orElse(null), + this.distance + ); this.event = null; } } @@ -95,9 +122,10 @@ public class VibrationHandler implements GameEventListener { } @Override - public boolean handleGameEvent(Level level, GameEvent event, @Nullable Entity entity, BlockPos pos) { + public boolean + handleGameEvent(Level level, GameEvent event, @Nullable Entity entity, BlockPos pos) { if (this.event != null) { - return false; + return false; } else { Optional optional = this.source.getPosition(level); if (!this.config.isValidVibration(event, entity)) { @@ -105,7 +133,9 @@ public class VibrationHandler implements GameEventListener { } else { Vec3 source = PositionUtils.toVec(pos); Vec3 target = PositionUtils.toVec(optional.get()); - if (!this.config.shouldListen((ServerLevel)level, this, new BlockPos(source), event, entity)) { + if (!this.config.shouldListen( + (ServerLevel) level, this, new BlockPos(source), event, entity + )) { return false; } else if (isOccluded(level, source, target)) { return false; @@ -117,23 +147,43 @@ public class VibrationHandler implements GameEventListener { } } - private void scheduleSignal(Level level, GameEvent event, @Nullable Entity entity, Vec3 source, Vec3 target) { - this.distance = (float)source.distanceTo(target); + private void scheduleSignal( + Level level, GameEvent event, @Nullable Entity entity, Vec3 source, Vec3 target + ) { + this.distance = (float) source.distanceTo(target); this.event = new Vibration(event, this.distance, source, entity); this.delay = Mth.floor(this.distance); - ((ServerLevel)level).sendVibrationParticle(new VibrationPath(PositionUtils.toBlockPos(source), this.source, this.delay)); + ((ServerLevel) level) + .sendVibrationParticle(new VibrationPath( + PositionUtils.toBlockPos(source), this.source, this.delay + )); this.config.onSignalSchedule(); } private static boolean isOccluded(Level level, Vec3 source, Vec3 target) { - Vec3 sourceVec = new Vec3((double)Mth.floor(source.x) + 0.5D, (double)Mth.floor(source.y) + 0.5D, (double)Mth.floor(source.z) + 0.5D); - Vec3 targetVec = new Vec3((double)Mth.floor(target.x) + 0.5D, (double)Mth.floor(target.y) + 0.5D, (double)Mth.floor(target.z) + 0.5D); + Vec3 sourceVec = new Vec3( + (double) Mth.floor(source.x) + 0.5D, + (double) Mth.floor(source.y) + 0.5D, + (double) Mth.floor(source.z) + 0.5D + ); + Vec3 targetVec = new Vec3( + (double) Mth.floor(target.x) + 0.5D, + (double) Mth.floor(target.y) + 0.5D, + (double) Mth.floor(target.z) + 0.5D + ); for (Direction direction : Direction.values()) { Vec3 offsetVec = PositionUtils.relative(sourceVec, direction, 1.0E-5F); - if (level.isBlockInLine(new ClipBlockStateContext(offsetVec, targetVec, state -> { - return state.is(BlockTags.OCCLUDES_VIBRATION_SIGNALS); - })).getType() != HitResult.Type.BLOCK) { + if (level + .isBlockInLine(new ClipBlockStateContext( + offsetVec, + targetVec, + state -> { + return state.is(BlockTags.OCCLUDES_VIBRATION_SIGNALS); + } + )) + .getType() + != HitResult.Type.BLOCK) { return false; } } @@ -141,23 +191,66 @@ public class VibrationHandler implements GameEventListener { return true; } - public record Vibration(GameEvent event, float distance, Vec3 pos, @Nullable UUID source, @Nullable UUID projectileOwner, @Nullable Entity entity) { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> { - return instance.group(Registry.GAME_EVENT.byNameCodec().fieldOf("game_event").forGetter(Vibration::event), Codec.floatRange(0.0F, Float.MAX_VALUE).fieldOf("distance").forGetter(Vibration::distance), PositionUtils.VEC_CODEC.fieldOf("pos").forGetter(Vibration::pos), SerializableUUID.CODEC.optionalFieldOf("source").forGetter(entity -> { - return Optional.ofNullable(entity.source()); - }), SerializableUUID.CODEC.optionalFieldOf("projectile_owner").forGetter(entity -> { - return Optional.ofNullable(entity.projectileOwner()); - })).apply(instance, (event, distance, pos, source, projectileOwner) -> { - return new Vibration(event, distance, pos, source.orElse(null), projectileOwner.orElse(null)); - }); - }); + public record Vibration( + GameEvent event, + float distance, + Vec3 pos, + @Nullable UUID source, + @Nullable UUID projectileOwner, + @Nullable Entity entity + ) { + public static final Codec CODEC = RecordCodecBuilder.create( + instance -> { + return instance + .group( + Registry.GAME_EVENT.byNameCodec() + .fieldOf("game_event") + .forGetter(Vibration::event), + Codec.floatRange(0.0F, Float.MAX_VALUE) + .fieldOf("distance") + .forGetter(Vibration::distance), + PositionUtils.VEC_CODEC.fieldOf("pos").forGetter(Vibration::pos), + SerializableUUID.CODEC.optionalFieldOf("source").forGetter( + entity -> { return Optional.ofNullable(entity.source()); } + ), + SerializableUUID.CODEC.optionalFieldOf("projectile_owner") + .forGetter(entity -> { + return Optional.ofNullable(entity.projectileOwner()); + }) + ) + .apply(instance, (event, distance, pos, source, projectileOwner) -> { + return new Vibration( + event, + distance, + pos, + source.orElse(null), + projectileOwner.orElse(null) + ); + }); + } + ); - public Vibration(GameEvent event, float distance, Vec3 pos, @Nullable UUID source, @Nullable UUID projectileOwner) { + public Vibration( + GameEvent event, + float distance, + Vec3 pos, + @Nullable UUID source, + @Nullable UUID projectileOwner + ) { this(event, distance, pos, source, projectileOwner, null); } - public Vibration(GameEvent event, float distance, Vec3 pos, @Nullable Entity entity) { - this(event, distance, pos, entity == null ? null : entity.getUUID(), getProjectileOwner(entity), entity); + public Vibration( + GameEvent event, float distance, Vec3 pos, @Nullable Entity entity + ) { + this( + event, + distance, + pos, + entity == null ? null : entity.getUUID(), + getProjectileOwner(entity), + entity + ); } @Nullable @@ -178,13 +271,14 @@ public class VibrationHandler implements GameEventListener { } public Optional getProjectileOwner(ServerLevel level) { - return this.getEntity(level).filter(entity -> { - return entity instanceof Projectile; - }).map(entity -> { - return (Projectile)entity; - }).map(Projectile::getOwner).or(() -> { - return Optional.ofNullable(this.projectileOwner).map(level::getEntity); - }); + return this.getEntity(level) + .filter(entity -> { return entity instanceof Projectile; }) + .map(entity -> { return (Projectile) entity; }) + .map(Projectile::getOwner) + .or(() -> { + return Optional.ofNullable(this.projectileOwner) + .map(level::getEntity); + }); } } @@ -198,7 +292,7 @@ public class VibrationHandler implements GameEventListener { } default boolean isValidVibration(GameEvent event, @Nullable Entity entity) { - if (!event.is(this.getListenableEvents())) { + if (!event.is(this.getListenableEvents())) { return false; } else { if (entity != null) { @@ -206,8 +300,10 @@ public class VibrationHandler implements GameEventListener { return false; } - if (entity.isSteppingCarefully() && event.is(GameEventTags.IGNORE_VIBRATIONS_SNEAKING)) { - if (this.canTriggerAvoidVibration() && entity instanceof ServerPlayer player) { + if (entity.isSteppingCarefully() + && event.is(GameEventTags.IGNORE_VIBRATIONS_SNEAKING)) { + if (this.canTriggerAvoidVibration() + && entity instanceof ServerPlayer player) { WBCriteriaTriggers.AVOID_VIBRATION.trigger(player); } @@ -221,9 +317,23 @@ public class VibrationHandler implements GameEventListener { } } - boolean shouldListen(ServerLevel level, GameEventListener listener, BlockPos pos, GameEvent event, @Nullable Entity entity); + boolean shouldListen( + ServerLevel level, + GameEventListener listener, + BlockPos pos, + GameEvent event, + @Nullable Entity entity + ); - void onSignalReceive(ServerLevel level, GameEventListener listener, BlockPos pos, GameEvent event, @Nullable Entity entity, @Nullable Entity source, float distance); + void onSignalReceive( + ServerLevel level, + GameEventListener listener, + BlockPos pos, + GameEvent event, + @Nullable Entity entity, + @Nullable Entity source, + float distance + ); default void onSignalSchedule() {} } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/warden/WardenAngerManager.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/warden/WardenAngerManager.java index e802733..3075726 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/warden/WardenAngerManager.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/warden/WardenAngerManager.java @@ -1,5 +1,16 @@ package com.cursedcauldron.wildbackport.common.entities.warden; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Optional; +import java.util.Random; +import java.util.UUID; +import java.util.function.Predicate; +import java.util.stream.Collectors; +import javax.annotation.Nullable; + import com.google.common.collect.Streams; import com.mojang.datafixers.util.Pair; import com.mojang.serialization.Codec; @@ -15,23 +26,23 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; -import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Optional; -import java.util.Random; -import java.util.UUID; -import java.util.function.Predicate; -import java.util.stream.Collectors; - //<> public class WardenAngerManager { private int updateTimer = Mth.randomBetweenInclusive(new Random(), 0, 2); int primeAnger; - private static final Codec> SUSPECT_CODEC = RecordCodecBuilder.create(instance -> instance.group(SerializableUUID.CODEC.fieldOf("uuid").forGetter(Pair::getFirst), ExtraCodecs.NON_NEGATIVE_INT.fieldOf("anger").forGetter(Pair::getSecond)).apply(instance, Pair::of)); + private static final Codec> SUSPECT_CODEC + = RecordCodecBuilder.create( + instance + -> instance + .group( + SerializableUUID.CODEC.fieldOf("uuid").forGetter(Pair::getFirst), + ExtraCodecs.NON_NEGATIVE_INT.fieldOf("anger").forGetter( + Pair::getSecond + ) + ) + .apply(instance, Pair::of) + ); private final Predicate suspectPredicate; protected final ArrayList suspects; private final SuspectComparator suspectComparator; @@ -39,20 +50,49 @@ public class WardenAngerManager { protected final Object2IntMap suspectUuidsToAngerLevel; public static Codec codec(Predicate validTarget) { - return RecordCodecBuilder.create(instance -> instance.group(SUSPECT_CODEC.listOf().fieldOf("suspects").orElse(Collections.emptyList()).forGetter(WardenAngerManager::getSuspects)).apply(instance, suspects -> new WardenAngerManager(validTarget, suspects))); + return RecordCodecBuilder.create( + instance + -> instance + .group(SUSPECT_CODEC.listOf() + .fieldOf("suspects") + .orElse(Collections.emptyList()) + .forGetter(WardenAngerManager::getSuspects)) + .apply( + instance, suspects -> new WardenAngerManager(validTarget, suspects) + ) + ); } - public WardenAngerManager(Predicate suspectPredicate, List> suspectUuidsToAngerLevel) { + public WardenAngerManager( + Predicate suspectPredicate, + List> suspectUuidsToAngerLevel + ) { this.suspectPredicate = suspectPredicate; this.suspects = new ArrayList<>(); this.suspectComparator = new SuspectComparator(this); this.suspectsToAngerLevel = new Object2IntOpenHashMap<>(); - this.suspectUuidsToAngerLevel = new Object2IntOpenHashMap<>(suspectUuidsToAngerLevel.size()); - suspectUuidsToAngerLevel.forEach(suspect -> this.suspectUuidsToAngerLevel.put(suspect.getFirst(), suspect.getSecond())); + this.suspectUuidsToAngerLevel + = new Object2IntOpenHashMap<>(suspectUuidsToAngerLevel.size()); + suspectUuidsToAngerLevel.forEach( + suspect + -> this.suspectUuidsToAngerLevel.put(suspect.getFirst(), suspect.getSecond()) + ); } private List> getSuspects() { - return Streams.concat(this.suspects.stream().map(suspect -> Pair.of(suspect.getUUID(), this.suspectsToAngerLevel.getInt(suspect))), this.suspectUuidsToAngerLevel.object2IntEntrySet().stream().map(entry -> Pair.of(entry.getKey(), entry.getIntValue()))).collect(Collectors.toList()); + return Streams + .concat( + this.suspects.stream().map( + suspect + -> Pair.of( + suspect.getUUID(), this.suspectsToAngerLevel.getInt(suspect) + ) + ), + this.suspectUuidsToAngerLevel.object2IntEntrySet().stream().map( + entry -> Pair.of(entry.getKey(), entry.getIntValue()) + ) + ) + .collect(Collectors.toList()); } public void tick(ServerLevel level, Predicate suspectPredicate) { @@ -62,9 +102,10 @@ public class WardenAngerManager { this.updateTimer = 2; } - ObjectIterator> uuidToAnger = this.suspectUuidsToAngerLevel.object2IntEntrySet().iterator(); + ObjectIterator> uuidToAnger + = this.suspectUuidsToAngerLevel.object2IntEntrySet().iterator(); - while(uuidToAnger.hasNext()) { + while (uuidToAnger.hasNext()) { Object2IntMap.Entry entry = uuidToAnger.next(); int anger = entry.getIntValue(); if (anger <= 1) { @@ -74,9 +115,10 @@ public class WardenAngerManager { } } - ObjectIterator> suspectToAnger = this.suspectsToAngerLevel.object2IntEntrySet().iterator(); + ObjectIterator> suspectToAnger + = this.suspectsToAngerLevel.object2IntEntrySet().iterator(); - while(suspectToAnger.hasNext()) { + while (suspectToAnger.hasNext()) { Object2IntMap.Entry entry = suspectToAnger.next(); int anger = entry.getIntValue(); Entity entity = entry.getKey(); @@ -121,57 +163,83 @@ public class WardenAngerManager { public int increaseAngerAt(Entity entity, int amount) { boolean isTarget = !this.suspectsToAngerLevel.containsKey(entity); int angerLevel = this.suspectsToAngerLevel.computeInt(entity, (suspect, anger) -> Math.min(150, (anger == null ? 0 : anger) + amount)); - if (isTarget) { - int modifier = this.suspectUuidsToAngerLevel.removeInt(entity.getUUID()); - this.suspectsToAngerLevel.put(entity, angerLevel += modifier); - this.suspects.add(entity); - } + if (isTarget) { + int modifier = this.suspectUuidsToAngerLevel.removeInt( + entity.getUUID() + ); + this.suspectsToAngerLevel.put( + entity, angerLevel += modifier + ); + this.suspects.add(entity); + } - this.updatePrimeAnger(); - return angerLevel; - } - - public void removeSuspect(Entity entity) { - this.suspectsToAngerLevel.removeInt(entity); - this.suspects.remove(entity); - this.updatePrimeAnger(); - } - - @Nullable - private Entity getPrimeSuspectInternal() { - return this.suspects.stream().filter(this.suspectPredicate).findFirst().orElse(null); - } - - public int getAngerFor(@Nullable Entity entity) { - return entity == null ? this.primeAnger : this.suspectsToAngerLevel.getInt(entity); - } - - public Optional getPrimeSuspect() { - return Optional.ofNullable(this.getPrimeSuspectInternal()).filter(suspect -> suspect instanceof LivingEntity).map(suspect -> (LivingEntity)suspect); - } - - protected record SuspectComparator(WardenAngerManager angerManagement) implements Comparator { - public int compare(Entity firstSuspect, Entity secondSuspect) { - if (firstSuspect.equals(secondSuspect)) { - return 0; - } else { - int angerToFirstSuspect = this.angerManagement.suspectsToAngerLevel.getOrDefault(firstSuspect, 0); - int angerToSecondSuspect = this.angerManagement.suspectsToAngerLevel.getOrDefault(secondSuspect, 0); - this.angerManagement.primeAnger = Math.max(this.angerManagement.primeAnger, Math.max(angerToFirstSuspect, angerToSecondSuspect)); - boolean isAngryWithFirstSuspect = Angriness.getForAnger(angerToFirstSuspect).isAngry(); - boolean isAngryWithSecondSuspect = Angriness.getForAnger(angerToSecondSuspect).isAngry(); - if (isAngryWithFirstSuspect != isAngryWithSecondSuspect) { - return isAngryWithFirstSuspect ? -1 : 1; - } else { - boolean isFirstSuspectPlayer = firstSuspect instanceof Player; - boolean isSecondSuspectPlayer = secondSuspect instanceof Player; - if (isFirstSuspectPlayer != isSecondSuspectPlayer) { - return isFirstSuspectPlayer ? -1 : 1; - } else { - return Integer.compare(angerToSecondSuspect, angerToFirstSuspect); + this.updatePrimeAnger(); + return angerLevel; } - } - } - } - } -} \ No newline at end of file + + public void removeSuspect(Entity entity) { + this.suspectsToAngerLevel.removeInt(entity); + this.suspects.remove(entity); + this.updatePrimeAnger(); + } + + @Nullable + private Entity getPrimeSuspectInternal() { + return this.suspects.stream() + .filter(this.suspectPredicate) + .findFirst() + .orElse(null); + } + + public int getAngerFor(@Nullable Entity entity) { + return entity == null ? this.primeAnger + : this.suspectsToAngerLevel.getInt(entity); + } + + public Optional getPrimeSuspect() { + return Optional.ofNullable(this.getPrimeSuspectInternal()) + .filter(suspect -> suspect instanceof LivingEntity) + .map(suspect -> (LivingEntity) suspect); + } + + protected record SuspectComparator(WardenAngerManager angerManagement) + implements Comparator { + public int compare(Entity firstSuspect, Entity secondSuspect) { + if (firstSuspect.equals(secondSuspect)) { + return 0; + } else { + int angerToFirstSuspect + = this.angerManagement.suspectsToAngerLevel + .getOrDefault(firstSuspect, 0); + int angerToSecondSuspect + = this.angerManagement.suspectsToAngerLevel + .getOrDefault(secondSuspect, 0); + this.angerManagement.primeAnger = Math.max( + this.angerManagement.primeAnger, + Math.max(angerToFirstSuspect, angerToSecondSuspect) + ); + boolean isAngryWithFirstSuspect + = Angriness.getForAnger(angerToFirstSuspect) + .isAngry(); + boolean isAngryWithSecondSuspect + = Angriness.getForAnger(angerToSecondSuspect) + .isAngry(); + if (isAngryWithFirstSuspect != isAngryWithSecondSuspect) { + return isAngryWithFirstSuspect ? -1 : 1; + } else { + boolean isFirstSuspectPlayer + = firstSuspect instanceof Player; + boolean isSecondSuspectPlayer + = secondSuspect instanceof Player; + if (isFirstSuspectPlayer != isSecondSuspectPlayer) { + return isFirstSuspectPlayer ? -1 : 1; + } else { + return Integer.compare( + angerToSecondSuspect, angerToFirstSuspect + ); + } + } + } + } + } + } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/warden/WardenSpawnHelper.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/warden/WardenSpawnHelper.java index b865caa..0b4563c 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/warden/WardenSpawnHelper.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/warden/WardenSpawnHelper.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.entities.warden; +import java.util.Optional; + import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; @@ -10,20 +12,30 @@ import net.minecraft.world.entity.MobSpawnType; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; -import java.util.Optional; - public class WardenSpawnHelper { - public static Optional trySpawnMob(EntityType type, MobSpawnType spawnType, ServerLevel level, BlockPos pos, int tries, int xzRange, int yRange) { + public static Optional trySpawnMob( + EntityType type, + MobSpawnType spawnType, + ServerLevel level, + BlockPos pos, + int tries, + int xzRange, + int yRange + ) { BlockPos.MutableBlockPos mutable = pos.mutable(); - for(int i = 0; i < tries; ++i) { + for (int i = 0; i < tries; ++i) { int x = Mth.randomBetweenInclusive(level.random, -xzRange, xzRange); int z = Mth.randomBetweenInclusive(level.random, -xzRange, xzRange); mutable.setWithOffset(pos, x, yRange, z); - if (level.getWorldBorder().isWithinBounds(mutable) && moveToPossibleSpawnPosition(level, yRange, mutable)) { - T mob = type.create(level, null, null, null, mutable, spawnType, false, false); + if (level.getWorldBorder().isWithinBounds(mutable) + && moveToPossibleSpawnPosition(level, yRange, mutable)) { + T mob = type.create( + level, null, null, null, mutable, spawnType, false, false + ); if (mob != null) { - if (mob.checkSpawnRules(level, spawnType) && mob.checkSpawnObstruction(level)) { + if (mob.checkSpawnRules(level, spawnType) + && mob.checkSpawnObstruction(level)) { level.addFreshEntityWithPassengers(mob); return Optional.of(mob); } @@ -36,11 +48,13 @@ public class WardenSpawnHelper { return Optional.empty(); } - private static boolean moveToPossibleSpawnPosition(ServerLevel level, int yRange, BlockPos.MutableBlockPos pos) { + private static boolean moveToPossibleSpawnPosition( + ServerLevel level, int yRange, BlockPos.MutableBlockPos pos + ) { BlockPos.MutableBlockPos toPos = (new BlockPos.MutableBlockPos()).set(pos); BlockState toState = level.getBlockState(toPos); - for(int i = yRange; i >= -yRange; --i) { + for (int i = yRange; i >= -yRange; --i) { pos.move(Direction.DOWN); toPos.setWithOffset(pos, Direction.UP); BlockState state = level.getBlockState(pos); @@ -55,7 +69,14 @@ public class WardenSpawnHelper { return false; } - public static boolean canSpawnOn(ServerLevel level, BlockPos pos, BlockState state, BlockPos toPos, BlockState toState) { - return toState.getCollisionShape(level, toPos).isEmpty() && Block.isFaceFull(state.getCollisionShape(level, pos), Direction.UP); + public static boolean canSpawnOn( + ServerLevel level, + BlockPos pos, + BlockState state, + BlockPos toPos, + BlockState toState + ) { + return toState.getCollisionShape(level, toPos).isEmpty() + && Block.isFaceFull(state.getCollisionShape(level, pos), Direction.UP); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/warden/WardenSpawnTracker.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/warden/WardenSpawnTracker.java index afb8cb1..105139a 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/warden/WardenSpawnTracker.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/entities/warden/WardenSpawnTracker.java @@ -1,5 +1,11 @@ package com.cursedcauldron.wildbackport.common.entities.warden; +import java.util.Comparator; +import java.util.List; +import java.util.Optional; +import java.util.OptionalInt; +import java.util.function.Predicate; + import com.cursedcauldron.wildbackport.common.entities.Warden; import com.cursedcauldron.wildbackport.common.entities.access.WardenTracker; import com.mojang.serialization.Codec; @@ -15,30 +21,34 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; -import java.util.Comparator; -import java.util.List; -import java.util.Optional; -import java.util.OptionalInt; -import java.util.function.Predicate; - //<> public class WardenSpawnTracker { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> { - return instance.group(ExtraCodecs.NON_NEGATIVE_INT.fieldOf("ticks_since_last_warning").orElse(0).forGetter(tracker -> { - return tracker.ticksSinceLastWarning; - }), ExtraCodecs.NON_NEGATIVE_INT.fieldOf("warning_level").orElse(0).forGetter(tracker -> { - return tracker.warningLevel; - }), ExtraCodecs.NON_NEGATIVE_INT.fieldOf("cooldown_ticks").orElse(0).forGetter(tracker -> { - return tracker.cooldownTicks; - })).apply(instance, WardenSpawnTracker::new); - }); + public static final Codec CODEC = RecordCodecBuilder.create( + instance -> { + return instance + .group( + ExtraCodecs.NON_NEGATIVE_INT.fieldOf("ticks_since_last_warning") + .orElse(0) + .forGetter(tracker -> { return tracker.ticksSinceLastWarning; }), + ExtraCodecs.NON_NEGATIVE_INT.fieldOf("warning_level") + .orElse(0) + .forGetter(tracker -> { return tracker.warningLevel; }), + ExtraCodecs.NON_NEGATIVE_INT.fieldOf("cooldown_ticks") + .orElse(0) + .forGetter(tracker -> { return tracker.cooldownTicks; }) + ) + .apply(instance, WardenSpawnTracker::new); + } + ); private int ticksSinceLastWarning; private int warningLevel; private int cooldownTicks; - public WardenSpawnTracker(int ticksSinceLastWarning, int warningLevel, int cooldownTicks) { + public WardenSpawnTracker( + int ticksSinceLastWarning, int warningLevel, int cooldownTicks + ) { this.ticksSinceLastWarning = ticksSinceLastWarning; this.warningLevel = warningLevel; this.cooldownTicks = cooldownTicks; @@ -67,21 +77,31 @@ public class WardenSpawnTracker { return this.cooldownTicks > 0; } - public static OptionalInt tryWarn(ServerLevel level, BlockPos pos, ServerPlayer player) { + public static OptionalInt + tryWarn(ServerLevel level, BlockPos pos, ServerPlayer player) { if (!hasNearbyWarden(level, pos)) { List players = getNearbyPlayers(level, pos); if (!players.contains(player)) { players.add(player); } - if (players.stream().anyMatch(playerIn -> WardenTracker.of(playerIn).getWardenSpawnTracker().onCooldown())) { + if (players.stream().anyMatch( + playerIn + -> WardenTracker.of(playerIn).getWardenSpawnTracker().onCooldown() + )) { return OptionalInt.empty(); } - Optional optional = players.stream().map(WardenTracker::getWardenSpawnTracker).max(Comparator.comparingInt(tracker -> tracker.warningLevel)); + Optional optional + = players.stream() + .map(WardenTracker::getWardenSpawnTracker) + .max(Comparator.comparingInt(tracker -> tracker.warningLevel)); WardenSpawnTracker tracker = optional.get(); tracker.increaseWarningLevel(); - players.forEach(playerIn -> WardenTracker.of(playerIn).getWardenSpawnTracker().copyData(tracker)); + players.forEach( + playerIn + -> WardenTracker.of(playerIn).getWardenSpawnTracker().copyData(tracker) + ); return OptionalInt.of(tracker.warningLevel); } else { return OptionalInt.empty(); @@ -95,8 +115,11 @@ public class WardenSpawnTracker { private static List getNearbyPlayers(ServerLevel level, BlockPos pos) { Vec3 center = Vec3.atCenterOf(pos); - Predicate predicate = player -> player.position().closerThan(center, 16.0D); - return level.getPlayers(predicate.and(LivingEntity::isAlive).and(EntitySelector.NO_SPECTATORS)); + Predicate predicate + = player -> player.position().closerThan(center, 16.0D); + return level.getPlayers( + predicate.and(LivingEntity::isAlive).and(EntitySelector.NO_SPECTATORS) + ); } private void increaseWarningLevel() { diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/items/ChestBoatItem.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/items/ChestBoatItem.java index 76b32fc..c1bcc02 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/items/ChestBoatItem.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/items/ChestBoatItem.java @@ -1,5 +1,8 @@ package com.cursedcauldron.wildbackport.common.items; +import java.util.List; +import java.util.function.Predicate; + import com.cursedcauldron.wildbackport.common.entities.ChestBoat; import com.cursedcauldron.wildbackport.common.entities.MangroveBoat; import net.minecraft.core.BlockPos; @@ -19,13 +22,11 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; -import java.util.List; -import java.util.function.Predicate; - //<> public class ChestBoatItem extends Item { - private static final Predicate RIDERS = EntitySelector.NO_SPECTATORS.and(Entity::isPickable); + private static final Predicate RIDERS + = EntitySelector.NO_SPECTATORS.and(Entity::isPickable); private final Boat.Type type; private final boolean chested; @@ -36,19 +37,27 @@ public class ChestBoatItem extends Item { } @Override - public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { + public InteractionResultHolder + use(Level level, Player player, InteractionHand hand) { ItemStack stack = player.getItemInHand(hand); HitResult hitResult = getPlayerPOVHitResult(level, player, ClipContext.Fluid.ANY); if (hitResult.getType() == HitResult.Type.MISS) { return InteractionResultHolder.pass(stack); } else { Vec3 viewVector = player.getViewVector(1.0F); - List entities = level.getEntities(player, player.getBoundingBox().expandTowards(viewVector.scale(5.0D)).inflate(1.0D), RIDERS); + List entities = level.getEntities( + player, + player.getBoundingBox() + .expandTowards(viewVector.scale(5.0D)) + .inflate(1.0D), + RIDERS + ); if (!entities.isEmpty()) { Vec3 eyePosition = player.getEyePosition(); for (Entity entity : entities) { AABB box = entity.getBoundingBox().inflate(entity.getPickRadius()); - if (box.contains(eyePosition)) return InteractionResultHolder.pass(stack); + if (box.contains(eyePosition)) + return InteractionResultHolder.pass(stack); } } @@ -61,12 +70,19 @@ public class ChestBoatItem extends Item { } else { if (!level.isClientSide) { level.addFreshEntity(boat); - level.gameEvent(player, GameEvent.ENTITY_PLACE, new BlockPos(hitResult.getLocation())); - if (!player.getAbilities().instabuild) stack.shrink(1); + level.gameEvent( + player, + GameEvent.ENTITY_PLACE, + new BlockPos(hitResult.getLocation()) + ); + if (!player.getAbilities().instabuild) + stack.shrink(1); } player.awardStat(Stats.ITEM_USED.get(this)); - return InteractionResultHolder.sidedSuccess(stack, level.isClientSide); + return InteractionResultHolder.sidedSuccess( + stack, level.isClientSide + ); } } else { return InteractionResultHolder.pass(stack); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/items/CompassItemPropertyFunction.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/items/CompassItemPropertyFunction.java index 41830e7..582fcb8 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/items/CompassItemPropertyFunction.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/items/CompassItemPropertyFunction.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.items; +import javax.annotation.Nullable; + import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.item.ClampedItemPropertyFunction; import net.minecraft.core.BlockPos; @@ -11,31 +13,43 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.phys.Vec3; -import javax.annotation.Nullable; - public class CompassItemPropertyFunction implements ClampedItemPropertyFunction { - private final CompassItemPropertyFunction.CompassWobble wobble = new CompassItemPropertyFunction.CompassWobble(); - private final CompassItemPropertyFunction.CompassWobble wobbleRandom = new CompassItemPropertyFunction.CompassWobble(); + private final CompassItemPropertyFunction.CompassWobble wobble + = new CompassItemPropertyFunction.CompassWobble(); + private final CompassItemPropertyFunction.CompassWobble wobbleRandom + = new CompassItemPropertyFunction.CompassWobble(); public final CompassItemPropertyFunction.CompassTarget compassTarget; public CompassItemPropertyFunction(CompassItemPropertyFunction.CompassTarget target) { this.compassTarget = target; } - public float unclampedCall(ItemStack p_234960_, @Nullable ClientLevel p_234961_, @Nullable LivingEntity p_234962_, int p_234963_) { - Entity entity = p_234962_ != null ? p_234962_ : p_234960_.getEntityRepresentation(); + public float unclampedCall( + ItemStack p_234960_, + @Nullable ClientLevel p_234961_, + @Nullable LivingEntity p_234962_, + int p_234963_ + ) { + Entity entity + = p_234962_ != null ? p_234962_ : p_234960_.getEntityRepresentation(); if (entity == null) { return 0.0F; } else { p_234961_ = this.tryFetchLevelIfMissing(entity, p_234961_); - return p_234961_ == null ? 0.0F : this.getCompassRotation(p_234960_, p_234961_, p_234963_, entity); + return p_234961_ == null + ? 0.0F + : this.getCompassRotation(p_234960_, p_234961_, p_234963_, entity); } } - private float getCompassRotation(ItemStack p_234955_, ClientLevel p_234956_, int p_234957_, Entity p_234958_) { + private float getCompassRotation( + ItemStack p_234955_, ClientLevel p_234956_, int p_234957_, Entity p_234958_ + ) { GlobalPos globalpos = this.compassTarget.getPos(p_234956_, p_234955_, p_234958_); long i = p_234956_.getGameTime(); - return !this.isValidCompassTargetPos(p_234958_, globalpos) ? this.getRandomlySpinningRotation(p_234957_, i) : this.getRotationTowardsCompassTarget(p_234958_, i, globalpos.pos()); + return !this.isValidCompassTargetPos(p_234958_, globalpos) + ? this.getRandomlySpinningRotation(p_234957_, i) + : this.getRotationTowardsCompassTarget(p_234958_, i, globalpos.pos()); } private float getRandomlySpinningRotation(int p_234937_, long p_234938_) { @@ -43,11 +57,14 @@ public class CompassItemPropertyFunction implements ClampedItemPropertyFunction this.wobbleRandom.update(p_234938_, Math.random()); } - double d0 = this.wobbleRandom.rotation + (double)((float)this.hash(p_234937_) / 2.14748365E9F); - return Mth.positiveModulo((float)d0, 1.0F); + double d0 = this.wobbleRandom.rotation + + (double) ((float) this.hash(p_234937_) / 2.14748365E9F); + return Mth.positiveModulo((float) d0, 1.0F); } - private float getRotationTowardsCompassTarget(Entity p_234942_, long p_234943_, BlockPos p_234944_) { + private float getRotationTowardsCompassTarget( + Entity p_234942_, long p_234943_, BlockPos p_234944_ + ) { double d0 = this.getAngleFromEntityToPos(p_234942_, p_234944_); double d1 = this.getWrappedVisualRotationY(p_234942_); if (p_234942_ instanceof Player player) { @@ -57,26 +74,35 @@ public class CompassItemPropertyFunction implements ClampedItemPropertyFunction } double d3 = d0 + this.wobble.rotation; - return Mth.positiveModulo((float)d3, 1.0F); + return Mth.positiveModulo((float) d3, 1.0F); } } double d2 = 0.5D - (d1 - 0.25D - d0); - return Mth.positiveModulo((float)d2, 1.0F); + return Mth.positiveModulo((float) d2, 1.0F); } @javax.annotation.Nullable - private ClientLevel tryFetchLevelIfMissing(Entity p_234946_, @javax.annotation.Nullable ClientLevel p_234947_) { - return p_234947_ == null && p_234946_.level instanceof ClientLevel ? (ClientLevel)p_234946_.level : p_234947_; + private ClientLevel tryFetchLevelIfMissing( + Entity p_234946_, @javax.annotation.Nullable ClientLevel p_234947_ + ) { + return p_234947_ == null && p_234946_.level instanceof ClientLevel + ? (ClientLevel) p_234946_.level + : p_234947_; } - private boolean isValidCompassTargetPos(Entity p_234952_, @javax.annotation.Nullable GlobalPos p_234953_) { - return p_234953_ != null && p_234953_.dimension() == p_234952_.level.dimension() && !(p_234953_.pos().distToCenterSqr(p_234952_.position()) < (double)1.0E-5F); + private boolean isValidCompassTargetPos( + Entity p_234952_, @javax.annotation.Nullable GlobalPos p_234953_ + ) { + return p_234953_ != null && p_234953_.dimension() == p_234952_.level.dimension() + && !(p_234953_.pos().distToCenterSqr(p_234952_.position()) < (double) 1.0E-5F + ); } private double getAngleFromEntityToPos(Entity p_234949_, BlockPos p_234950_) { Vec3 vec3 = Vec3.atCenterOf(p_234950_); - return Math.atan2(vec3.z() - p_234949_.getZ(), vec3.x() - p_234949_.getX()) / (double)((float)Math.PI * 2F); + return Math.atan2(vec3.z() - p_234949_.getZ(), vec3.x() - p_234949_.getX()) + / (double) ((float) Math.PI * 2F); } private double getWrappedVisualRotationY(Entity entity) { @@ -88,7 +114,8 @@ public class CompassItemPropertyFunction implements ClampedItemPropertyFunction } public interface CompassTarget { - @Nullable GlobalPos getPos(ClientLevel level, ItemStack stack, Entity entity); + @Nullable + GlobalPos getPos(ClientLevel level, ItemStack stack, Entity entity); } static class CompassWobble { diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/items/DiscFragmentItem.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/items/DiscFragmentItem.java index f417f6d..3f8fce5 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/items/DiscFragmentItem.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/items/DiscFragmentItem.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.items; +import java.util.List; + import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TranslatableComponent; @@ -9,15 +11,19 @@ import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.level.Level; import org.jetbrains.annotations.Nullable; -import java.util.List; - public class DiscFragmentItem extends Item { public DiscFragmentItem(Properties properties) { super(properties); } @Override - public void appendHoverText(ItemStack stack, @Nullable Level level, List components, TooltipFlag tooltip) { - components.add(new TranslatableComponent(this.getDescriptionId() + ".desc").withStyle(ChatFormatting.GRAY)); + public void appendHoverText( + ItemStack stack, + @Nullable Level level, + List components, + TooltipFlag tooltip + ) { + components.add(new TranslatableComponent(this.getDescriptionId() + ".desc") + .withStyle(ChatFormatting.GRAY)); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/items/GoatHornItem.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/items/GoatHornItem.java index 2431b45..dbb9458 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/items/GoatHornItem.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/items/GoatHornItem.java @@ -1,5 +1,10 @@ package com.cursedcauldron.wildbackport.common.items; +import java.util.Iterator; +import java.util.List; +import java.util.Optional; +import java.util.Random; + import com.cursedcauldron.wildbackport.common.registry.WBGameEvents; import com.cursedcauldron.wildbackport.common.registry.WBItems; import com.cursedcauldron.wildbackport.common.registry.WBRegistries; @@ -26,11 +31,6 @@ import net.minecraft.world.item.UseAnim; import net.minecraft.world.level.Level; import org.jetbrains.annotations.Nullable; -import java.util.Iterator; -import java.util.List; -import java.util.Optional; -import java.util.Random; - public class GoatHornItem extends Item { private static final String INSTRUMENT_KEY = "instrument"; private TagKey instruments; @@ -41,43 +41,65 @@ public class GoatHornItem extends Item { } @Override - public void appendHoverText(ItemStack stack, @Nullable Level level, List components, TooltipFlag tooltipFlag) { + public void appendHoverText( + ItemStack stack, + @Nullable Level level, + List components, + TooltipFlag tooltipFlag + ) { super.appendHoverText(stack, level, components, tooltipFlag); - Optional> instrument = this.getInstrument(stack).flatMap(Holder::unwrapKey); + Optional> instrument + = this.getInstrument(stack).flatMap(Holder::unwrapKey); if (instrument.isPresent()) { - MutableComponent component = new TranslatableComponent(Util.makeDescriptionId(INSTRUMENT_KEY, instrument.get().location())); + MutableComponent component = new TranslatableComponent( + Util.makeDescriptionId(INSTRUMENT_KEY, instrument.get().location()) + ); components.add(component.withStyle(ChatFormatting.GRAY)); } } - public static ItemStack getStackForInstrument(Item item, Holder instrument) { + public static ItemStack + getStackForInstrument(Item item, Holder instrument) { ItemStack stack = new ItemStack(item); setInstrument(stack, instrument); return stack; } - public static void setRandomInstrumentFromTag(ItemStack stack, TagKey tag, Random random) { - Optional> instrument = WBRegistries.INSTRUMENT.registry().getTag(tag).flatMap(holders -> holders.getRandomElement(random)); + public static void + setRandomInstrumentFromTag(ItemStack stack, TagKey tag, Random random) { + Optional> instrument + = WBRegistries.INSTRUMENT.registry().getTag(tag).flatMap( + holders -> holders.getRandomElement(random) + ); instrument.ifPresent(holder -> setInstrument(stack, holder)); } private static void setInstrument(ItemStack stack, Holder instrument) { - stack.getOrCreateTag().putString(INSTRUMENT_KEY, instrument.unwrapKey().orElseThrow(() -> { - return new IllegalStateException("Invalid instrument"); - }).location().toString()); + stack.getOrCreateTag().putString( + INSTRUMENT_KEY, + instrument.unwrapKey() + .orElseThrow(() -> { + return new IllegalStateException("Invalid instrument"); + }) + .location() + .toString() + ); } @Override public void fillItemCategory(CreativeModeTab tab, NonNullList stacks) { if (this.allowdedIn(tab)) { - for (Holder holder : WBRegistries.INSTRUMENT.registry().getTagOrEmpty(this.instruments)) { -// stacks.add(getStackForInstrument(WBItems.GOAT_HORN.get(), holder)); + for (Holder holder : + WBRegistries.INSTRUMENT.registry().getTagOrEmpty(this.instruments)) { + // stacks.add(getStackForInstrument(WBItems.GOAT_HORN.get(), + // holder)); } } } @Override - public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { + public InteractionResultHolder + use(Level level, Player player, InteractionHand hand) { ItemStack stack = player.getItemInHand(hand); Optional> holder = this.getInstrument(stack); if (holder.isPresent()) { @@ -100,13 +122,18 @@ public class GoatHornItem extends Item { private Optional> getInstrument(ItemStack stack) { CompoundTag tag = stack.getTag(); if (tag != null) { - ResourceLocation location = ResourceLocation.tryParse(tag.getString("instrument")); + ResourceLocation location + = ResourceLocation.tryParse(tag.getString("instrument")); if (location != null) { - return WBRegistries.INSTRUMENT.registry().getHolder(ResourceKey.create(WBRegistries.INSTRUMENT.key(), location)); + return WBRegistries.INSTRUMENT.registry().getHolder( + ResourceKey.create(WBRegistries.INSTRUMENT.key(), location) + ); } } - Iterator> instruments = WBRegistries.INSTRUMENT.registry().getTagOrEmpty(this.instruments).iterator(); + Iterator> instruments = WBRegistries.INSTRUMENT.registry() + .getTagOrEmpty(this.instruments) + .iterator(); return instruments.hasNext() ? Optional.of(instruments.next()) : Optional.empty(); } @@ -116,7 +143,14 @@ public class GoatHornItem extends Item { } private static void playSound(Level level, Player player, Instrument instrument) { - level.playSound(player, player, instrument.soundEvent(), SoundSource.RECORDS, instrument.range() / 16.0F, 1.0F); + level.playSound( + player, + player, + instrument.soundEvent(), + SoundSource.RECORDS, + instrument.range() / 16.0F, + 1.0F + ); level.gameEvent(WBGameEvents.INSTRUMENT_PLAY.get(), player); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/items/Instrument.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/items/Instrument.java index 82e7907..c3ad482 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/items/Instrument.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/items/Instrument.java @@ -7,6 +7,13 @@ import net.minecraft.util.ExtraCodecs; public record Instrument(SoundEvent soundEvent, int useDuration, float range) { public static final Codec CODEC = RecordCodecBuilder.create(instance -> { - return instance.group(SoundEvent.CODEC.fieldOf("sound_event").forGetter(Instrument::soundEvent), ExtraCodecs.POSITIVE_INT.fieldOf("use_duration").forGetter(Instrument::useDuration), ExtraCodecs.POSITIVE_FLOAT.fieldOf("range").forGetter(Instrument::range)).apply(instance, Instrument::new); + return instance + .group( + SoundEvent.CODEC.fieldOf("sound_event").forGetter(Instrument::soundEvent), + ExtraCodecs.POSITIVE_INT.fieldOf("use_duration") + .forGetter(Instrument::useDuration), + ExtraCodecs.POSITIVE_FLOAT.fieldOf("range").forGetter(Instrument::range) + ) + .apply(instance, Instrument::new); }); } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/items/TadpoleBucketItem.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/items/TadpoleBucketItem.java index 4bb08e7..0ed29ea 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/items/TadpoleBucketItem.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/items/TadpoleBucketItem.java @@ -1,5 +1,9 @@ package com.cursedcauldron.wildbackport.common.items; +import java.util.List; +import java.util.function.Supplier; +import javax.annotation.Nullable; + import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; @@ -24,60 +28,82 @@ import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.material.Fluid; -import javax.annotation.Nullable; -import java.util.List; -import java.util.function.Supplier; - //<> public class TadpoleBucketItem extends BucketItem { private final Supplier> entityType; private final Supplier emptySound; - public TadpoleBucketItem(Supplier> entityType, Fluid fluid, Supplier emptySound, Item.Properties properties) { + public TadpoleBucketItem( + Supplier> entityType, + Fluid fluid, + Supplier emptySound, + Item.Properties properties + ) { super(fluid, properties); this.entityType = entityType; this.emptySound = emptySound; } - public void checkExtraContent(@Nullable Player player, Level level, ItemStack stack, BlockPos pos) { + public void checkExtraContent( + @Nullable Player player, Level level, ItemStack stack, BlockPos pos + ) { if (level instanceof ServerLevel server) { this.spawn(server, stack, pos); level.gameEvent(player, GameEvent.ENTITY_PLACE, pos); } } - protected void playEmptySound(@Nullable Player player, LevelAccessor access, BlockPos pos) { - access.playSound(player, pos, this.emptySound.get(), SoundSource.NEUTRAL, 1.0F, 1.0F); + protected void + playEmptySound(@Nullable Player player, LevelAccessor access, BlockPos pos) { + access.playSound( + player, pos, this.emptySound.get(), SoundSource.NEUTRAL, 1.0F, 1.0F + ); } private void spawn(ServerLevel level, ItemStack stack, BlockPos pos) { - Entity entity = this.entityType.get().spawn(level, stack, null, pos, MobSpawnType.BUCKET, true, false); + Entity entity = this.entityType.get().spawn( + level, stack, null, pos, MobSpawnType.BUCKET, true, false + ); if (entity instanceof Bucketable bucketable) { bucketable.loadFromBucketTag(stack.getOrCreateTag()); bucketable.setFromBucket(true); } } - public void appendHoverText(ItemStack stack, @Nullable Level level, List components, TooltipFlag tooltip) { + public void appendHoverText( + ItemStack stack, + @Nullable Level level, + List components, + TooltipFlag tooltip + ) { if (this.entityType.get() == EntityType.TROPICAL_FISH) { CompoundTag tag = stack.getTag(); if (tag != null && tag.contains("BucketVariantTag", 3)) { int variant = tag.getInt("BucketVariantTag"); - ChatFormatting[] format = new ChatFormatting[]{ChatFormatting.ITALIC, ChatFormatting.GRAY}; + ChatFormatting[] format + = new ChatFormatting[] { ChatFormatting.ITALIC, ChatFormatting.GRAY }; String base = "color.minecraft." + TropicalFish.getBaseColor(variant); - String pattern = "color.minecraft." + TropicalFish.getPatternColor(variant); + String pattern + = "color.minecraft." + TropicalFish.getPatternColor(variant); - for(int i = 0; i < TropicalFish.COMMON_VARIANTS.length; ++i) { + for (int i = 0; i < TropicalFish.COMMON_VARIANTS.length; ++i) { if (variant == TropicalFish.COMMON_VARIANTS[i]) { - components.add((new TranslatableComponent(TropicalFish.getPredefinedName(i))).withStyle(format)); + components.add( + (new TranslatableComponent(TropicalFish.getPredefinedName(i))) + .withStyle(format) + ); return; } } - components.add(new TranslatableComponent(TropicalFish.getFishTypeName(variant)).withStyle(format)); + components.add( + new TranslatableComponent(TropicalFish.getFishTypeName(variant)) + .withStyle(format) + ); MutableComponent component = new TranslatableComponent(base); - if (!base.equals(pattern)) component.append(", ").append(new TranslatableComponent(pattern)); + if (!base.equals(pattern)) + component.append(", ").append(new TranslatableComponent(pattern)); component.withStyle(format); components.add(component); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/Instruments.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/Instruments.java index 3e8dad2..ba58998 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/Instruments.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/Instruments.java @@ -1,50 +1,71 @@ package com.cursedcauldron.wildbackport.common.registry; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.client.registry.WBSoundEvents; import com.cursedcauldron.wildbackport.common.items.Instrument; import com.cursedcauldron.wildbackport.core.api.CoreRegistry; import net.minecraft.sounds.SoundEvent; -import java.util.function.Supplier; - public class Instruments { - public static final CoreRegistry INSTRUMENTS = CoreRegistry.create(WBRegistries.INSTRUMENT.registry(), "minecraft"); + public static final CoreRegistry INSTRUMENTS + = CoreRegistry.create(WBRegistries.INSTRUMENT.registry(), "minecraft"); - public static final Supplier PONDER_GOAT_HORN = create("ponder_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(0)); - public static final Supplier SIGN_GOAT_HORN = create("sign_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(1)); - public static final Supplier SEEK_GOAT_HORN = create("seek_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(2)); - public static final Supplier FEEL_GOAT_HORN = create("feel_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(3)); - public static final Supplier ADMIRE_GOAT_HORN = create("admire_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(4)); - public static final Supplier CALL_GOAT_HORN = create("call_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(5)); - public static final Supplier YEARN_GOAT_HORN = create("yearn_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(6)); - public static final Supplier DREAM_GOAT_HORN = create("dream_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(7)); + public static final Supplier PONDER_GOAT_HORN + = create("ponder_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(0)); + public static final Supplier SIGN_GOAT_HORN + = create("sign_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(1)); + public static final Supplier SEEK_GOAT_HORN + = create("seek_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(2)); + public static final Supplier FEEL_GOAT_HORN + = create("feel_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(3)); + public static final Supplier ADMIRE_GOAT_HORN + = create("admire_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(4)); + public static final Supplier CALL_GOAT_HORN + = create("call_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(5)); + public static final Supplier YEARN_GOAT_HORN + = create("yearn_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(6)); + public static final Supplier DREAM_GOAT_HORN + = create("dream_goat_horn", WBSoundEvents.GOAT_HORN_SOUNDS.get(7)); private static Supplier create(String key, SoundEvent soundEvent) { return INSTRUMENTS.register(key, () -> new Instrument(soundEvent, 140, 256.0F)); } -// public static final ResourceKey PONDER_GOAT_HORN = Instruments.of("ponder_goat_horn"); -// public static final ResourceKey SIGN_GOAT_HORN = Instruments.of("sign_goat_horn"); -// public static final ResourceKey SEEK_GOAT_HORN = Instruments.of("seek_goat_horn"); -// public static final ResourceKey FEEL_GOAT_HORN = Instruments.of("feel_goat_horn"); -// public static final ResourceKey ADMIRE_GOAT_HORN = Instruments.of("admire_goat_horn"); -// public static final ResourceKey CALL_GOAT_HORN = Instruments.of("call_goat_horn"); -// public static final ResourceKey YEARN_GOAT_HORN = Instruments.of("yearn_goat_horn"); -// public static final ResourceKey DREAM_GOAT_HORN = Instruments.of("dream_goat_horn"); -// -// private static ResourceKey of(String name) { -// return ResourceKey.create(WBRegistries.INSTRUMENT.key(), new ResourceLocation(name)); -// } -// -// public static Instrument registerAndGetDefault(Registry registry) { -// Registry.register(registry, PONDER_GOAT_HORN, new Instrument(WBSoundEvents.GOAT_HORN_SOUNDS.get(0), 140, 256.0F)); -// Registry.register(registry, SIGN_GOAT_HORN, new Instrument(WBSoundEvents.GOAT_HORN_SOUNDS.get(1), 140, 256.0F)); -// Registry.register(registry, SEEK_GOAT_HORN, new Instrument(WBSoundEvents.GOAT_HORN_SOUNDS.get(2), 140, 256.0F)); -// Registry.register(registry, FEEL_GOAT_HORN, new Instrument(WBSoundEvents.GOAT_HORN_SOUNDS.get(3), 140, 256.0F)); -// Registry.register(registry, ADMIRE_GOAT_HORN, new Instrument(WBSoundEvents.GOAT_HORN_SOUNDS.get(4), 140, 256.0F)); -// Registry.register(registry, CALL_GOAT_HORN, new Instrument(WBSoundEvents.GOAT_HORN_SOUNDS.get(5), 140, 256.0F)); -// Registry.register(registry, YEARN_GOAT_HORN, new Instrument(WBSoundEvents.GOAT_HORN_SOUNDS.get(6), 140, 256.0F)); -// return Registry.register(registry, DREAM_GOAT_HORN, new Instrument(WBSoundEvents.GOAT_HORN_SOUNDS.get(7), 140, 256.0F)); -// } + // public static final ResourceKey PONDER_GOAT_HORN = + // Instruments.of("ponder_goat_horn"); public static final ResourceKey + // SIGN_GOAT_HORN = Instruments.of("sign_goat_horn"); public static final + // ResourceKey SEEK_GOAT_HORN = Instruments.of("seek_goat_horn"); + // public static final ResourceKey FEEL_GOAT_HORN = + // Instruments.of("feel_goat_horn"); public static final ResourceKey + // ADMIRE_GOAT_HORN = Instruments.of("admire_goat_horn"); public static final + // ResourceKey CALL_GOAT_HORN = Instruments.of("call_goat_horn"); + // public static final ResourceKey YEARN_GOAT_HORN = + // Instruments.of("yearn_goat_horn"); public static final ResourceKey + // DREAM_GOAT_HORN = Instruments.of("dream_goat_horn"); + // + // private static ResourceKey of(String name) { + // return ResourceKey.create(WBRegistries.INSTRUMENT.key(), new + // ResourceLocation(name)); + // } + // + // public static Instrument registerAndGetDefault(Registry registry) { + // Registry.register(registry, PONDER_GOAT_HORN, new + // Instrument(WBSoundEvents.GOAT_HORN_SOUNDS.get(0), 140, 256.0F)); + // Registry.register(registry, SIGN_GOAT_HORN, new + // Instrument(WBSoundEvents.GOAT_HORN_SOUNDS.get(1), 140, 256.0F)); + // Registry.register(registry, SEEK_GOAT_HORN, new + // Instrument(WBSoundEvents.GOAT_HORN_SOUNDS.get(2), 140, 256.0F)); + // Registry.register(registry, FEEL_GOAT_HORN, new + // Instrument(WBSoundEvents.GOAT_HORN_SOUNDS.get(3), 140, 256.0F)); + // Registry.register(registry, ADMIRE_GOAT_HORN, new + // Instrument(WBSoundEvents.GOAT_HORN_SOUNDS.get(4), 140, 256.0F)); + // Registry.register(registry, CALL_GOAT_HORN, new + // Instrument(WBSoundEvents.GOAT_HORN_SOUNDS.get(5), 140, 256.0F)); + // Registry.register(registry, YEARN_GOAT_HORN, new + // Instrument(WBSoundEvents.GOAT_HORN_SOUNDS.get(6), 140, 256.0F)); return + // Registry.register(registry, DREAM_GOAT_HORN, new + // Instrument(WBSoundEvents.GOAT_HORN_SOUNDS.get(7), 140, 256.0F)); + // } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBBiomes.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBBiomes.java index 2caae33..ffdd7dc 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBBiomes.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBBiomes.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.registry; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.core.api.CoreRegistry; import com.cursedcauldron.wildbackport.core.mixin.access.OverworldBiomesAccessor; @@ -19,34 +21,66 @@ import net.minecraft.world.level.biome.BiomeSpecialEffects; import net.minecraft.world.level.biome.MobSpawnSettings; import net.minecraft.world.level.levelgen.GenerationStep; -import java.util.function.Supplier; - public class WBBiomes { - public static final CoreRegistry BIOMES = CoreRegistry.create(BuiltinRegistries.BIOME, "minecraft"); + public static final CoreRegistry BIOMES + = CoreRegistry.create(BuiltinRegistries.BIOME, "minecraft"); - public static final ResourceKey MANGROVE_SWAMP = create("mangrove_swamp", WBBiomes::mangroveSwamp); - public static final ResourceKey DEEP_DARK = create("deep_dark", WBBiomes::deepDark); + public static final ResourceKey MANGROVE_SWAMP + = create("mangrove_swamp", WBBiomes::mangroveSwamp); + public static final ResourceKey DEEP_DARK + = create("deep_dark", WBBiomes::deepDark); // Mangrove Swamp public static Biome mangroveSwamp() { MobSpawnSettings.Builder spawn = new MobSpawnSettings.Builder(); BiomeDefaultFeatures.commonSpawns(spawn); - BiomeGenerationSettings.Builder generation = new BiomeGenerationSettings.Builder(); + BiomeGenerationSettings.Builder generation + = new BiomeGenerationSettings.Builder(); BiomeDefaultFeatures.addFossilDecoration(generation); OverworldBiomesAccessor.callGlobalOverworldGeneration(generation); BiomeDefaultFeatures.addDefaultOres(generation); BiomeDefaultFeatures.addSwampClayDisk(generation); - generation.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, VegetationPlacements.PATCH_GRASS_NORMAL); - generation.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, VegetationPlacements.PATCH_DEAD_BUSH); - generation.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, VegetationPlacements.PATCH_WATERLILY); - generation.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, AquaticPlacements.SEAGRASS_SWAMP); - return new Biome.BiomeBuilder().biomeCategory(Biome.BiomeCategory.SWAMP).precipitation(Biome.Precipitation.RAIN).temperature(0.8F).downfall(0.9F).specialEffects(new BiomeSpecialEffects.Builder().waterColor(3832426).waterFogColor(5077600).fogColor(12638463).skyColor(calculateSkyColor(0.8f)).foliageColorOverride(9285927).grassColorModifier(BiomeSpecialEffects.GrassColorModifier.SWAMP).ambientMoodSound(AmbientMoodSettings.LEGACY_CAVE_SETTINGS).build()).mobSpawnSettings(spawn.build()).generationSettings(generation.build()).build(); + generation.addFeature( + GenerationStep.Decoration.VEGETAL_DECORATION, + VegetationPlacements.PATCH_GRASS_NORMAL + ); + generation.addFeature( + GenerationStep.Decoration.VEGETAL_DECORATION, + VegetationPlacements.PATCH_DEAD_BUSH + ); + generation.addFeature( + GenerationStep.Decoration.VEGETAL_DECORATION, + VegetationPlacements.PATCH_WATERLILY + ); + generation.addFeature( + GenerationStep.Decoration.VEGETAL_DECORATION, AquaticPlacements.SEAGRASS_SWAMP + ); + return new Biome.BiomeBuilder() + .biomeCategory(Biome.BiomeCategory.SWAMP) + .precipitation(Biome.Precipitation.RAIN) + .temperature(0.8F) + .downfall(0.9F) + .specialEffects( + new BiomeSpecialEffects.Builder() + .waterColor(3832426) + .waterFogColor(5077600) + .fogColor(12638463) + .skyColor(calculateSkyColor(0.8f)) + .foliageColorOverride(9285927) + .grassColorModifier(BiomeSpecialEffects.GrassColorModifier.SWAMP) + .ambientMoodSound(AmbientMoodSettings.LEGACY_CAVE_SETTINGS) + .build() + ) + .mobSpawnSettings(spawn.build()) + .generationSettings(generation.build()) + .build(); } // Deep Dark public static Biome deepDark() { MobSpawnSettings.Builder spawn = new MobSpawnSettings.Builder(); - BiomeGenerationSettings.Builder generation = new BiomeGenerationSettings.Builder(); + BiomeGenerationSettings.Builder generation + = new BiomeGenerationSettings.Builder(); generation.addCarver(GenerationStep.Carving.AIR, Carvers.CAVE); generation.addCarver(GenerationStep.Carving.AIR, Carvers.CAVE_EXTRA_UNDERGROUND); generation.addCarver(GenerationStep.Carving.AIR, Carvers.CANYON); @@ -60,14 +94,31 @@ public class WBBiomes { BiomeDefaultFeatures.addPlainVegetation(generation); BiomeDefaultFeatures.addDefaultMushrooms(generation); BiomeDefaultFeatures.addDefaultExtraVegetation(generation); - return new Biome.BiomeBuilder().biomeCategory(Biome.BiomeCategory.UNDERGROUND).precipitation(Biome.Precipitation.RAIN).temperature(0.8F).downfall(0.4F).specialEffects(new BiomeSpecialEffects.Builder().waterColor(4159204).waterFogColor(329011).fogColor(12638463).skyColor(calculateSkyColor(0.8F)).ambientMoodSound(AmbientMoodSettings.LEGACY_CAVE_SETTINGS).build()).mobSpawnSettings(spawn.build()).generationSettings(generation.build()).build(); + return new Biome.BiomeBuilder() + .biomeCategory(Biome.BiomeCategory.UNDERGROUND) + .precipitation(Biome.Precipitation.RAIN) + .temperature(0.8F) + .downfall(0.4F) + .specialEffects(new BiomeSpecialEffects.Builder() + .waterColor(4159204) + .waterFogColor(329011) + .fogColor(12638463) + .skyColor(calculateSkyColor(0.8F)) + .ambientMoodSound(AmbientMoodSettings.LEGACY_CAVE_SETTINGS + ) + .build()) + .mobSpawnSettings(spawn.build()) + .generationSettings(generation.build()) + .build(); } // Registry private static ResourceKey create(String key, Supplier biome) { BIOMES.register(key, biome); - return ResourceKey.create(Registry.BIOME_REGISTRY, new ResourceLocation("minecraft", key)); + return ResourceKey.create( + Registry.BIOME_REGISTRY, new ResourceLocation("minecraft", key) + ); } protected static int calculateSkyColor(float temperature) { diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBBlockEntities.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBBlockEntities.java index afc84dc..c31179c 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBBlockEntities.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBBlockEntities.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.registry; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.common.blocks.entity.MangroveSignBlockEntity; import com.cursedcauldron.wildbackport.common.blocks.entity.SculkCatalystBlockEntity; @@ -8,13 +10,26 @@ import com.cursedcauldron.wildbackport.core.api.CoreRegistry; import net.minecraft.core.Registry; import net.minecraft.world.level.block.entity.BlockEntityType; -import java.util.function.Supplier; - //<> public class WBBlockEntities { - public static final CoreRegistry> BLOCKS = CoreRegistry.create(Registry.BLOCK_ENTITY_TYPE, "minecraft"); + public static final CoreRegistry> BLOCKS + = CoreRegistry.create(Registry.BLOCK_ENTITY_TYPE, "minecraft"); - public static final Supplier> SCULK_CATALYST = BLOCKS.register("sculk_catalyst", () -> BlockEntityType.Builder.of(SculkCatalystBlockEntity::new, WBBlocks.SCULK_CATALYST.get()).build(null)); - public static final Supplier> SCULK_SHRIEKER = BLOCKS.register("sculk_shrieker", () -> BlockEntityType.Builder.of(SculkShriekerBlockEntity::new, WBBlocks.SCULK_SHRIEKER.get()).build(null)); + public static final Supplier> SCULK_CATALYST + = BLOCKS.register( + "sculk_catalyst", + () + -> BlockEntityType.Builder + .of(SculkCatalystBlockEntity::new, WBBlocks.SCULK_CATALYST.get()) + .build(null) + ); + public static final Supplier> SCULK_SHRIEKER + = BLOCKS.register( + "sculk_shrieker", + () + -> BlockEntityType.Builder + .of(SculkShriekerBlockEntity::new, WBBlocks.SCULK_SHRIEKER.get()) + .build(null) + ); } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBBlocks.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBBlocks.java index bdbac13..7387c17 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBBlocks.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBBlocks.java @@ -1,8 +1,10 @@ package com.cursedcauldron.wildbackport.common.registry; +import java.util.function.Function; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.client.registry.WBSoundTypes; -import com.cursedcauldron.wildbackport.common.blocks.StateProperties; import com.cursedcauldron.wildbackport.common.blocks.FrogspawnBlock; import com.cursedcauldron.wildbackport.common.blocks.MangroveLeavesBlock; import com.cursedcauldron.wildbackport.common.blocks.MangrovePropaguleBlock; @@ -12,6 +14,7 @@ import com.cursedcauldron.wildbackport.common.blocks.SculkBlock; import com.cursedcauldron.wildbackport.common.blocks.SculkCatalystBlock; import com.cursedcauldron.wildbackport.common.blocks.SculkShriekerBlock; import com.cursedcauldron.wildbackport.common.blocks.SculkVeinBlock; +import com.cursedcauldron.wildbackport.common.blocks.StateProperties; import com.cursedcauldron.wildbackport.core.api.CoreRegistry; import com.cursedcauldron.wildbackport.core.api.WoodTypeRegistry; import com.cursedcauldron.wildbackport.core.mixin.access.DoorBlockAccessor; @@ -45,63 +48,365 @@ import net.minecraft.world.level.block.state.properties.WoodType; import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.MaterialColor; -import java.util.function.Function; -import java.util.function.Supplier; - //<> public class WBBlocks { - public static final CoreRegistry BLOCKS = CoreRegistry.create(Registry.BLOCK, "minecraft"); + public static final CoreRegistry BLOCKS + = CoreRegistry.create(Registry.BLOCK, "minecraft"); // Sculk - public static final Supplier SCULK = create("sculk", () -> new SculkBlock(BlockBehaviour.Properties.of(Material.SCULK).strength(0.6F).sound(WBSoundTypes.SCULK)), CreativeModeTab.TAB_DECORATIONS); - public static final Supplier SCULK_VEIN = create("sculk_vein", () -> new SculkVeinBlock(BlockBehaviour.Properties.of(Material.SCULK).noCollission().strength(0.2F).sound(WBSoundTypes.SCULK_VEIN)), CreativeModeTab.TAB_DECORATIONS); - public static final Supplier SCULK_CATALYST = create("sculk_catalyst", () -> new SculkCatalystBlock(BlockBehaviour.Properties.of(Material.SCULK).requiresCorrectToolForDrops().strength(3.0F).sound(WBSoundTypes.SCULK_CATALYST).lightLevel(value -> 6)), CreativeModeTab.TAB_REDSTONE); - public static final Supplier SCULK_SHRIEKER = create("sculk_shrieker", () -> new SculkShriekerBlock(BlockBehaviour.Properties.of(Material.SCULK, MaterialColor.COLOR_BLACK).strength(3.0F).sound(WBSoundTypes.SCULK_SHRIEKER)), CreativeModeTab.TAB_REDSTONE); + public static final Supplier SCULK = create( + "sculk", + () + -> new SculkBlock(BlockBehaviour.Properties.of(Material.SCULK) + .strength(0.6F) + .sound(WBSoundTypes.SCULK)), + CreativeModeTab.TAB_DECORATIONS + ); + public static final Supplier SCULK_VEIN = create( + "sculk_vein", + () + -> new SculkVeinBlock(BlockBehaviour.Properties.of(Material.SCULK) + .noCollission() + .strength(0.2F) + .sound(WBSoundTypes.SCULK_VEIN)), + CreativeModeTab.TAB_DECORATIONS + ); + public static final Supplier SCULK_CATALYST = create( + "sculk_catalyst", + () + -> new SculkCatalystBlock(BlockBehaviour.Properties.of(Material.SCULK) + .requiresCorrectToolForDrops() + .strength(3.0F) + .sound(WBSoundTypes.SCULK_CATALYST) + .lightLevel(value -> 6)), + CreativeModeTab.TAB_REDSTONE + ); + public static final Supplier SCULK_SHRIEKER = create( + "sculk_shrieker", + () + -> new SculkShriekerBlock(BlockBehaviour.Properties + .of(Material.SCULK, MaterialColor.COLOR_BLACK) + .strength(3.0F) + .sound(WBSoundTypes.SCULK_SHRIEKER)), + CreativeModeTab.TAB_REDSTONE + ); // Frog - public static final Supplier OCHRE_FROGLIGHT = create("ochre_froglight", () -> new RotatedPillarBlock(BlockBehaviour.Properties.of(Material.DECORATION).instabreak().lightLevel(value -> 15).sound(WBSoundTypes.FROGLIGHT)), CreativeModeTab.TAB_DECORATIONS); - public static final Supplier VERDANT_FROGLIGHT = create("verdant_froglight", () -> new RotatedPillarBlock(BlockBehaviour.Properties.of(Material.DECORATION).instabreak().lightLevel(value -> 15).sound(WBSoundTypes.FROGLIGHT)), CreativeModeTab.TAB_DECORATIONS); - public static final Supplier PEARLESCENT_FROGLIGHT = create("pearlescent_froglight", () -> new RotatedPillarBlock(BlockBehaviour.Properties.of(Material.DECORATION).instabreak().lightLevel(value -> 15).sound(WBSoundTypes.FROGLIGHT)), CreativeModeTab.TAB_DECORATIONS); - public static final Supplier FROGSPAWN = create("frogspawn", () -> new FrogspawnBlock(BlockBehaviour.Properties.of(Material.BUILDABLE_GLASS).instabreak().noDrops().noOcclusion().noCollission().sound(WBSoundTypes.FROGSPAWN)), entry -> new WaterLilyBlockItem(entry.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC))); + public static final Supplier OCHRE_FROGLIGHT = create( + "ochre_froglight", + () + -> new RotatedPillarBlock(BlockBehaviour.Properties.of(Material.DECORATION) + .instabreak() + .lightLevel(value -> 15) + .sound(WBSoundTypes.FROGLIGHT)), + CreativeModeTab.TAB_DECORATIONS + ); + public static final Supplier VERDANT_FROGLIGHT = create( + "verdant_froglight", + () + -> new RotatedPillarBlock(BlockBehaviour.Properties.of(Material.DECORATION) + .instabreak() + .lightLevel(value -> 15) + .sound(WBSoundTypes.FROGLIGHT)), + CreativeModeTab.TAB_DECORATIONS + ); + public static final Supplier PEARLESCENT_FROGLIGHT = create( + "pearlescent_froglight", + () + -> new RotatedPillarBlock(BlockBehaviour.Properties.of(Material.DECORATION) + .instabreak() + .lightLevel(value -> 15) + .sound(WBSoundTypes.FROGLIGHT)), + CreativeModeTab.TAB_DECORATIONS + ); + public static final Supplier FROGSPAWN = create( + "frogspawn", + () + -> new FrogspawnBlock(BlockBehaviour.Properties.of(Material.BUILDABLE_GLASS) + .instabreak() + .noDrops() + .noOcclusion() + .noCollission() + .sound(WBSoundTypes.FROGSPAWN)), + entry + -> new WaterLilyBlockItem( + entry.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC) + ) + ); // Mangrove - public static final Supplier MANGROVE_LOG = create("mangrove_log", () -> new RotatedPillarBlock(BlockBehaviour.Properties.of(Material.WOOD, state -> state.getValue(RotatedPillarBlock.AXIS) == Direction.Axis.Y ? MaterialColor.COLOR_RED : MaterialColor.PODZOL).strength(2.0F).sound(SoundType.WOOD)), CreativeModeTab.TAB_BUILDING_BLOCKS); - public static final Supplier MANGROVE_WOOD = create("mangrove_wood", () -> new RotatedPillarBlock(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_RED).strength(2.0F).sound(SoundType.WOOD)), CreativeModeTab.TAB_BUILDING_BLOCKS); - public static final Supplier STRIPPED_MANGROVE_LOG = create("stripped_mangrove_log", () -> new RotatedPillarBlock(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_RED).strength(2.0F).sound(SoundType.WOOD)), CreativeModeTab.TAB_BUILDING_BLOCKS); - public static final Supplier STRIPPED_MANGROVE_WOOD = create("stripped_mangrove_wood", () -> new RotatedPillarBlock(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_RED).strength(2.0F).sound(SoundType.WOOD)), CreativeModeTab.TAB_BUILDING_BLOCKS); - public static final Supplier MANGROVE_PLANKS = create("mangrove_planks", () -> new Block(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_RED).strength(2.0F, 3.0F).sound(SoundType.WOOD)), CreativeModeTab.TAB_BUILDING_BLOCKS); - public static final Supplier MANGROVE_STAIRS = create("mangrove_stairs", () -> StairBlockAccessor.createStairBlock(MANGROVE_PLANKS.get().defaultBlockState(), BlockBehaviour.Properties.copy(MANGROVE_PLANKS.get())), CreativeModeTab.TAB_BUILDING_BLOCKS); - public static final Supplier MANGROVE_SLAB = create("mangrove_slab", () -> new SlabBlock(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_RED).strength(2.0F, 3.0F).sound(SoundType.WOOD)), CreativeModeTab.TAB_BUILDING_BLOCKS); - public static final Supplier MANGROVE_FENCE = create("mangrove_fence", () -> new FenceBlock(BlockBehaviour.Properties.of(Material.WOOD, MANGROVE_PLANKS.get().defaultMaterialColor()).strength(2.0F, 3.0F).sound(SoundType.WOOD)), CreativeModeTab.TAB_DECORATIONS); - public static final Supplier MANGROVE_FENCE_GATE = create("mangrove_fence_gate", () -> new FenceGateBlock(BlockBehaviour.Properties.of(Material.WOOD, MANGROVE_PLANKS.get().defaultMaterialColor()).strength(2.0F, 3.0F).sound(SoundType.WOOD)), CreativeModeTab.TAB_REDSTONE); - public static final Supplier MANGROVE_DOOR = create("mangrove_door", () -> DoorBlockAccessor.createDoorBlock(BlockBehaviour.Properties.of(Material.WOOD, MANGROVE_PLANKS.get().defaultMaterialColor()).strength(3.0F).sound(SoundType.WOOD).noOcclusion()), CreativeModeTab.TAB_REDSTONE); - public static final Supplier MANGROVE_TRAPDOOR = create("mangrove_trapdoor", () -> TrapDoorBlockAccessor.createTrapDoorBlock(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_RED).strength(3.0F).sound(SoundType.WOOD).noOcclusion().isValidSpawn(StateProperties::never)), CreativeModeTab.TAB_REDSTONE); - public static final Supplier MANGROVE_PRESSURE_PLATE = create("mangrove_pressure_plate", () -> PressurePlateBlockAccessor.createPressurePlateBlock(PressurePlateBlock.Sensitivity.EVERYTHING, BlockBehaviour.Properties.of(Material.WOOD, MANGROVE_PLANKS.get().defaultMaterialColor()).noCollission().strength(0.5F).sound(SoundType.WOOD)), CreativeModeTab.TAB_REDSTONE); - public static final Supplier MANGROVE_BUTTON = create("mangrove_button", () -> WoodButtonBlockAccessor.createWoodButtonBlock(BlockBehaviour.Properties.of(Material.DECORATION).noCollission().strength(0.5F).sound(SoundType.WOOD)), CreativeModeTab.TAB_REDSTONE); - public static final Supplier MANGROVE_LEAVES = create("mangrove_leaves", () -> new MangroveLeavesBlock(BlockBehaviour.Properties.of(Material.LEAVES).strength(0.2F).randomTicks().sound(SoundType.GRASS).noOcclusion().isValidSpawn(StateProperties::ocelotOrParrot).isSuffocating(StateProperties::never).isViewBlocking(StateProperties::never)), CreativeModeTab.TAB_DECORATIONS); - public static final Supplier MANGROVE_PROPAGULE = create("mangrove_propagule", () -> new MangrovePropaguleBlock(BlockBehaviour.Properties.of(Material.PLANT).noCollission().randomTicks().instabreak().sound(SoundType.GRASS)), CreativeModeTab.TAB_DECORATIONS); - public static final Supplier POTTED_MANGROVE_PROPAGULE = create("potted_mangrove_propagule", () -> new FlowerPotBlock(MANGROVE_PROPAGULE.get(), BlockBehaviour.Properties.of(Material.DECORATION).instabreak().noOcclusion())); - public static final Supplier MANGROVE_ROOTS = create("mangrove_roots", () -> new MangroveRootsBlock(BlockBehaviour.Properties.of(Material.WOOD).strength(0.7F).randomTicks().sound(WBSoundTypes.MANGROVE_ROOTS).noOcclusion().isValidSpawn(StateProperties::ocelotOrParrot).isSuffocating(StateProperties::never).isViewBlocking(StateProperties::never)), CreativeModeTab.TAB_BUILDING_BLOCKS); - public static final Supplier MUDDY_MANGROVE_ROOTS = create("muddy_mangrove_roots", () -> new RotatedPillarBlock(BlockBehaviour.Properties.of(Material.DIRT).strength(0.7F).sound(WBSoundTypes.MUDDY_MANGROVE_ROOTS)), CreativeModeTab.TAB_BUILDING_BLOCKS); - public static final Pair, Supplier> MANGROVE_SIGN = create("mangrove", Material.WOOD, MaterialColor.COLOR_RED); + public static final Supplier MANGROVE_LOG = create( + "mangrove_log", + () + -> new RotatedPillarBlock(BlockBehaviour.Properties + .of(Material.WOOD, + state + -> state.getValue(RotatedPillarBlock.AXIS) + == Direction.Axis.Y + ? MaterialColor.COLOR_RED + : MaterialColor.PODZOL) + .strength(2.0F) + .sound(SoundType.WOOD)), + CreativeModeTab.TAB_BUILDING_BLOCKS + ); + public static final Supplier MANGROVE_WOOD = create( + "mangrove_wood", + () + -> new RotatedPillarBlock(BlockBehaviour.Properties + .of(Material.WOOD, MaterialColor.COLOR_RED) + .strength(2.0F) + .sound(SoundType.WOOD)), + CreativeModeTab.TAB_BUILDING_BLOCKS + ); + public static final Supplier STRIPPED_MANGROVE_LOG = create( + "stripped_mangrove_log", + () + -> new RotatedPillarBlock(BlockBehaviour.Properties + .of(Material.WOOD, MaterialColor.COLOR_RED) + .strength(2.0F) + .sound(SoundType.WOOD)), + CreativeModeTab.TAB_BUILDING_BLOCKS + ); + public static final Supplier STRIPPED_MANGROVE_WOOD = create( + "stripped_mangrove_wood", + () + -> new RotatedPillarBlock(BlockBehaviour.Properties + .of(Material.WOOD, MaterialColor.COLOR_RED) + .strength(2.0F) + .sound(SoundType.WOOD)), + CreativeModeTab.TAB_BUILDING_BLOCKS + ); + public static final Supplier MANGROVE_PLANKS = create( + "mangrove_planks", + () + -> new Block(BlockBehaviour.Properties + .of(Material.WOOD, MaterialColor.COLOR_RED) + .strength(2.0F, 3.0F) + .sound(SoundType.WOOD)), + CreativeModeTab.TAB_BUILDING_BLOCKS + ); + public static final Supplier MANGROVE_STAIRS = create( + "mangrove_stairs", + () + -> StairBlockAccessor.createStairBlock( + MANGROVE_PLANKS.get().defaultBlockState(), + BlockBehaviour.Properties.copy(MANGROVE_PLANKS.get()) + ), + CreativeModeTab.TAB_BUILDING_BLOCKS + ); + public static final Supplier MANGROVE_SLAB = create( + "mangrove_slab", + () + -> new SlabBlock(BlockBehaviour.Properties + .of(Material.WOOD, MaterialColor.COLOR_RED) + .strength(2.0F, 3.0F) + .sound(SoundType.WOOD)), + CreativeModeTab.TAB_BUILDING_BLOCKS + ); + public static final Supplier MANGROVE_FENCE = create( + "mangrove_fence", + () + -> new FenceBlock(BlockBehaviour.Properties + .of(Material.WOOD, + MANGROVE_PLANKS.get().defaultMaterialColor()) + .strength(2.0F, 3.0F) + .sound(SoundType.WOOD)), + CreativeModeTab.TAB_DECORATIONS + ); + public static final Supplier MANGROVE_FENCE_GATE = create( + "mangrove_fence_gate", + () + -> new FenceGateBlock(BlockBehaviour.Properties + .of(Material.WOOD, + MANGROVE_PLANKS.get().defaultMaterialColor()) + .strength(2.0F, 3.0F) + .sound(SoundType.WOOD)), + CreativeModeTab.TAB_REDSTONE + ); + public static final Supplier MANGROVE_DOOR = create( + "mangrove_door", + () + -> DoorBlockAccessor.createDoorBlock( + BlockBehaviour.Properties + .of(Material.WOOD, MANGROVE_PLANKS.get().defaultMaterialColor()) + .strength(3.0F) + .sound(SoundType.WOOD) + .noOcclusion() + ), + CreativeModeTab.TAB_REDSTONE + ); + public static final Supplier MANGROVE_TRAPDOOR = create( + "mangrove_trapdoor", + () + -> TrapDoorBlockAccessor.createTrapDoorBlock( + BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_RED) + .strength(3.0F) + .sound(SoundType.WOOD) + .noOcclusion() + .isValidSpawn(StateProperties::never) + ), + CreativeModeTab.TAB_REDSTONE + ); + public static final Supplier MANGROVE_PRESSURE_PLATE = create( + "mangrove_pressure_plate", + () + -> PressurePlateBlockAccessor.createPressurePlateBlock( + PressurePlateBlock.Sensitivity.EVERYTHING, + BlockBehaviour.Properties + .of(Material.WOOD, MANGROVE_PLANKS.get().defaultMaterialColor()) + .noCollission() + .strength(0.5F) + .sound(SoundType.WOOD) + ), + CreativeModeTab.TAB_REDSTONE + ); + public static final Supplier MANGROVE_BUTTON = create( + "mangrove_button", + () + -> WoodButtonBlockAccessor.createWoodButtonBlock(BlockBehaviour.Properties + .of(Material.DECORATION) + .noCollission() + .strength(0.5F) + .sound(SoundType.WOOD)), + CreativeModeTab.TAB_REDSTONE + ); + public static final Supplier MANGROVE_LEAVES = create( + "mangrove_leaves", + () + -> new MangroveLeavesBlock(BlockBehaviour.Properties.of(Material.LEAVES) + .strength(0.2F) + .randomTicks() + .sound(SoundType.GRASS) + .noOcclusion() + .isValidSpawn(StateProperties::ocelotOrParrot) + .isSuffocating(StateProperties::never) + .isViewBlocking(StateProperties::never)), + CreativeModeTab.TAB_DECORATIONS + ); + public static final Supplier MANGROVE_PROPAGULE = create( + "mangrove_propagule", + () + -> new MangrovePropaguleBlock(BlockBehaviour.Properties.of(Material.PLANT) + .noCollission() + .randomTicks() + .instabreak() + .sound(SoundType.GRASS)), + CreativeModeTab.TAB_DECORATIONS + ); + public static final Supplier POTTED_MANGROVE_PROPAGULE = create( + "potted_mangrove_propagule", + () + -> new FlowerPotBlock( + MANGROVE_PROPAGULE.get(), + BlockBehaviour.Properties.of(Material.DECORATION) + .instabreak() + .noOcclusion() + ) + ); + public static final Supplier MANGROVE_ROOTS = create( + "mangrove_roots", + () + -> new MangroveRootsBlock(BlockBehaviour.Properties.of(Material.WOOD) + .strength(0.7F) + .randomTicks() + .sound(WBSoundTypes.MANGROVE_ROOTS) + .noOcclusion() + .isValidSpawn(StateProperties::ocelotOrParrot) + .isSuffocating(StateProperties::never) + .isViewBlocking(StateProperties::never)), + CreativeModeTab.TAB_BUILDING_BLOCKS + ); + public static final Supplier MUDDY_MANGROVE_ROOTS = create( + "muddy_mangrove_roots", + () + -> new RotatedPillarBlock(BlockBehaviour.Properties.of(Material.DIRT) + .strength(0.7F) + .sound(WBSoundTypes.MUDDY_MANGROVE_ROOTS)), + CreativeModeTab.TAB_BUILDING_BLOCKS + ); + public static final Pair, Supplier> + MANGROVE_SIGN = create("mangrove", Material.WOOD, MaterialColor.COLOR_RED); // Mud - public static final Supplier MUD = create("mud", () -> new MudBlock(BlockBehaviour.Properties.copy(Blocks.DIRT).color(MaterialColor.TERRACOTTA_CYAN).isValidSpawn(StateProperties::always).isRedstoneConductor(StateProperties::always).isViewBlocking(StateProperties::always).isSuffocating(StateProperties::always).sound(WBSoundTypes.MUD)), CreativeModeTab.TAB_BUILDING_BLOCKS); - public static final Supplier PACKED_MUD = create("packed_mud", () -> new Block(BlockBehaviour.Properties.copy(Blocks.DIRT).strength(1.0F, 3.0F).sound(WBSoundTypes.PACKED_MUD)), CreativeModeTab.TAB_BUILDING_BLOCKS); - public static final Supplier MUD_BRICKS = create("mud_bricks", () -> new Block(BlockBehaviour.Properties.of(Material.STONE, MaterialColor.COLOR_LIGHT_GRAY).requiresCorrectToolForDrops().strength(1.5F, 3.0F).sound(WBSoundTypes.MUD_BRICKS)), CreativeModeTab.TAB_BUILDING_BLOCKS); - public static final Supplier MUD_BRICK_STAIRS = create("mud_brick_stairs", () -> StairBlockAccessor.createStairBlock(MUD_BRICKS.get().defaultBlockState(), BlockBehaviour.Properties.copy(MUD_BRICKS.get())), CreativeModeTab.TAB_BUILDING_BLOCKS); - public static final Supplier MUD_BRICK_SLAB = create("mud_brick_slab", () -> new SlabBlock(BlockBehaviour.Properties.of(Material.STONE, MaterialColor.COLOR_BROWN).requiresCorrectToolForDrops().strength(1.5F, 3.0F)), CreativeModeTab.TAB_BUILDING_BLOCKS); - public static final Supplier MUD_BRICK_WALL = create("mud_brick_wall", () -> new WallBlock(BlockBehaviour.Properties.copy(MUD_BRICKS.get())), CreativeModeTab.TAB_DECORATIONS); + public static final Supplier MUD = create( + "mud", + () + -> new MudBlock(BlockBehaviour.Properties.copy(Blocks.DIRT) + .color(MaterialColor.TERRACOTTA_CYAN) + .isValidSpawn(StateProperties::always) + .isRedstoneConductor(StateProperties::always) + .isViewBlocking(StateProperties::always) + .isSuffocating(StateProperties::always) + .sound(WBSoundTypes.MUD)), + CreativeModeTab.TAB_BUILDING_BLOCKS + ); + public static final Supplier PACKED_MUD = create( + "packed_mud", + () + -> new Block(BlockBehaviour.Properties.copy(Blocks.DIRT) + .strength(1.0F, 3.0F) + .sound(WBSoundTypes.PACKED_MUD)), + CreativeModeTab.TAB_BUILDING_BLOCKS + ); + public static final Supplier MUD_BRICKS = create( + "mud_bricks", + () + -> new Block(BlockBehaviour.Properties + .of(Material.STONE, MaterialColor.COLOR_LIGHT_GRAY) + .requiresCorrectToolForDrops() + .strength(1.5F, 3.0F) + .sound(WBSoundTypes.MUD_BRICKS)), + CreativeModeTab.TAB_BUILDING_BLOCKS + ); + public static final Supplier MUD_BRICK_STAIRS = create( + "mud_brick_stairs", + () + -> StairBlockAccessor.createStairBlock( + MUD_BRICKS.get().defaultBlockState(), + BlockBehaviour.Properties.copy(MUD_BRICKS.get()) + ), + CreativeModeTab.TAB_BUILDING_BLOCKS + ); + public static final Supplier MUD_BRICK_SLAB = create( + "mud_brick_slab", + () + -> new SlabBlock(BlockBehaviour.Properties + .of(Material.STONE, MaterialColor.COLOR_BROWN) + .requiresCorrectToolForDrops() + .strength(1.5F, 3.0F)), + CreativeModeTab.TAB_BUILDING_BLOCKS + ); + public static final Supplier MUD_BRICK_WALL = create( + "mud_brick_wall", + () + -> new WallBlock(BlockBehaviour.Properties.copy(MUD_BRICKS.get())), + CreativeModeTab.TAB_DECORATIONS + ); // Deepslate - public static final Supplier REINFORCED_DEEPSLATE = create("reinforced_deepslate", () -> new Block(BlockBehaviour.Properties.of(Material.STONE, MaterialColor.DEEPSLATE).sound(SoundType.DEEPSLATE).strength(55.0F, 1200.0F).noDrops()), CreativeModeTab.TAB_DECORATIONS); + public static final Supplier REINFORCED_DEEPSLATE = create( + "reinforced_deepslate", + () + -> new Block(BlockBehaviour.Properties + .of(Material.STONE, MaterialColor.DEEPSLATE) + .sound(SoundType.DEEPSLATE) + .strength(55.0F, 1200.0F) + .noDrops()), + CreativeModeTab.TAB_DECORATIONS + ); - private static Supplier create(String key, Supplier block, CreativeModeTab tab) { - return create(key, block, entry -> new BlockItem(entry.get(), new Item.Properties().tab(tab))); + private static Supplier + create(String key, Supplier block, CreativeModeTab tab) { + return create( + key, + block, + entry -> new BlockItem(entry.get(), new Item.Properties().tab(tab)) + ); } - private static Supplier create(String key, Supplier block, Function, Item> item) { + private static Supplier + create(String key, Supplier block, Function, Item> item) { Supplier entry = create(key, block); WBItems.ITEMS.register(key, () -> item.apply(entry)); return entry; @@ -112,15 +417,30 @@ public class WBBlocks { } // Signs - public static Pair, Supplier> create(String key, Material material, MaterialColor color) { - return create(key, BlockBehaviour.Properties.of(material, color).noCollission().strength(1.0F).sound(SoundType.WOOD), new Item.Properties().stacksTo(16).tab(CreativeModeTab.TAB_DECORATIONS)); + public static Pair, Supplier> + create(String key, Material material, MaterialColor color) { + return create( + key, + BlockBehaviour.Properties.of(material, color) + .noCollission() + .strength(1.0F) + .sound(SoundType.WOOD), + new Item.Properties().stacksTo(16).tab(CreativeModeTab.TAB_DECORATIONS) + ); } - public static Pair, Supplier> create(String key, BlockBehaviour.Properties blocks, Item.Properties items) { + public static Pair, Supplier> + create(String key, BlockBehaviour.Properties blocks, Item.Properties items) { WoodType woodType = WoodTypeRegistry.create(new ResourceLocation(key)); - Supplier standing = create(key + "_sign", () -> new StandingSignBlock(blocks, woodType)); - Supplier wall = create(key + "_wall_sign", () -> new WallSignBlock(blocks.dropsLike(standing.get()), woodType)); - WBItems.ITEMS.register(key + "_sign", () -> new SignItem(items, standing.get(), wall.get())); + Supplier standing + = create(key + "_sign", () -> new StandingSignBlock(blocks, woodType)); + Supplier wall = create( + key + "_wall_sign", + () -> new WallSignBlock(blocks.dropsLike(standing.get()), woodType) + ); + WBItems.ITEMS.register( + key + "_sign", () -> new SignItem(items, standing.get(), wall.get()) + ); return Pair.of(standing, wall); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBEnchantments.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBEnchantments.java index 3c3b3b8..a23e4a7 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBEnchantments.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBEnchantments.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.registry; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.common.enchantments.SwiftSneakEnchantment; import com.cursedcauldron.wildbackport.core.api.CoreRegistry; @@ -7,10 +9,15 @@ import net.minecraft.core.Registry; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.item.enchantment.Enchantment; -import java.util.function.Supplier; - public class WBEnchantments { - public static final CoreRegistry ENCHANTMENTS = CoreRegistry.create(Registry.ENCHANTMENT, "minecraft"); + public static final CoreRegistry ENCHANTMENTS + = CoreRegistry.create(Registry.ENCHANTMENT, "minecraft"); - public static final Supplier SWIFT_SNEAK = ENCHANTMENTS.register("swift_sneak", () -> new SwiftSneakEnchantment(Enchantment.Rarity.VERY_RARE, new EquipmentSlot[]{EquipmentSlot.LEGS})); + public static final Supplier SWIFT_SNEAK = ENCHANTMENTS.register( + "swift_sneak", + () + -> new SwiftSneakEnchantment( + Enchantment.Rarity.VERY_RARE, new EquipmentSlot[] { EquipmentSlot.LEGS } + ) + ); } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBGameEvents.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBGameEvents.java index b46ab1a..f4d1d6f 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBGameEvents.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBGameEvents.java @@ -1,22 +1,24 @@ package com.cursedcauldron.wildbackport.common.registry; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.core.api.CoreRegistry; import net.minecraft.core.Registry; import net.minecraft.world.level.gameevent.GameEvent; -import java.util.function.Supplier; - //<> public class WBGameEvents { - public static final CoreRegistry EVENTS = CoreRegistry.create(Registry.GAME_EVENT, "minecraft"); + public static final CoreRegistry EVENTS + = CoreRegistry.create(Registry.GAME_EVENT, "minecraft"); - public static final Supplier NOTE_BLOCK_PLAY = create("note_block_play"); - public static final Supplier SCULK_SENSOR_TENDRILS_CLICKING = create("sculk_sensor_tendrils_clicking"); - public static final Supplier ENTITY_DIE = create("entity_die"); - public static final Supplier SHRIEK = create("shriek", 32); - public static final Supplier INSTRUMENT_PLAY = create("instrument_play"); + public static final Supplier NOTE_BLOCK_PLAY = create("note_block_play"); + public static final Supplier SCULK_SENSOR_TENDRILS_CLICKING + = create("sculk_sensor_tendrils_clicking"); + public static final Supplier ENTITY_DIE = create("entity_die"); + public static final Supplier SHRIEK = create("shriek", 32); + public static final Supplier INSTRUMENT_PLAY = create("instrument_play"); private static Supplier create(String key) { return create(key, 16); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBGameRules.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBGameRules.java index a968ab8..4ec1f1e 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBGameRules.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBGameRules.java @@ -7,9 +7,14 @@ import net.minecraft.world.level.GameRules; public class WBGameRules { public static void setup() {} - public static final GameRules.Key DO_WARDEN_SPAWNING = create("doWardenSpawning", GameRules.Category.SPAWNING, BooleanValueAccessor.callCreate(true)); + public static final GameRules.Key DO_WARDEN_SPAWNING = create( + "doWardenSpawning", + GameRules.Category.SPAWNING, + BooleanValueAccessor.callCreate(true) + ); - private static > GameRules.Key create(String key, GameRules.Category category, GameRules.Type type) { + private static > GameRules.Key + create(String key, GameRules.Category category, GameRules.Type type) { return GameRulesAccessor.callRegister(key, category, type); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBItems.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBItems.java index 395844b..07856d5 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBItems.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBItems.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.registry; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.client.registry.WBSoundEvents; import com.cursedcauldron.wildbackport.common.entities.access.api.BoatTypes; @@ -19,49 +21,102 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.Rarity; import net.minecraft.world.level.material.Fluids; -import java.util.function.Supplier; - //<> public class WBItems { - public static final CoreRegistry ITEMS = CoreRegistry.create(Registry.ITEM, "minecraft"); + public static final CoreRegistry ITEMS + = CoreRegistry.create(Registry.ITEM, "minecraft"); // Spawns - public static final Supplier ALLAY_SPAWN_EGG = create("allay_spawn_egg", spawnEgg(WBEntityTypes.ALLAY, 56063, 44543)); - public static final Supplier FROG_SPAWN_EGG = create("frog_spawn_egg", spawnEgg(WBEntityTypes.FROG, 13661252, 16762748)); - public static final Supplier TADPOLE_SPAWN_EGG = create("tadpole_spawn_egg", spawnEgg(WBEntityTypes.TADPOLE, 7164733, 1444352)); - public static final Supplier WARDEN_SPAWN_EGG = create("warden_spawn_egg", spawnEgg(WBEntityTypes.WARDEN, 1001033, 3790560)); - public static final Supplier TADPOLE_BUCKET = create("tadpole_bucket", () -> new TadpoleBucketItem(WBEntityTypes.TADPOLE, Fluids.WATER, () -> WBSoundEvents.BUCKED_EMPTY_TADPOLE, new Item.Properties().stacksTo(1).tab(CreativeModeTab.TAB_MISC))); + public static final Supplier ALLAY_SPAWN_EGG + = create("allay_spawn_egg", spawnEgg(WBEntityTypes.ALLAY, 56063, 44543)); + public static final Supplier FROG_SPAWN_EGG + = create("frog_spawn_egg", spawnEgg(WBEntityTypes.FROG, 13661252, 16762748)); + public static final Supplier TADPOLE_SPAWN_EGG + = create("tadpole_spawn_egg", spawnEgg(WBEntityTypes.TADPOLE, 7164733, 1444352)); + public static final Supplier WARDEN_SPAWN_EGG + = create("warden_spawn_egg", spawnEgg(WBEntityTypes.WARDEN, 1001033, 3790560)); + public static final Supplier TADPOLE_BUCKET = create( + "tadpole_bucket", + () + -> new TadpoleBucketItem( + WBEntityTypes.TADPOLE, + Fluids.WATER, + () + -> WBSoundEvents.BUCKED_EMPTY_TADPOLE, + new Item.Properties().stacksTo(1).tab(CreativeModeTab.TAB_MISC) + ) + ); // Boats - public static final Supplier MANGROVE_BOAT = create("mangrove_boat", boat(false, BoatTypes.MANGROVE.get())); - public static final Supplier OAK_CHEST_BOAT = create("oak_chest_boat", boat(true, Boat.Type.OAK)); - public static final Supplier SPRUCE_CHEST_BOAT = create("spruce_chest_boat", boat(true, Boat.Type.SPRUCE)); - public static final Supplier ACACIA_CHEST_BOAT = create("acacia_chest_boat", boat(true, Boat.Type.ACACIA)); - public static final Supplier BIRCH_CHEST_BOAT = create("birch_chest_boat", boat(true, Boat.Type.BIRCH)); - public static final Supplier JUNGLE_CHEST_BOAT = create("jungle_chest_boat", boat(true, Boat.Type.JUNGLE)); - public static final Supplier DARK_OAK_CHEST_BOAT = create("dark_oak_chest_boat", boat(true, Boat.Type.DARK_OAK)); - public static final Supplier MANGROVE_CHEST_BOAT = create("mangrove_chest_boat", boat(true, BoatTypes.MANGROVE.get())); + public static final Supplier MANGROVE_BOAT + = create("mangrove_boat", boat(false, BoatTypes.MANGROVE.get())); + public static final Supplier OAK_CHEST_BOAT + = create("oak_chest_boat", boat(true, Boat.Type.OAK)); + public static final Supplier SPRUCE_CHEST_BOAT + = create("spruce_chest_boat", boat(true, Boat.Type.SPRUCE)); + public static final Supplier ACACIA_CHEST_BOAT + = create("acacia_chest_boat", boat(true, Boat.Type.ACACIA)); + public static final Supplier BIRCH_CHEST_BOAT + = create("birch_chest_boat", boat(true, Boat.Type.BIRCH)); + public static final Supplier JUNGLE_CHEST_BOAT + = create("jungle_chest_boat", boat(true, Boat.Type.JUNGLE)); + public static final Supplier DARK_OAK_CHEST_BOAT + = create("dark_oak_chest_boat", boat(true, Boat.Type.DARK_OAK)); + public static final Supplier MANGROVE_CHEST_BOAT + = create("mangrove_chest_boat", boat(true, BoatTypes.MANGROVE.get())); // Deep Dark - public static final Supplier ECHO_SHARD = create("echo_shard", () -> new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC))); - public static final Supplier RECOVERY_COMPASS = create("recovery_compass", () -> new Item(new Item.Properties().tab(CreativeModeTab.TAB_TOOLS))); + public static final Supplier ECHO_SHARD = create( + "echo_shard", () -> new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC)) + ); + public static final Supplier RECOVERY_COMPASS = create( + "recovery_compass", + () -> new Item(new Item.Properties().tab(CreativeModeTab.TAB_TOOLS)) + ); // Music - public static final Supplier MUSIC_DISC_5 = create("music_disc_5", () -> RecordItemAccessor.createRecordItem(15, WBSoundEvents.MUSIC_DISC_5, new Item.Properties().stacksTo(1).tab(CreativeModeTab.TAB_MISC).rarity(Rarity.RARE))); - public static final Supplier DISC_FRAGMENT_5 = create("disc_fragment_5", () -> new DiscFragmentItem(new Item.Properties().tab(CreativeModeTab.TAB_MISC))); -// public static final Supplier GOAT_HORN = create("goat_horn", () -> new GoatHornItem(new Item.Properties().stacksTo(1).tab(CreativeModeTab.TAB_MISC), InstrumentTags.GOAT_HORNS)); + public static final Supplier MUSIC_DISC_5 = create( + "music_disc_5", + () + -> RecordItemAccessor.createRecordItem( + 15, + WBSoundEvents.MUSIC_DISC_5, + new Item.Properties() + .stacksTo(1) + .tab(CreativeModeTab.TAB_MISC) + .rarity(Rarity.RARE) + ) + ); + public static final Supplier DISC_FRAGMENT_5 = create( + "disc_fragment_5", + () -> new DiscFragmentItem(new Item.Properties().tab(CreativeModeTab.TAB_MISC)) + ); + + // public static final Supplier GOAT_HORN = create("goat_horn", () + // -> new GoatHornItem(new + // Item.Properties().stacksTo(1).tab(CreativeModeTab.TAB_MISC), + // InstrumentTags.GOAT_HORNS)); private static Supplier create(String key, Supplier item) { return ITEMS.register(key, item); } @ExpectPlatform - private static Supplier spawnEgg(Supplier> mob, int background, int highlight) { + private static Supplier spawnEgg( + Supplier> mob, int background, int highlight + ) { throw new AssertionError(); } private static Supplier boat(boolean chested, Boat.Type type) { - return () -> new ChestBoatItem(chested, type, new Item.Properties().stacksTo(1).tab(CreativeModeTab.TAB_TRANSPORTATION)); + return () + -> new ChestBoatItem( + chested, + type, + new Item.Properties().stacksTo(1).tab( + CreativeModeTab.TAB_TRANSPORTATION + ) + ); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBMobEffects.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBMobEffects.java index 034081c..2967324 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBMobEffects.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBMobEffects.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.registry; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.common.effects.EffectFactor; import com.cursedcauldron.wildbackport.common.effects.FactorCalculationData; @@ -9,10 +11,17 @@ import net.minecraft.core.Registry; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffectCategory; -import java.util.function.Supplier; - public class WBMobEffects { - public static final CoreRegistry EFFECTS = CoreRegistry.create(Registry.MOB_EFFECT, "minecraft"); + public static final CoreRegistry EFFECTS + = CoreRegistry.create(Registry.MOB_EFFECT, "minecraft"); - public static final Supplier DARKNESS = EFFECTS.register("darkness", () -> EffectFactor.of(MobEffectAccessor.createMobEffect(MobEffectCategory.HARMFUL, 2696993)).setFactorCalculationData(() -> new FactorCalculationData(22))); + public static final Supplier DARKNESS = EFFECTS.register( + "darkness", + () + -> EffectFactor + .of(MobEffectAccessor.createMobEffect( + MobEffectCategory.HARMFUL, 2696993 + )) + .setFactorCalculationData(() -> new FactorCalculationData(22)) + ); } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBPositionSources.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBPositionSources.java index 00873f4..5a95ccd 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBPositionSources.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBPositionSources.java @@ -1,15 +1,17 @@ package com.cursedcauldron.wildbackport.common.registry; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.common.entities.warden.MobPositionSource; import com.cursedcauldron.wildbackport.core.api.CoreRegistry; import net.minecraft.core.Registry; import net.minecraft.world.level.gameevent.PositionSourceType; -import java.util.function.Supplier; - public class WBPositionSources { - public static final CoreRegistry> SOURCES = CoreRegistry.create(Registry.POSITION_SOURCE_TYPE, "minecraft"); + public static final CoreRegistry> SOURCES + = CoreRegistry.create(Registry.POSITION_SOURCE_TYPE, "minecraft"); - public static final Supplier> MOB = SOURCES.register("mob", MobPositionSource.Type::new); + public static final Supplier> MOB + = SOURCES.register("mob", MobPositionSource.Type::new); } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBRegistries.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBRegistries.java index 0822294..be7ef18 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBRegistries.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/WBRegistries.java @@ -12,7 +12,13 @@ import com.cursedcauldron.wildbackport.core.api.SampleRegistry; public class WBRegistries { public static final RegistryBuilder BUILDER = RegistryBuilder.create("minecraft"); - public static final SampleRegistry> ROOT_PLACER_TYPES = BUILDER.create("worldgen/root_placer_type", registry -> RootPlacerType.MANGROVE_ROOT_PLACER.get()); - public static final SampleRegistry INSTRUMENT = BUILDER.create("instrument", registry -> Instruments.DREAM_GOAT_HORN.get()); -// public static final SampleRegistry INSTRUMENT = BUILDER.create("instrument", Instruments::registerAndGetDefault); + public static final SampleRegistry> ROOT_PLACER_TYPES + = BUILDER.create( + "worldgen/root_placer_type", + registry -> RootPlacerType.MANGROVE_ROOT_PLACER.get() + ); + public static final SampleRegistry INSTRUMENT + = BUILDER.create("instrument", registry -> Instruments.DREAM_GOAT_HORN.get()); + // public static final SampleRegistry INSTRUMENT = + // BUILDER.create("instrument", Instruments::registerAndGetDefault); } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/entity/WBActivities.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/entity/WBActivities.java index 8e8eb6f..54b4498 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/entity/WBActivities.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/entity/WBActivities.java @@ -1,26 +1,27 @@ package com.cursedcauldron.wildbackport.common.registry.entity; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.core.api.CoreRegistry; import com.cursedcauldron.wildbackport.core.mixin.access.ActivityAccessor; import net.minecraft.core.Registry; import net.minecraft.world.entity.schedule.Activity; -import java.util.function.Supplier; - //<> public class WBActivities { - public static final CoreRegistry ACTIVITIES = CoreRegistry.create(Registry.ACTIVITY, "minecraft"); + public static final CoreRegistry ACTIVITIES + = CoreRegistry.create(Registry.ACTIVITY, "minecraft"); - public static final Supplier SNIFF = create("sniff"); - public static final Supplier INVESTIGATE = create("investigate"); - public static final Supplier ROAR = create("roar"); - public static final Supplier EMERGE = create("emerge"); - public static final Supplier TONGUE = create("tongue"); - public static final Supplier DIG = create("dig"); - public static final Supplier SWIM = create("swim"); - public static final Supplier LAY_SPAWN = create("lay_spawn"); + public static final Supplier SNIFF = create("sniff"); + public static final Supplier INVESTIGATE = create("investigate"); + public static final Supplier ROAR = create("roar"); + public static final Supplier EMERGE = create("emerge"); + public static final Supplier TONGUE = create("tongue"); + public static final Supplier DIG = create("dig"); + public static final Supplier SWIM = create("swim"); + public static final Supplier LAY_SPAWN = create("lay_spawn"); public static Supplier create(String key) { return ACTIVITIES.register(key, () -> ActivityAccessor.createActivity(key)); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/entity/WBEntityTypes.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/entity/WBEntityTypes.java index 946e7c5..f1b3813 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/entity/WBEntityTypes.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/entity/WBEntityTypes.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.registry.entity; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.common.entities.Allay; import com.cursedcauldron.wildbackport.common.entities.ChestBoat; @@ -13,21 +15,53 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MobCategory; -import java.util.function.Supplier; - //<> public class WBEntityTypes { - public static final CoreRegistry> ENTITIES = CoreRegistry.create(Registry.ENTITY_TYPE, "minecraft"); + public static final CoreRegistry> ENTITIES + = CoreRegistry.create(Registry.ENTITY_TYPE, "minecraft"); - public static final Supplier> ALLAY = create("allay", EntityType.Builder.of(Allay::new, MobCategory.CREATURE).sized(0.35F, 0.6F).clientTrackingRange(8).updateInterval(2)); - public static final Supplier> FROG = create("frog", EntityType.Builder.of(Frog::new, MobCategory.CREATURE).sized(0.5F, 0.5F).clientTrackingRange(10)); - public static final Supplier> TADPOLE = create("tadpole", EntityType.Builder.of(Tadpole::new, MobCategory.CREATURE).sized(0.4F, 0.3F).clientTrackingRange(10)); - public static final Supplier> WARDEN = create("warden", EntityType.Builder.of(Warden::new, MobCategory.MONSTER).sized(0.9F, 2.9F).clientTrackingRange(16).fireImmune()); - public static final Supplier> MANGROVE_BOAT = create("mangrove_boat", EntityType.Builder.of(MangroveBoat::new, MobCategory.MISC).sized(1.375F, 0.5625F).clientTrackingRange(10)); - public static final Supplier> CHEST_BOAT = create("chest_boat", EntityType.Builder.of(ChestBoat::new, MobCategory.MISC).sized(1.375F, 0.5625F).clientTrackingRange(10)); + public static final Supplier> ALLAY = create( + "allay", + EntityType.Builder.of(Allay::new, MobCategory.CREATURE) + .sized(0.35F, 0.6F) + .clientTrackingRange(8) + .updateInterval(2) + ); + public static final Supplier> FROG = create( + "frog", + EntityType.Builder.of(Frog::new, MobCategory.CREATURE) + .sized(0.5F, 0.5F) + .clientTrackingRange(10) + ); + public static final Supplier> TADPOLE = create( + "tadpole", + EntityType.Builder.of(Tadpole::new, MobCategory.CREATURE) + .sized(0.4F, 0.3F) + .clientTrackingRange(10) + ); + public static final Supplier> WARDEN = create( + "warden", + EntityType.Builder.of(Warden::new, MobCategory.MONSTER) + .sized(0.9F, 2.9F) + .clientTrackingRange(16) + .fireImmune() + ); + public static final Supplier> MANGROVE_BOAT = create( + "mangrove_boat", + EntityType.Builder.of(MangroveBoat::new, MobCategory.MISC) + .sized(1.375F, 0.5625F) + .clientTrackingRange(10) + ); + public static final Supplier> CHEST_BOAT = create( + "chest_boat", + EntityType.Builder.of(ChestBoat::new, MobCategory.MISC) + .sized(1.375F, 0.5625F) + .clientTrackingRange(10) + ); - private static Supplier> create(String key, EntityType.Builder builder) { + private static Supplier> + create(String key, EntityType.Builder builder) { return ENTITIES.register(key, () -> builder.build(key)); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/entity/WBMemoryModules.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/entity/WBMemoryModules.java index 9669b6a..b3d155f 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/entity/WBMemoryModules.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/entity/WBMemoryModules.java @@ -1,5 +1,10 @@ package com.cursedcauldron.wildbackport.common.registry.entity; +import java.util.List; +import java.util.Optional; +import java.util.UUID; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.core.api.CoreRegistry; import com.cursedcauldron.wildbackport.core.mixin.access.MemoryModuleTypeAccessor; @@ -12,44 +17,64 @@ import net.minecraft.util.Unit; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.memory.MemoryModuleType; -import java.util.List; -import java.util.Optional; -import java.util.UUID; -import java.util.function.Supplier; - //<> public class WBMemoryModules { - public static final CoreRegistry> MEMORIES = CoreRegistry.create(Registry.MEMORY_MODULE_TYPE, "minecraft"); + public static final CoreRegistry> MEMORIES + = CoreRegistry.create(Registry.MEMORY_MODULE_TYPE, "minecraft"); - - public static final Supplier> IS_IN_WATER = create("is_in_water", Codec.unit(Unit.INSTANCE)); - public static final Supplier> IS_PREGNANT = create("is_pregnant", Codec.unit(Unit.INSTANCE)); - public static final Supplier>> UNREACHABLE_TONGUE_TARGETS = create("unreachable_tongue_targets"); - public static final Supplier> ROAR_TARGET = create("roar_target"); - public static final Supplier> DISTURBANCE_LOCATION = create("disturbance_location"); - public static final Supplier> RECENT_PROJECTILE = create("recent_projectile", Codec.unit(Unit.INSTANCE)); - public static final Supplier> IS_SNIFFING = create("is_sniffing", Codec.unit(Unit.INSTANCE)); - public static final Supplier> IS_EMERGING = create("is_emerging", Codec.unit(Unit.INSTANCE)); - public static final Supplier> ROAR_SOUND_DELAY = create("roar_sound_delay", Codec.unit(Unit.INSTANCE)); - public static final Supplier> DIG_COOLDOWN = create("dig_cooldown", Codec.unit(Unit.INSTANCE)); - public static final Supplier> ROAR_SOUND_COOLDOWN = create("roar_sound_cooldown", Codec.unit(Unit.INSTANCE)); - public static final Supplier> SNIFF_COOLDOWN = create("sniff_cooldown", Codec.unit(Unit.INSTANCE)); - public static final Supplier> TOUCH_COOLDOWN = create("touch_cooldown", Codec.unit(Unit.INSTANCE)); - public static final Supplier> VIBRATION_COOLDOWN = create("vibration_cooldown", Codec.unit(Unit.INSTANCE)); - public static final Supplier> SONIC_BOOM_COOLDOWN = create("sonic_boom_cooldown", Codec.unit(Unit.INSTANCE)); - public static final Supplier> SONIC_BOOM_SOUND_COOLDOWN = create("sonic_boom_sound_cooldown", Codec.unit(Unit.INSTANCE)); - public static final Supplier> SONIC_BOOM_SOUND_DELAY = create("sonic_boom_sound_delay", Codec.unit(Unit.INSTANCE)); - public static final Supplier> LIKED_PLAYER = create("liked_player", SerializableUUID.CODEC); - public static final Supplier> LIKED_NOTEBLOCK = create("liked_noteblock", GlobalPos.CODEC); - public static final Supplier> LIKED_NOTEBLOCK_COOLDOWN_TICKS = create("liked_noteblock_cooldown_ticks", Codec.INT); - public static final Supplier> ITEM_PICKUP_COOLDOWN_TICKS = create("item_pickup_cooldown_ticks", Codec.INT); + public static final Supplier> IS_IN_WATER + = create("is_in_water", Codec.unit(Unit.INSTANCE)); + public static final Supplier> IS_PREGNANT + = create("is_pregnant", Codec.unit(Unit.INSTANCE)); + public static final Supplier>> UNREACHABLE_TONGUE_TARGETS + = create("unreachable_tongue_targets"); + public static final Supplier> ROAR_TARGET + = create("roar_target"); + public static final Supplier> DISTURBANCE_LOCATION + = create("disturbance_location"); + public static final Supplier> RECENT_PROJECTILE + = create("recent_projectile", Codec.unit(Unit.INSTANCE)); + public static final Supplier> IS_SNIFFING + = create("is_sniffing", Codec.unit(Unit.INSTANCE)); + public static final Supplier> IS_EMERGING + = create("is_emerging", Codec.unit(Unit.INSTANCE)); + public static final Supplier> ROAR_SOUND_DELAY + = create("roar_sound_delay", Codec.unit(Unit.INSTANCE)); + public static final Supplier> DIG_COOLDOWN + = create("dig_cooldown", Codec.unit(Unit.INSTANCE)); + public static final Supplier> ROAR_SOUND_COOLDOWN + = create("roar_sound_cooldown", Codec.unit(Unit.INSTANCE)); + public static final Supplier> SNIFF_COOLDOWN + = create("sniff_cooldown", Codec.unit(Unit.INSTANCE)); + public static final Supplier> TOUCH_COOLDOWN + = create("touch_cooldown", Codec.unit(Unit.INSTANCE)); + public static final Supplier> VIBRATION_COOLDOWN + = create("vibration_cooldown", Codec.unit(Unit.INSTANCE)); + public static final Supplier> SONIC_BOOM_COOLDOWN + = create("sonic_boom_cooldown", Codec.unit(Unit.INSTANCE)); + public static final Supplier> SONIC_BOOM_SOUND_COOLDOWN + = create("sonic_boom_sound_cooldown", Codec.unit(Unit.INSTANCE)); + public static final Supplier> SONIC_BOOM_SOUND_DELAY + = create("sonic_boom_sound_delay", Codec.unit(Unit.INSTANCE)); + public static final Supplier> LIKED_PLAYER + = create("liked_player", SerializableUUID.CODEC); + public static final Supplier> LIKED_NOTEBLOCK + = create("liked_noteblock", GlobalPos.CODEC); + public static final Supplier> LIKED_NOTEBLOCK_COOLDOWN_TICKS + = create("liked_noteblock_cooldown_ticks", Codec.INT); + public static final Supplier> ITEM_PICKUP_COOLDOWN_TICKS + = create("item_pickup_cooldown_ticks", Codec.INT); private static Supplier> create(String key) { - return MEMORIES.register(key, () -> MemoryModuleTypeAccessor.createMemoryModuleType(Optional.empty())); + return MEMORIES.register( + key, () -> MemoryModuleTypeAccessor.createMemoryModuleType(Optional.empty()) + ); } private static Supplier> create(String key, Codec codec) { - return MEMORIES.register(key, () -> MemoryModuleTypeAccessor.createMemoryModuleType(Optional.of(codec))); + return MEMORIES.register( + key, () -> MemoryModuleTypeAccessor.createMemoryModuleType(Optional.of(codec)) + ); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/entity/WBSensorTypes.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/entity/WBSensorTypes.java index aa26300..d22fe51 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/entity/WBSensorTypes.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/entity/WBSensorTypes.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.registry.entity; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.common.entities.brain.FrogBrain; import com.cursedcauldron.wildbackport.common.entities.brain.frog.FrogAttackablesSensor; @@ -12,19 +14,23 @@ import net.minecraft.world.entity.ai.sensing.Sensor; import net.minecraft.world.entity.ai.sensing.SensorType; import net.minecraft.world.entity.ai.sensing.TemptingSensor; -import java.util.function.Supplier; - //<> public class WBSensorTypes { - public static final CoreRegistry> SENSORS = CoreRegistry.create(Registry.SENSOR_TYPE, "minecraft"); + public static final CoreRegistry> SENSORS + = CoreRegistry.create(Registry.SENSOR_TYPE, "minecraft"); - public static final Supplier> WARDEN_ENTITY_SENSOR = create("warden_entity_sensor", WardenEntitySensor::new); - public static final Supplier> FROG_TEMPTATIONS = create("frog_temptations", () -> new TemptingSensor(FrogBrain.getTemptItems())); - public static final Supplier> FROG_ATTACKABLES = create("frog_attackables", FrogAttackablesSensor::new); - public static final Supplier> IS_IN_WATER = create("is_in_water", IsInWaterSensor::new); + public static final Supplier> WARDEN_ENTITY_SENSOR + = create("warden_entity_sensor", WardenEntitySensor::new); + public static final Supplier> FROG_TEMPTATIONS + = create("frog_temptations", () -> new TemptingSensor(FrogBrain.getTemptItems())); + public static final Supplier> FROG_ATTACKABLES + = create("frog_attackables", FrogAttackablesSensor::new); + public static final Supplier> IS_IN_WATER + = create("is_in_water", IsInWaterSensor::new); - private static > Supplier> create(String key, Supplier sensor) { + private static > Supplier> + create(String key, Supplier sensor) { return SENSORS.register(key, () -> SensorTypeAccessor.createSensorType(sensor)); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/RootPlacerType.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/RootPlacerType.java index 3e9dd5b..bc32b8d 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/RootPlacerType.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/RootPlacerType.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.registry.worldgen; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.common.registry.WBRegistries; import com.cursedcauldron.wildbackport.common.worldgen.placers.MangroveRootPlacer; @@ -7,13 +9,14 @@ import com.cursedcauldron.wildbackport.common.worldgen.placers.RootPlacer; import com.cursedcauldron.wildbackport.core.api.CoreRegistry; import com.mojang.serialization.Codec; -import java.util.function.Supplier; - public class RootPlacerType

{ - public static final CoreRegistry> PLACERS = CoreRegistry.create(WBRegistries.ROOT_PLACER_TYPES.registry(), "minecraft"); - - public static final Supplier> MANGROVE_ROOT_PLACER = PLACERS.register("mangrove_root_placer", () -> new RootPlacerType<>(MangroveRootPlacer.CODEC)); + public static final CoreRegistry> PLACERS + = CoreRegistry.create(WBRegistries.ROOT_PLACER_TYPES.registry(), "minecraft"); + public static final Supplier> MANGROVE_ROOT_PLACER + = PLACERS.register( + "mangrove_root_placer", () -> new RootPlacerType<>(MangroveRootPlacer.CODEC) + ); private final Codec

codec; diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBFeatures.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBFeatures.java index fdc8c1d..cdeb3bf 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBFeatures.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBFeatures.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.registry.worldgen; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.common.worldgen.features.GrassDiskConfiguration; import com.cursedcauldron.wildbackport.common.worldgen.features.GrassDiskFeature; @@ -13,15 +15,25 @@ import net.minecraft.core.Registry; import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.configurations.GlowLichenConfiguration; -import java.util.function.Supplier; - //<> public class WBFeatures { - public static final CoreRegistry> FEATURES = CoreRegistry.create(Registry.FEATURE, "minecraft"); + public static final CoreRegistry> FEATURES + = CoreRegistry.create(Registry.FEATURE, "minecraft"); - public static final Supplier> TREE = FEATURES.register("rooted_tree", () -> new RootedTreeFeature(RootedTreeConfig.CODEC)); - public static final Supplier> DISK = FEATURES.register("grass_disk", () -> new GrassDiskFeature(GrassDiskConfiguration.CODEC)); - public static final Supplier> SCULK_PATCH = FEATURES.register("sculk_patch", () -> new SculkPatchFeature(SculkPatchConfiguration.CODEC)); - public static final Supplier> SCULK_GROWTH = FEATURES.register("sculk_growth", () -> new SculkGrowthFeature(GlowLichenConfiguration.CODEC)); + public static final Supplier> TREE = FEATURES.register( + "rooted_tree", () -> new RootedTreeFeature(RootedTreeConfig.CODEC) + ); + public static final Supplier> DISK + = FEATURES.register( + "grass_disk", () -> new GrassDiskFeature(GrassDiskConfiguration.CODEC) + ); + public static final Supplier> SCULK_PATCH + = FEATURES.register( + "sculk_patch", () -> new SculkPatchFeature(SculkPatchConfiguration.CODEC) + ); + public static final Supplier> SCULK_GROWTH + = FEATURES.register( + "sculk_growth", () -> new SculkGrowthFeature(GlowLichenConfiguration.CODEC) + ); } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBStructures.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBStructures.java index c1a3d01..b739239 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBStructures.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBStructures.java @@ -11,9 +11,18 @@ import net.minecraft.world.level.levelgen.feature.StructureFeature; import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; public class WBStructures { -// public static final Holder> ANCIENT_CITY = create("ancient_city", ) + // public static final Holder> ANCIENT_CITY = + // create("ancient_city", ) - private static > Holder> create(String key, ConfiguredStructureFeature feature) { - return BuiltinRegistries.register(BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE, ResourceKey.create(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY, new ResourceLocation(key)), feature); + private static > + Holder> + create(String key, ConfiguredStructureFeature feature) { + return BuiltinRegistries.register( + BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE, + ResourceKey.create( + Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY, new ResourceLocation(key) + ), + feature + ); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBTreeDecorators.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBTreeDecorators.java index 98fb0e2..1af3920 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBTreeDecorators.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBTreeDecorators.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.registry.worldgen; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.common.worldgen.decorator.AttachedToLeavesDecorator; import com.cursedcauldron.wildbackport.common.worldgen.decorator.WeightedLeaveVineDecorator; @@ -11,13 +13,26 @@ import net.minecraft.core.Registry; import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType; import net.minecraft.world.level.levelgen.feature.trunkplacers.TrunkPlacerType; -import java.util.function.Supplier; - //<> public class WBTreeDecorators { - public static final CoreRegistry> DECORATORS = CoreRegistry.create(Registry.TREE_DECORATOR_TYPES, "minecraft"); + public static final CoreRegistry> DECORATORS + = CoreRegistry.create(Registry.TREE_DECORATOR_TYPES, "minecraft"); - public static final Supplier> WEIGHTED_LEAVE_VINE = DECORATORS.register("weighted_leave_vine", () -> TreeDecoratorTypeAccessor.createTreeDecoratorType(WeightedLeaveVineDecorator.CODEC)); - public static final Supplier> ATTACHED_TO_LEAVES = DECORATORS.register("attached_to_leaves", () -> TreeDecoratorTypeAccessor.createTreeDecoratorType(AttachedToLeavesDecorator.CODEC)); + public static final Supplier> + WEIGHTED_LEAVE_VINE = DECORATORS.register( + "weighted_leave_vine", + () + -> TreeDecoratorTypeAccessor.createTreeDecoratorType( + WeightedLeaveVineDecorator.CODEC + ) + ); + public static final Supplier> + ATTACHED_TO_LEAVES = DECORATORS.register( + "attached_to_leaves", + () + -> TreeDecoratorTypeAccessor.createTreeDecoratorType( + AttachedToLeavesDecorator.CODEC + ) + ); } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBTrunkPlacers.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBTrunkPlacers.java index a4748b6..85a7d4b 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBTrunkPlacers.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBTrunkPlacers.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.registry.worldgen; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.common.worldgen.placers.UpwardBranchingTrunk; import com.cursedcauldron.wildbackport.core.api.CoreRegistry; @@ -7,12 +9,16 @@ import com.cursedcauldron.wildbackport.core.mixin.access.TrunkPlacerTypeAccessor import net.minecraft.core.Registry; import net.minecraft.world.level.levelgen.feature.trunkplacers.TrunkPlacerType; -import java.util.function.Supplier; - //<> public class WBTrunkPlacers { - public static final CoreRegistry> PLACERS = CoreRegistry.create(Registry.TRUNK_PLACER_TYPES, "minecraft"); + public static final CoreRegistry> PLACERS + = CoreRegistry.create(Registry.TRUNK_PLACER_TYPES, "minecraft"); - public static final Supplier> UPWARDS_BRANCHING_TRUNK = PLACERS.register("upward_branching_trunk", () -> TrunkPlacerTypeAccessor.createTrunkPlacerType(UpwardBranchingTrunk.CODEC)); + public static final Supplier> + UPWARDS_BRANCHING_TRUNK = PLACERS.register( + "upward_branching_trunk", + ( + ) -> TrunkPlacerTypeAccessor.createTrunkPlacerType(UpwardBranchingTrunk.CODEC) + ); } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBWorldGeneration.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBWorldGeneration.java index 5e254ff..a45d004 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBWorldGeneration.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/registry/worldgen/WBWorldGeneration.java @@ -1,13 +1,16 @@ package com.cursedcauldron.wildbackport.common.registry.worldgen; +import java.util.List; +import java.util.Optional; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.common.blocks.MangrovePropaguleBlock; import com.cursedcauldron.wildbackport.common.registry.WBBlocks; import com.cursedcauldron.wildbackport.common.tag.WBBlockTags; import com.cursedcauldron.wildbackport.common.worldgen.PredicatedStateProvider; import com.cursedcauldron.wildbackport.common.worldgen.WorldGenerator; -import com.cursedcauldron.wildbackport.common.worldgen.decorator.AttachedToLeavesDecorator; import com.cursedcauldron.wildbackport.common.worldgen.decorator.AboveRootPlacement; +import com.cursedcauldron.wildbackport.common.worldgen.decorator.AttachedToLeavesDecorator; import com.cursedcauldron.wildbackport.common.worldgen.decorator.MangroveRootPlacement; import com.cursedcauldron.wildbackport.common.worldgen.decorator.WeightedLeaveVineDecorator; import com.cursedcauldron.wildbackport.common.worldgen.features.GrassDiskConfiguration; @@ -49,9 +52,6 @@ import net.minecraft.world.level.levelgen.placement.RandomOffsetPlacement; import net.minecraft.world.level.levelgen.placement.SurfaceWaterDepthFilter; import net.minecraft.world.level.material.Fluids; -import java.util.List; -import java.util.Optional; - //<> public class WBWorldGeneration { @@ -60,52 +60,282 @@ public class WBWorldGeneration { } // Mangrove Swamp - public static final Holder> MANGROVE = create("mangrove", WBFeatures.TREE.get(), new RootedTreeConfig.Builder( - BlockStateProvider.simple(WBBlocks.MANGROVE_LOG.get()), - new UpwardBranchingTrunk(2, 1, 4, UniformInt.of(1, 4), 0.5F, UniformInt.of(0, 1), Registry.BLOCK.getOrCreateTag(WBBlockTags.MANGROVE_LOGS_CAN_GROW_THROUGH)), - BlockStateProvider.simple(WBBlocks.MANGROVE_LEAVES.get()), - new RandomSpreadFoliagePlacer(ConstantInt.of(3), ConstantInt.of(0), ConstantInt.of(2), 70), - Optional.of(new MangroveRootPlacer(UniformInt.of(1, 3), BlockStateProvider.simple(WBBlocks.MANGROVE_ROOTS.get()), Optional.of(new AboveRootPlacement(BlockStateProvider.simple(Blocks.MOSS_CARPET), 0.5F)), new MangroveRootPlacement(Registry.BLOCK.getOrCreateTag(WBBlockTags.MANGROVE_ROOTS_CAN_GROW_THROUGH), HolderSet.direct(Block::builtInRegistryHolder, WBBlocks.MUD.get(), WBBlocks.MUDDY_MANGROVE_ROOTS.get()), BlockStateProvider.simple(WBBlocks.MUDDY_MANGROVE_ROOTS.get()), 8, 15, 0.2F))), - new TwoLayersFeatureSize(2, 0, 2) - ).decorators(List.of( - new WeightedLeaveVineDecorator(0.125F), - new AttachedToLeavesDecorator(0.14F, 1, 0, new RandomizedIntStateProvider(BlockStateProvider.simple(WBBlocks.MANGROVE_PROPAGULE.get().defaultBlockState().setValue(MangrovePropaguleBlock.HANGING, true)), MangrovePropaguleBlock.AGE, UniformInt.of(0, 4)), 2, List.of(Direction.DOWN)), - new BeehiveDecorator(0.01F) - )).ignoreVines().build()); - public static final Holder> TALL_MANGROVE = create("tall_mangrove", WBFeatures.TREE.get(), new RootedTreeConfig.Builder( - BlockStateProvider.simple(WBBlocks.MANGROVE_LOG.get()), - new UpwardBranchingTrunk(4, 1, 9, UniformInt.of(1, 6), 0.5F, UniformInt.of(0, 1), Registry.BLOCK.getOrCreateTag(WBBlockTags.MANGROVE_LOGS_CAN_GROW_THROUGH)), - BlockStateProvider.simple(WBBlocks.MANGROVE_LEAVES.get()), - new RandomSpreadFoliagePlacer(ConstantInt.of(3), ConstantInt.of(0), ConstantInt.of(2), 70), - Optional.of(new MangroveRootPlacer(UniformInt.of(3, 7), BlockStateProvider.simple(WBBlocks.MANGROVE_ROOTS.get()), Optional.of(new AboveRootPlacement(BlockStateProvider.simple(Blocks.MOSS_CARPET), 0.5F)), new MangroveRootPlacement(Registry.BLOCK.getOrCreateTag(WBBlockTags.MANGROVE_ROOTS_CAN_GROW_THROUGH), HolderSet.direct(Block::builtInRegistryHolder, WBBlocks.MUD.get(), WBBlocks.MUDDY_MANGROVE_ROOTS.get()), BlockStateProvider.simple(WBBlocks.MUDDY_MANGROVE_ROOTS.get()), 8, 15, 0.2F))), - new TwoLayersFeatureSize(3, 0, 2) - ).decorators(List.of( - new WeightedLeaveVineDecorator(0.125F), - new AttachedToLeavesDecorator(0.14F, 1, 0, new RandomizedIntStateProvider(BlockStateProvider.simple(WBBlocks.MANGROVE_PROPAGULE.get().defaultBlockState().setValue(MangrovePropaguleBlock.HANGING, true)), MangrovePropaguleBlock.AGE, UniformInt.of(0, 4)), 2, List.of(Direction.DOWN)), - new BeehiveDecorator(0.01F) - )).ignoreVines().build()); - public static final Holder MANGROVE_CHECKED = create("mangrove_checked", MANGROVE, PlacementUtils.filteredByBlockSurvival(WBBlocks.MANGROVE_PROPAGULE.get())); - public static final Holder TALL_MANGROVE_CHECKED = create("tall_mangrove_checked", TALL_MANGROVE, PlacementUtils.filteredByBlockSurvival(WBBlocks.MANGROVE_PROPAGULE.get())); - public static final Holder> MANGROVE_VEGETATION = create("mangrove_vegetation", Feature.RANDOM_SELECTOR, new RandomFeatureConfiguration(List.of(new WeightedPlacedFeature(TALL_MANGROVE_CHECKED, 0.85F)), MANGROVE_CHECKED)); - public static final Holder TREES_MANGROVE_PLACED = create("trees_mangrove", MANGROVE_VEGETATION, CountPlacement.of(25), InSquarePlacement.spread(), SurfaceWaterDepthFilter.forMaxDepth(5), PlacementUtils.HEIGHTMAP_OCEAN_FLOOR, BiomeFilter.biome(), BlockPredicateFilter.forPredicate(BlockPredicate.wouldSurvive(WBBlocks.MANGROVE_PROPAGULE.get().defaultBlockState(), BlockPos.ZERO))); - public static final Holder> DISK_GRASS = create("disk_grass", WBFeatures.DISK.get(), new GrassDiskConfiguration(new PredicatedStateProvider(BlockStateProvider.simple(Blocks.DIRT), List.of(new PredicatedStateProvider.Rule(BlockPredicate.not(BlockPredicate.allOf(BlockPredicate.solid(Direction.UP.getNormal()), BlockPredicate.matchesFluid(Fluids.WATER, Direction.UP.getNormal()))), BlockStateProvider.simple(Blocks.GRASS_BLOCK)))), BlockPredicate.matchesBlocks(List.of(Blocks.DIRT, WBBlocks.MUD.get())), UniformInt.of(2, 6), 2)); - public static final Holder DISK_GRASS_PLACED = create("disk_grass", DISK_GRASS, CountPlacement.of(1), InSquarePlacement.spread(), PlacementUtils.HEIGHTMAP_TOP_SOLID, RandomOffsetPlacement.vertical(ConstantInt.of(-1)), BlockPredicateFilter.forPredicate(BlockPredicate.matchesBlock(WBBlocks.MUD.get(), Vec3i.ZERO)), BiomeFilter.biome()); + public static final Holder> MANGROVE = create( + "mangrove", + WBFeatures.TREE.get(), + new RootedTreeConfig + .Builder( + BlockStateProvider.simple(WBBlocks.MANGROVE_LOG.get()), + new UpwardBranchingTrunk( + 2, + 1, + 4, + UniformInt.of(1, 4), + 0.5F, + UniformInt.of(0, 1), + Registry.BLOCK.getOrCreateTag( + WBBlockTags.MANGROVE_LOGS_CAN_GROW_THROUGH + ) + ), + BlockStateProvider.simple(WBBlocks.MANGROVE_LEAVES.get()), + new RandomSpreadFoliagePlacer( + ConstantInt.of(3), ConstantInt.of(0), ConstantInt.of(2), 70 + ), + Optional.of(new MangroveRootPlacer( + UniformInt.of(1, 3), + BlockStateProvider.simple(WBBlocks.MANGROVE_ROOTS.get()), + Optional.of(new AboveRootPlacement( + BlockStateProvider.simple(Blocks.MOSS_CARPET), 0.5F + )), + new MangroveRootPlacement( + Registry.BLOCK + .getOrCreateTag(WBBlockTags.MANGROVE_ROOTS_CAN_GROW_THROUGH), + HolderSet.direct( + Block::builtInRegistryHolder, + WBBlocks.MUD.get(), + WBBlocks.MUDDY_MANGROVE_ROOTS.get() + ), + BlockStateProvider.simple(WBBlocks.MUDDY_MANGROVE_ROOTS.get()), + 8, + 15, + 0.2F + ) + )), + new TwoLayersFeatureSize(2, 0, 2) + ) + .decorators(List.of( + new WeightedLeaveVineDecorator(0.125F), + new AttachedToLeavesDecorator( + 0.14F, + 1, + 0, + new RandomizedIntStateProvider( + BlockStateProvider + .simple(WBBlocks.MANGROVE_PROPAGULE.get() + .defaultBlockState() + .setValue(MangrovePropaguleBlock.HANGING, true)), + MangrovePropaguleBlock.AGE, + UniformInt.of(0, 4) + ), + 2, + List.of(Direction.DOWN) + ), + new BeehiveDecorator(0.01F) + )) + .ignoreVines() + .build() + ); + public static final Holder> TALL_MANGROVE + = create( + "tall_mangrove", + WBFeatures.TREE.get(), + new RootedTreeConfig + .Builder( + BlockStateProvider.simple(WBBlocks.MANGROVE_LOG.get()), + new UpwardBranchingTrunk( + 4, + 1, + 9, + UniformInt.of(1, 6), + 0.5F, + UniformInt.of(0, 1), + Registry.BLOCK.getOrCreateTag( + WBBlockTags.MANGROVE_LOGS_CAN_GROW_THROUGH + ) + ), + BlockStateProvider.simple(WBBlocks.MANGROVE_LEAVES.get()), + new RandomSpreadFoliagePlacer( + ConstantInt.of(3), ConstantInt.of(0), ConstantInt.of(2), 70 + ), + Optional.of(new MangroveRootPlacer( + UniformInt.of(3, 7), + BlockStateProvider.simple(WBBlocks.MANGROVE_ROOTS.get()), + Optional.of(new AboveRootPlacement( + BlockStateProvider.simple(Blocks.MOSS_CARPET), 0.5F + )), + new MangroveRootPlacement( + Registry.BLOCK.getOrCreateTag( + WBBlockTags.MANGROVE_ROOTS_CAN_GROW_THROUGH + ), + HolderSet.direct( + Block::builtInRegistryHolder, + WBBlocks.MUD.get(), + WBBlocks.MUDDY_MANGROVE_ROOTS.get() + ), + BlockStateProvider.simple(WBBlocks.MUDDY_MANGROVE_ROOTS.get() + ), + 8, + 15, + 0.2F + ) + )), + new TwoLayersFeatureSize(3, 0, 2) + ) + .decorators(List.of( + new WeightedLeaveVineDecorator(0.125F), + new AttachedToLeavesDecorator( + 0.14F, + 1, + 0, + new RandomizedIntStateProvider( + BlockStateProvider.simple( + WBBlocks.MANGROVE_PROPAGULE.get() + .defaultBlockState() + .setValue(MangrovePropaguleBlock.HANGING, true) + ), + MangrovePropaguleBlock.AGE, + UniformInt.of(0, 4) + ), + 2, + List.of(Direction.DOWN) + ), + new BeehiveDecorator(0.01F) + )) + .ignoreVines() + .build() + ); + public static final Holder MANGROVE_CHECKED = create( + "mangrove_checked", + MANGROVE, + PlacementUtils.filteredByBlockSurvival(WBBlocks.MANGROVE_PROPAGULE.get()) + ); + public static final Holder TALL_MANGROVE_CHECKED = create( + "tall_mangrove_checked", + TALL_MANGROVE, + PlacementUtils.filteredByBlockSurvival(WBBlocks.MANGROVE_PROPAGULE.get()) + ); + public static final Holder> + MANGROVE_VEGETATION = create( + "mangrove_vegetation", + Feature.RANDOM_SELECTOR, + new RandomFeatureConfiguration( + List.of(new WeightedPlacedFeature(TALL_MANGROVE_CHECKED, 0.85F)), + MANGROVE_CHECKED + ) + ); + public static final Holder TREES_MANGROVE_PLACED = create( + "trees_mangrove", + MANGROVE_VEGETATION, + CountPlacement.of(25), + InSquarePlacement.spread(), + SurfaceWaterDepthFilter.forMaxDepth(5), + PlacementUtils.HEIGHTMAP_OCEAN_FLOOR, + BiomeFilter.biome(), + BlockPredicateFilter.forPredicate(BlockPredicate.wouldSurvive( + WBBlocks.MANGROVE_PROPAGULE.get().defaultBlockState(), BlockPos.ZERO + )) + ); + public static final Holder> DISK_GRASS + = create( + "disk_grass", + WBFeatures.DISK.get(), + new GrassDiskConfiguration( + new PredicatedStateProvider( + BlockStateProvider.simple(Blocks.DIRT), + List.of(new PredicatedStateProvider.Rule( + BlockPredicate.not(BlockPredicate.allOf( + BlockPredicate.solid(Direction.UP.getNormal()), + BlockPredicate + .matchesFluid(Fluids.WATER, Direction.UP.getNormal()) + )), + BlockStateProvider.simple(Blocks.GRASS_BLOCK) + )) + ), + BlockPredicate.matchesBlocks(List.of(Blocks.DIRT, WBBlocks.MUD.get())), + UniformInt.of(2, 6), + 2 + ) + ); + public static final Holder DISK_GRASS_PLACED = create( + "disk_grass", + DISK_GRASS, + CountPlacement.of(1), + InSquarePlacement.spread(), + PlacementUtils.HEIGHTMAP_TOP_SOLID, + RandomOffsetPlacement.vertical(ConstantInt.of(-1)), + BlockPredicateFilter.forPredicate( + BlockPredicate.matchesBlock(WBBlocks.MUD.get(), Vec3i.ZERO) + ), + BiomeFilter.biome() + ); // Deep Dark - public static final Holder> SCULK_PATCH_DEEP_DARK = create("sculk_patch_deep_dark", WBFeatures.SCULK_PATCH.get(), new SculkPatchConfiguration(10, 32, 64, 0, 1, ConstantInt.of(0), 0.5F)); - public static final Holder SCULK_PATCH_DEEP_DARK_PLACED = create("sculk_patch_deep_dark", SCULK_PATCH_DEEP_DARK, CountPlacement.of(ConstantInt.of(256)), InSquarePlacement.spread(), PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT, BiomeFilter.biome()); - public static final Holder> SCULK_PATCH_ANCIENT_CITY = create("sculk_patch_ancient_city", WBFeatures.SCULK_PATCH.get(), new SculkPatchConfiguration(10, 32, 64, 0, 1, UniformInt.of(1, 3), 0.5F)); - public static final Holder SCULK_PATCH_ANCIENT_CITY_PLACED = create("sculk_patch_ancient_city", SCULK_PATCH_ANCIENT_CITY); - public static final Holder> SCULK_VEIN = create("sculk_vein", WBFeatures.SCULK_GROWTH.get(), new GlowLichenConfiguration(20, true, true, true, 1.0F, HolderSet.direct(Block::builtInRegistryHolder, Blocks.STONE, Blocks.ANDESITE, Blocks.DIORITE, Blocks.GRANITE, Blocks.DRIPSTONE_BLOCK, Blocks.CALCITE, Blocks.TUFF, Blocks.DEEPSLATE))); - public static final Holder SCULK_VEIN_PLACED = create("sculk_vein", SCULK_VEIN, CountPlacement.of(UniformInt.of(204, 250)), InSquarePlacement.spread(), PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT, BiomeFilter.biome()); + public static final Holder> + SCULK_PATCH_DEEP_DARK = create( + "sculk_patch_deep_dark", + WBFeatures.SCULK_PATCH.get(), + new SculkPatchConfiguration(10, 32, 64, 0, 1, ConstantInt.of(0), 0.5F) + ); + public static final Holder SCULK_PATCH_DEEP_DARK_PLACED = create( + "sculk_patch_deep_dark", + SCULK_PATCH_DEEP_DARK, + CountPlacement.of(ConstantInt.of(256)), + InSquarePlacement.spread(), + PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT, + BiomeFilter.biome() + ); + public static final Holder> + SCULK_PATCH_ANCIENT_CITY = create( + "sculk_patch_ancient_city", + WBFeatures.SCULK_PATCH.get(), + new SculkPatchConfiguration(10, 32, 64, 0, 1, UniformInt.of(1, 3), 0.5F) + ); + public static final Holder SCULK_PATCH_ANCIENT_CITY_PLACED + = create("sculk_patch_ancient_city", SCULK_PATCH_ANCIENT_CITY); + public static final Holder> SCULK_VEIN + = create( + "sculk_vein", + WBFeatures.SCULK_GROWTH.get(), + new GlowLichenConfiguration( + 20, + true, + true, + true, + 1.0F, + HolderSet.direct( + Block::builtInRegistryHolder, + Blocks.STONE, + Blocks.ANDESITE, + Blocks.DIORITE, + Blocks.GRANITE, + Blocks.DRIPSTONE_BLOCK, + Blocks.CALCITE, + Blocks.TUFF, + Blocks.DEEPSLATE + ) + ) + ); + public static final Holder SCULK_VEIN_PLACED = create( + "sculk_vein", + SCULK_VEIN, + CountPlacement.of(UniformInt.of(204, 250)), + InSquarePlacement.spread(), + PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT, + BiomeFilter.biome() + ); // Registry - public static > Holder> create(String key, F feature, FC configuration) { - return BuiltinRegistries.registerExact(BuiltinRegistries.CONFIGURED_FEATURE, "minecraft" + ":" + key, new ConfiguredFeature<>(feature, configuration)); + public static > + Holder> create(String key, F feature, FC configuration) { + return BuiltinRegistries.registerExact( + BuiltinRegistries.CONFIGURED_FEATURE, + "minecraft" + + ":" + key, + new ConfiguredFeature<>(feature, configuration) + ); } - public static Holder create(String key, Holder> feature, PlacementModifier... modifiers) { - return BuiltinRegistries.registerExact(BuiltinRegistries.PLACED_FEATURE, "minecraft" + ":" + key, new PlacedFeature(Holder.hackyErase(feature), List.copyOf(List.of(modifiers)))); + public static Holder create( + String key, + Holder> feature, + PlacementModifier... modifiers + ) { + return BuiltinRegistries.registerExact( + BuiltinRegistries.PLACED_FEATURE, + "minecraft" + + ":" + key, + new PlacedFeature(Holder.hackyErase(feature), List.copyOf(List.of(modifiers))) + ); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/InstrumentTags.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/InstrumentTags.java index 737153e..3e36c88 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/InstrumentTags.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/InstrumentTags.java @@ -7,9 +7,12 @@ import com.cursedcauldron.wildbackport.core.api.TagBuilder; import net.minecraft.tags.TagKey; public class InstrumentTags { - public static final TagBuilder TAGS = TagBuilder.create(WBRegistries.INSTRUMENT.registry(), "minecraft"); + public static final TagBuilder TAGS + = TagBuilder.create(WBRegistries.INSTRUMENT.registry(), "minecraft"); - public static final TagKey REGULAR_GOAT_HORNS = TAGS.create("regular_goat_horns"); - public static final TagKey SCREAMING_GOAT_HORNS = TAGS.create("screaming_goat_horns"); + public static final TagKey REGULAR_GOAT_HORNS + = TAGS.create("regular_goat_horns"); + public static final TagKey SCREAMING_GOAT_HORNS + = TAGS.create("screaming_goat_horns"); public static final TagKey GOAT_HORNS = TAGS.create("goat_horns"); } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/WBBiomeTags.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/WBBiomeTags.java index bc07603..457a7bf 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/WBBiomeTags.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/WBBiomeTags.java @@ -7,10 +7,15 @@ import net.minecraft.tags.TagKey; import net.minecraft.world.level.biome.Biome; public class WBBiomeTags { - public static final TagBuilder TAGS = TagBuilder.create(BuiltinRegistries.BIOME, "minecraft"); + public static final TagBuilder TAGS + = TagBuilder.create(BuiltinRegistries.BIOME, "minecraft"); - public static final TagKey SPAWNS_WARM_VARIANT_FROGS = TAGS.create("spawns_warm_variant_frogs"); - public static final TagKey SPAWNS_COLD_VARIANT_FROGS = TAGS.create("spawns_cold_variant_frogs"); - public static final TagKey ALLOWS_SURFACE_SLIME_SPAWNS = TAGS.create("allows_surface_slime_spawns"); - public static final TagKey HAS_ANCIENT_CITY = TAGS.create("has_structure/ancient_city"); + public static final TagKey SPAWNS_WARM_VARIANT_FROGS + = TAGS.create("spawns_warm_variant_frogs"); + public static final TagKey SPAWNS_COLD_VARIANT_FROGS + = TAGS.create("spawns_cold_variant_frogs"); + public static final TagKey ALLOWS_SURFACE_SLIME_SPAWNS + = TAGS.create("allows_surface_slime_spawns"); + public static final TagKey HAS_ANCIENT_CITY + = TAGS.create("has_structure/ancient_city"); } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/WBBlockTags.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/WBBlockTags.java index 1004a0d..abe8cbf 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/WBBlockTags.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/WBBlockTags.java @@ -7,19 +7,28 @@ import net.minecraft.tags.TagKey; import net.minecraft.world.level.block.Block; public class WBBlockTags { - public static final TagBuilder BUILDER = TagBuilder.create(Registry.BLOCK, "minecraft"); + public static final TagBuilder BUILDER + = TagBuilder.create(Registry.BLOCK, "minecraft"); // Mangrove Swamp - public static final TagKey CONVERTABLE_TO_MUD = BUILDER.create("convertable_to_mud"); - public static final TagKey FROG_PREFER_JUMP_TO = BUILDER.create("frog_prefer_jump_to"); - public static final TagKey FROGS_SPAWNABLE_ON = BUILDER.create("frogs_spawnable_on"); - public static final TagKey MANGROVE_LOGS_CAN_GROW_THROUGH = BUILDER.create("mangrove_logs_can_grow_through"); - public static final TagKey MANGROVE_ROOTS_CAN_GROW_THROUGH = BUILDER.create("mangrove_roots_can_grow_through"); + public static final TagKey CONVERTABLE_TO_MUD + = BUILDER.create("convertable_to_mud"); + public static final TagKey FROG_PREFER_JUMP_TO + = BUILDER.create("frog_prefer_jump_to"); + public static final TagKey FROGS_SPAWNABLE_ON + = BUILDER.create("frogs_spawnable_on"); + public static final TagKey MANGROVE_LOGS_CAN_GROW_THROUGH + = BUILDER.create("mangrove_logs_can_grow_through"); + public static final TagKey MANGROVE_ROOTS_CAN_GROW_THROUGH + = BUILDER.create("mangrove_roots_can_grow_through"); // Deep Dark - public static final TagKey SCULK_REPLACEABLE = BUILDER.create("sculk_replaceable"); - public static final TagKey SCULK_REPLACEABLE_WORLD_GEN = BUILDER.create("sculk_replaceable_world_gen"); - public static final TagKey ANCIENT_CITY_REPLACEABLE = BUILDER.create("ancient_city_replaceable"); + public static final TagKey SCULK_REPLACEABLE + = BUILDER.create("sculk_replaceable"); + public static final TagKey SCULK_REPLACEABLE_WORLD_GEN + = BUILDER.create("sculk_replaceable_world_gen"); + public static final TagKey ANCIENT_CITY_REPLACEABLE + = BUILDER.create("ancient_city_replaceable"); // Compatibility public static final TagKey MUD = BUILDER.create("mud"); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/WBEntityTypeTags.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/WBEntityTypeTags.java index f51a231..24543a9 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/WBEntityTypeTags.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/WBEntityTypeTags.java @@ -7,7 +7,8 @@ import net.minecraft.tags.TagKey; import net.minecraft.world.entity.EntityType; public class WBEntityTypeTags { - public static final TagBuilder> TAGS = TagBuilder.create(Registry.ENTITY_TYPE, "minecraft"); + public static final TagBuilder> TAGS + = TagBuilder.create(Registry.ENTITY_TYPE, "minecraft"); public static final TagKey> FROG_FOOD = TAGS.create("frog_food"); } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/WBGameEventTags.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/WBGameEventTags.java index 87ad461..149c3e1 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/WBGameEventTags.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/WBGameEventTags.java @@ -7,9 +7,13 @@ import net.minecraft.tags.TagKey; import net.minecraft.world.level.gameevent.GameEvent; public class WBGameEventTags { - public static final TagBuilder TAGS = TagBuilder.create(Registry.GAME_EVENT, "minecraft"); + public static final TagBuilder TAGS + = TagBuilder.create(Registry.GAME_EVENT, "minecraft"); - public static final TagKey SHRIEKER_CAN_LISTEN = TAGS.create("shrieker_can_listen"); - public static final TagKey WARDEN_CAN_LISTEN = TAGS.create("warden_can_listen"); - public static final TagKey ALLAY_CAN_LISTEN = TAGS.create("allay_can_listen"); + public static final TagKey SHRIEKER_CAN_LISTEN + = TAGS.create("shrieker_can_listen"); + public static final TagKey WARDEN_CAN_LISTEN + = TAGS.create("warden_can_listen"); + public static final TagKey ALLAY_CAN_LISTEN + = TAGS.create("allay_can_listen"); } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/WBItemTags.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/WBItemTags.java index 1f0b5e8..5ce66a0 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/WBItemTags.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/tag/WBItemTags.java @@ -7,8 +7,9 @@ import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; public class WBItemTags { - public static final TagBuilder TAGS = TagBuilder.create(Registry.ITEM, "minecraft"); + public static final TagBuilder TAGS + = TagBuilder.create(Registry.ITEM, "minecraft"); - public static final TagKey CHEST_BOATS = TAGS.create("chest_boats"); - public static final TagKey MANGROVE_LOGS = TAGS.create("mangrove_logs"); + public static final TagKey CHEST_BOATS = TAGS.create("chest_boats"); + public static final TagKey MANGROVE_LOGS = TAGS.create("mangrove_logs"); } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/utils/DirectionUtils.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/utils/DirectionUtils.java index bd221b9..e4bb243 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/utils/DirectionUtils.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/utils/DirectionUtils.java @@ -1,7 +1,5 @@ package com.cursedcauldron.wildbackport.common.utils; -import net.minecraft.core.Direction; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -11,9 +9,12 @@ import java.util.Random; import java.util.stream.Collectors; import java.util.stream.Stream; +import net.minecraft.core.Direction; + public class DirectionUtils { public static Collection shuffle(Random random) { - List directions = Arrays.stream(Direction.values()).collect(Collectors.toList()); + List directions + = Arrays.stream(Direction.values()).collect(Collectors.toList()); Collections.shuffle(directions, random); return directions; } @@ -25,7 +26,7 @@ public class DirectionUtils { public static Collection unpack(byte faces) { ArrayList directions = new ArrayList<>(6); for (Direction direction : Direction.values()) { - if ((faces & (byte)(2 << direction.ordinal() >> 1)) > 0) { + if ((faces & (byte) (2 << direction.ordinal() >> 1)) > 0) { directions.add(direction); } } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/utils/MathUtils.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/utils/MathUtils.java index 43661b7..688fb7a 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/utils/MathUtils.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/utils/MathUtils.java @@ -1,7 +1,13 @@ package com.cursedcauldron.wildbackport.common.utils; public class MathUtils { - public static float catmullrom(float delta, float startPoint, float start, float end, float endPoint) { - return 0.5F * (2.0F * start + (end - startPoint) * delta + (2.0F * startPoint - 5.0F * start + 4.0F * end - endPoint) * delta * delta + (3.0F * start - startPoint - 3.0F * end + endPoint) * delta * delta * delta); + public static float + catmullrom(float delta, float startPoint, float start, float end, float endPoint) { + return 0.5F + * (2.0F * start + (end - startPoint) * delta + + (2.0F * startPoint - 5.0F * start + 4.0F * end - endPoint) * delta + * delta + + (3.0F * start - startPoint - 3.0F * end + endPoint) * delta * delta + * delta); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/utils/MobUtils.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/utils/MobUtils.java index 45f9d50..02615fc 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/utils/MobUtils.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/utils/MobUtils.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.utils; +import java.util.List; + import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.effect.MobEffect; @@ -14,24 +16,45 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.Nullable; -import java.util.List; - public class MobUtils { - public static void addEffectToPlayersWithinDistance(ServerLevel level, @Nullable Entity entity, Vec3 position, double distance, MobEffectInstance instance, int duration) { + public static void addEffectToPlayersWithinDistance( + ServerLevel level, + @Nullable Entity entity, + Vec3 position, + double distance, + MobEffectInstance instance, + int duration + ) { MobEffect mobeffect = instance.getEffect(); - List players = level.getPlayers(player -> player.gameMode.isSurvival() && (entity == null || !entity.isAlliedTo(player)) && position.closerThan(player.position(), distance) && (!player.hasEffect(mobeffect) || player.getEffect(mobeffect).getAmplifier() < instance.getAmplifier() || player.getEffect(mobeffect).getDuration() < duration)); - players.forEach(player -> player.addEffect(new MobEffectInstance(instance), entity)); + List players = level.getPlayers( + player + -> player.gameMode.isSurvival() + && (entity == null || !entity.isAlliedTo(player)) + && position.closerThan(player.position(), distance) + && (!player.hasEffect(mobeffect) + || player.getEffect(mobeffect).getAmplifier() + < instance.getAmplifier() + || player.getEffect(mobeffect).getDuration() < duration) + ); + players.forEach( + player -> player.addEffect(new MobEffectInstance(instance), entity) + ); } - public static void walkTowards(LivingEntity entity, PositionTracker target, float speed, int closeEnough) { + public static void walkTowards( + LivingEntity entity, PositionTracker target, float speed, int closeEnough + ) { WalkTarget walkTarget = new WalkTarget(target, speed, closeEnough); entity.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, target); entity.getBrain().setMemory(MemoryModuleType.WALK_TARGET, walkTarget); } - public static void give(LivingEntity entity, ItemStack stack, Vec3 target, Vec3 velocity, float yOffset) { - double y = entity.getEyeY() - (double)yOffset; - ItemEntity item = new ItemEntity(entity.level, entity.getX(), y, entity.getZ(), stack); + public static void give( + LivingEntity entity, ItemStack stack, Vec3 target, Vec3 velocity, float yOffset + ) { + double y = entity.getEyeY() - (double) yOffset; + ItemEntity item + = new ItemEntity(entity.level, entity.getX(), y, entity.getZ(), stack); item.setThrower(entity.getUUID()); Vec3 distance = target.subtract(entity.position()); distance = distance.normalize().multiply(velocity.x, velocity.y, velocity.z); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/utils/ModUtils.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/utils/ModUtils.java index 9e1dfe0..8f347ee 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/utils/ModUtils.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/utils/ModUtils.java @@ -1,10 +1,10 @@ package com.cursedcauldron.wildbackport.common.utils; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; - import java.util.List; import java.util.Random; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; + public class ModUtils { public static void shuffle(List entries, Random random) { int size = entries.size(); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/utils/ParticleUtils.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/utils/ParticleUtils.java index 56beee9..3b4b3c2 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/utils/ParticleUtils.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/utils/ParticleUtils.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.utils; +import java.util.function.Supplier; + import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.particles.ParticleOptions; @@ -9,28 +11,50 @@ import net.minecraft.util.valueproviders.IntProvider; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; -import java.util.function.Supplier; - public class ParticleUtils { - public static void spawnParticles(Level world, BlockPos pos, ParticleOptions effect, IntProvider count, Direction direction, Supplier velocity, double offset) { + public static void spawnParticles( + Level world, + BlockPos pos, + ParticleOptions effect, + IntProvider count, + Direction direction, + Supplier velocity, + double offset + ) { int sample = count.sample(world.getRandom()); for (int i = 0; i < sample; ++i) { spawnParticle(world, pos, direction, effect, velocity.get(), offset); } } - public static void spawnParticle(Level level, BlockPos pos, Direction direction, ParticleOptions effect, Vec3 velocity, double offset) { + public static void spawnParticle( + Level level, + BlockPos pos, + Direction direction, + ParticleOptions effect, + Vec3 velocity, + double offset + ) { Vec3 center = Vec3.atCenterOf(pos); int xStep = direction.getStepX(); int yStep = direction.getStepY(); int zStep = direction.getStepZ(); - double x = center.x + (xStep == 0 ? Mth.nextDouble(level.getRandom(), -0.5D, 0.5D) : (double)xStep * offset); - double y = center.y + (yStep == 0 ? Mth.nextDouble(level.getRandom(), -0.5D, 0.5D) : (double)yStep * offset); - double z = center.z + (zStep == 0 ? Mth.nextDouble(level.getRandom(), -0.5D, 0.5D) : (double)zStep * offset); + double x = center.x + + (xStep == 0 ? Mth.nextDouble(level.getRandom(), -0.5D, 0.5D) + : (double) xStep * offset); + double y = center.y + + (yStep == 0 ? Mth.nextDouble(level.getRandom(), -0.5D, 0.5D) + : (double) yStep * offset); + double z = center.z + + (zStep == 0 ? Mth.nextDouble(level.getRandom(), -0.5D, 0.5D) + : (double) zStep * offset); double xVelocity = xStep == 0 ? velocity.x() : 0.0D; double yVelocity = yStep == 0 ? velocity.y() : 0.0D; double zVelocity = zStep == 0 ? velocity.z() : 0.0D; ServerLevel server = level instanceof ServerLevel side ? side : null; - if (server != null) server.sendParticles(effect, x, y, z, 1, xVelocity, yVelocity, zVelocity, 0.0D); + if (server != null) + server.sendParticles( + effect, x, y, z, 1, xVelocity, yVelocity, zVelocity, 0.0D + ); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/utils/PositionUtils.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/utils/PositionUtils.java index 21aa135..4320099 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/utils/PositionUtils.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/utils/PositionUtils.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.utils; +import java.util.List; + import com.mojang.serialization.Codec; import net.minecraft.Util; import net.minecraft.core.BlockPos; @@ -7,16 +9,16 @@ import net.minecraft.core.Direction; import net.minecraft.core.Vec3i; import net.minecraft.world.phys.Vec3; -import java.util.List; - public class PositionUtils { - public static final Codec VEC_CODEC = Codec.DOUBLE.listOf().comapFlatMap(values -> { - return Util.fixedSize(values, 3).map(pos -> { - return new Vec3(pos.get(0), pos.get(1), pos.get(2)); - }); - }, pos -> { - return List.of(pos.x(), pos.y(), pos.z()); - }); + public static final Codec VEC_CODEC = Codec.DOUBLE.listOf().comapFlatMap( + values + -> { + return Util.fixedSize(values, 3).map(pos -> { + return new Vec3(pos.get(0), pos.get(1), pos.get(2)); + }); + }, + pos -> { return List.of(pos.x(), pos.y(), pos.z()); } + ); public static BlockPos toBlockPos(Vec3 pos) { return new BlockPos(pos.x, pos.y, pos.z); @@ -28,6 +30,10 @@ public class PositionUtils { public static Vec3 relative(Vec3 pos, Direction direction, double offset) { Vec3i normal = direction.getNormal(); - return new Vec3(pos.x + offset * (double)normal.getX(), pos.y + offset * (double)normal.getY(), pos.z + offset * (double)normal.getZ()); + return new Vec3( + pos.x + offset * (double) normal.getX(), + pos.y + offset * (double) normal.getY(), + pos.z + offset * (double) normal.getZ() + ); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/MangroveSwampSurface.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/MangroveSwampSurface.java index cc6d68f..b146bf9 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/MangroveSwampSurface.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/MangroveSwampSurface.java @@ -9,13 +9,49 @@ import net.minecraft.world.level.levelgen.SurfaceRules; import net.minecraft.world.level.levelgen.VerticalAnchor; public class MangroveSwampSurface { - public static final SurfaceRules.ConditionSource ABOVE_60 = SurfaceRules.yBlockCheck(VerticalAnchor.absolute(60), 0); - public static final SurfaceRules.ConditionSource ABOVE_63 = SurfaceRules.yBlockCheck(VerticalAnchor.absolute(63), 0); + public static final SurfaceRules.ConditionSource ABOVE_60 + = SurfaceRules.yBlockCheck(VerticalAnchor.absolute(60), 0); + public static final SurfaceRules.ConditionSource ABOVE_63 + = SurfaceRules.yBlockCheck(VerticalAnchor.absolute(63), 0); public static SurfaceRules.RuleSource makeRules() { - SurfaceRules.RuleSource terrain = SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.isBiome(WBBiomes.MANGROVE_SWAMP), makeStateRule(WBBlocks.MUD.get()))); - SurfaceRules.RuleSource generation = SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.ON_FLOOR, SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.isBiome(WBBiomes.MANGROVE_SWAMP), SurfaceRules.ifTrue(ABOVE_60, SurfaceRules.ifTrue(SurfaceRules.not(ABOVE_63), SurfaceRules.ifTrue(SurfaceRules.noiseCondition(Noises.SWAMP, 0.0F), makeStateRule(Blocks.WATER))))))), SurfaceRules.ifTrue(SurfaceRules.ON_FLOOR, SurfaceRules.ifTrue(SurfaceRules.waterBlockCheck(-1, 0), SurfaceRules.sequence(terrain))), SurfaceRules.ifTrue(SurfaceRules.waterStartCheck(-6, -1), SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.UNDER_FLOOR, terrain)))); - return SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.abovePreliminarySurface(), generation)); + SurfaceRules.RuleSource terrain = SurfaceRules.sequence(SurfaceRules.ifTrue( + SurfaceRules.isBiome(WBBiomes.MANGROVE_SWAMP), + makeStateRule(WBBlocks.MUD.get()) + )); + SurfaceRules.RuleSource generation = SurfaceRules.sequence( + SurfaceRules.ifTrue( + SurfaceRules.ON_FLOOR, + SurfaceRules.sequence(SurfaceRules.ifTrue( + SurfaceRules.isBiome(WBBiomes.MANGROVE_SWAMP), + SurfaceRules.ifTrue( + ABOVE_60, + SurfaceRules.ifTrue( + SurfaceRules.not(ABOVE_63), + SurfaceRules.ifTrue( + SurfaceRules.noiseCondition(Noises.SWAMP, 0.0F), + makeStateRule(Blocks.WATER) + ) + ) + ) + )) + ), + SurfaceRules.ifTrue( + SurfaceRules.ON_FLOOR, + SurfaceRules.ifTrue( + SurfaceRules.waterBlockCheck(-1, 0), SurfaceRules.sequence(terrain) + ) + ), + SurfaceRules.ifTrue( + SurfaceRules.waterStartCheck(-6, -1), + SurfaceRules.sequence( + SurfaceRules.ifTrue(SurfaceRules.UNDER_FLOOR, terrain) + ) + ) + ); + return SurfaceRules.sequence( + SurfaceRules.ifTrue(SurfaceRules.abovePreliminarySurface(), generation) + ); } private static SurfaceRules.RuleSource makeStateRule(Block block) { diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/PredicatedStateProvider.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/PredicatedStateProvider.java index 48a90f1..8054207 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/PredicatedStateProvider.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/PredicatedStateProvider.java @@ -1,5 +1,8 @@ package com.cursedcauldron.wildbackport.common.worldgen; +import java.util.List; +import java.util.Random; + import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.core.BlockPos; @@ -9,11 +12,19 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate; import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider; -import java.util.List; -import java.util.Random; - public record PredicatedStateProvider(BlockStateProvider fallback, List rules) { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group(BlockStateProvider.CODEC.fieldOf("fallback").forGetter(PredicatedStateProvider::fallback), Rule.CODEC.listOf().fieldOf("rules").forGetter(PredicatedStateProvider::rules)).apply(instance, PredicatedStateProvider::new)); + public static final Codec CODEC = RecordCodecBuilder.create( + instance + -> instance + .group( + BlockStateProvider.CODEC.fieldOf("fallback") + .forGetter(PredicatedStateProvider::fallback), + Rule.CODEC.listOf().fieldOf("rules").forGetter( + PredicatedStateProvider::rules + ) + ) + .apply(instance, PredicatedStateProvider::new) + ); public static PredicatedStateProvider of(BlockStateProvider provider) { return new PredicatedStateProvider(provider, List.of()); @@ -24,11 +35,21 @@ public record PredicatedStateProvider(BlockStateProvider fallback, List ru } public BlockState getBlockState(WorldGenLevel level, Random random, BlockPos pos) { - for (Rule rule : this.rules) if (rule.ifTrue.test(level, pos)) return rule.then.getState(random, pos); + for (Rule rule : this.rules) + if (rule.ifTrue.test(level, pos)) + return rule.then.getState(random, pos); return this.fallback.getState(random, pos); } public record Rule(BlockPredicate ifTrue, BlockStateProvider then) { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group(BlockPredicate.CODEC.fieldOf("if_true").forGetter(Rule::ifTrue), BlockStateProvider.CODEC.fieldOf("then").forGetter(Rule::then)).apply(instance, Rule::new)); + public static final Codec CODEC = RecordCodecBuilder.create( + instance + -> instance + .group( + BlockPredicate.CODEC.fieldOf("if_true").forGetter(Rule::ifTrue), + BlockStateProvider.CODEC.fieldOf("then").forGetter(Rule::then) + ) + .apply(instance, Rule::new) + ); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/VeinGrower.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/VeinGrower.java index 7a9f2fb..67645de 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/VeinGrower.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/VeinGrower.java @@ -1,5 +1,8 @@ package com.cursedcauldron.wildbackport.common.worldgen; +import java.util.Optional; +import java.util.Random; + import com.cursedcauldron.wildbackport.common.blocks.SculkVeinBlock; import com.cursedcauldron.wildbackport.common.utils.DirectionUtils; import net.minecraft.core.BlockPos; @@ -11,11 +14,10 @@ import net.minecraft.world.level.block.MultifaceBlock; import net.minecraft.world.level.block.state.BlockState; import org.jetbrains.annotations.Nullable; -import java.util.Optional; -import java.util.Random; - public class VeinGrower { - public static final GrowType[] GROW_TYPES = new GrowType[]{GrowType.SAME_POSITION, GrowType.SAME_PLANE, GrowType.WRAP_AROUND}; + public static final GrowType[] GROW_TYPES = new GrowType[] { GrowType.SAME_POSITION, + GrowType.SAME_PLANE, + GrowType.WRAP_AROUND }; private final GrowChecker growChecker; public VeinGrower(MultifaceBlock lichen) { @@ -26,48 +28,120 @@ public class VeinGrower { this.growChecker = growChecker; } - public boolean canGrow(BlockState state, BlockGetter getter, BlockPos pos, Direction direction) { - return DirectionUtils.stream().anyMatch(newDirection -> this.getGrowPos(state, getter, pos, direction, newDirection, this.growChecker::canGrow).isPresent()); + public boolean + canGrow(BlockState state, BlockGetter getter, BlockPos pos, Direction direction) { + return DirectionUtils.stream().anyMatch( + newDirection + -> this.getGrowPos( + state, + getter, + pos, + direction, + newDirection, + this.growChecker::canGrow + ) + .isPresent() + ); } - public Optional grow(BlockState state, LevelAccessor level, BlockPos pos, Random random) { - return DirectionUtils.shuffle(random).stream().filter(direction -> this.growChecker.canGrow(state, direction)).map(direction -> this.grow(state, level, pos, direction, random, false)).filter(Optional::isPresent).findFirst().orElse(Optional.empty()); + public Optional + grow(BlockState state, LevelAccessor level, BlockPos pos, Random random) { + return DirectionUtils.shuffle(random) + .stream() + .filter(direction -> this.growChecker.canGrow(state, direction)) + .map(direction -> this.grow(state, level, pos, direction, random, false)) + .filter(Optional::isPresent) + .findFirst() + .orElse(Optional.empty()); } - public long grow(BlockState state, LevelAccessor level, BlockPos pos, boolean postProcess) { - return DirectionUtils.stream().filter(direction -> this.growChecker.canGrow(state, direction)).map(direction -> this.grow(state, level, pos, direction, postProcess)).reduce(0L, Long::sum); + public long + grow(BlockState state, LevelAccessor level, BlockPos pos, boolean postProcess) { + return DirectionUtils.stream() + .filter(direction -> this.growChecker.canGrow(state, direction)) + .map(direction -> this.grow(state, level, pos, direction, postProcess)) + .reduce(0L, Long::sum); } - public Optional grow(BlockState state, LevelAccessor level, BlockPos pos, Direction direction, Random random, boolean postProcess) { - return DirectionUtils.shuffle(random).stream().map(newDirection -> this.grow(state, level, pos, direction, newDirection, postProcess)).filter(Optional::isPresent).findFirst().orElse(Optional.empty()); + public Optional grow( + BlockState state, + LevelAccessor level, + BlockPos pos, + Direction direction, + Random random, + boolean postProcess + ) { + return DirectionUtils.shuffle(random) + .stream() + .map( + newDirection + -> this.grow(state, level, pos, direction, newDirection, postProcess) + ) + .filter(Optional::isPresent) + .findFirst() + .orElse(Optional.empty()); } - private long grow(BlockState state, LevelAccessor level, BlockPos pos, Direction direction, boolean postProcess) { - return DirectionUtils.stream().map(newDirection -> this.grow(state, level, pos, direction, newDirection, postProcess)).filter(Optional::isPresent).count(); + private long grow( + BlockState state, + LevelAccessor level, + BlockPos pos, + Direction direction, + boolean postProcess + ) { + return DirectionUtils.stream() + .map( + newDirection + -> this.grow(state, level, pos, direction, newDirection, postProcess) + ) + .filter(Optional::isPresent) + .count(); } - public Optional grow(BlockState state, LevelAccessor world, BlockPos pos, Direction oldDirection, Direction newDirection, boolean postProcess) { - return this.getGrowPos(state, world, pos, oldDirection, newDirection, this.growChecker::canGrow).flatMap(growPos -> this.place(world, growPos, postProcess)); + public Optional grow( + BlockState state, + LevelAccessor world, + BlockPos pos, + Direction oldDirection, + Direction newDirection, + boolean postProcess + ) { + return this + .getGrowPos( + state, world, pos, oldDirection, newDirection, this.growChecker::canGrow + ) + .flatMap(growPos -> this.place(world, growPos, postProcess)); } - public Optional getGrowPos(BlockState state, BlockGetter world, BlockPos pos, Direction oldDirection, Direction newDirection, GrowPosPredicate predicate) { + public Optional getGrowPos( + BlockState state, + BlockGetter world, + BlockPos pos, + Direction oldDirection, + Direction newDirection, + GrowPosPredicate predicate + ) { if (newDirection.getAxis() == oldDirection.getAxis()) { return Optional.empty(); } - if (!(this.growChecker.canGrow(state) || this.growChecker.hasDirection(state, oldDirection) && !this.growChecker.hasDirection(state, newDirection))) { + if (!(this.growChecker.canGrow(state) + || this.growChecker.hasDirection(state, oldDirection) + && !this.growChecker.hasDirection(state, newDirection))) { return Optional.empty(); } for (GrowType growType : this.growChecker.getGrowTypes()) { GrowPos growPos = growType.getGrowPos(pos, newDirection, oldDirection); - if (!predicate.test(world, pos, growPos)) continue; + if (!predicate.test(world, pos, growPos)) + continue; return Optional.of(growPos); } return Optional.empty(); } - public Optional place(LevelAccessor world, GrowPos pos, boolean markForPostProcessing) { + public Optional + place(LevelAccessor world, GrowPos pos, boolean markForPostProcessing) { BlockState state = world.getBlockState(pos.pos()); if (this.growChecker.place(world, pos, state, markForPostProcessing)) { return Optional.of(pos); @@ -82,24 +156,41 @@ public class VeinGrower { this.multifaceBlock = multifaceBlock; } - @Override @Nullable - public BlockState getStateWithDirection(BlockState state, BlockGetter getter, BlockPos pos, Direction face) { + @Override + @Nullable + public BlockState getStateWithDirection( + BlockState state, BlockGetter getter, BlockPos pos, Direction face + ) { return this.multifaceBlock.getStateForPlacement(state, getter, pos, face); } - protected boolean canGrow(BlockGetter getter, BlockPos pos, BlockPos growPos, Direction direction, BlockState state) { - return state.isAir() || state.is(this.multifaceBlock) || state.is(Blocks.WATER) && state.getFluidState().isSource(); + protected boolean canGrow( + BlockGetter getter, + BlockPos pos, + BlockPos growPos, + Direction direction, + BlockState state + ) { + return state.isAir() || state.is(this.multifaceBlock) + || state.is(Blocks.WATER) && state.getFluidState().isSource(); } @Override public boolean canGrow(BlockGetter getter, BlockPos pos, GrowPos growPos) { BlockState state = getter.getBlockState(growPos.pos()); - return this.canGrow(getter, pos, growPos.pos(), growPos.face(), state) && ((SculkVeinBlock)this.multifaceBlock).canGrowWithDirection(getter, state, growPos.pos(), growPos.face()); + return this.canGrow(getter, pos, growPos.pos(), growPos.face(), state) + && ((SculkVeinBlock) this.multifaceBlock) + .canGrowWithDirection( + getter, state, growPos.pos(), growPos.face() + ); } } public interface GrowChecker { - @Nullable BlockState getStateWithDirection(BlockState state, BlockGetter getter, BlockPos pos, Direction face); + @Nullable + BlockState getStateWithDirection( + BlockState state, BlockGetter getter, BlockPos pos, Direction face + ); boolean canGrow(BlockGetter getter, BlockPos pos, GrowPos growPos); @@ -119,8 +210,11 @@ public class VeinGrower { return this.canGrow(state) || this.hasDirection(state, direction); } - default boolean place(LevelAccessor world, GrowPos growPos, BlockState state, boolean postProcess) { - BlockState blockState = this.getStateWithDirection(state, world, growPos.pos(), growPos.face()); + default boolean place( + LevelAccessor world, GrowPos growPos, BlockState state, boolean postProcess + ) { + BlockState blockState + = this.getStateWithDirection(state, world, growPos.pos(), growPos.face()); if (blockState != null) { if (postProcess) { world.getChunk(growPos.pos()).markPosForPostprocessing(growPos.pos()); @@ -138,24 +232,31 @@ public class VeinGrower { public enum GrowType { SAME_POSITION { @Override - public GrowPos getGrowPos(BlockPos pos, Direction newDirection, Direction oldDirection) { + public GrowPos + getGrowPos(BlockPos pos, Direction newDirection, Direction oldDirection) { return new GrowPos(pos, newDirection); } }, SAME_PLANE { @Override - public GrowPos getGrowPos(BlockPos pos, Direction newDirection, Direction oldDirection) { + public GrowPos + getGrowPos(BlockPos pos, Direction newDirection, Direction oldDirection) { return new GrowPos(pos.relative(newDirection), oldDirection); } }, WRAP_AROUND { @Override - public GrowPos getGrowPos(BlockPos pos, Direction newDirection, Direction oldDirection) { - return new GrowPos(pos.relative(newDirection).relative(oldDirection), newDirection.getOpposite()); + public GrowPos + getGrowPos(BlockPos pos, Direction newDirection, Direction oldDirection) { + return new GrowPos( + pos.relative(newDirection).relative(oldDirection), + newDirection.getOpposite() + ); } }; - public abstract GrowPos getGrowPos(BlockPos pos, Direction newDirection, Direction oldDirection); + public abstract GrowPos + getGrowPos(BlockPos pos, Direction newDirection, Direction oldDirection); } public record GrowPos(BlockPos pos, Direction face) {} diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/WorldGenerator.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/WorldGenerator.java index 852b1e8..08583de 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/WorldGenerator.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/WorldGenerator.java @@ -17,21 +17,32 @@ public class WorldGenerator { BiomeModifier.add(WorldGenerator::mangroveSwamp, WBBiomes.MANGROVE_SWAMP); BiomeModifier.add(WorldGenerator::deepDark, WBBiomes.DEEP_DARK); - BiomeModifier.add(WorldGenerator::addFrogs, Biome.BiomeCategory.SWAMP); } public static void mangroveSwamp(BiomeWriter writer) { - writer.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, WBWorldGeneration.DISK_GRASS_PLACED); - writer.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, WBWorldGeneration.TREES_MANGROVE_PLACED); + writer.addFeature( + GenerationStep.Decoration.UNDERGROUND_ORES, + WBWorldGeneration.DISK_GRASS_PLACED + ); + writer.addFeature( + GenerationStep.Decoration.VEGETAL_DECORATION, + WBWorldGeneration.TREES_MANGROVE_PLACED + ); writer.addSpawn(MobCategory.MONSTER, EntityType.SLIME, 1, 1, 1); writer.addSpawn(MobCategory.WATER_AMBIENT, EntityType.TROPICAL_FISH, 25, 8, 8); } public static void deepDark(BiomeWriter writer) { - writer.addFeature(GenerationStep.Decoration.UNDERGROUND_DECORATION, WBWorldGeneration.SCULK_VEIN_PLACED); - writer.addFeature(GenerationStep.Decoration.UNDERGROUND_DECORATION, WBWorldGeneration.SCULK_PATCH_DEEP_DARK_PLACED); + writer.addFeature( + GenerationStep.Decoration.UNDERGROUND_DECORATION, + WBWorldGeneration.SCULK_VEIN_PLACED + ); + writer.addFeature( + GenerationStep.Decoration.UNDERGROUND_DECORATION, + WBWorldGeneration.SCULK_PATCH_DEEP_DARK_PLACED + ); } public static void addFrogs(BiomeWriter writer) { diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/decorator/AboveRootPlacement.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/decorator/AboveRootPlacement.java index bcea1bf..e1e9217 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/decorator/AboveRootPlacement.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/decorator/AboveRootPlacement.java @@ -4,12 +4,21 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider; -public record AboveRootPlacement(BlockStateProvider aboveRootProvider, float aboveRootPlacementChance) { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> { - return instance.group(BlockStateProvider.CODEC.fieldOf("above_root_provider").forGetter(decorator -> { - return decorator.aboveRootProvider; - }), Codec.floatRange(0.0F, 1.0F).fieldOf("above_root_placement_chance").forGetter(decorator -> { - return decorator.aboveRootPlacementChance; - })).apply(instance, AboveRootPlacement::new); - }); +public record +AboveRootPlacement(BlockStateProvider aboveRootProvider, float aboveRootPlacementChance) { + public static final Codec CODEC = RecordCodecBuilder.create( + instance -> { + return instance + .group( + BlockStateProvider.CODEC.fieldOf("above_root_provider") + .forGetter(decorator -> { return decorator.aboveRootProvider; }), + Codec.floatRange(0.0F, 1.0F) + .fieldOf("above_root_placement_chance") + .forGetter(decorator -> { + return decorator.aboveRootPlacementChance; + }) + ) + .apply(instance, AboveRootPlacement::new); + } + ); } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/decorator/AttachedToLeavesDecorator.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/decorator/AttachedToLeavesDecorator.java index 3fd8d83..a3ab2d0 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/decorator/AttachedToLeavesDecorator.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/decorator/AttachedToLeavesDecorator.java @@ -1,5 +1,10 @@ package com.cursedcauldron.wildbackport.common.worldgen.decorator; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.function.BiConsumer; + import com.cursedcauldron.wildbackport.common.registry.worldgen.WBTreeDecorators; import com.cursedcauldron.wildbackport.common.utils.ModUtils; import com.mojang.serialization.Codec; @@ -15,27 +20,35 @@ import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvi import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecorator; import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType; -import java.util.HashSet; -import java.util.List; -import java.util.Random; -import java.util.function.BiConsumer; - public class AttachedToLeavesDecorator extends TreeDecorator { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> { - return instance.group(Codec.floatRange(0.0F, 1.0F).fieldOf("probability").forGetter(decorator -> { - return decorator.probability; - }), Codec.intRange(0, 16).fieldOf("exclusion_radius_xz").forGetter(decorator -> { - return decorator.exclusionRadiusXZ; - }), Codec.intRange(0, 16).fieldOf("exclusion_radius_y").forGetter(decorator -> { - return decorator.exclusionRadiusY; - }), BlockStateProvider.CODEC.fieldOf("block_provider").forGetter(decorator -> { - return decorator.blockProvider; - }), Codec.intRange(1, 16).fieldOf("required_empty_blocks").forGetter(decorator -> { - return decorator.requiredEmptyBlocks; - }), Direction.CODEC.listOf().fieldOf("directions").forGetter(decorator -> { - return decorator.directions; - })).apply(instance, AttachedToLeavesDecorator::new); - }); + public static final Codec CODEC + = RecordCodecBuilder.create(instance -> { + return instance + .group( + Codec.floatRange(0.0F, 1.0F) + .fieldOf("probability") + .forGetter(decorator -> { return decorator.probability; }), + Codec.intRange(0, 16) + .fieldOf("exclusion_radius_xz") + .forGetter(decorator -> { + return decorator.exclusionRadiusXZ; + }), + Codec.intRange(0, 16) + .fieldOf("exclusion_radius_y") + .forGetter(decorator -> { return decorator.exclusionRadiusY; }), + BlockStateProvider.CODEC.fieldOf("block_provider") + .forGetter(decorator -> { return decorator.blockProvider; }), + Codec.intRange(1, 16) + .fieldOf("required_empty_blocks") + .forGetter(decorator -> { + return decorator.requiredEmptyBlocks; + }), + Direction.CODEC.listOf() + .fieldOf("directions") + .forGetter(decorator -> { return decorator.directions; }) + ) + .apply(instance, AttachedToLeavesDecorator::new); + }); protected final float probability; protected final int exclusionRadiusXZ; protected final int exclusionRadiusY; @@ -43,7 +56,14 @@ public class AttachedToLeavesDecorator extends TreeDecorator { protected final int requiredEmptyBlocks; protected final List directions; - public AttachedToLeavesDecorator(float probability, int exclusionRadiusXZ, int exclusionRadiusY, BlockStateProvider blockProvider, int requiredEmptyBlocks, List directions) { + public AttachedToLeavesDecorator( + float probability, + int exclusionRadiusXZ, + int exclusionRadiusY, + BlockStateProvider blockProvider, + int requiredEmptyBlocks, + List directions + ) { this.probability = probability; this.exclusionRadiusXZ = exclusionRadiusXZ; this.exclusionRadiusY = exclusionRadiusY; @@ -53,14 +73,28 @@ public class AttachedToLeavesDecorator extends TreeDecorator { } @Override - public void place(LevelSimulatedReader level, BiConsumer replacer, Random random, List trunkPositions, List foliagePositions) { + public void place( + LevelSimulatedReader level, + BiConsumer replacer, + Random random, + List trunkPositions, + List foliagePositions + ) { HashSet positions = new HashSet<>(); - for (BlockPos pos : ModUtils.copyShuffled(new ObjectArrayList<>(foliagePositions), random)) { + for (BlockPos pos : + ModUtils.copyShuffled(new ObjectArrayList<>(foliagePositions), random)) { Direction direction = Util.getRandom(this.directions, random); BlockPos offset = pos.relative(direction); - if (!positions.contains(offset) && random.nextFloat() < this.probability && this.meetsRequiredEmptyBlocks(level, pos, direction)) { - BlockPos minRadius = offset.offset(-this.exclusionRadiusXZ, -this.exclusionRadiusY, -this.exclusionRadiusXZ); - BlockPos maxRadius = offset.offset(this.exclusionRadiusXZ, this.exclusionRadiusY, this.exclusionRadiusXZ); + if (!positions.contains(offset) && random.nextFloat() < this.probability + && this.meetsRequiredEmptyBlocks(level, pos, direction)) { + BlockPos minRadius = offset.offset( + -this.exclusionRadiusXZ, + -this.exclusionRadiusY, + -this.exclusionRadiusXZ + ); + BlockPos maxRadius = offset.offset( + this.exclusionRadiusXZ, this.exclusionRadiusY, this.exclusionRadiusXZ + ); for (BlockPos position : BlockPos.betweenClosed(minRadius, maxRadius)) { positions.add(position.immutable()); } @@ -70,9 +104,12 @@ public class AttachedToLeavesDecorator extends TreeDecorator { } } - private boolean meetsRequiredEmptyBlocks(LevelSimulatedReader level, BlockPos pos, Direction direction) { + private boolean meetsRequiredEmptyBlocks( + LevelSimulatedReader level, BlockPos pos, Direction direction + ) { for (int i = 1; i <= this.requiredEmptyBlocks; i++) { - if (!Feature.isAir(level, pos.relative(direction, i))) return false; + if (!Feature.isAir(level, pos.relative(direction, i))) + return false; } return true; diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/decorator/MangroveRootPlacement.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/decorator/MangroveRootPlacement.java index bf58e4e..330d51e 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/decorator/MangroveRootPlacement.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/decorator/MangroveRootPlacement.java @@ -8,20 +8,37 @@ import net.minecraft.core.RegistryCodecs; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider; -public record MangroveRootPlacement(HolderSet canGrowThrough, HolderSet muddyRootsIn, BlockStateProvider muddyRootsProvider, int maxRootWidth, int maxRootLength, float randomSkewChance) { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> { - return instance.group(RegistryCodecs.homogeneousList(Registry.BLOCK_REGISTRY).fieldOf("can_grow_through").forGetter(placer -> { - return placer.canGrowThrough; - }), RegistryCodecs.homogeneousList(Registry.BLOCK_REGISTRY).fieldOf("muddy_roots_in").forGetter(placer -> { - return placer.muddyRootsIn; - }), BlockStateProvider.CODEC.fieldOf("muddy_roots_provider").forGetter(placer -> { - return placer.muddyRootsProvider; - }), Codec.intRange(1, 12).fieldOf("max_root_width").forGetter(placer -> { - return placer.maxRootWidth; - }), Codec.intRange(1, 64).fieldOf("max_root_length").forGetter(placer -> { - return placer.maxRootLength; - }), Codec.floatRange(0.0F, 1.0F).fieldOf("random_skew_chance").forGetter(placer -> { - return placer.randomSkewChance; - })).apply(instance, MangroveRootPlacement::new); - }); +public record MangroveRootPlacement( + HolderSet canGrowThrough, + HolderSet muddyRootsIn, + BlockStateProvider muddyRootsProvider, + int maxRootWidth, + int maxRootLength, + float randomSkewChance +) { + public static final Codec CODEC = RecordCodecBuilder.create( + instance -> { + return instance + .group( + RegistryCodecs.homogeneousList(Registry.BLOCK_REGISTRY) + .fieldOf("can_grow_through") + .forGetter(placer -> { return placer.canGrowThrough; }), + RegistryCodecs.homogeneousList(Registry.BLOCK_REGISTRY) + .fieldOf("muddy_roots_in") + .forGetter(placer -> { return placer.muddyRootsIn; }), + BlockStateProvider.CODEC.fieldOf("muddy_roots_provider") + .forGetter(placer -> { return placer.muddyRootsProvider; }), + Codec.intRange(1, 12).fieldOf("max_root_width").forGetter(placer -> { + return placer.maxRootWidth; + }), + Codec.intRange(1, 64).fieldOf("max_root_length").forGetter(placer -> { + return placer.maxRootLength; + }), + Codec.floatRange(0.0F, 1.0F) + .fieldOf("random_skew_chance") + .forGetter(placer -> { return placer.randomSkewChance; }) + ) + .apply(instance, MangroveRootPlacement::new); + } + ); } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/decorator/WeightedLeaveVineDecorator.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/decorator/WeightedLeaveVineDecorator.java index 3b2a443..91ee047 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/decorator/WeightedLeaveVineDecorator.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/decorator/WeightedLeaveVineDecorator.java @@ -1,5 +1,9 @@ package com.cursedcauldron.wildbackport.common.worldgen.decorator; +import java.util.List; +import java.util.Random; +import java.util.function.BiConsumer; + import com.cursedcauldron.wildbackport.common.registry.worldgen.WBTreeDecorators; import com.mojang.serialization.Codec; import net.minecraft.core.BlockPos; @@ -12,16 +16,17 @@ import net.minecraft.world.level.levelgen.feature.treedecorators.LeaveVineDecora import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecorator; import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType; -import java.util.List; -import java.util.Random; -import java.util.function.BiConsumer; - //<> public class WeightedLeaveVineDecorator extends TreeDecorator { - public static final Codec CODEC = Codec.floatRange(0.0F, 1.0F).fieldOf("probability").xmap(WeightedLeaveVineDecorator::new, decorator -> { - return decorator.probability; - }).codec(); + public static final Codec CODEC + = Codec.floatRange(0.0F, 1.0F) + .fieldOf("probability") + .xmap( + WeightedLeaveVineDecorator::new, + decorator -> { return decorator.probability; } + ) + .codec(); private final float probability; public WeightedLeaveVineDecorator(float probability) { @@ -29,16 +34,33 @@ public class WeightedLeaveVineDecorator extends TreeDecorator { } @Override - public void place(LevelSimulatedReader level, BiConsumer replacer, Random random, List trunkPositions, List foliagePositions) { + public void place( + LevelSimulatedReader level, + BiConsumer replacer, + Random random, + List trunkPositions, + List foliagePositions + ) { foliagePositions.forEach(pos -> { - if (random.nextFloat() < this.probability && Feature.isAir(level, pos.west())) addHangingVine(level, pos.west(), VineBlock.EAST, replacer); - if (random.nextFloat() < this.probability && Feature.isAir(level, pos.east())) addHangingVine(level, pos.east(), VineBlock.WEST, replacer); - if (random.nextFloat() < this.probability && Feature.isAir(level, pos.north())) addHangingVine(level, pos.north(), VineBlock.SOUTH, replacer); - if (random.nextFloat() < this.probability && Feature.isAir(level, pos.south())) addHangingVine(level, pos.south(), VineBlock.NORTH, replacer); + if (random.nextFloat() < this.probability && Feature.isAir(level, pos.west())) + addHangingVine(level, pos.west(), VineBlock.EAST, replacer); + if (random.nextFloat() < this.probability && Feature.isAir(level, pos.east())) + addHangingVine(level, pos.east(), VineBlock.WEST, replacer); + if (random.nextFloat() < this.probability + && Feature.isAir(level, pos.north())) + addHangingVine(level, pos.north(), VineBlock.SOUTH, replacer); + if (random.nextFloat() < this.probability + && Feature.isAir(level, pos.south())) + addHangingVine(level, pos.south(), VineBlock.NORTH, replacer); }); } - private static void addHangingVine(LevelSimulatedReader level, BlockPos pos, BooleanProperty property, BiConsumer replacer) { + private static void addHangingVine( + LevelSimulatedReader level, + BlockPos pos, + BooleanProperty property, + BiConsumer replacer + ) { LeaveVineDecorator.placeVine(replacer, pos, property); pos = pos.below(); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/GrassDiskConfiguration.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/GrassDiskConfiguration.java index 9fd4ceb..aac1979 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/GrassDiskConfiguration.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/GrassDiskConfiguration.java @@ -7,6 +7,28 @@ import net.minecraft.util.valueproviders.IntProvider; import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate; import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; -public record GrassDiskConfiguration(PredicatedStateProvider stateProvider, BlockPredicate target, IntProvider radius, int halfHeight) implements FeatureConfiguration { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group(PredicatedStateProvider.CODEC.fieldOf("state_provider").forGetter(GrassDiskConfiguration::stateProvider), BlockPredicate.CODEC.fieldOf("target").forGetter(GrassDiskConfiguration::target), IntProvider.codec(0, 8).fieldOf("radius").forGetter(GrassDiskConfiguration::radius), Codec.intRange(0, 4).fieldOf("half_height").forGetter(GrassDiskConfiguration::halfHeight)).apply(instance, GrassDiskConfiguration::new)); +public record GrassDiskConfiguration( + PredicatedStateProvider stateProvider, + BlockPredicate target, + IntProvider radius, + int halfHeight +) implements FeatureConfiguration { + public static final Codec CODEC = RecordCodecBuilder.create( + instance + -> instance + .group( + PredicatedStateProvider.CODEC.fieldOf("state_provider") + .forGetter(GrassDiskConfiguration::stateProvider), + BlockPredicate.CODEC.fieldOf("target").forGetter( + GrassDiskConfiguration::target + ), + IntProvider.codec(0, 8).fieldOf("radius").forGetter( + GrassDiskConfiguration::radius + ), + Codec.intRange(0, 4) + .fieldOf("half_height") + .forGetter(GrassDiskConfiguration::halfHeight) + ) + .apply(instance, GrassDiskConfiguration::new) + ); } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/GrassDiskFeature.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/GrassDiskFeature.java index ff769e6..16c181a 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/GrassDiskFeature.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/GrassDiskFeature.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.worldgen.features; +import java.util.Random; + import com.mojang.serialization.Codec; import net.minecraft.core.BlockPos; import net.minecraft.world.level.WorldGenLevel; @@ -7,8 +9,6 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; -import java.util.Random; - public class GrassDiskFeature extends Feature { public GrassDiskFeature(Codec codec) { super(codec); @@ -27,23 +27,35 @@ public class GrassDiskFeature extends Feature { int radius = config.radius().sample(random); BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos(); - for (BlockPos position : BlockPos.betweenClosed(pos.offset(-radius, 0, -radius), pos.offset(radius, 0, radius))) { + for (BlockPos position : BlockPos.betweenClosed( + pos.offset(-radius, 0, -radius), pos.offset(radius, 0, radius) + )) { int x = position.getX() - position.getX(); int z = position.getZ() - position.getZ(); if (x * x + z * z <= radius * radius) { - place |= this.placeBlock(config, level, random, topY, bottomY, mutable.set(position)); + place |= this.placeBlock( + config, level, random, topY, bottomY, mutable.set(position) + ); } } return place; } - protected boolean placeBlock(GrassDiskConfiguration config, WorldGenLevel level, Random random, int topY, int bottomY, BlockPos.MutableBlockPos pos) { + protected boolean placeBlock( + GrassDiskConfiguration config, + WorldGenLevel level, + Random random, + int topY, + int bottomY, + BlockPos.MutableBlockPos pos + ) { boolean place = false; for (int y = topY; y > bottomY; y--) { pos.setY(y); if (config.target().test(level, pos)) { - BlockState state = config.stateProvider().getBlockState(level, random, pos); + BlockState state + = config.stateProvider().getBlockState(level, random, pos); level.setBlock(pos, state, 2); this.markAboveForPostProcessing(level, pos); place = true; diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/RootedTreeConfig.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/RootedTreeConfig.java index 5127c76..d5cd1a8 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/RootedTreeConfig.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/RootedTreeConfig.java @@ -1,5 +1,8 @@ package com.cursedcauldron.wildbackport.common.worldgen.features; +import java.util.List; +import java.util.Optional; + import com.cursedcauldron.wildbackport.common.worldgen.placers.RootPlacer; import com.google.common.collect.ImmutableList; import com.mojang.serialization.Codec; @@ -12,39 +15,69 @@ import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvi import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecorator; import net.minecraft.world.level.levelgen.feature.trunkplacers.TrunkPlacer; -import java.util.List; -import java.util.Optional; - //<> public class RootedTreeConfig extends TreeConfiguration { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> { - return instance.group(BlockStateProvider.CODEC.fieldOf("trunk_provider").forGetter(config -> { - return config.trunkProvider; - }), TrunkPlacer.CODEC.fieldOf("trunk_placer").forGetter(config -> { - return config.trunkPlacer; - }), BlockStateProvider.CODEC.fieldOf("foliage_provider").forGetter(config -> { - return config.foliageProvider; - }), FoliagePlacer.CODEC.fieldOf("foliage_placer").forGetter(config -> { - return config.foliagePlacer; - }), RootPlacer.CODEC.optionalFieldOf("root_placer").forGetter(config -> { - return config.rootPlacer; - }), BlockStateProvider.CODEC.fieldOf("dirt_provider").forGetter(config -> { - return config.dirtProvider; - }), FeatureSize.CODEC.fieldOf("minimum_size").forGetter(config -> { - return config.minimumSize; - }), TreeDecorator.CODEC.listOf().fieldOf("decorators").forGetter(config -> { - return config.decorators; - }), Codec.BOOL.fieldOf("ignore_vines").orElse(false).forGetter(config -> { - return config.ignoreVines; - }), Codec.BOOL.fieldOf("force_dirt").orElse(false).forGetter(config -> { - return config.forceDirt; - })).apply(instance, RootedTreeConfig::new); - }); + public static final Codec CODEC = RecordCodecBuilder.create( + instance -> { + return instance + .group( + BlockStateProvider.CODEC.fieldOf("trunk_provider") + .forGetter(config -> { return config.trunkProvider; }), + TrunkPlacer.CODEC.fieldOf("trunk_placer").forGetter(config -> { + return config.trunkPlacer; + }), + BlockStateProvider.CODEC.fieldOf("foliage_provider") + .forGetter(config -> { return config.foliageProvider; }), + FoliagePlacer.CODEC.fieldOf("foliage_placer").forGetter(config -> { + return config.foliagePlacer; + }), + RootPlacer.CODEC.optionalFieldOf("root_placer").forGetter(config -> { + return config.rootPlacer; + }), + BlockStateProvider.CODEC.fieldOf("dirt_provider") + .forGetter(config -> { return config.dirtProvider; }), + FeatureSize.CODEC.fieldOf("minimum_size").forGetter(config -> { + return config.minimumSize; + }), + TreeDecorator.CODEC.listOf() + .fieldOf("decorators") + .forGetter(config -> { return config.decorators; }), + Codec.BOOL.fieldOf("ignore_vines").orElse(false).forGetter(config -> { + return config.ignoreVines; + }), + Codec.BOOL.fieldOf("force_dirt").orElse(false).forGetter(config -> { + return config.forceDirt; + }) + ) + .apply(instance, RootedTreeConfig::new); + } + ); public final Optional rootPlacer; - protected RootedTreeConfig(BlockStateProvider trunkProvider, TrunkPlacer trunkPlacer, BlockStateProvider foliageProvider, FoliagePlacer foliagePlacer, Optional rootPlacer, BlockStateProvider dirtProvider, FeatureSize minimumSize, List decorators, boolean ignoreVines, boolean forceDirt) { - super(trunkProvider, trunkPlacer, foliageProvider, foliagePlacer, dirtProvider, minimumSize, decorators, ignoreVines, forceDirt); + protected RootedTreeConfig( + BlockStateProvider trunkProvider, + TrunkPlacer trunkPlacer, + BlockStateProvider foliageProvider, + FoliagePlacer foliagePlacer, + Optional rootPlacer, + BlockStateProvider dirtProvider, + FeatureSize minimumSize, + List decorators, + boolean ignoreVines, + boolean forceDirt + ) { + super( + trunkProvider, + trunkPlacer, + foliageProvider, + foliagePlacer, + dirtProvider, + minimumSize, + decorators, + ignoreVines, + forceDirt + ); this.rootPlacer = rootPlacer; } @@ -60,7 +93,14 @@ public class RootedTreeConfig extends TreeConfiguration { private boolean ignoreVines; private boolean forceDirt; - public Builder(BlockStateProvider trunkProvider, TrunkPlacer trunkPlacer, BlockStateProvider foliageProvider, FoliagePlacer foliagePlacer, Optional rootPlacer, FeatureSize minimumSize) { + public Builder( + BlockStateProvider trunkProvider, + TrunkPlacer trunkPlacer, + BlockStateProvider foliageProvider, + FoliagePlacer foliagePlacer, + Optional rootPlacer, + FeatureSize minimumSize + ) { this.trunkProvider = trunkProvider; this.trunkPlacer = trunkPlacer; this.foliageProvider = foliageProvider; @@ -70,8 +110,21 @@ public class RootedTreeConfig extends TreeConfiguration { this.minimumSize = minimumSize; } - public Builder(BlockStateProvider trunkProvider, TrunkPlacer trunkPlacer, BlockStateProvider foliageProvider, FoliagePlacer foliagePlacer, FeatureSize minimumSize) { - this(trunkProvider, trunkPlacer, foliageProvider, foliagePlacer, Optional.empty(), minimumSize); + public Builder( + BlockStateProvider trunkProvider, + TrunkPlacer trunkPlacer, + BlockStateProvider foliageProvider, + FoliagePlacer foliagePlacer, + FeatureSize minimumSize + ) { + this( + trunkProvider, + trunkPlacer, + foliageProvider, + foliagePlacer, + Optional.empty(), + minimumSize + ); } public Builder dirtProvider(BlockStateProvider dirtProvider) { @@ -95,7 +148,18 @@ public class RootedTreeConfig extends TreeConfiguration { } public RootedTreeConfig build() { - return new RootedTreeConfig(this.trunkProvider, this.trunkPlacer, this.foliageProvider, this.foliagePlacer, this.rootPlacer, this.dirtProvider, this.minimumSize, this.decorators, this.ignoreVines, this.forceDirt); + return new RootedTreeConfig( + this.trunkProvider, + this.trunkPlacer, + this.foliageProvider, + this.foliagePlacer, + this.rootPlacer, + this.dirtProvider, + this.minimumSize, + this.decorators, + this.ignoreVines, + this.forceDirt + ); } } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/RootedTreeFeature.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/RootedTreeFeature.java index fa2503b..b908d88 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/RootedTreeFeature.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/RootedTreeFeature.java @@ -1,5 +1,14 @@ package com.cursedcauldron.wildbackport.common.worldgen.features; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashSet; +import java.util.List; +import java.util.OptionalInt; +import java.util.Random; +import java.util.Set; +import java.util.function.BiConsumer; + import com.cursedcauldron.wildbackport.common.worldgen.placers.UpwardBranchingTrunk; import com.cursedcauldron.wildbackport.core.mixin.access.TreeFeatureAccessor; import com.google.common.collect.Iterables; @@ -25,15 +34,6 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemp import net.minecraft.world.phys.shapes.BitSetDiscreteVoxelShape; import net.minecraft.world.phys.shapes.DiscreteVoxelShape; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.HashSet; -import java.util.List; -import java.util.OptionalInt; -import java.util.Random; -import java.util.Set; -import java.util.function.BiConsumer; - //<> public class RootedTreeFeature extends Feature { @@ -41,23 +41,59 @@ public class RootedTreeFeature extends Feature { super(codec); } - private boolean generate(WorldGenLevel level, Random random, BlockPos pos, BiConsumer rootPlacerReplacer, BiConsumer trunkPlacerReplacer, BiConsumer foliagePlacerReplacer, RootedTreeConfig config) { + private boolean generate( + WorldGenLevel level, + Random random, + BlockPos pos, + BiConsumer rootPlacerReplacer, + BiConsumer trunkPlacerReplacer, + BiConsumer foliagePlacerReplacer, + RootedTreeConfig config + ) { int treeHeight = config.trunkPlacer.getTreeHeight(random); - int foliageHeight = config.foliagePlacer.foliageHeight(random, treeHeight, config); + int foliageHeight + = config.foliagePlacer.foliageHeight(random, treeHeight, config); int trunkLength = treeHeight - foliageHeight; int foliageRadius = config.foliagePlacer.foliageRadius(random, trunkLength); - BlockPos origin = config.rootPlacer.map(rootPlacer -> rootPlacer.trunkOffset(pos, random)).orElse(pos); + BlockPos origin + = config.rootPlacer.map(rootPlacer -> rootPlacer.trunkOffset(pos, random)) + .orElse(pos); int minHeight = Math.min(pos.getY(), origin.getY()); int maxHeight = Math.max(pos.getY(), origin.getY()) + treeHeight + 1; - if (minHeight >= level.getMinBuildHeight() + 1 && maxHeight <= level.getMaxBuildHeight()) { + if (minHeight >= level.getMinBuildHeight() + 1 + && maxHeight <= level.getMaxBuildHeight()) { OptionalInt clippedHeight = config.minimumSize.minClippedHeight(); int topPosition = this.getTopPosition(level, treeHeight, origin, config); - if (topPosition >= treeHeight || clippedHeight.isPresent() && topPosition >= clippedHeight.getAsInt()) { - if (config.rootPlacer.isPresent() && !config.rootPlacer.get().generate(level, rootPlacerReplacer, random, pos, origin, config)) { + if (topPosition >= treeHeight + || clippedHeight.isPresent() && topPosition >= clippedHeight.getAsInt()) { + if (config.rootPlacer.isPresent() + && !config.rootPlacer.get().generate( + level, rootPlacerReplacer, random, pos, origin, config + )) { return false; } else { - List foliage = config.trunkPlacer.placeTrunk(level, trunkPlacerReplacer, random, topPosition, origin, config); - foliage.forEach(node -> config.foliagePlacer.createFoliage(level, foliagePlacerReplacer, random, config, topPosition, node, foliageHeight, foliageRadius)); + List foliage + = config.trunkPlacer.placeTrunk( + level, + trunkPlacerReplacer, + random, + topPosition, + origin, + config + ); + foliage.forEach( + node + -> config.foliagePlacer.createFoliage( + level, + foliagePlacerReplacer, + random, + config, + topPosition, + node, + foliageHeight, + foliageRadius + ) + ); return true; } } else { @@ -69,7 +105,9 @@ public class RootedTreeFeature extends Feature { } @SuppressWarnings("ConstantConditions") - private int getTopPosition(LevelSimulatedReader level, int height, BlockPos pos, RootedTreeConfig config) { + private int getTopPosition( + LevelSimulatedReader level, int height, BlockPos pos, RootedTreeConfig config + ) { BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos(); for (int y = 0; y <= height + 1; ++y) { int size = config.minimumSize.getSizeAtHeight(height, y); @@ -77,8 +115,16 @@ public class RootedTreeFeature extends Feature { for (int x = -size; x <= size; ++x) { for (int z = -size; z <= size; ++z) { mutable.setWithOffset(pos, x, y, z); - boolean isValid = TreeFeature.validTreePos(level, pos) || level.isStateAtPosition(pos, state -> state.is(BlockTags.LOGS)) || (config.trunkPlacer instanceof UpwardBranchingTrunk trunk && level.isStateAtPosition(pos, state -> state.is(trunk.canGrowThrough))); - if (!isValid || (!config.ignoreVines && TreeFeatureAccessor.isVine(level, mutable))) return y - 2; + boolean isValid = TreeFeature.validTreePos(level, pos) + || level.isStateAtPosition(pos, state -> state.is(BlockTags.LOGS)) + || (config.trunkPlacer instanceof UpwardBranchingTrunk trunk + && level.isStateAtPosition( + pos, state -> state.is(trunk.canGrowThrough) + )); + if (!isValid + || (!config.ignoreVines + && TreeFeatureAccessor.isVine(level, mutable))) + return y - 2; } } } @@ -112,8 +158,11 @@ public class RootedTreeFeature extends Feature { decoratorPos.add(position.immutable()); level.setBlock(position, state, 19); }; - boolean generate = this.generate(level, random, pos, rootReplacer, trunkReplacer, foliageReplacer, config); - if (!generate || trunkPos.isEmpty() && foliagePos.isEmpty()) return false; + boolean generate = this.generate( + level, random, pos, rootReplacer, trunkReplacer, foliageReplacer, config + ); + if (!generate || trunkPos.isEmpty() && foliagePos.isEmpty()) + return false; if (!config.decorators.isEmpty()) { ArrayList rootPositions = Lists.newArrayList(rootPos); ArrayList trunkPositions = Lists.newArrayList(trunkPos); @@ -121,36 +170,77 @@ public class RootedTreeFeature extends Feature { trunkPositions.sort(Comparator.comparingInt(Vec3i::getY)); foliagePositions.sort(Comparator.comparingInt(Vec3i::getY)); rootPositions.sort(Comparator.comparingInt(Vec3i::getY)); - config.decorators.forEach(treeDecorator -> treeDecorator.place(level, decoratorReplacer, random, trunkPositions, foliagePositions)); + config.decorators.forEach( + treeDecorator + -> treeDecorator.place( + level, decoratorReplacer, random, trunkPositions, foliagePositions + ) + ); } - return BoundingBox.encapsulatingPositions(Iterables.concat(trunkPos, foliagePos, decoratorPos)).map(box -> { - DiscreteVoxelShape shape = RootedTreeFeature.placeLogsAndLeaves(level, box, trunkPos, decoratorPos); - StructureTemplate.updateShapeAtEdge(level, Block.UPDATE_ALL, shape, box.minX(), box.minY(), box.minZ()); - return true; - }).orElse(false); + return BoundingBox + .encapsulatingPositions(Iterables.concat(trunkPos, foliagePos, decoratorPos)) + .map(box -> { + DiscreteVoxelShape shape = RootedTreeFeature.placeLogsAndLeaves( + level, box, trunkPos, decoratorPos + ); + StructureTemplate.updateShapeAtEdge( + level, Block.UPDATE_ALL, shape, box.minX(), box.minY(), box.minZ() + ); + return true; + }) + .orElse(false); } - private static DiscreteVoxelShape placeLogsAndLeaves(LevelAccessor level, BoundingBox box, Set trunkPositions, Set decoratorPositions) { + private static DiscreteVoxelShape placeLogsAndLeaves( + LevelAccessor level, + BoundingBox box, + Set trunkPositions, + Set decoratorPositions + ) { ArrayList> positions = Lists.newArrayList(); - BitSetDiscreteVoxelShape shape = new BitSetDiscreteVoxelShape(box.getXSpan(), box.getYSpan(), box.getZSpan()); + BitSetDiscreteVoxelShape shape = new BitSetDiscreteVoxelShape( + box.getXSpan(), box.getYSpan(), box.getZSpan() + ); - for (int tries = 0; tries < 6; ++tries) positions.add(Sets.newHashSet()); + for (int tries = 0; tries < 6; ++tries) + positions.add(Sets.newHashSet()); BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos(); - for (BlockPos pos : Lists.newArrayList(decoratorPositions)) if (box.isInside(pos)) shape.fill(pos.getX() - box.minX(), pos.getY() - box.minY(), pos.getZ() - box.minZ()); + for (BlockPos pos : Lists.newArrayList(decoratorPositions)) + if (box.isInside(pos)) + shape.fill( + pos.getX() - box.minX(), + pos.getY() - box.minY(), + pos.getZ() - box.minZ() + ); for (BlockPos pos : Lists.newArrayList(trunkPositions)) { - if (box.isInside(pos)) shape.fill(pos.getX() - box.minX(), pos.getY() - box.minY(), pos.getZ() - box.minZ()); + if (box.isInside(pos)) + shape.fill( + pos.getX() - box.minX(), + pos.getY() - box.minY(), + pos.getZ() - box.minZ() + ); for (Direction direction : Direction.values()) { BlockState blockState; mutable.setWithOffset(pos, direction); - if (trunkPositions.contains(mutable) || !(blockState = level.getBlockState(mutable)).hasProperty(BlockStateProperties.DISTANCE)) continue; + if (trunkPositions.contains(mutable) + || !(blockState = level.getBlockState(mutable)) + .hasProperty(BlockStateProperties.DISTANCE)) + continue; positions.get(0).add(mutable.immutable()); - TreeFeatureAccessor.setBlockKnownShape(level, mutable, blockState.setValue(BlockStateProperties.DISTANCE, 1)); - if (!box.isInside(mutable)) continue; - shape.fill(mutable.getX() - box.minX(), mutable.getY() - box.minY(), mutable.getZ() - box.minZ()); + TreeFeatureAccessor.setBlockKnownShape( + level, mutable, blockState.setValue(BlockStateProperties.DISTANCE, 1) + ); + if (!box.isInside(mutable)) + continue; + shape.fill( + mutable.getX() - box.minX(), + mutable.getY() - box.minY(), + mutable.getZ() - box.minZ() + ); } } @@ -158,15 +248,29 @@ public class RootedTreeFeature extends Feature { Set trunkPos = positions.get(tries - 1); Set foliagePos = positions.get(tries); for (BlockPos pos : trunkPos) { - if (box.isInside(pos)) shape.fill(pos.getX() - box.minX(), pos.getY() - box.minY(), pos.getZ() - box.minZ()); + if (box.isInside(pos)) + shape.fill( + pos.getX() - box.minX(), + pos.getY() - box.minY(), + pos.getZ() - box.minZ() + ); for (Direction direction : Direction.values()) { mutable.setWithOffset(pos, direction); BlockState state = level.getBlockState(mutable); - if (trunkPos.contains(mutable) || foliagePos.contains(mutable) || !state.hasProperty(BlockStateProperties.DISTANCE) || (state.getValue(BlockStateProperties.DISTANCE)) <= tries + 1) continue; - BlockState foliage = state.setValue(BlockStateProperties.DISTANCE, tries + 1); + if (trunkPos.contains(mutable) || foliagePos.contains(mutable) + || !state.hasProperty(BlockStateProperties.DISTANCE) + || (state.getValue(BlockStateProperties.DISTANCE)) <= tries + 1) + continue; + BlockState foliage + = state.setValue(BlockStateProperties.DISTANCE, tries + 1); TreeFeatureAccessor.setBlockKnownShape(level, mutable, foliage); - if (box.isInside(mutable)) (shape).fill(mutable.getX() - box.minX(), mutable.getY() - box.minY(), mutable.getZ() - box.minZ()); + if (box.isInside(mutable)) + (shape).fill( + mutable.getX() - box.minX(), + mutable.getY() - box.minY(), + mutable.getZ() - box.minZ() + ); foliagePos.add(mutable.immutable()); } } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/SculkGrowthFeature.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/SculkGrowthFeature.java index d79aff8..0a4d937 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/SculkGrowthFeature.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/SculkGrowthFeature.java @@ -1,5 +1,10 @@ package com.cursedcauldron.wildbackport.common.worldgen.features; +import java.util.Collections; +import java.util.List; +import java.util.Random; +import java.util.stream.Collectors; + import com.cursedcauldron.wildbackport.common.blocks.SculkVeinBlock; import com.cursedcauldron.wildbackport.common.registry.WBBlocks; import com.google.common.collect.Lists; @@ -13,11 +18,6 @@ import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; import net.minecraft.world.level.levelgen.feature.configurations.GlowLichenConfiguration; -import java.util.Collections; -import java.util.List; -import java.util.Random; -import java.util.stream.Collectors; - public class SculkGrowthFeature extends Feature { public SculkGrowthFeature(Codec codec) { super(codec); @@ -31,23 +31,30 @@ public class SculkGrowthFeature extends Feature { GlowLichenConfiguration config = context.config(); if (!isNotAirOrWater(level.getBlockState(pos))) { List directions = getShuffledDirections(config, random); - if (placeGrowthIfPossible(level, pos, level.getBlockState(pos), config, random, directions)) { + if (placeGrowthIfPossible( + level, pos, level.getBlockState(pos), config, random, directions + )) { return true; } else { BlockPos.MutableBlockPos mutable = pos.mutable(); for (Direction direction : directions) { mutable.set(pos); - List filteredDirections = getShuffledDirectionsExcept(config, random, direction.getOpposite()); + List filteredDirections = getShuffledDirectionsExcept( + config, random, direction.getOpposite() + ); for (int i = 0; i < config.searchRange; i++) { mutable.setWithOffset(pos, direction); BlockState state = level.getBlockState(mutable); - if (isNotAirOrWater(state) && !state.is(WBBlocks.SCULK_VEIN.get())) { + if (isNotAirOrWater(state) + && !state.is(WBBlocks.SCULK_VEIN.get())) { break; } - if (placeGrowthIfPossible(level, mutable, state, config, random, filteredDirections)) { + if (placeGrowthIfPossible( + level, mutable, state, config, random, filteredDirections + )) { return true; } } @@ -58,14 +65,23 @@ public class SculkGrowthFeature extends Feature { return false; } - public static boolean placeGrowthIfPossible(WorldGenLevel level, BlockPos pos, BlockState state, GlowLichenConfiguration config, Random random, List directions) { + public static boolean placeGrowthIfPossible( + WorldGenLevel level, + BlockPos pos, + BlockState state, + GlowLichenConfiguration config, + Random random, + List directions + ) { BlockPos.MutableBlockPos mutable = pos.mutable(); for (Direction direction : directions) { - BlockState blockState = level.getBlockState(mutable.setWithOffset(pos, direction)); + BlockState blockState + = level.getBlockState(mutable.setWithOffset(pos, direction)); if (blockState.is(config.canBePlacedOn)) { SculkVeinBlock veinBlock = (SculkVeinBlock) WBBlocks.SCULK_VEIN.get(); - BlockState veinState = veinBlock.getStateForPlacement(state, level, pos, direction); + BlockState veinState + = veinBlock.getStateForPlacement(state, level, pos, direction); if (veinState == null) { return false; } @@ -73,7 +89,9 @@ public class SculkGrowthFeature extends Feature { level.setBlock(pos, veinState, 3); level.getChunk(pos).markPosForPostprocessing(pos); if (random.nextFloat() < config.chanceOfSpreading) { - veinBlock.allGrowTypeGrower.grow(veinState, level, pos, direction, random, true); + veinBlock.allGrowTypeGrower.grow( + veinState, level, pos, direction, random, true + ); } return true; @@ -83,14 +101,19 @@ public class SculkGrowthFeature extends Feature { return false; } - public static List getShuffledDirections(GlowLichenConfiguration config, Random random) { + public static List + getShuffledDirections(GlowLichenConfiguration config, Random random) { List list = Lists.newArrayList(config.validDirections); Collections.shuffle(list, random); return list; } - public static List getShuffledDirectionsExcept(GlowLichenConfiguration config, Random random, Direction except) { - List list = config.validDirections.stream().filter(direction -> direction != except).collect(Collectors.toList()); + public static List getShuffledDirectionsExcept( + GlowLichenConfiguration config, Random random, Direction except + ) { + List list = config.validDirections.stream() + .filter(direction -> direction != except) + .collect(Collectors.toList()); Collections.shuffle(list, random); return list; } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/SculkPatchConfiguration.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/SculkPatchConfiguration.java index 5a268d7..4303c2f 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/SculkPatchConfiguration.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/SculkPatchConfiguration.java @@ -5,22 +5,42 @@ import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.util.valueproviders.IntProvider; import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; -public record SculkPatchConfiguration(int chargeCount, int amountPerCharge, int spreadAttempts, int growthRounds, int spreadRounds, IntProvider extraRareGrowths, float catalystChance) implements FeatureConfiguration { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> { - return instance.group(Codec.intRange(1, 32).fieldOf("charge_count").forGetter(config -> { - return config.chargeCount; - }), Codec.intRange(1, 500).fieldOf("amount_per_charge").forGetter(config -> { - return config.amountPerCharge; - }), Codec.intRange(1, 64).fieldOf("spread_attempts").forGetter(config -> { - return config.spreadAttempts; - }), Codec.intRange(0, 8).fieldOf("growth_rounds").forGetter(config -> { - return config.growthRounds; - }), Codec.intRange(0, 8).fieldOf("spread_rounds").forGetter(config -> { - return config.spreadRounds; - }), IntProvider.CODEC.fieldOf("extra_rare_growths").forGetter(config -> { - return config.extraRareGrowths; - }), Codec.floatRange(0.0F, 1.0F).fieldOf("catalyst_chance").forGetter(config -> { - return config.catalystChance; - })).apply(instance, SculkPatchConfiguration::new); - }); +public record SculkPatchConfiguration( + int chargeCount, + int amountPerCharge, + int spreadAttempts, + int growthRounds, + int spreadRounds, + IntProvider extraRareGrowths, + float catalystChance +) implements FeatureConfiguration { + public static final Codec CODEC = RecordCodecBuilder.create( + instance -> { + return instance + .group( + Codec.intRange(1, 32).fieldOf("charge_count").forGetter(config -> { + return config.chargeCount; + }), + Codec.intRange(1, 500) + .fieldOf("amount_per_charge") + .forGetter(config -> { return config.amountPerCharge; }), + Codec.intRange(1, 64).fieldOf("spread_attempts").forGetter(config -> { + return config.spreadAttempts; + }), + Codec.intRange(0, 8).fieldOf("growth_rounds").forGetter(config -> { + return config.growthRounds; + }), + Codec.intRange(0, 8).fieldOf("spread_rounds").forGetter(config -> { + return config.spreadRounds; + }), + IntProvider.CODEC.fieldOf("extra_rare_growths").forGetter(config -> { + return config.extraRareGrowths; + }), + Codec.floatRange(0.0F, 1.0F) + .fieldOf("catalyst_chance") + .forGetter(config -> { return config.catalystChance; }) + ) + .apply(instance, SculkPatchConfiguration::new); + } + ); } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/SculkPatchFeature.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/SculkPatchFeature.java index ae8a184..9f28890 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/SculkPatchFeature.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/features/SculkPatchFeature.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.worldgen.features; +import java.util.Random; + import com.cursedcauldron.wildbackport.common.blocks.SculkShriekerBlock; import com.cursedcauldron.wildbackport.common.blocks.SculkSpreadManager; import com.cursedcauldron.wildbackport.common.blocks.SculkSpreadable; @@ -15,8 +17,6 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; -import java.util.Random; - //<> public class SculkPatchFeature extends Feature { @@ -51,16 +51,27 @@ public class SculkPatchFeature extends Feature { } BlockPos catalystPos = pos.below(); - if (random.nextFloat() <= config.catalystChance() && level.getBlockState(catalystPos).isCollisionShapeFullBlock(level, catalystPos)) { + if (random.nextFloat() <= config.catalystChance() + && level.getBlockState(catalystPos) + .isCollisionShapeFullBlock(level, catalystPos)) { level.setBlock(pos, WBBlocks.SCULK_CATALYST.get().defaultBlockState(), 3); } int extraRareGrowths = config.extraRareGrowths().sample(random); for (int i = 0; i < extraRareGrowths; i++) { - BlockPos shriekPos = pos.offset(random.nextInt(5) - 2, 0, random.nextInt(5) - 2); - if (level.getBlockState(shriekPos).isAir() && level.getBlockState(shriekPos.below()).isFaceSturdy(level, shriekPos.below(), Direction.UP)) { - level.setBlock(shriekPos, WBBlocks.SCULK_SHRIEKER.get().defaultBlockState().setValue(SculkShriekerBlock.CAN_SUMMON, true), 3); + BlockPos shriekPos + = pos.offset(random.nextInt(5) - 2, 0, random.nextInt(5) - 2); + if (level.getBlockState(shriekPos).isAir() + && level.getBlockState(shriekPos.below()) + .isFaceSturdy(level, shriekPos.below(), Direction.UP)) { + level.setBlock( + shriekPos, + WBBlocks.SCULK_SHRIEKER.get().defaultBlockState().setValue( + SculkShriekerBlock.CAN_SUMMON, true + ), + 3 + ); } } @@ -73,9 +84,13 @@ public class SculkPatchFeature extends Feature { if (state.getBlock() instanceof SculkSpreadable) { return true; } else { - return (state.isAir() || (state.is(Blocks.WATER) && state.getFluidState().isSource())) && DirectionUtils.stream().map(pos::relative).anyMatch(position -> { - return level.getBlockState(position).isCollisionShapeFullBlock(level, position); - }); + return (state.isAir() + || (state.is(Blocks.WATER) && state.getFluidState().isSource())) + && DirectionUtils.stream().map(pos::relative).anyMatch(position -> { + return level.getBlockState(position).isCollisionShapeFullBlock( + level, position + ); + }); } } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/placers/MangroveRootPlacer.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/placers/MangroveRootPlacer.java index eedc21b..8cf37fe 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/placers/MangroveRootPlacer.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/placers/MangroveRootPlacer.java @@ -1,5 +1,11 @@ package com.cursedcauldron.wildbackport.common.worldgen.placers; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.Random; +import java.util.function.BiConsumer; + import com.cursedcauldron.wildbackport.common.registry.worldgen.RootPlacerType; import com.cursedcauldron.wildbackport.common.worldgen.decorator.AboveRootPlacement; import com.cursedcauldron.wildbackport.common.worldgen.decorator.MangroveRootPlacement; @@ -14,58 +20,89 @@ import net.minecraft.world.level.LevelSimulatedReader; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.Random; -import java.util.function.BiConsumer; - public class MangroveRootPlacer extends RootPlacer { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> { - return codec(instance).and(MangroveRootPlacement.CODEC.fieldOf("mangrove_root_placement").forGetter(placer -> { - return placer.mangroveRootPlacement; - })).apply(instance, MangroveRootPlacer::new); - }); + public static final Codec CODEC + = RecordCodecBuilder.create(instance -> { + return codec(instance) + .and(MangroveRootPlacement.CODEC.fieldOf("mangrove_root_placement") + .forGetter(placer -> { return placer.mangroveRootPlacement; })) + .apply(instance, MangroveRootPlacer::new); + }); private final MangroveRootPlacement mangroveRootPlacement; - public MangroveRootPlacer(IntProvider trunkOffsetY, BlockStateProvider rootProvider, Optional aboveRootPlacement, MangroveRootPlacement mangroveRootPlacement) { + public MangroveRootPlacer( + IntProvider trunkOffsetY, + BlockStateProvider rootProvider, + Optional aboveRootPlacement, + MangroveRootPlacement mangroveRootPlacement + ) { super(trunkOffsetY, rootProvider, aboveRootPlacement); this.mangroveRootPlacement = mangroveRootPlacement; } @Override - public boolean generate(LevelSimulatedReader level, BiConsumer replacer, Random random, BlockPos pos, BlockPos origin, RootedTreeConfig config) { + public boolean generate( + LevelSimulatedReader level, + BiConsumer replacer, + Random random, + BlockPos pos, + BlockPos origin, + RootedTreeConfig config + ) { ArrayList positions = Lists.newArrayList(); BlockPos.MutableBlockPos mutable = pos.mutable(); - while(mutable.getY() < origin.getY()) { - if (!this.canGrowThrough(level, mutable)) return false; + while (mutable.getY() < origin.getY()) { + if (!this.canGrowThrough(level, mutable)) + return false; mutable.move(Direction.UP); } positions.add(origin.below()); - for(Direction direction : Direction.Plane.HORIZONTAL) { + for (Direction direction : Direction.Plane.HORIZONTAL) { BlockPos position = origin.relative(direction); ArrayList offshootPositions = Lists.newArrayList(); - if (!this.canGrow(level, random, position, direction, origin, offshootPositions, 0)) return false; + if (!this.canGrow( + level, random, position, direction, origin, offshootPositions, 0 + )) + return false; positions.addAll(offshootPositions); positions.add(origin.relative(direction)); } - for(BlockPos position : positions) this.placeRoots(level, replacer, random, position, config); + for (BlockPos position : positions) + this.placeRoots(level, replacer, random, position, config); return true; } - private boolean canGrow(LevelSimulatedReader level, Random random, BlockPos pos, Direction direction, BlockPos origin, List offshootPositions, int rootLength) { + private boolean canGrow( + LevelSimulatedReader level, + Random random, + BlockPos pos, + Direction direction, + BlockPos origin, + List offshootPositions, + int rootLength + ) { int length = this.mangroveRootPlacement.maxRootLength(); if (rootLength != length && offshootPositions.size() <= length) { - for(BlockPos position : this.getOffshootPositions(pos, direction, random, origin)) { + for (BlockPos position : + this.getOffshootPositions(pos, direction, random, origin)) { if (this.canGrowThrough(level, position)) { offshootPositions.add(position); - if (!this.canGrow(level, random, position, direction, origin, offshootPositions, rootLength + 1)) return false; + if (!this.canGrow( + level, + random, + position, + direction, + origin, + offshootPositions, + rootLength + 1 + )) + return false; } } @@ -75,14 +112,17 @@ public class MangroveRootPlacer extends RootPlacer { } } - protected List getOffshootPositions(BlockPos pos, Direction direction, Random random, BlockPos origin) { + protected List getOffshootPositions( + BlockPos pos, Direction direction, Random random, BlockPos origin + ) { BlockPos below = pos.below(); BlockPos offset = pos.relative(direction); int distance = pos.distManhattan(origin); int rootWidth = this.mangroveRootPlacement.maxRootWidth(); float chance = this.mangroveRootPlacement.randomSkewChance(); if (distance > rootWidth - 3 && distance <= rootWidth) { - return random.nextFloat() < chance ? List.of(below, offset.below()) : List.of(below); + return random.nextFloat() < chance ? List.of(below, offset.below()) + : List.of(below); } else if (distance > rootWidth) { return List.of(below); } else if (random.nextFloat() < chance) { @@ -94,13 +134,25 @@ public class MangroveRootPlacer extends RootPlacer { @Override protected boolean canGrowThrough(LevelSimulatedReader level, BlockPos pos) { - return super.canGrowThrough(level, pos) || level.isStateAtPosition(pos, state -> state.is(this.mangroveRootPlacement.canGrowThrough())); + return super.canGrowThrough(level, pos) + || level.isStateAtPosition( + pos, state -> state.is(this.mangroveRootPlacement.canGrowThrough()) + ); } @Override - protected void placeRoots(LevelSimulatedReader level, BiConsumer replacer, Random random, BlockPos pos, RootedTreeConfig config) { - if (level.isStateAtPosition(pos, state -> state.is(this.mangroveRootPlacement.muddyRootsIn()))) { - BlockState state = this.mangroveRootPlacement.muddyRootsProvider().getState(random, pos); + protected void placeRoots( + LevelSimulatedReader level, + BiConsumer replacer, + Random random, + BlockPos pos, + RootedTreeConfig config + ) { + if (level.isStateAtPosition( + pos, state -> state.is(this.mangroveRootPlacement.muddyRootsIn()) + )) { + BlockState state + = this.mangroveRootPlacement.muddyRootsProvider().getState(random, pos); replacer.accept(pos, this.applyWaterlogging(level, pos, state)); } else { super.placeRoots(level, replacer, random, pos, config); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/placers/RootPlacer.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/placers/RootPlacer.java index dc07aec..61fe264 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/placers/RootPlacer.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/placers/RootPlacer.java @@ -1,7 +1,11 @@ package com.cursedcauldron.wildbackport.common.worldgen.placers; -import com.cursedcauldron.wildbackport.common.registry.worldgen.RootPlacerType; +import java.util.Optional; +import java.util.Random; +import java.util.function.BiConsumer; + import com.cursedcauldron.wildbackport.common.registry.WBRegistries; +import com.cursedcauldron.wildbackport.common.registry.worldgen.RootPlacerType; import com.cursedcauldron.wildbackport.common.worldgen.decorator.AboveRootPlacement; import com.cursedcauldron.wildbackport.common.worldgen.features.RootedTreeConfig; import com.mojang.datafixers.Products; @@ -17,27 +21,38 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.levelgen.feature.TreeFeature; import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider; -import java.util.Optional; -import java.util.Random; -import java.util.function.BiConsumer; - public abstract class RootPlacer { - public static final Codec CODEC = WBRegistries.ROOT_PLACER_TYPES.registry().byNameCodec().dispatch(RootPlacer::getType, RootPlacerType::codec); + public static final Codec CODEC + = WBRegistries.ROOT_PLACER_TYPES.registry().byNameCodec().dispatch( + RootPlacer::getType, RootPlacerType::codec + ); protected final IntProvider trunkOffsetY; protected final BlockStateProvider rootProvider; protected final Optional aboveRootPlacement; - protected static

Products.P3, IntProvider, BlockStateProvider, Optional> codec(RecordCodecBuilder.Instance

instance) { - return instance.group(IntProvider.CODEC.fieldOf("trunk_offset_y").forGetter(placer -> { - return placer.trunkOffsetY; - }), BlockStateProvider.CODEC.fieldOf("root_provider").forGetter(placer -> { - return placer.rootProvider; - }), AboveRootPlacement.CODEC.optionalFieldOf("above_root_placement").forGetter(placer -> { - return placer.aboveRootPlacement; - })); + protected static

Products + .P3, + IntProvider, + BlockStateProvider, + Optional> + codec(RecordCodecBuilder.Instance

instance) { + return instance.group( + IntProvider.CODEC.fieldOf("trunk_offset_y").forGetter(placer -> { + return placer.trunkOffsetY; + }), + BlockStateProvider.CODEC.fieldOf("root_provider").forGetter(placer -> { + return placer.rootProvider; + }), + AboveRootPlacement.CODEC.optionalFieldOf("above_root_placement") + .forGetter(placer -> { return placer.aboveRootPlacement; }) + ); } - public RootPlacer(IntProvider trunkOffsetY, BlockStateProvider rootProvider, Optional aboveRootPlacement) { + public RootPlacer( + IntProvider trunkOffsetY, + BlockStateProvider rootProvider, + Optional aboveRootPlacement + ) { this.trunkOffsetY = trunkOffsetY; this.rootProvider = rootProvider; this.aboveRootPlacement = aboveRootPlacement; @@ -45,27 +60,60 @@ public abstract class RootPlacer { protected abstract RootPlacerType getType(); - public abstract boolean generate(LevelSimulatedReader level, BiConsumer replacer, Random random, BlockPos pos, BlockPos origin, RootedTreeConfig config); + public abstract boolean generate( + LevelSimulatedReader level, + BiConsumer replacer, + Random random, + BlockPos pos, + BlockPos origin, + RootedTreeConfig config + ); protected boolean canGrowThrough(LevelSimulatedReader level, BlockPos pos) { return TreeFeature.validTreePos(level, pos); } - protected void placeRoots(LevelSimulatedReader level, BiConsumer replacer, Random random, BlockPos pos, RootedTreeConfig config) { + protected void placeRoots( + LevelSimulatedReader level, + BiConsumer replacer, + Random random, + BlockPos pos, + RootedTreeConfig config + ) { if (this.canGrowThrough(level, pos)) { - replacer.accept(pos, this.applyWaterlogging(level, pos, this.rootProvider.getState(random, pos))); + replacer.accept( + pos, + this.applyWaterlogging( + level, pos, this.rootProvider.getState(random, pos) + ) + ); if (this.aboveRootPlacement.isPresent()) { AboveRootPlacement placement = this.aboveRootPlacement.get(); BlockPos above = pos.above(); - if (random.nextFloat() < placement.aboveRootPlacementChance() && level.isStateAtPosition(above, BlockBehaviour.BlockStateBase::isAir)) { - replacer.accept(above, this.applyWaterlogging(level, above, placement.aboveRootProvider().getState(random, above))); + if (random.nextFloat() < placement.aboveRootPlacementChance() + && level.isStateAtPosition( + above, BlockBehaviour.BlockStateBase::isAir + )) { + replacer.accept( + above, + this.applyWaterlogging( + level, + above, + placement.aboveRootProvider().getState(random, above) + ) + ); } } } } - protected BlockState applyWaterlogging(LevelSimulatedReader level, BlockPos pos, BlockState state) { - return state.hasProperty(BlockStateProperties.WATERLOGGED) ? state.setValue(BlockStateProperties.WATERLOGGED, level.isFluidAtPosition(pos, fluid -> fluid.is(FluidTags.WATER))) : state; + protected BlockState + applyWaterlogging(LevelSimulatedReader level, BlockPos pos, BlockState state) { + return state.hasProperty(BlockStateProperties.WATERLOGGED) ? state.setValue( + BlockStateProperties.WATERLOGGED, + level.isFluidAtPosition(pos, fluid -> fluid.is(FluidTags.WATER)) + ) + : state; } public BlockPos trunkOffset(BlockPos pos, Random random) { diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/placers/UpwardBranchingTrunk.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/placers/UpwardBranchingTrunk.java index e8b7ee0..5e34bbf 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/placers/UpwardBranchingTrunk.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/placers/UpwardBranchingTrunk.java @@ -1,5 +1,9 @@ package com.cursedcauldron.wildbackport.common.worldgen.placers; +import java.util.List; +import java.util.Random; +import java.util.function.BiConsumer; + import com.cursedcauldron.wildbackport.common.registry.worldgen.WBTrunkPlacers; import com.google.common.collect.Lists; import com.mojang.serialization.Codec; @@ -18,30 +22,42 @@ import net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacer; import net.minecraft.world.level.levelgen.feature.trunkplacers.TrunkPlacer; import net.minecraft.world.level.levelgen.feature.trunkplacers.TrunkPlacerType; -import java.util.List; -import java.util.Random; -import java.util.function.BiConsumer; - //<> public class UpwardBranchingTrunk extends TrunkPlacer { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> { - return trunkPlacerParts(instance).and(instance.group(IntProvider.POSITIVE_CODEC.fieldOf("extra_branch_steps").forGetter(placer -> { - return placer.extraBranchSteps; - }), Codec.floatRange(0.0F, 1.0F).fieldOf("place_branch_per_log_probability").forGetter(placer -> { - return placer.placeBranchPerLogProbability; - }), IntProvider.NON_NEGATIVE_CODEC.fieldOf("extra_branch_length").forGetter(placer -> { - return placer.extraBranchLength; - }), RegistryCodecs.homogeneousList(Registry.BLOCK_REGISTRY).fieldOf("can_grow_through").forGetter(placer -> { - return placer.canGrowThrough; - }))).apply(instance, UpwardBranchingTrunk::new); - }); + public static final Codec CODEC + = RecordCodecBuilder.create(instance -> { + return trunkPlacerParts(instance) + .and(instance.group( + IntProvider.POSITIVE_CODEC.fieldOf("extra_branch_steps") + .forGetter(placer -> { return placer.extraBranchSteps; }), + Codec.floatRange(0.0F, 1.0F) + .fieldOf("place_branch_per_log_probability") + .forGetter(placer -> { + return placer.placeBranchPerLogProbability; + }), + IntProvider.NON_NEGATIVE_CODEC.fieldOf("extra_branch_length") + .forGetter(placer -> { return placer.extraBranchLength; }), + RegistryCodecs.homogeneousList(Registry.BLOCK_REGISTRY) + .fieldOf("can_grow_through") + .forGetter(placer -> { return placer.canGrowThrough; }) + )) + .apply(instance, UpwardBranchingTrunk::new); + }); private final IntProvider extraBranchSteps; private final float placeBranchPerLogProbability; private final IntProvider extraBranchLength; public final HolderSet canGrowThrough; - public UpwardBranchingTrunk(int baseHeight, int firstRandomHeight, int secondRandomHeight, IntProvider extraBranchSteps, float placeBranchPerLogProbability, IntProvider extraBranchLength, HolderSet canGrowThrough) { + public UpwardBranchingTrunk( + int baseHeight, + int firstRandomHeight, + int secondRandomHeight, + IntProvider extraBranchSteps, + float placeBranchPerLogProbability, + IntProvider extraBranchLength, + HolderSet canGrowThrough + ) { super(baseHeight, firstRandomHeight, secondRandomHeight); this.extraBranchSteps = extraBranchSteps; this.placeBranchPerLogProbability = placeBranchPerLogProbability; @@ -49,40 +65,87 @@ public class UpwardBranchingTrunk extends TrunkPlacer { this.canGrowThrough = canGrowThrough; } - public List placeTrunk(LevelSimulatedReader level, BiConsumer replacer, Random random, int height, BlockPos startPos, TreeConfiguration config) { + public List placeTrunk( + LevelSimulatedReader level, + BiConsumer replacer, + Random random, + int height, + BlockPos startPos, + TreeConfiguration config + ) { List attachments = Lists.newArrayList(); BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos(); - for(int i = 0; i < height; ++i) { + for (int i = 0; i < height; ++i) { int yOffset = startPos.getY() + i; - if (placeLog(level, replacer, random, mutable.set(startPos.getX(), yOffset, startPos.getZ()), config) && i < height - 1 && random.nextFloat() < this.placeBranchPerLogProbability) { - Direction direction = Direction.Plane.HORIZONTAL.getRandomDirection(random); + if (placeLog( + level, + replacer, + random, + mutable.set(startPos.getX(), yOffset, startPos.getZ()), + config + ) + && i < height - 1 + && random.nextFloat() < this.placeBranchPerLogProbability) { + Direction direction + = Direction.Plane.HORIZONTAL.getRandomDirection(random); int offset = this.extraBranchLength.sample(random); - int length = Math.max(0, offset - this.extraBranchLength.sample(random) - 1); + int length + = Math.max(0, offset - this.extraBranchLength.sample(random) - 1); int steps = this.extraBranchSteps.sample(random); - this.placeBranch(level, replacer, random, height, config, attachments, mutable, yOffset, direction, length, steps); + this.placeBranch( + level, + replacer, + random, + height, + config, + attachments, + mutable, + yOffset, + direction, + length, + steps + ); } - if (i == height - 1) attachments.add(new FoliagePlacer.FoliageAttachment(mutable.set(startPos.getX(), yOffset + 1, startPos.getZ()), 0, false)); + if (i == height - 1) + attachments.add(new FoliagePlacer.FoliageAttachment( + mutable.set(startPos.getX(), yOffset + 1, startPos.getZ()), 0, false + )); } return attachments; } - private void placeBranch(LevelSimulatedReader level, BiConsumer replacer, Random random, int height, TreeConfiguration config, List attachments, BlockPos.MutableBlockPos mutable, int yOffset, Direction direction, int length, int steps) { + private void placeBranch( + LevelSimulatedReader level, + BiConsumer replacer, + Random random, + int height, + TreeConfiguration config, + List attachments, + BlockPos.MutableBlockPos mutable, + int yOffset, + Direction direction, + int length, + int steps + ) { int y = yOffset + length; int x = mutable.getX(); int z = mutable.getZ(); - for(int l = length; l < height && steps > 0; --steps) { + for (int l = length; l < height && steps > 0; --steps) { if (l >= 1) { int offset = yOffset + l; x += direction.getStepX(); z += direction.getStepZ(); y = offset; - if (placeLog(level, replacer, random, mutable.set(x, offset, z), config)) y = offset + 1; + if (placeLog(level, replacer, random, mutable.set(x, offset, z), config)) + y = offset + 1; - attachments.add(new FoliagePlacer.FoliageAttachment(mutable.immutable(), 0, false)); + attachments.add( + new FoliagePlacer.FoliageAttachment(mutable.immutable(), 0, false) + ); } ++l; diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/AncientCityStructurePieces.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/AncientCityStructurePieces.java index 935216a..864e177 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/AncientCityStructurePieces.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/AncientCityStructurePieces.java @@ -12,7 +12,35 @@ import net.minecraft.world.level.levelgen.structure.pools.StructurePoolElement; import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool; public class AncientCityStructurePieces { - public static final Holder START = Pools.register(new StructureTemplatePool(new ResourceLocation("ancient_city/city_center"), new ResourceLocation("empty"), ImmutableList.of(Pair.of(StructurePoolElement.single("ancient_city/city_center/city_center_1", WBProcessorLists.ANCIENT_CITY_START_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city_center/city_center_2", WBProcessorLists.ANCIENT_CITY_START_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city_center/city_center_3", WBProcessorLists.ANCIENT_CITY_START_DEGRADATION), 1)), StructureTemplatePool.Projection.RIGID)); + public static final Holder START + = Pools.register(new StructureTemplatePool( + new ResourceLocation("ancient_city/city_center"), + new ResourceLocation("empty"), + ImmutableList.of( + Pair.of( + StructurePoolElement.single( + "ancient_city/city_center/city_center_1", + WBProcessorLists.ANCIENT_CITY_START_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/city_center/city_center_2", + WBProcessorLists.ANCIENT_CITY_START_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/city_center/city_center_3", + WBProcessorLists.ANCIENT_CITY_START_DEGRADATION + ), + 1 + ) + ), + StructureTemplatePool.Projection.RIGID + )); public static void bootstrap() { AncientCityStructurePools.bootstrap(); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/StructureGeneration.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/StructureGeneration.java index d956f28..10f8f32 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/StructureGeneration.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/StructureGeneration.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.worldgen.structure; +import java.util.List; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.core.mixin.access.StructureTemplatePoolAccessor; import com.mojang.datafixers.util.Pair; @@ -10,26 +12,36 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.levelgen.structure.pools.StructurePoolElement; import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool; -import java.util.List; - //<> public class StructureGeneration { public static void registerAllayCages() { PillagerOutpostPools.bootstrap(); - StructureGeneration.addToPool(new ResourceLocation("pillager_outpost/features"), new ResourceLocation("pillager_outpost/feature_cage_with_allays"), 1); + StructureGeneration.addToPool( + new ResourceLocation("pillager_outpost/features"), + new ResourceLocation("pillager_outpost/feature_cage_with_allays"), + 1 + ); } - private static void addToPool(ResourceLocation poolId, ResourceLocation pieceId, int weight) { + private static void + addToPool(ResourceLocation poolId, ResourceLocation pieceId, int weight) { StructureTemplatePool pool = BuiltinRegistries.TEMPLATE_POOL.get(poolId); - if (pool == null) return; + if (pool == null) + return; - StructurePoolElement piece = StructurePoolElement.legacy(pieceId.toString(), ProcessorLists.EMPTY).apply(StructureTemplatePool.Projection.RIGID); - List templates = ((StructureTemplatePoolAccessor)pool).getTemplates(); - List> rawTemplates = ((StructureTemplatePoolAccessor)pool).getRawTemplates(); - if (templates == null || rawTemplates == null) return; + StructurePoolElement piece + = StructurePoolElement.legacy(pieceId.toString(), ProcessorLists.EMPTY) + .apply(StructureTemplatePool.Projection.RIGID); + List templates + = ((StructureTemplatePoolAccessor) pool).getTemplates(); + List> rawTemplates + = ((StructureTemplatePoolAccessor) pool).getRawTemplates(); + if (templates == null || rawTemplates == null) + return; - for (int i = 0; i < weight; i++) templates.add(piece); + for (int i = 0; i < weight; i++) + templates.add(piece); rawTemplates.add(Pair.of(piece, weight)); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/pools/AncientCityStructurePools.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/pools/AncientCityStructurePools.java index 788493b..d2cf1a8 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/pools/AncientCityStructurePools.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/pools/AncientCityStructurePools.java @@ -12,11 +12,476 @@ import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool; public class AncientCityStructurePools { public static void bootstrap() { - Pools.register(new StructureTemplatePool(new ResourceLocation("ancient_city/structures"), new ResourceLocation("empty"), ImmutableList.of(Pair.of(StructurePoolElement.empty(), 7), Pair.of(StructurePoolElement.single("ancient_city/structures/barracks", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 4), Pair.of(StructurePoolElement.single("ancient_city/structures/chamber_1", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 4), Pair.of(StructurePoolElement.single("ancient_city/structures/chamber_2", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 4), Pair.of(StructurePoolElement.single("ancient_city/structures/chamber_3", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 4), Pair.of(StructurePoolElement.single("ancient_city/structures/sauna_1", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 4), Pair.of(StructurePoolElement.single("ancient_city/structures/small_statue", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 4), Pair.of(StructurePoolElement.single("ancient_city/structures/large_ruin_1", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/structures/tall_ruin_1", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/structures/tall_ruin_2", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/structures/tall_ruin_3", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 2), Pair.of(StructurePoolElement.single("ancient_city/structures/tall_ruin_4", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 2), Pair.of(StructurePoolElement.list(ImmutableList.of(StructurePoolElement.single("ancient_city/structures/camp_1", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), StructurePoolElement.single("ancient_city/structures/camp_2", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), StructurePoolElement.single("ancient_city/structures/camp_3", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION))), 1), Pair.of(StructurePoolElement.single("ancient_city/structures/medium_ruin_1", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/structures/medium_ruin_2", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/structures/small_ruin_1", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/structures/small_ruin_2", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/structures/large_pillar_1", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/structures/medium_pillar_1", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.list(ImmutableList.of(StructurePoolElement.single("ancient_city/structures/ice_box_1"))), 1)), StructureTemplatePool.Projection.RIGID)); - Pools.register(new StructureTemplatePool(new ResourceLocation("ancient_city/sculk"), new ResourceLocation("empty"), ImmutableList.of(Pair.of(StructurePoolElement.feature(WBWorldGeneration.SCULK_PATCH_ANCIENT_CITY_PLACED), 6), Pair.of(StructurePoolElement.empty(), 1)), StructureTemplatePool.Projection.RIGID)); - Pools.register(new StructureTemplatePool(new ResourceLocation("ancient_city/walls"), new ResourceLocation("empty"), ImmutableList.of(Pair.of(StructurePoolElement.single("ancient_city/walls/intact_corner_wall_1", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_intersection_wall_1", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_lshape_wall_1", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_1", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_2", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_stairs_1", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_stairs_2", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_stairs_3", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_stairs_4", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 4), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_passage_1", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 3), Pair.of(StructurePoolElement.single("ancient_city/walls/ruined_corner_wall_1", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/ruined_corner_wall_2", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/ruined_horizontal_wall_stairs_1", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 2), Pair.of(StructurePoolElement.single("ancient_city/walls/ruined_horizontal_wall_stairs_2", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 2), Pair.of(StructurePoolElement.single("ancient_city/walls/ruined_horizontal_wall_stairs_3", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 3), Pair.of(StructurePoolElement.single("ancient_city/walls/ruined_horizontal_wall_stairs_4", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 3)), StructureTemplatePool.Projection.RIGID)); - Pools.register(new StructureTemplatePool(new ResourceLocation("ancient_city/walls/no_corners"), new ResourceLocation("empty"), ImmutableList.of(Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_1", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_2", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_stairs_1", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_stairs_2", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_stairs_3", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_stairs_4", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_stairs_5", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/walls/intact_horizontal_wall_bridge", WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION), 1)), StructureTemplatePool.Projection.RIGID)); - Pools.register(new StructureTemplatePool(new ResourceLocation("ancient_city/city_center/walls"), new ResourceLocation("empty"), ImmutableList.of(Pair.of(StructurePoolElement.single("ancient_city/city_center/walls/bottom_1", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city_center/walls/bottom_2", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city_center/walls/bottom_left_corner", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city_center/walls/bottom_right_corner_1", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city_center/walls/bottom_right_corner_2", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city_center/walls/left", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city_center/walls/right", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city_center/walls/top", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city_center/walls/top_right_corner", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city_center/walls/top_left_corner", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1)), StructureTemplatePool.Projection.RIGID)); - Pools.register(new StructureTemplatePool(new ResourceLocation("ancient_city/city/entrance"), new ResourceLocation("empty"), ImmutableList.of(Pair.of(StructurePoolElement.single("ancient_city/city/entrance/entrance_connector", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city/entrance/entrance_path_1", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city/entrance/entrance_path_2", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city/entrance/entrance_path_3", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city/entrance/entrance_path_4", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1), Pair.of(StructurePoolElement.single("ancient_city/city/entrance/entrance_path_5", WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION), 1)), StructureTemplatePool.Projection.RIGID)); + Pools.register(new StructureTemplatePool( + new ResourceLocation("ancient_city/structures"), + new ResourceLocation("empty"), + ImmutableList.of( + Pair.of(StructurePoolElement.empty(), 7), + Pair.of( + StructurePoolElement.single( + "ancient_city/structures/barracks", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 4 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/structures/chamber_1", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 4 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/structures/chamber_2", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 4 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/structures/chamber_3", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 4 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/structures/sauna_1", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 4 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/structures/small_statue", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 4 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/structures/large_ruin_1", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/structures/tall_ruin_1", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/structures/tall_ruin_2", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/structures/tall_ruin_3", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 2 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/structures/tall_ruin_4", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 2 + ), + Pair.of( + StructurePoolElement.list(ImmutableList.of( + StructurePoolElement.single( + "ancient_city/structures/camp_1", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + StructurePoolElement.single( + "ancient_city/structures/camp_2", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + StructurePoolElement.single( + "ancient_city/structures/camp_3", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ) + )), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/structures/medium_ruin_1", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/structures/medium_ruin_2", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/structures/small_ruin_1", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/structures/small_ruin_2", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/structures/large_pillar_1", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/structures/medium_pillar_1", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.list(ImmutableList.of( + StructurePoolElement.single("ancient_city/structures/ice_box_1") + )), + 1 + ) + ), + StructureTemplatePool.Projection.RIGID + )); + Pools.register(new StructureTemplatePool( + new ResourceLocation("ancient_city/sculk"), + new ResourceLocation("empty"), + ImmutableList.of( + Pair.of( + StructurePoolElement + .feature(WBWorldGeneration.SCULK_PATCH_ANCIENT_CITY_PLACED), + 6 + ), + Pair.of(StructurePoolElement.empty(), 1) + ), + StructureTemplatePool.Projection.RIGID + )); + Pools.register(new StructureTemplatePool( + new ResourceLocation("ancient_city/walls"), + new ResourceLocation("empty"), + ImmutableList.of( + Pair.of( + StructurePoolElement.single( + "ancient_city/walls/intact_corner_wall_1", + WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/walls/intact_intersection_wall_1", + WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/walls/intact_lshape_wall_1", + WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/walls/intact_horizontal_wall_1", + WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/walls/intact_horizontal_wall_2", + WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/walls/intact_horizontal_wall_stairs_1", + WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/walls/intact_horizontal_wall_stairs_2", + WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/walls/intact_horizontal_wall_stairs_3", + WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/walls/intact_horizontal_wall_stairs_4", + WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION + ), + 4 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/walls/intact_horizontal_wall_passage_1", + WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION + ), + 3 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/walls/ruined_corner_wall_1", + WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/walls/ruined_corner_wall_2", + WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/walls/ruined_horizontal_wall_stairs_1", + WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION + ), + 2 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/walls/ruined_horizontal_wall_stairs_2", + WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION + ), + 2 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/walls/ruined_horizontal_wall_stairs_3", + WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION + ), + 3 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/walls/ruined_horizontal_wall_stairs_4", + WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION + ), + 3 + ) + ), + StructureTemplatePool.Projection.RIGID + )); + Pools.register(new StructureTemplatePool( + new ResourceLocation("ancient_city/walls/no_corners"), + new ResourceLocation("empty"), + ImmutableList.of( + Pair.of( + StructurePoolElement.single( + "ancient_city/walls/intact_horizontal_wall_1", + WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/walls/intact_horizontal_wall_2", + WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/walls/intact_horizontal_wall_stairs_1", + WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/walls/intact_horizontal_wall_stairs_2", + WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/walls/intact_horizontal_wall_stairs_3", + WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/walls/intact_horizontal_wall_stairs_4", + WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/walls/intact_horizontal_wall_stairs_5", + WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/walls/intact_horizontal_wall_bridge", + WBProcessorLists.ANCIENT_CITY_WALLS_DEGRADATION + ), + 1 + ) + ), + StructureTemplatePool.Projection.RIGID + )); + Pools.register(new StructureTemplatePool( + new ResourceLocation("ancient_city/city_center/walls"), + new ResourceLocation("empty"), + ImmutableList.of( + Pair.of( + StructurePoolElement.single( + "ancient_city/city_center/walls/bottom_1", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/city_center/walls/bottom_2", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/city_center/walls/bottom_left_corner", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/city_center/walls/bottom_right_corner_1", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/city_center/walls/bottom_right_corner_2", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/city_center/walls/left", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/city_center/walls/right", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/city_center/walls/top", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/city_center/walls/top_right_corner", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/city_center/walls/top_left_corner", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ) + ), + StructureTemplatePool.Projection.RIGID + )); + Pools.register(new StructureTemplatePool( + new ResourceLocation("ancient_city/city/entrance"), + new ResourceLocation("empty"), + ImmutableList.of( + Pair.of( + StructurePoolElement.single( + "ancient_city/city/entrance/entrance_connector", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/city/entrance/entrance_path_1", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/city/entrance/entrance_path_2", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/city/entrance/entrance_path_3", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/city/entrance/entrance_path_4", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ), + Pair.of( + StructurePoolElement.single( + "ancient_city/city/entrance/entrance_path_5", + WBProcessorLists.ANCIENT_CITY_GENERIC_DEGRADATION + ), + 1 + ) + ), + StructureTemplatePool.Projection.RIGID + )); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/processors/BlockTagRotProcessor.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/processors/BlockTagRotProcessor.java index 204a754..432e415 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/processors/BlockTagRotProcessor.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/processors/BlockTagRotProcessor.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.common.worldgen.structure.processors; +import java.util.Optional; + import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.core.BlockPos; @@ -16,17 +18,24 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProc import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; import org.jetbrains.annotations.Nullable; -import java.util.Optional; - public class BlockTagRotProcessor extends StructureProcessor { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> { - return instance.group(RegistryCodecs.homogeneousList(Registry.BLOCK_REGISTRY).optionalFieldOf("rottable_blocks").forGetter(processor -> { - return processor.rottableBlocks; - }), Codec.floatRange(0.0F, 1.0F).fieldOf("integrity").forGetter(processor -> { - return processor.integrity; - })).apply(instance, BlockTagRotProcessor::new); - }); - private static final StructureProcessorType BLOCK_TAG_ROT = Registry.register(Registry.STRUCTURE_PROCESSOR, new ResourceLocation("block_rot"), () -> CODEC); + public static final Codec CODEC + = RecordCodecBuilder.create(instance -> { + return instance + .group( + RegistryCodecs.homogeneousList(Registry.BLOCK_REGISTRY) + .optionalFieldOf("rottable_blocks") + .forGetter(processor -> { return processor.rottableBlocks; }), + Codec.floatRange(0.0F, 1.0F) + .fieldOf("integrity") + .forGetter(processor -> { return processor.integrity; }) + ) + .apply(instance, BlockTagRotProcessor::new); + }); + private static final StructureProcessorType BLOCK_TAG_ROT + = Registry.register( + Registry.STRUCTURE_PROCESSOR, new ResourceLocation("block_rot"), () -> CODEC + ); private final Optional> rottableBlocks; private final float integrity; @@ -34,14 +43,27 @@ public class BlockTagRotProcessor extends StructureProcessor { this(Optional.of(Registry.BLOCK.getOrCreateTag(rottableBlocks)), integrity); } - public BlockTagRotProcessor(Optional> rottableBlocks, float integrity) { + public BlockTagRotProcessor( + Optional> rottableBlocks, float integrity + ) { this.rottableBlocks = rottableBlocks; this.integrity = integrity; } - @Override @Nullable - public StructureTemplate.StructureBlockInfo processBlock(LevelReader level, BlockPos from, BlockPos to, StructureTemplate.StructureBlockInfo pre, StructureTemplate.StructureBlockInfo post, StructurePlaceSettings settings) { - return (this.rottableBlocks.isEmpty() || pre.state.is(this.rottableBlocks.get())) && !(settings.getRandom(post.pos).nextFloat() <= this.integrity) ? null : post; + @Override + @Nullable + public StructureTemplate.StructureBlockInfo processBlock( + LevelReader level, + BlockPos from, + BlockPos to, + StructureTemplate.StructureBlockInfo pre, + StructureTemplate.StructureBlockInfo post, + StructurePlaceSettings settings + ) { + return (this.rottableBlocks.isEmpty() || pre.state.is(this.rottableBlocks.get())) + && !(settings.getRandom(post.pos).nextFloat() <= this.integrity) + ? null + : post; } @Override diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/processors/WBProcessorLists.java b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/processors/WBProcessorLists.java index c247868..8daf5d9 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/processors/WBProcessorLists.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/common/worldgen/structure/processors/WBProcessorLists.java @@ -17,13 +17,94 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProc import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorList; public class WBProcessorLists { - public static final Holder ANCIENT_CITY_START_DEGRADATION = create("ancient_city_start_degradation", ImmutableList.of(new RuleProcessor(ImmutableList.of(new ProcessorRule(new RandomBlockMatchTest(Blocks.DEEPSLATE_BRICKS, 0.3F), AlwaysTrueTest.INSTANCE, Blocks.CRACKED_DEEPSLATE_BRICKS.defaultBlockState()), new ProcessorRule(new RandomBlockMatchTest(Blocks.DEEPSLATE_TILES, 0.3F), AlwaysTrueTest.INSTANCE, Blocks.CRACKED_DEEPSLATE_TILES.defaultBlockState()), new ProcessorRule(new RandomBlockMatchTest(Blocks.SOUL_LANTERN, 0.05F), AlwaysTrueTest.INSTANCE, Blocks.AIR.defaultBlockState()))), new ProtectedBlockProcessor(BlockTags.FEATURES_CANNOT_REPLACE))); - public static final Holder ANCIENT_CITY_GENERIC_DEGRADATION = create("ancient_city_generic_degradation", ImmutableList.of(new BlockTagRotProcessor(WBBlockTags.ANCIENT_CITY_REPLACEABLE, 0.95F), new RuleProcessor(ImmutableList.of(new ProcessorRule(new RandomBlockMatchTest(Blocks.DEEPSLATE_BRICKS, 0.3F), AlwaysTrueTest.INSTANCE, Blocks.CRACKED_DEEPSLATE_BRICKS.defaultBlockState()), new ProcessorRule(new RandomBlockMatchTest(Blocks.DEEPSLATE_TILES, 0.3F), AlwaysTrueTest.INSTANCE, Blocks.CRACKED_DEEPSLATE_TILES.defaultBlockState()), new ProcessorRule(new RandomBlockMatchTest(Blocks.SOUL_LANTERN, 0.05F), AlwaysTrueTest.INSTANCE, Blocks.AIR.defaultBlockState()))), new ProtectedBlockProcessor(BlockTags.FEATURES_CANNOT_REPLACE))); - public static final Holder ANCIENT_CITY_WALLS_DEGRADATION = create("ancient_city_walls_degradation", ImmutableList.of(new BlockTagRotProcessor(WBBlockTags.ANCIENT_CITY_REPLACEABLE, 0.95F), new RuleProcessor(ImmutableList.of(new ProcessorRule(new RandomBlockMatchTest(Blocks.DEEPSLATE_BRICKS, 0.3F), AlwaysTrueTest.INSTANCE, Blocks.CRACKED_DEEPSLATE_BRICKS.defaultBlockState()), new ProcessorRule(new RandomBlockMatchTest(Blocks.DEEPSLATE_TILES, 0.3F), AlwaysTrueTest.INSTANCE, Blocks.CRACKED_DEEPSLATE_TILES.defaultBlockState()), new ProcessorRule(new RandomBlockMatchTest(Blocks.DEEPSLATE_TILE_SLAB, 0.3F), AlwaysTrueTest.INSTANCE, Blocks.AIR.defaultBlockState()), new ProcessorRule(new RandomBlockMatchTest(Blocks.SOUL_LANTERN, 0.05F), AlwaysTrueTest.INSTANCE, Blocks.AIR.defaultBlockState()))), new ProtectedBlockProcessor(BlockTags.FEATURES_CANNOT_REPLACE))); + public static final Holder ANCIENT_CITY_START_DEGRADATION + = create( + "ancient_city_start_degradation", + ImmutableList.of( + new RuleProcessor(ImmutableList.of( + new ProcessorRule( + new RandomBlockMatchTest(Blocks.DEEPSLATE_BRICKS, 0.3F), + AlwaysTrueTest.INSTANCE, + Blocks.CRACKED_DEEPSLATE_BRICKS.defaultBlockState() + ), + new ProcessorRule( + new RandomBlockMatchTest(Blocks.DEEPSLATE_TILES, 0.3F), + AlwaysTrueTest.INSTANCE, + Blocks.CRACKED_DEEPSLATE_TILES.defaultBlockState() + ), + new ProcessorRule( + new RandomBlockMatchTest(Blocks.SOUL_LANTERN, 0.05F), + AlwaysTrueTest.INSTANCE, + Blocks.AIR.defaultBlockState() + ) + )), + new ProtectedBlockProcessor(BlockTags.FEATURES_CANNOT_REPLACE) + ) + ); + public static final Holder ANCIENT_CITY_GENERIC_DEGRADATION + = create( + "ancient_city_generic_degradation", + ImmutableList.of( + new BlockTagRotProcessor(WBBlockTags.ANCIENT_CITY_REPLACEABLE, 0.95F), + new RuleProcessor(ImmutableList.of( + new ProcessorRule( + new RandomBlockMatchTest(Blocks.DEEPSLATE_BRICKS, 0.3F), + AlwaysTrueTest.INSTANCE, + Blocks.CRACKED_DEEPSLATE_BRICKS.defaultBlockState() + ), + new ProcessorRule( + new RandomBlockMatchTest(Blocks.DEEPSLATE_TILES, 0.3F), + AlwaysTrueTest.INSTANCE, + Blocks.CRACKED_DEEPSLATE_TILES.defaultBlockState() + ), + new ProcessorRule( + new RandomBlockMatchTest(Blocks.SOUL_LANTERN, 0.05F), + AlwaysTrueTest.INSTANCE, + Blocks.AIR.defaultBlockState() + ) + )), + new ProtectedBlockProcessor(BlockTags.FEATURES_CANNOT_REPLACE) + ) + ); + public static final Holder ANCIENT_CITY_WALLS_DEGRADATION + = create( + "ancient_city_walls_degradation", + ImmutableList.of( + new BlockTagRotProcessor(WBBlockTags.ANCIENT_CITY_REPLACEABLE, 0.95F), + new RuleProcessor(ImmutableList.of( + new ProcessorRule( + new RandomBlockMatchTest(Blocks.DEEPSLATE_BRICKS, 0.3F), + AlwaysTrueTest.INSTANCE, + Blocks.CRACKED_DEEPSLATE_BRICKS.defaultBlockState() + ), + new ProcessorRule( + new RandomBlockMatchTest(Blocks.DEEPSLATE_TILES, 0.3F), + AlwaysTrueTest.INSTANCE, + Blocks.CRACKED_DEEPSLATE_TILES.defaultBlockState() + ), + new ProcessorRule( + new RandomBlockMatchTest(Blocks.DEEPSLATE_TILE_SLAB, 0.3F), + AlwaysTrueTest.INSTANCE, + Blocks.AIR.defaultBlockState() + ), + new ProcessorRule( + new RandomBlockMatchTest(Blocks.SOUL_LANTERN, 0.05F), + AlwaysTrueTest.INSTANCE, + Blocks.AIR.defaultBlockState() + ) + )), + new ProtectedBlockProcessor(BlockTags.FEATURES_CANNOT_REPLACE) + ) + ); public static void bootstrap() {} - private static Holder create(String key, ImmutableList processors) { - return BuiltinRegistries.register(BuiltinRegistries.PROCESSOR_LIST, new ResourceLocation(key), new StructureProcessorList(processors)); + private static Holder + create(String key, ImmutableList processors) { + return BuiltinRegistries.register( + BuiltinRegistries.PROCESSOR_LIST, + new ResourceLocation(key), + new StructureProcessorList(processors) + ); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/api/ColorRegistry.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/ColorRegistry.java index 6d29e0d..38b0f25 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/api/ColorRegistry.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/ColorRegistry.java @@ -1,25 +1,29 @@ package com.cursedcauldron.wildbackport.core.api; +import java.util.function.Supplier; + import dev.architectury.injectables.annotations.ExpectPlatform; import net.minecraft.client.color.block.BlockColor; import net.minecraft.client.color.item.ItemColor; import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.block.Block; -import java.util.function.Supplier; - //<> public class ColorRegistry { @SafeVarargs @ExpectPlatform - public static void register(ItemColor itemColor, Supplier... items) { + public static void register( + ItemColor itemColor, Supplier... items + ) { throw new AssertionError(); } @SafeVarargs @ExpectPlatform - public static void register(BlockColor blockColor, Supplier... blocks) { + public static void register( + BlockColor blockColor, Supplier... blocks + ) { throw new AssertionError(); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/api/CoreRegistry.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/CoreRegistry.java index d095149..db9d88b 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/api/CoreRegistry.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/CoreRegistry.java @@ -1,11 +1,11 @@ package com.cursedcauldron.wildbackport.core.api; +import java.util.function.Supplier; + import dev.architectury.injectables.annotations.ExpectPlatform; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceLocation; -import java.util.function.Supplier; - /** * @author Trikzon & Andante */ @@ -28,7 +28,10 @@ public abstract class CoreRegistry { public abstract Supplier register(String key, Supplier entry); public void register() { - if (this.isPresent) throw new IllegalArgumentException("Duplication of Registry: " + this.registry); + if (this.isPresent) + throw new IllegalArgumentException( + "Duplication of Registry: " + this.registry + ); this.isPresent = true; this.bootstrap(); } @@ -42,7 +45,9 @@ public abstract class CoreRegistry { @Override public Supplier register(String key, Supplier entry) { - E registry = Registry.register(this.registry, new ResourceLocation(this.modId, key), entry.get()); + E registry = Registry.register( + this.registry, new ResourceLocation(this.modId, key), entry.get() + ); return () -> registry; } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/api/Environment.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/Environment.java index cacf2a7..efd2ec9 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/api/Environment.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/Environment.java @@ -21,8 +21,5 @@ public class Environment { throw new AssertionError(); } - public enum Platform { - FORGE, - FABRIC - } + public enum Platform { FORGE, FABRIC } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/api/MobRegistry.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/MobRegistry.java index ca754b9..a3c49af 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/api/MobRegistry.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/MobRegistry.java @@ -1,15 +1,18 @@ package com.cursedcauldron.wildbackport.core.api; +import java.util.function.Supplier; + import dev.architectury.injectables.annotations.ExpectPlatform; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; -import java.util.function.Supplier; - public class MobRegistry { @ExpectPlatform - public static void registerAttributes(Supplier> type, Supplier builder) { + public static void registerAttributes( + Supplier> type, + Supplier builder + ) { throw new AssertionError(); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/api/ParticleRegistry.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/ParticleRegistry.java index 6806a47..34dc622 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/api/ParticleRegistry.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/ParticleRegistry.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.core.api; +import java.util.function.Supplier; + import dev.architectury.injectables.annotations.ExpectPlatform; import net.minecraft.client.particle.ParticleProvider; import net.minecraft.client.particle.SpriteSet; @@ -7,20 +9,21 @@ import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleType; import org.jetbrains.annotations.NotNull; -import java.util.function.Supplier; - public class ParticleRegistry { @ExpectPlatform - public static > void create(Supplier

type, ParticleProvider provider) { + public static > void + create(Supplier

type, ParticleProvider provider) { throw new AssertionError(); } @ExpectPlatform - public static > void create(Supplier

type, Factory provider) { + public static > void + create(Supplier

type, Factory provider) { throw new AssertionError(); } public interface Factory { - @NotNull ParticleProvider create(SpriteSet sprites); + @NotNull + ParticleProvider create(SpriteSet sprites); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/api/RegistryBuilder.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/RegistryBuilder.java index c2f7b15..9aa3857 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/api/RegistryBuilder.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/RegistryBuilder.java @@ -15,8 +15,12 @@ public class RegistryBuilder { return new RegistryBuilder(modId); } - public SampleRegistry create(String key, Registry.RegistryBootstrap bootstrap) { - ResourceKey> resource = ResourceKey.createRegistryKey(new ResourceLocation(this.modId, key)); - return new SampleRegistry<>(resource, Registry.registerSimple(resource, bootstrap)); + public SampleRegistry + create(String key, Registry.RegistryBootstrap bootstrap) { + ResourceKey> resource + = ResourceKey.createRegistryKey(new ResourceLocation(this.modId, key)); + return new SampleRegistry<>( + resource, Registry.registerSimple(resource, bootstrap) + ); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/api/RenderRegistry.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/RenderRegistry.java index 7cee5e9..79bde10 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/api/RenderRegistry.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/RenderRegistry.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.core.api; +import java.util.function.Supplier; + import dev.architectury.injectables.annotations.ExpectPlatform; import net.minecraft.client.model.geom.ModelLayerLocation; import net.minecraft.client.model.geom.builders.LayerDefinition; @@ -12,8 +14,6 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; -import java.util.function.Supplier; - //<> public class RenderRegistry { @@ -23,17 +23,24 @@ public class RenderRegistry { } @ExpectPlatform - public static void setBlockEntityRender(Supplier> type, BlockEntityRendererProvider provider) { + public static void setBlockEntityRender( + Supplier> type, + BlockEntityRendererProvider provider + ) { throw new AssertionError(); } @ExpectPlatform - public static void setEntityRender(Supplier> type, EntityRendererProvider provider) { + public static void setEntityRender( + Supplier> type, + EntityRendererProvider provider + ) { throw new AssertionError(); } @ExpectPlatform - public static void setLayerDefinition(ModelLayerLocation layer, Supplier definition) { + public static void + setLayerDefinition(ModelLayerLocation layer, Supplier definition) { throw new AssertionError(); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/api/worldgen/BiomeModifier.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/worldgen/BiomeModifier.java index b70564c..621f055 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/api/worldgen/BiomeModifier.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/worldgen/BiomeModifier.java @@ -1,16 +1,18 @@ package com.cursedcauldron.wildbackport.core.api.worldgen; -import dev.architectury.injectables.annotations.ExpectPlatform; -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.level.biome.Biome; - import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Consumer; +import dev.architectury.injectables.annotations.ExpectPlatform; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.biome.Biome; + public class BiomeModifier { - private static final Map, ResourceKey[]> FEATURES_PER_BIOME = new ConcurrentHashMap<>(); - private static final Map, Biome.BiomeCategory[]> FEATURES_PER_CATEGORY = new ConcurrentHashMap<>(); + private static final Map, ResourceKey[]> + FEATURES_PER_BIOME = new ConcurrentHashMap<>(); + private static final Map, Biome.BiomeCategory[]> + FEATURES_PER_CATEGORY = new ConcurrentHashMap<>(); public static final BiomeModifier INSTANCE = new BiomeModifier(); @ExpectPlatform diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/api/worldgen/BiomeWriter.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/worldgen/BiomeWriter.java index f168864..8f3c277 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/api/worldgen/BiomeWriter.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/api/worldgen/BiomeWriter.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.core.api.worldgen; +import java.util.function.Consumer; + import net.minecraft.core.Holder; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; @@ -10,18 +12,21 @@ import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.levelgen.GenerationStep; import net.minecraft.world.level.levelgen.placement.PlacedFeature; -import java.util.function.Consumer; - //<> public abstract class BiomeWriter { @SafeVarargs public final void add(Consumer writer, ResourceKey... biomes) { - for (ResourceKey biome : biomes) if (this.is(biome)) writer.accept(this); + for (ResourceKey biome : biomes) + if (this.is(biome)) + writer.accept(this); } - public final void add(Consumer writer, Biome.BiomeCategory... categories) { - for (Biome.BiomeCategory category : categories) if (this.is(category)) writer.accept(this); + public final void + add(Consumer writer, Biome.BiomeCategory... categories) { + for (Biome.BiomeCategory category : categories) + if (this.is(category)) + writer.accept(this); } public boolean is(ResourceKey biome) { @@ -36,7 +41,14 @@ public abstract class BiomeWriter { public abstract Biome.BiomeCategory category(); - public abstract void addFeature(GenerationStep.Decoration step, Holder feature); + public abstract void + addFeature(GenerationStep.Decoration step, Holder feature); - public abstract void addSpawn(MobCategory category, EntityType entityType, int weight, int minGroupSize, int maxGroupSize); + public abstract void addSpawn( + MobCategory category, + EntityType entityType, + int weight, + int minGroupSize, + int maxGroupSize + ); } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/AxeItemAccessor.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/AxeItemAccessor.java index 0ed39cd..7a045b4 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/AxeItemAccessor.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/AxeItemAccessor.java @@ -1,13 +1,13 @@ package com.cursedcauldron.wildbackport.core.mixin.access; +import java.util.Map; + import net.minecraft.world.item.AxeItem; import net.minecraft.world.level.block.Block; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; - @Mixin(AxeItem.class) public interface AxeItemAccessor { @Accessor diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/GameRulesAccessor.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/GameRulesAccessor.java index 39207bd..e1ac8f8 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/GameRulesAccessor.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/GameRulesAccessor.java @@ -1,16 +1,17 @@ package com.cursedcauldron.wildbackport.core.mixin.access; +import java.util.Map; + import net.minecraft.world.level.GameRules; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Invoker; -import java.util.Map; - @Mixin(GameRules.class) public interface GameRulesAccessor { @Invoker - static > GameRules.Key callRegister(String string, GameRules.Category category, GameRules.Type type) { + static > GameRules.Key + callRegister(String string, GameRules.Category category, GameRules.Type type) { throw new UnsupportedOperationException(); } } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/MemoryModuleTypeAccessor.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/MemoryModuleTypeAccessor.java index f391d66..04b4e79 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/MemoryModuleTypeAccessor.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/MemoryModuleTypeAccessor.java @@ -1,12 +1,12 @@ package com.cursedcauldron.wildbackport.core.mixin.access; +import java.util.Optional; + import com.mojang.serialization.Codec; import net.minecraft.world.entity.ai.memory.MemoryModuleType; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; -import java.util.Optional; - @Mixin(MemoryModuleType.class) public interface MemoryModuleTypeAccessor { @Invoker("") diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/ModelPartAccessor.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/ModelPartAccessor.java index 9af7318..5a2ca26 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/ModelPartAccessor.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/ModelPartAccessor.java @@ -1,11 +1,11 @@ package com.cursedcauldron.wildbackport.core.mixin.access; +import java.util.Map; + import net.minecraft.client.model.geom.ModelPart; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; - @Mixin(ModelPart.class) public interface ModelPartAccessor { @Accessor diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/PointedDripstoneBlockAccessor.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/PointedDripstoneBlockAccessor.java index ec82099..cd25d91 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/PointedDripstoneBlockAccessor.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/PointedDripstoneBlockAccessor.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.core.mixin.access; +import java.util.Optional; + import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.PointedDripstoneBlock; @@ -7,12 +9,11 @@ import net.minecraft.world.level.block.state.BlockState; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; -import java.util.Optional; - @Mixin(PointedDripstoneBlock.class) public interface PointedDripstoneBlockAccessor { @Invoker - static Optional callFindRootBlock(Level level, BlockPos blockPos2, BlockState blockState2, int i) { + static Optional + callFindRootBlock(Level level, BlockPos blockPos2, BlockState blockState2, int i) { throw new UnsupportedOperationException(); } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/PressurePlateBlockAccessor.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/PressurePlateBlockAccessor.java index 8948e1c..7f08525 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/PressurePlateBlockAccessor.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/PressurePlateBlockAccessor.java @@ -8,7 +8,9 @@ import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(PressurePlateBlock.class) public interface PressurePlateBlockAccessor { @Invoker("") - static PressurePlateBlock createPressurePlateBlock(PressurePlateBlock.Sensitivity sensitivity, BlockBehaviour.Properties properties) { + static PressurePlateBlock createPressurePlateBlock( + PressurePlateBlock.Sensitivity sensitivity, BlockBehaviour.Properties properties + ) { throw new UnsupportedOperationException(); } } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/RecordItemAccessor.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/RecordItemAccessor.java index f3a44d0..9e36445 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/RecordItemAccessor.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/RecordItemAccessor.java @@ -9,7 +9,8 @@ import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(RecordItem.class) public interface RecordItemAccessor { @Invoker("") - static RecordItem createRecordItem(int i, SoundEvent soundEvent, Item.Properties properties) { + static RecordItem + createRecordItem(int i, SoundEvent soundEvent, Item.Properties properties) { throw new UnsupportedOperationException(); } } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/RenderTypeAccessor.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/RenderTypeAccessor.java index 7e6864a..722bc95 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/RenderTypeAccessor.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/RenderTypeAccessor.java @@ -8,7 +8,15 @@ import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(RenderType.class) public interface RenderTypeAccessor { @Invoker - static RenderType.CompositeRenderType callCreate(String string, VertexFormat vertexFormat, VertexFormat.Mode mode, int i, boolean bl, boolean bl2, RenderType.CompositeState compositeState) { + static RenderType.CompositeRenderType callCreate( + String string, + VertexFormat vertexFormat, + VertexFormat.Mode mode, + int i, + boolean bl, + boolean bl2, + RenderType.CompositeState compositeState + ) { throw new UnsupportedOperationException(); } } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/SensorTypeAccessor.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/SensorTypeAccessor.java index 83d7bde..7faddce 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/SensorTypeAccessor.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/SensorTypeAccessor.java @@ -1,12 +1,12 @@ package com.cursedcauldron.wildbackport.core.mixin.access; +import java.util.function.Supplier; + import net.minecraft.world.entity.ai.sensing.Sensor; import net.minecraft.world.entity.ai.sensing.SensorType; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; -import java.util.function.Supplier; - @Mixin(SensorType.class) public interface SensorTypeAccessor { @Invoker("") diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/StairBlockAccessor.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/StairBlockAccessor.java index c597157..96b79e1 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/StairBlockAccessor.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/StairBlockAccessor.java @@ -9,7 +9,8 @@ import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(StairBlock.class) public interface StairBlockAccessor { @Invoker("") - static StairBlock createStairBlock(BlockState blockState, BlockBehaviour.Properties properties) { + static StairBlock + createStairBlock(BlockState blockState, BlockBehaviour.Properties properties) { throw new UnsupportedOperationException(); } } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/StructureTemplatePoolAccessor.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/StructureTemplatePoolAccessor.java index 25ad62d..ee76e8e 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/StructureTemplatePoolAccessor.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/StructureTemplatePoolAccessor.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.core.mixin.access; +import java.util.List; + import com.mojang.datafixers.util.Pair; import net.minecraft.world.level.levelgen.structure.pools.StructurePoolElement; import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool; @@ -7,8 +9,6 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; - @Mixin(StructureTemplatePool.class) public interface StructureTemplatePoolAccessor { @Accessor diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/TreeDecoratorTypeAccessor.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/TreeDecoratorTypeAccessor.java index 7e12e90..86c13ee 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/TreeDecoratorTypeAccessor.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/TreeDecoratorTypeAccessor.java @@ -9,7 +9,8 @@ import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(TreeDecoratorType.class) public interface TreeDecoratorTypeAccessor { @Invoker("") - static

TreeDecoratorType

createTreeDecoratorType(Codec

codec) { + static

TreeDecoratorType

+ createTreeDecoratorType(Codec

codec) { throw new UnsupportedOperationException(); } } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/TreeFeatureAccessor.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/TreeFeatureAccessor.java index aabca95..58555b9 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/TreeFeatureAccessor.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/TreeFeatureAccessor.java @@ -16,17 +16,21 @@ public interface TreeFeatureAccessor { } @Invoker("isBlockWater") - static boolean isBlockWater(LevelSimulatedReader levelSimulatedReader, BlockPos blockPos) { + static boolean + isBlockWater(LevelSimulatedReader levelSimulatedReader, BlockPos blockPos) { throw new UnsupportedOperationException(); } @Invoker("isReplaceablePlant") - static boolean isReplaceablePlant(LevelSimulatedReader levelSimulatedReader, BlockPos blockPos) { + static boolean + isReplaceablePlant(LevelSimulatedReader levelSimulatedReader, BlockPos blockPos) { throw new UnsupportedOperationException(); } @Invoker("setBlockKnownShape") - static void setBlockKnownShape(LevelWriter levelWriter, BlockPos blockPos, BlockState blockState) { + static void setBlockKnownShape( + LevelWriter levelWriter, BlockPos blockPos, BlockState blockState + ) { throw new UnsupportedOperationException(); } } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/TrunkPlacerTypeAccessor.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/TrunkPlacerTypeAccessor.java index e2c6a67..beff0ee 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/TrunkPlacerTypeAccessor.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/access/TrunkPlacerTypeAccessor.java @@ -9,7 +9,8 @@ import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(TrunkPlacerType.class) public interface TrunkPlacerTypeAccessor { @Invoker("") - static

TrunkPlacerType

createTrunkPlacerType(Codec

codec) { + static

TrunkPlacerType

createTrunkPlacerType(Codec

codec + ) { throw new UnsupportedOperationException(); } } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/client/LightTextureMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/client/LightTextureMixin.java index 1e7db80..2c29135 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/client/LightTextureMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/client/LightTextureMixin.java @@ -25,46 +25,75 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(LightTexture.class) public abstract class LightTextureMixin { - @Shadow @Final private Minecraft minecraft; - @Shadow private boolean updateLightTexture; - @Shadow private float blockLightRedFlicker; - @Shadow protected abstract float getBrightness(Level level, int i); - @Shadow @Final private DynamicTexture lightTexture; - @Shadow @Final private NativeImage lightPixels; - @Shadow @Final private GameRenderer renderer; + @Shadow + @Final + private Minecraft minecraft; + @Shadow + private boolean updateLightTexture; + @Shadow + private float blockLightRedFlicker; + @Shadow + protected abstract float getBrightness(Level level, int i); + @Shadow + @Final + private DynamicTexture lightTexture; + @Shadow + @Final + private NativeImage lightPixels; + @Shadow + @Final + private GameRenderer renderer; private LocalPlayer getPlayer() { return this.minecraft.player; } private float getDarknessFactor(float delta) { - MobEffectInstance instance = this.getPlayer().getEffect(WBMobEffects.DARKNESS.get()); - if (this.getPlayer().hasEffect(WBMobEffects.DARKNESS.get()) && instance != null && EffectFactor.Instance.of(instance).getFactorCalculationData().isPresent()) { - return EffectFactor.Instance.of(instance).getFactorCalculationData().get().lerp(this.getPlayer(), delta); + MobEffectInstance instance + = this.getPlayer().getEffect(WBMobEffects.DARKNESS.get()); + if (this.getPlayer().hasEffect(WBMobEffects.DARKNESS.get()) && instance != null + && EffectFactor.Instance.of(instance).getFactorCalculationData().isPresent( + )) { + return EffectFactor.Instance.of(instance) + .getFactorCalculationData() + .get() + .lerp(this.getPlayer(), delta); } else { return 0.0F; } } private float getDarkness(LivingEntity entity, float factor, float delta) { - return Math.max(0.0F, Mth.cos(((float)entity.tickCount - delta) * (float) Math.PI * 0.025F) * 0.45F * factor); + return Math.max( + 0.0F, + Mth.cos(((float) entity.tickCount - delta) * (float) Math.PI * 0.025F) * 0.45F + * factor + ); } //TODO simplify @Inject(method = "updateLightTexture(F)V", at = @At("HEAD")) private void updateLight(float delta, CallbackInfo ci) { - if (Environment.isModLoaded("lod")) return; + if (Environment.isModLoaded("lod")) + return; if (this.updateLightTexture) { this.updateLightTexture = false; this.minecraft.getProfiler().push("lightTex"); ClientLevel level = this.minecraft.level; if (level != null) { float skyDarken = level.getSkyDarken(1.0F); - float skyFlashTime = level.getSkyFlashTime() > 0 ? 1.0F : skyDarken * 0.95F + 0.05F; + float skyFlashTime + = level.getSkyFlashTime() > 0 ? 1.0F : skyDarken * 0.95F + 0.05F; float darknessFactor = this.getDarknessFactor(delta); - float darkness = this.getDarkness(this.getPlayer(), darknessFactor, delta); + float darkness + = this.getDarkness(this.getPlayer(), darknessFactor, delta); float waterVision = this.getPlayer().getWaterVision(); - float visionScale = this.getPlayer().hasEffect(MobEffects.NIGHT_VISION) ? GameRenderer.getNightVisionScale(this.getPlayer(), delta) : (waterVision > 0.0F && this.getPlayer().hasEffect(MobEffects.CONDUIT_POWER) ? waterVision : 0.0F); + float visionScale = this.getPlayer().hasEffect(MobEffects.NIGHT_VISION) + ? GameRenderer.getNightVisionScale(this.getPlayer(), delta) + : (waterVision > 0.0F + && this.getPlayer().hasEffect(MobEffects.CONDUIT_POWER) + ? waterVision + : 0.0F); Vector3f vec3f = new Vector3f(skyDarken, skyDarken, 1.0F); vec3f.lerp(new Vector3f(1.0F, 1.0F, 1.0F), 0.35F); float blockLightFlicker = this.blockLightRedFlicker + 1.5F; @@ -72,10 +101,14 @@ public abstract class LightTextureMixin { for (int skyLight = 0; skyLight < 16; ++skyLight) { for (int blockLight = 0; blockLight < 16; ++blockLight) { - float skyBrightness = this.getBrightness(level, skyLight) * skyFlashTime; - float blockBrightness = this.getBrightness(level, blockLight) * blockLightFlicker; - float yLight = blockBrightness * ((blockBrightness * 0.6F + 0.4F) * 0.6F + 0.4F); - float xzLight = blockBrightness * (blockBrightness * blockBrightness * 0.6F + 0.4F); + float skyBrightness + = this.getBrightness(level, skyLight) * skyFlashTime; + float blockBrightness + = this.getBrightness(level, blockLight) * blockLightFlicker; + float yLight = blockBrightness + * ((blockBrightness * 0.6F + 0.4F) * 0.6F + 0.4F); + float xzLight = blockBrightness + * (blockBrightness * blockBrightness * 0.6F + 0.4F); vec3f2.set(blockBrightness, yLight, xzLight); boolean forceLightmap = level.effects().forceBrightLightmap(); @@ -88,7 +121,8 @@ public abstract class LightTextureMixin { vec3f2.add(vec3f3); vec3f2.lerp(new Vector3f(0.75F, 0.75F, 0.75F), 0.04F); if (this.renderer.getDarkenWorldAmount(delta) > 0.0f) { - float darkenWorldAmount = this.renderer.getDarkenWorldAmount(delta); + float darkenWorldAmount + = this.renderer.getDarkenWorldAmount(delta); Vector3f vec3f4 = vec3f2.copy(); vec3f4.mul(0.7F, 0.6F, 0.6F); vec3f2.lerp(vec3f4, darkenWorldAmount); @@ -96,7 +130,8 @@ public abstract class LightTextureMixin { } if (visionScale > 0.0F) { - float modifier = Math.max(vec3f2.x(), Math.max(vec3f2.y(), vec3f2.z())); + float modifier + = Math.max(vec3f2.x(), Math.max(vec3f2.y(), vec3f2.z())); if (modifier < 1.0F) { float scale = 1.0F / modifier; Vector3f vec3f3 = vec3f2.copy(); @@ -113,17 +148,19 @@ public abstract class LightTextureMixin { vec3f2.clamp(0.0F, 1.0F); } - float gamma = (float)this.minecraft.options.gamma; + float gamma = (float) this.minecraft.options.gamma; Vector3f vec3f3 = vec3f2.copy(); vec3f3.map(this::notGamma); vec3f2.lerp(vec3f3, Math.max(0.0F, gamma - darknessFactor)); vec3f2.lerp(new Vector3f(0.75F, 0.75F, 0.75F), 0.04F); vec3f2.clamp(0.0F, 1.0F); vec3f2.mul(255.0F); - int x = (int)vec3f2.x(); - int y = (int)vec3f2.y(); - int z = (int)vec3f2.z(); - this.lightPixels.setPixelRGBA(blockLight, skyLight, -16777216 | z << 16 | y << 8 | x); + int x = (int) vec3f2.x(); + int y = (int) vec3f2.y(); + int z = (int) vec3f2.z(); + this.lightPixels.setPixelRGBA( + blockLight, skyLight, -16777216 | z << 16 | y << 8 | x + ); } } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/client/LocalPlayerMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/client/LocalPlayerMixin.java index c8d6820..68fbc1e 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/client/LocalPlayerMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/client/LocalPlayerMixin.java @@ -16,16 +16,31 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(LocalPlayer.class) public class LocalPlayerMixin { - @Shadow public Input input; + @Shadow + public Input input; - @Inject(method = "aiStep", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/tutorial/Tutorial;onInput(Lnet/minecraft/client/player/Input;)V", shift = At.Shift.BEFORE)) - private void wb$aiStep(CallbackInfo ci) { + @Inject( + method = "aiStep", + at = @At( + value = "INVOKE", + target + = "Lnet/minecraft/client/tutorial/Tutorial;onInput(Lnet/minecraft/client/player/Input;)V", + shift = At.Shift.BEFORE + ) + ) + private void + wb$aiStep(CallbackInfo ci) { LocalPlayer player = LocalPlayer.class.cast(this); - float swiftnessModifier = (float)EnchantmentHelper.getEnchantmentLevel(WBEnchantments.SWIFT_SNEAK.get(), player) * 0.15F; + float swiftnessModifier = (float) EnchantmentHelper.getEnchantmentLevel( + WBEnchantments.SWIFT_SNEAK.get(), player + ) + * 0.15F; float slownessModifier = Mth.clamp(0.3F + swiftnessModifier, 0.0F, 1.0F); if (this.input instanceof KeyboardInput input && !player.isVisuallySwimming()) { - input.forwardImpulse = input.up == input.down ? 0.0F : (input.up ? 1.0F : -1.0F); - input.leftImpulse = input.left == input.right ? 0.0F : (input.left ? 1.0F : -1.0F); + input.forwardImpulse + = input.up == input.down ? 0.0F : (input.up ? 1.0F : -1.0F); + input.leftImpulse + = input.left == input.right ? 0.0F : (input.left ? 1.0F : -1.0F); if (player.isCrouching()) { input.leftImpulse *= slownessModifier; input.forwardImpulse *= slownessModifier; diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/client/ModelPartMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/client/ModelPartMixin.java index eb2f2b7..be18594 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/client/ModelPartMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/client/ModelPartMixin.java @@ -1,5 +1,8 @@ package com.cursedcauldron.wildbackport.core.mixin.client; +import java.util.List; +import java.util.Map; + import com.cursedcauldron.wildbackport.client.animation.api.Animated; import com.cursedcauldron.wildbackport.client.render.model.Drawable; import com.mojang.blaze3d.vertex.PoseStack; @@ -13,19 +16,20 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.List; -import java.util.Map; - //<> @Mixin(ModelPart.class) public abstract class ModelPartMixin implements Animated, Drawable { @Shadow public boolean visible; - @Shadow @Final + @Shadow + @Final private List cubes; - @Shadow @Final private Map children; - @Shadow public abstract void translateAndRotate(PoseStack pose); + @Shadow + @Final + private Map children; + @Shadow + public abstract void translateAndRotate(PoseStack pose); private float scaleX = 1.0F; private float scaleY = 1.0F; @@ -64,15 +68,34 @@ public abstract class ModelPartMixin implements Animated, Drawable { } } - @Inject(method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;IIFFFF)V", at = @At("HEAD"), cancellable = true) - private void wb$render(PoseStack pose, VertexConsumer consumer, int light, int delta, float red, float green, float blue, float alpha, CallbackInfo ci) { + @Inject( + method + = "render(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;IIFFFF)V", + at = @At("HEAD"), + cancellable = true + ) + private void + wb$render( + PoseStack pose, + VertexConsumer consumer, + int light, + int delta, + float red, + float green, + float blue, + float alpha, + CallbackInfo ci + ) { if (this.skipDraw()) { if (this.visible) { if (!this.cubes.isEmpty() || !this.children.isEmpty()) { pose.pushPose(); this.translateAndRotate(pose); - for (ModelPart part : this.children.values()) part.render(pose, consumer, light, delta, red, green, blue, alpha); + for (ModelPart part : this.children.values()) + part.render( + pose, consumer, light, delta, red, green, blue, alpha + ); pose.popPose(); } } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/client/PartDefinitionMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/client/PartDefinitionMixin.java index e31a885..d20e4e9 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/client/PartDefinitionMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/client/PartDefinitionMixin.java @@ -13,7 +13,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PartDefinition.class) public class PartDefinitionMixin { - @Shadow @Final private PartPose partPose; + @Shadow + @Final + private PartPose partPose; @Inject(method = "bake", at = @At(value = "RETURN"), cancellable = true) private void wb$bake(int i, int j, CallbackInfoReturnable cir) { diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/BlockEntityTypeMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/BlockEntityTypeMixin.java index 424a0a6..217481f 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/BlockEntityTypeMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/BlockEntityTypeMixin.java @@ -14,7 +14,9 @@ public class BlockEntityTypeMixin { @SuppressWarnings("EqualsBetweenInconvertibleTypes") @Inject(method = "isValid", at = @At("HEAD"), cancellable = true) private void wb$isValid(BlockState state, CallbackInfoReturnable cir) { - if (BlockEntityType.SIGN.equals(this) && (state.getBlock() instanceof SignBlock || state.getBlock() instanceof WallSignBlock)) { + if (BlockEntityType.SIGN.equals(this) + && (state.getBlock() instanceof SignBlock + || state.getBlock() instanceof WallSignBlock)) { cir.setReturnValue(true); } } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/FlyNodeEvaluatorMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/FlyNodeEvaluatorMixin.java index ad810cd..c094377 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/FlyNodeEvaluatorMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/FlyNodeEvaluatorMixin.java @@ -19,21 +19,39 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(FlyNodeEvaluator.class) public abstract class FlyNodeEvaluatorMixin extends WalkNodeEvaluator { - @Shadow protected abstract BlockPathTypes getCachedBlockPathType(int i, int j, int k); + @Shadow + protected abstract BlockPathTypes getCachedBlockPathType(int i, int j, int k); - @Shadow @Nullable protected abstract Node getNode(int i, int j, int k); + @Shadow + @Nullable + protected abstract Node getNode(int i, int j, int k); - @Shadow public abstract BlockPathTypes getBlockPathType(BlockGetter blockGetter, int i, int j, int k); + @Shadow + public abstract BlockPathTypes + getBlockPathType(BlockGetter blockGetter, int i, int j, int k); - @Inject(method = "getStart", at = @At(value = "INVOKE", target = "Lcom/google/common/collect/ImmutableSet;of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Lcom/google/common/collect/ImmutableSet;", shift = At.Shift.AFTER), cancellable = true) - private void wb$start(CallbackInfoReturnable cir) { + @Inject( + method = "getStart", + at = @At( + value = "INVOKE", + target + = "Lcom/google/common/collect/ImmutableSet;of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Lcom/google/common/collect/ImmutableSet;", + shift = At.Shift.AFTER + ), + cancellable = true + ) + private void + wb$start(CallbackInfoReturnable cir) { if (this.mob instanceof Allay allay) { for (BlockPos pos : allay.getPotentialEscapePositions()) { - BlockPathTypes types = this.getCachedBlockPathType(pos.getX(), pos.getY(), pos.getZ()); + BlockPathTypes types + = this.getCachedBlockPathType(pos.getX(), pos.getY(), pos.getZ()); if (this.mob.getPathfindingMalus(types) >= 0.0F) { Node node = this.getNode(pos); if (node != null) { - node.type = ((WalkNodeEvaluatorAccessor)this).callGetBlockPathType(this.mob, node.asBlockPos()); + node.type + = ((WalkNodeEvaluatorAccessor) this) + .callGetBlockPathType(this.mob, node.asBlockPos()); node.costMalus = this.mob.getPathfindingMalus(node.type); } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/ItemsMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/ItemsMixin.java index c6a67bb..058809a 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/ItemsMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/ItemsMixin.java @@ -2,19 +2,17 @@ package com.cursedcauldron.wildbackport.core.mixin.common; import java.util.Optional; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.gen.Invoker; - import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(Items.class) public class ItemsMixin { - @Overwrite private static Optional ifPart2(T object) { return Optional.of(object); @@ -29,5 +27,4 @@ public class ItemsMixin { public static Item registerItem(String string, Item item) { throw new UnsupportedOperationException(); } - } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/LivingEntityMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/LivingEntityMixin.java index e3f6ae6..ba9142b 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/LivingEntityMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/LivingEntityMixin.java @@ -17,14 +17,17 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(LivingEntity.class) public abstract class LivingEntityMixin extends Entity implements EntityExperience { - @Shadow @Nullable protected Player lastHurtByPlayer; + @Shadow + @Nullable + protected Player lastHurtByPlayer; private boolean expDroppingDisabled; public LivingEntityMixin(EntityType type, Level level) { super(type, level); } - @Shadow protected abstract int getExperienceReward(Player player); + @Shadow + protected abstract int getExperienceReward(Player player); @Inject(method = "die", at = @At("HEAD")) private void wb$die(DamageSource source, CallbackInfo ci) { @@ -48,6 +51,7 @@ public abstract class LivingEntityMixin extends Entity implements EntityExperien @Inject(method = "dropExperience", at = @At("HEAD"), cancellable = true) private void wb$dropExp(CallbackInfo ci) { - if (this.isExpDropDisabled()) ci.cancel(); + if (this.isExpDropDisabled()) + ci.cancel(); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/MobEffectMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/MobEffectMixin.java index b690f70..63f0d0f 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/MobEffectMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/MobEffectMixin.java @@ -1,5 +1,8 @@ package com.cursedcauldron.wildbackport.core.mixin.common; +import java.util.Optional; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.common.effects.EffectFactor; import com.cursedcauldron.wildbackport.common.effects.FactorCalculationData; @@ -17,9 +20,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.util.Optional; -import java.util.function.Supplier; - @Mixin(MobEffect.class) public class MobEffectMixin implements EffectFactor { private Supplier factorCalculationData = () -> null; @@ -37,17 +37,38 @@ public class MobEffectMixin implements EffectFactor { @Mixin(MobEffectInstance.class) public static class MobEffectInstanceMixin implements EffectFactor.Instance { - @Shadow @Final private MobEffect effect; - @Shadow private int duration; + @Shadow + @Final + private MobEffect effect; + @Shadow + private int duration; private Optional factorCalculationData; - @Inject(method = "(Lnet/minecraft/world/effect/MobEffect;IIZZZLnet/minecraft/world/effect/MobEffectInstance;)V", at = @At("TAIL")) - private void wb$create(MobEffect effect, int duration, int amplifier, boolean ambient, boolean showParticles, boolean showIcon, MobEffectInstance hiddenEffect, CallbackInfo ci) { + @Inject( + method + = "(Lnet/minecraft/world/effect/MobEffect;IIZZZLnet/minecraft/world/effect/MobEffectInstance;)V", + at = @At("TAIL") + ) + private void + wb$create( + MobEffect effect, + int duration, + int amplifier, + boolean ambient, + boolean showParticles, + boolean showIcon, + MobEffectInstance hiddenEffect, + CallbackInfo ci + ) { this.setFactorCalculationData(EffectFactor.create(effect)); } - @Inject(method = "(Lnet/minecraft/world/effect/MobEffectInstance;)V", at = @At("TAIL")) - private void wb$create(MobEffectInstance instance, CallbackInfo ci) { + @Inject( + method = "(Lnet/minecraft/world/effect/MobEffectInstance;)V", + at = @At("TAIL") + ) + private void + wb$create(MobEffectInstance instance, CallbackInfo ci) { this.setFactorCalculationData(EffectFactor.create(this.effect)); } @@ -62,27 +83,51 @@ public class MobEffectMixin implements EffectFactor { } @Inject(method = "update", at = @At("HEAD"), cancellable = true) - private void wb$update(MobEffectInstance instance, CallbackInfoReturnable cir) { + private void + wb$update(MobEffectInstance instance, CallbackInfoReturnable cir) { int i = this.duration; if (i != this.duration) { - this.factorCalculationData.ifPresent(data -> data.effectChangedTimestamp += this.duration - i); + this.factorCalculationData.ifPresent( + data -> data.effectChangedTimestamp += this.duration - i + ); cir.setReturnValue(true); } } @Inject(method = "tick", at = @At("HEAD")) - private void wb$tick(LivingEntity entity, Runnable runnable, CallbackInfoReturnable cir) { - this.factorCalculationData.ifPresent(data -> data.update(MobEffectInstance.class.cast(this))); + private void wb$tick( + LivingEntity entity, Runnable runnable, CallbackInfoReturnable cir + ) { + this.factorCalculationData.ifPresent( + data -> data.update(MobEffectInstance.class.cast(this)) + ); } @Inject(method = "writeDetailsTo", at = @At("TAIL")) private void wb$write(CompoundTag tag, CallbackInfo ci) { - this.factorCalculationData.flatMap(instance -> FactorCalculationData.CODEC.encodeStart(NbtOps.INSTANCE, instance).resultOrPartial(WildBackport.LOGGER::error)).ifPresent(data -> tag.put("FactorCalculationData", data)); + this.factorCalculationData + .flatMap( + instance + -> FactorCalculationData.CODEC.encodeStart(NbtOps.INSTANCE, instance) + .resultOrPartial(WildBackport.LOGGER::error) + ) + .ifPresent(data -> tag.put("FactorCalculationData", data)); } @Inject(method = "loadSpecifiedEffect", at = @At("TAIL")) - private static void wb$load(MobEffect effect, CompoundTag tag, CallbackInfoReturnable cir) { - Optional data = tag.contains("FactorCalculationData", 10) ? FactorCalculationData.CODEC.parse(new Dynamic<>(NbtOps.INSTANCE, tag.getCompound("FactorCalculationData"))).resultOrPartial(WildBackport.LOGGER::error) : Optional.empty(); + private static void wb$load( + MobEffect effect, + CompoundTag tag, + CallbackInfoReturnable cir + ) { + Optional data + = tag.contains("FactorCalculationData", 10) + ? FactorCalculationData.CODEC + .parse(new Dynamic<>( + NbtOps.INSTANCE, tag.getCompound("FactorCalculationData") + )) + .resultOrPartial(WildBackport.LOGGER::error) + : Optional.empty(); EffectFactor.Instance.of(cir.getReturnValue()).setFactorCalculationData(data); } } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/NoteBlockMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/NoteBlockMixin.java index 2df3a74..b405a33 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/NoteBlockMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/NoteBlockMixin.java @@ -11,8 +11,17 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(NoteBlock.class) public class NoteBlockMixin { - @Inject(method = "playNote", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;blockEvent(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/Block;II)V", shift = At.Shift.AFTER)) - private void wb$playNote(Level level, BlockPos pos, CallbackInfo ci) { + @Inject( + method = "playNote", + at = @At( + value = "INVOKE", + target + = "Lnet/minecraft/world/level/Level;blockEvent(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/Block;II)V", + shift = At.Shift.AFTER + ) + ) + private void + wb$playNote(Level level, BlockPos pos, CallbackInfo ci) { level.gameEvent(WBGameEvents.NOTE_BLOCK_PLAY.get(), pos); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/PathfinderMobMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/PathfinderMobMixin.java index bcd8115..914a7b9 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/PathfinderMobMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/PathfinderMobMixin.java @@ -10,8 +10,19 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(PathfinderMob.class) public class PathfinderMobMixin { @SuppressWarnings("ConstantConditions") - @Inject(method = "tickLeash", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/ai/goal/GoalSelector;enableControlFlag(Lnet/minecraft/world/entity/ai/goal/Goal$Flag;)V", shift = At.Shift.BEFORE), cancellable = true) - private void wb$tickLeash(CallbackInfo ci) { - if (PathfinderMob.class.cast(this) instanceof Allay) ci.cancel(); + @Inject( + method = "tickLeash", + at = @At( + value = "INVOKE", + target + = "Lnet/minecraft/world/entity/ai/goal/GoalSelector;enableControlFlag(Lnet/minecraft/world/entity/ai/goal/Goal$Flag;)V", + shift = At.Shift.BEFORE + ), + cancellable = true + ) + private void + wb$tickLeash(CallbackInfo ci) { + if (PathfinderMob.class.cast(this) instanceof Allay) + ci.cancel(); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/PlayerMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/PlayerMixin.java index 7346bfe..568bf9f 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/PlayerMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/PlayerMixin.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.core.mixin.common; +import java.util.Optional; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.common.entities.Warden; import com.cursedcauldron.wildbackport.common.entities.access.Recovery; @@ -16,8 +18,6 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.Optional; - //<> @Mixin(Player.class) @@ -28,22 +28,30 @@ public class PlayerMixin implements WardenTracker, Recovery { @Inject(method = "tick", at = @At("TAIL")) private void wb$tick(CallbackInfo ci) { - if (!player.level.isClientSide) this.spawnTracker.tick(); + if (!player.level.isClientSide) + this.spawnTracker.tick(); } @Inject(method = "readAdditionalSaveData", at = @At("TAIL")) private void wb$readData(CompoundTag tag, CallbackInfo ci) { - if (tag.contains("warden_spawn_tracker", 10)) WardenSpawnTracker.CODEC.parse(new Dynamic<>(NbtOps.INSTANCE, tag.get("warden_spawn_tracker"))).resultOrPartial(WildBackport.LOGGER::error).ifPresent(tracker -> this.spawnTracker = tracker); + if (tag.contains("warden_spawn_tracker", 10)) + WardenSpawnTracker.CODEC + .parse(new Dynamic<>(NbtOps.INSTANCE, tag.get("warden_spawn_tracker"))) + .resultOrPartial(WildBackport.LOGGER::error) + .ifPresent(tracker -> this.spawnTracker = tracker); } @Inject(method = "addAdditionalSaveData", at = @At("TAIL")) private void wb$writeData(CompoundTag tag, CallbackInfo ci) { - WardenSpawnTracker.CODEC.encodeStart(NbtOps.INSTANCE, this.spawnTracker).resultOrPartial(WildBackport.LOGGER::error).ifPresent(tracker -> tag.put("warden_spawn_Tracker", tracker)); + WardenSpawnTracker.CODEC.encodeStart(NbtOps.INSTANCE, this.spawnTracker) + .resultOrPartial(WildBackport.LOGGER::error) + .ifPresent(tracker -> tag.put("warden_spawn_Tracker", tracker)); } @Inject(method = "blockUsingShield", at = @At("HEAD")) private void wb$blockShield(LivingEntity entity, CallbackInfo ci) { - if (entity instanceof Warden) player.disableShield(true); + if (entity instanceof Warden) + player.disableShield(true); } @Override diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/PointedDripstoneBlockMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/PointedDripstoneBlockMixin.java index 984b4b4..c01094b 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/PointedDripstoneBlockMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/PointedDripstoneBlockMixin.java @@ -13,7 +13,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(PointedDripstoneBlock.class) public class PointedDripstoneBlockMixin { @Inject(method = "maybeFillCauldron", at = @At("HEAD"), cancellable = true) - private static void wb$maybeFillCauldron(BlockState state, ServerLevel level, BlockPos pos, float dripChance, CallbackInfo ci) { + private static void wb$maybeFillCauldron( + BlockState state, + ServerLevel level, + BlockPos pos, + float dripChance, + CallbackInfo ci + ) { DrippingFluid.fillCauldron(state, level, pos, ci); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/SculkSensorBlockEntityMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/SculkSensorBlockEntityMixin.java index 5ff984f..a712e28 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/SculkSensorBlockEntityMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/SculkSensorBlockEntityMixin.java @@ -21,17 +21,31 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(SculkSensorBlockEntity.class) public class SculkSensorBlockEntityMixin extends BlockEntity { - @Shadow @Final private VibrationListener listener; + @Shadow + @Final + private VibrationListener listener; - public SculkSensorBlockEntityMixin(BlockEntityType type, BlockPos pos, BlockState state) { + public SculkSensorBlockEntityMixin( + BlockEntityType type, BlockPos pos, BlockState state + ) { super(type, pos, state); } @Inject(method = "onSignalReceive", at = @At("HEAD")) - private void receiveSignal(Level level, GameEventListener listener, GameEvent event, int delay, CallbackInfo ci) { + private void receiveSignal( + Level level, + GameEventListener listener, + GameEvent event, + int delay, + CallbackInfo ci + ) { if (!level.isClientSide() && SculkSensorBlock.canActivate(this.getBlockState())) { Vibration.Instance instance = Vibration.Instance.of(this.listener); - level.gameEvent(instance.getEntity(), WBGameEvents.SCULK_SENSOR_TENDRILS_CLICKING.get(), instance.getPos()); + level.gameEvent( + instance.getEntity(), + WBGameEvents.SCULK_SENSOR_TENDRILS_CLICKING.get(), + instance.getPos() + ); } } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/SculkSensorBlockMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/SculkSensorBlockMixin.java index 5a699a0..27b27ae 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/SculkSensorBlockMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/SculkSensorBlockMixin.java @@ -23,14 +23,19 @@ public abstract class SculkSensorBlockMixin extends BaseEntityBlock { public void stepOn(Level level, BlockPos pos, BlockState state, Entity entity) { if (!level.isClientSide() && SculkSensorBlock.canActivate(state)) { SculkSensorBlock.activate(level, pos, state, 1); - level.gameEvent(entity, WBGameEvents.SCULK_SENSOR_TENDRILS_CLICKING.get(), pos); + level.gameEvent( + entity, WBGameEvents.SCULK_SENSOR_TENDRILS_CLICKING.get(), pos + ); } super.stepOn(level, pos, state, entity); } @Override - public void spawnAfterBreak(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack) { - if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, stack) == 0) this.popExperience(level, pos, 5); + public void + spawnAfterBreak(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack) { + if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, stack) + == 0) + this.popExperience(level, pos, 5); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/SlimeMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/SlimeMixin.java index 97c5a65..e7d1e01 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/SlimeMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/SlimeMixin.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.core.mixin.common; +import java.util.Random; + import com.cursedcauldron.wildbackport.common.tag.WBBiomeTags; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.EntityType; @@ -12,13 +14,31 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.util.Random; - @Mixin(Slime.class) public class SlimeMixin { - @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelAccessor;getDifficulty()Lnet/minecraft/world/Difficulty;", shift = At.Shift.AFTER), method = "checkSlimeSpawnRules", cancellable = true) - private static void WB$checkSlimeSpawnRules(EntityType entity, LevelAccessor level, MobSpawnType spawn, BlockPos pos, Random random, CallbackInfoReturnable cir) { - if (level.getBiome(pos).is(WBBiomeTags.ALLOWS_SURFACE_SLIME_SPAWNS) && pos.getY() > 50 && pos.getY() < 70 && random.nextFloat() < 0.5F && random.nextFloat() < level.getMoonBrightness() && level.getMaxLocalRawBrightness(pos) <= random.nextInt(8)) { + @Inject( + at = @At( + value = "INVOKE", + target + = "Lnet/minecraft/world/level/LevelAccessor;getDifficulty()Lnet/minecraft/world/Difficulty;", + shift = At.Shift.AFTER + ), + method = "checkSlimeSpawnRules", + cancellable = true + ) + private static void + WB$checkSlimeSpawnRules( + EntityType entity, + LevelAccessor level, + MobSpawnType spawn, + BlockPos pos, + Random random, + CallbackInfoReturnable cir + ) { + if (level.getBiome(pos).is(WBBiomeTags.ALLOWS_SURFACE_SLIME_SPAWNS) + && pos.getY() > 50 && pos.getY() < 70 && random.nextFloat() < 0.5F + && random.nextFloat() < level.getMoonBrightness() + && level.getMaxLocalRawBrightness(pos) <= random.nextInt(8)) { cir.setReturnValue(Mob.checkMobSpawnRules(entity, level, spawn, pos, random)); } } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/VibrationListenerMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/VibrationListenerMixin.java index e1f39ba..cfad89a 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/VibrationListenerMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/common/VibrationListenerMixin.java @@ -20,7 +20,13 @@ public class VibrationListenerMixin implements Vibration.Instance { private Vibration vibration; @Inject(method = "handleGameEvent", at = @At("HEAD")) - private void handleSource(Level level, GameEvent event, Entity entity, BlockPos pos, CallbackInfoReturnable cir) { + private void handleSource( + Level level, + GameEvent event, + Entity entity, + BlockPos pos, + CallbackInfoReturnable cir + ) { if (level instanceof ServerLevel server) { this.setPos(pos); this.setVibration(new Vibration(entity)); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/extension/BoatTypeMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/extension/BoatTypeMixin.java index fa87ed3..3c32702 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/extension/BoatTypeMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/extension/BoatTypeMixin.java @@ -1,5 +1,9 @@ package com.cursedcauldron.wildbackport.core.mixin.extension; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.common.entities.access.api.BoatTypes; import com.cursedcauldron.wildbackport.common.registry.WBBlocks; @@ -18,31 +22,44 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - //<> @Mixin(Boat.Type.class) public class BoatTypeMixin { - @Shadow @Mutable @Final private static Boat.Type[] $VALUES; + @Shadow + @Mutable + @Final + private static Boat.Type[] $VALUES; @Invoker("") public static Boat.Type create(String internal, int id, Block planks, String name) { throw new AssertionError(); } - @Inject(method = "", at = @At(value = "FIELD", target = "Lnet/minecraft/world/entity/vehicle/Boat$Type;$VALUES:[Lnet/minecraft/world/entity/vehicle/Boat$Type;", shift = At.Shift.AFTER)) - private static void wb$addBoat(CallbackInfo ci) { + @Inject( + method = "", + at = @At( + value = "FIELD", + target + = "Lnet/minecraft/world/entity/vehicle/Boat$Type;$VALUES:[Lnet/minecraft/world/entity/vehicle/Boat$Type;", + shift = At.Shift.AFTER + ) + ) + private static void + wb$addBoat(CallbackInfo ci) { List types = new ArrayList<>(Arrays.asList($VALUES)); Boat.Type last = types.get(types.size() - 1); int i = 1; -// for (BoatTypes type : BoatTypes.values()) { - types.add(create("mangrove", last.ordinal() + 1, Registry.BLOCK.get(new ResourceLocation("mangrove_planks")), "mangrove")); -// i++; -// } + // for (BoatTypes type : BoatTypes.values()) { + types.add(create( + "mangrove", + last.ordinal() + 1, + Registry.BLOCK.get(new ResourceLocation("mangrove_planks")), + "mangrove" + )); + // i++; + // } $VALUES = types.toArray(new Boat.Type[0]); } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/extension/PoseMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/extension/PoseMixin.java index 29f8230..022d597 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/extension/PoseMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/extension/PoseMixin.java @@ -1,5 +1,9 @@ package com.cursedcauldron.wildbackport.core.mixin.extension; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import com.cursedcauldron.wildbackport.common.entities.access.api.Poses; import net.minecraft.world.entity.Pose; import org.spongepowered.asm.mixin.Final; @@ -11,21 +15,29 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - @Mixin(Pose.class) public class PoseMixin { - @Shadow @Mutable @Final private static Pose[] $VALUES; + @Shadow + @Mutable + @Final + private static Pose[] $VALUES; @Invoker("") public static Pose create(String name, int id) { throw new AssertionError(); } - @Inject(method = "", at = @At(value = "FIELD", target = "Lnet/minecraft/world/entity/Pose;$VALUES:[Lnet/minecraft/world/entity/Pose;", shift = At.Shift.AFTER)) - private static void wb$addPose(CallbackInfo ci) { + @Inject( + method = "", + at = @At( + value = "FIELD", + target + = "Lnet/minecraft/world/entity/Pose;$VALUES:[Lnet/minecraft/world/entity/Pose;", + shift = At.Shift.AFTER + ) + ) + private static void + wb$addPose(CallbackInfo ci) { List poses = new ArrayList<>(Arrays.asList($VALUES)); Pose last = poses.get(poses.size() - 1); int i = 1; diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/network/ClientPacketListenerMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/network/ClientPacketListenerMixin.java index 0e7a510..68f5bb7 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/network/ClientPacketListenerMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/network/ClientPacketListenerMixin.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.core.mixin.network; +import java.util.Optional; + import com.cursedcauldron.wildbackport.common.effects.EffectFactor; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; @@ -17,24 +19,39 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.Optional; - @Mixin(ClientPacketListener.class) public class ClientPacketListenerMixin { - @Shadow private ClientLevel level; - @Shadow @Final private Minecraft minecraft; + @Shadow + private ClientLevel level; + @Shadow + @Final + private Minecraft minecraft; //TODO simplify @Inject(method = "handleUpdateMobEffect", at = @At("HEAD"), cancellable = true) - private void wb$updateEffect(ClientboundUpdateMobEffectPacket packet, CallbackInfo ci) { - PacketUtils.ensureRunningOnSameThread(packet, ClientPacketListener.class.cast(this), this.minecraft); + private void + wb$updateEffect(ClientboundUpdateMobEffectPacket packet, CallbackInfo ci) { + PacketUtils.ensureRunningOnSameThread( + packet, ClientPacketListener.class.cast(this), this.minecraft + ); Entity entity = this.level.getEntity(packet.getEntityId()); if (entity instanceof LivingEntity living) { MobEffect effect = MobEffect.byId(packet.getEffectId() & 0xFF); if (effect != null) { - MobEffectInstance instance = new MobEffectInstance(effect, packet.getEffectDurationTicks(), packet.getEffectAmplifier(), packet.isEffectAmbient(), packet.isEffectVisible(), packet.effectShowsIcon()); + MobEffectInstance instance = new MobEffectInstance( + effect, + packet.getEffectDurationTicks(), + packet.getEffectAmplifier(), + packet.isEffectAmbient(), + packet.isEffectVisible(), + packet.effectShowsIcon() + ); instance.setNoCounter(packet.isSuperLongDuration()); - EffectFactor.Instance.of(instance).setFactorCalculationData(Optional.ofNullable(EffectFactor.Network.of(packet).getFactorCalculationData())); + EffectFactor.Instance.of(instance).setFactorCalculationData( + Optional.ofNullable( + EffectFactor.Network.of(packet).getFactorCalculationData() + ) + ); living.forceAddEffect(instance, null); } } diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/network/ClientboundUpdateMobEffectPacketMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/network/ClientboundUpdateMobEffectPacketMixin.java index df30bfc..fd961b8 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/network/ClientboundUpdateMobEffectPacketMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/network/ClientboundUpdateMobEffectPacketMixin.java @@ -1,5 +1,8 @@ package com.cursedcauldron.wildbackport.core.mixin.network; +import java.util.function.BiConsumer; +import java.util.function.Function; + import com.cursedcauldron.wildbackport.common.effects.EffectFactor; import com.cursedcauldron.wildbackport.common.effects.FactorCalculationData; import net.minecraft.network.FriendlyByteBuf; @@ -11,26 +14,34 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.function.BiConsumer; -import java.util.function.Function; - @Mixin(ClientboundUpdateMobEffectPacket.class) public class ClientboundUpdateMobEffectPacketMixin implements EffectFactor.Network { private FactorCalculationData factorCalculationData; - @Inject(method = "(ILnet/minecraft/world/effect/MobEffectInstance;)V", at = @At("TAIL")) - private void create(int id, MobEffectInstance instance, CallbackInfo ci) { - this.factorCalculationData = EffectFactor.Instance.of(instance).getFactorCalculationData().orElse(null); + @Inject( + method = "(ILnet/minecraft/world/effect/MobEffectInstance;)V", + at = @At("TAIL") + ) + private void + create(int id, MobEffectInstance instance, CallbackInfo ci) { + this.factorCalculationData + = EffectFactor.Instance.of(instance).getFactorCalculationData().orElse(null); } @Inject(method = "(Lnet/minecraft/network/FriendlyByteBuf;)V", at = @At("TAIL")) private void create(FriendlyByteBuf buf, CallbackInfo ci) { - this.factorCalculationData = this.readNullable(buf, buffer -> buffer.readWithCodec(FactorCalculationData.CODEC)); + this.factorCalculationData = this.readNullable( + buf, buffer -> buffer.readWithCodec(FactorCalculationData.CODEC) + ); } @Inject(method = "write", at = @At("TAIL")) private void writeData(FriendlyByteBuf buf, CallbackInfo ci) { - this.writeNullable(buf, this.factorCalculationData, (buffer, data) -> buffer.writeWithCodec(FactorCalculationData.CODEC, data)); + this.writeNullable( + buf, + this.factorCalculationData, + (buffer, data) -> buffer.writeWithCodec(FactorCalculationData.CODEC, data) + ); } @Override @@ -38,11 +49,14 @@ public class ClientboundUpdateMobEffectPacketMixin implements EffectFactor.Netwo return this.factorCalculationData; } - private T readNullable(FriendlyByteBuf buf, Function consumer) { + private + T readNullable(FriendlyByteBuf buf, Function consumer) { return buf.readBoolean() ? consumer.apply(buf) : null; } - private void writeNullable(FriendlyByteBuf buf, @Nullable T entry, BiConsumer consumer) { + private void writeNullable( + FriendlyByteBuf buf, @Nullable T entry, BiConsumer consumer + ) { if (entry != null) { buf.writeBoolean(true); consumer.accept(buf, entry); diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/network/MultiPlayerGameModeMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/network/MultiPlayerGameModeMixin.java index a15b049..6d8eea4 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/network/MultiPlayerGameModeMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/network/MultiPlayerGameModeMixin.java @@ -13,11 +13,17 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(MultiPlayerGameMode.class) public class MultiPlayerGameModeMixin { - @Shadow @Final private Minecraft minecraft; + @Shadow + @Final + private Minecraft minecraft; @Inject(method = "isServerControlledInventory", at = @At("TAIL"), cancellable = true) private void wb$handleInventory(CallbackInfoReturnable cir) { LocalPlayer player = this.minecraft.player; - cir.setReturnValue(player != null && player.isPassenger() && player.getVehicle() instanceof ChestBoat || cir.getReturnValue()); + cir.setReturnValue( + player != null && player.isPassenger() + && player.getVehicle() instanceof ChestBoat + || cir.getReturnValue() + ); } } \ No newline at end of file diff --git a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/network/ServerGamePacketListenerImplMixin.java b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/network/ServerGamePacketListenerImplMixin.java index c06f7cd..afb5373 100644 --- a/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/network/ServerGamePacketListenerImplMixin.java +++ b/common/src/main/java/com/cursedcauldron/wildbackport/core/mixin/network/ServerGamePacketListenerImplMixin.java @@ -12,10 +12,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ServerGamePacketListenerImpl.class) public class ServerGamePacketListenerImplMixin { - @Shadow public ServerPlayer player; + @Shadow + public ServerPlayer player; @Inject(method = "handlePlayerCommand", at = @At("HEAD")) - private void wb$handleInventory(ServerboundPlayerCommandPacket packet, CallbackInfo ci) { + private void + wb$handleInventory(ServerboundPlayerCommandPacket packet, CallbackInfo ci) { if (packet.getAction() == ServerboundPlayerCommandPacket.Action.OPEN_INVENTORY) { if (this.player.getVehicle() instanceof ChestBoat boat) { boat.openInventory(this.player); diff --git a/fabric/src/main/java/com/cursedcauldron/wildbackport/common/registry/fabric/WBItemsImpl.java b/fabric/src/main/java/com/cursedcauldron/wildbackport/common/registry/fabric/WBItemsImpl.java index 0fdffb2..5a898de 100644 --- a/fabric/src/main/java/com/cursedcauldron/wildbackport/common/registry/fabric/WBItemsImpl.java +++ b/fabric/src/main/java/com/cursedcauldron/wildbackport/common/registry/fabric/WBItemsImpl.java @@ -1,17 +1,25 @@ package com.cursedcauldron.wildbackport.common.registry.fabric; +import java.util.function.Supplier; + import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; import net.minecraft.world.item.SpawnEggItem; -import java.util.function.Supplier; - //<> public class WBItemsImpl { - public static Supplier spawnEgg(Supplier> mob, int background, int highlight) { - return () -> new SpawnEggItem(mob.get(), background, highlight, new Item.Properties().tab(CreativeModeTab.TAB_MISC)); + public static Supplier spawnEgg( + Supplier> mob, int background, int highlight + ) { + return () + -> new SpawnEggItem( + mob.get(), + background, + highlight, + new Item.Properties().tab(CreativeModeTab.TAB_MISC) + ); } } \ No newline at end of file diff --git a/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/event/fabric/InteractionsImpl.java b/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/event/fabric/InteractionsImpl.java index 9c780c7..eb7e050 100644 --- a/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/event/fabric/InteractionsImpl.java +++ b/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/event/fabric/InteractionsImpl.java @@ -6,6 +6,9 @@ import net.minecraft.world.item.context.UseOnContext; public class InteractionsImpl { public static void addRightClick(Interactions.Interaction interaction) { - UseBlockCallback.EVENT.register((player, level, hand, hitResult) -> interaction.of(new UseOnContext(player, hand, hitResult))); + UseBlockCallback.EVENT.register( + (player, level, hand, hitResult + ) -> interaction.of(new UseOnContext(player, hand, hitResult)) + ); } } \ No newline at end of file diff --git a/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/fabric/ColorRegistryImpl.java b/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/fabric/ColorRegistryImpl.java index 6e08344..c3cedf4 100644 --- a/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/fabric/ColorRegistryImpl.java +++ b/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/fabric/ColorRegistryImpl.java @@ -1,23 +1,27 @@ package com.cursedcauldron.wildbackport.core.api.fabric; +import java.util.function.Supplier; + import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; import net.minecraft.client.color.block.BlockColor; import net.minecraft.client.color.item.ItemColor; import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.block.Block; -import java.util.function.Supplier; - public class ColorRegistryImpl { @SafeVarargs - public static void register(ItemColor itemColor, Supplier... items) { + public static void register( + ItemColor itemColor, Supplier... items + ) { for (Supplier item : items) { ColorProviderRegistry.ITEM.register(itemColor, item.get()); } } @SafeVarargs - public static void register(BlockColor blockColor, Supplier... blocks) { + public static void register( + BlockColor blockColor, Supplier... blocks + ) { for (Supplier block : blocks) { ColorProviderRegistry.BLOCK.register(blockColor, block.get()); } diff --git a/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/fabric/MobRegistryImpl.java b/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/fabric/MobRegistryImpl.java index da5ccf9..b6482f2 100644 --- a/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/fabric/MobRegistryImpl.java +++ b/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/fabric/MobRegistryImpl.java @@ -1,15 +1,18 @@ package com.cursedcauldron.wildbackport.core.api.fabric; +import java.util.function.Supplier; + import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; -import java.util.function.Supplier; - public class MobRegistryImpl { @SuppressWarnings("ConstantConditions") - public static void registerAttributes(Supplier> type, Supplier builder) { + public static void registerAttributes( + Supplier> type, + Supplier builder + ) { FabricDefaultAttributeRegistry.register(type.get(), builder.get()); } } diff --git a/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/fabric/ParticleRegistryImpl.java b/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/fabric/ParticleRegistryImpl.java index 1ea8699..032fa67 100644 --- a/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/fabric/ParticleRegistryImpl.java +++ b/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/fabric/ParticleRegistryImpl.java @@ -1,19 +1,21 @@ package com.cursedcauldron.wildbackport.core.api.fabric; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.core.api.ParticleRegistry; import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry; import net.minecraft.client.particle.ParticleProvider; import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleType; -import java.util.function.Supplier; - public class ParticleRegistryImpl { - public static > void create(Supplier

type, ParticleProvider provider) { + public static > void + create(Supplier

type, ParticleProvider provider) { ParticleFactoryRegistry.getInstance().register(type.get(), provider); } - public static > void create(Supplier

type, ParticleRegistry.Factory factory) { + public static > void + create(Supplier

type, ParticleRegistry.Factory factory) { ParticleFactoryRegistry.getInstance().register(type.get(), factory::create); } } \ No newline at end of file diff --git a/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/fabric/RenderRegistryImpl.java b/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/fabric/RenderRegistryImpl.java index 5c4190e..e1fc0b9 100644 --- a/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/fabric/RenderRegistryImpl.java +++ b/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/fabric/RenderRegistryImpl.java @@ -1,5 +1,7 @@ package com.cursedcauldron.wildbackport.core.api.fabric; +import java.util.function.Supplier; + import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; import net.fabricmc.fabric.api.client.rendering.v1.BlockEntityRendererRegistry; import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry; @@ -15,22 +17,27 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; -import java.util.function.Supplier; - public class RenderRegistryImpl { public static void setBlockRenderType(RenderType type, Block... blocks) { BlockRenderLayerMap.INSTANCE.putBlocks(type, blocks); } - public static void setEntityRender(Supplier> type, EntityRendererProvider provider) { + public static void setEntityRender( + Supplier> type, + EntityRendererProvider provider + ) { EntityRendererRegistry.register(type.get(), provider); } - public static void setLayerDefinition(ModelLayerLocation layer, Supplier definition) { + public static void + setLayerDefinition(ModelLayerLocation layer, Supplier definition) { EntityModelLayerRegistry.registerModelLayer(layer, definition::get); } - public static void setBlockEntityRender(Supplier> type, BlockEntityRendererProvider provider) { + public static void setBlockEntityRender( + Supplier> type, + BlockEntityRendererProvider provider + ) { BlockEntityRendererRegistry.register(type.get(), provider); } } diff --git a/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/fabric/WoodTypeRegistryImpl.java b/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/fabric/WoodTypeRegistryImpl.java index c042f89..535c342 100644 --- a/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/fabric/WoodTypeRegistryImpl.java +++ b/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/fabric/WoodTypeRegistryImpl.java @@ -11,7 +11,10 @@ import net.minecraft.world.level.block.state.properties.WoodType; public class WoodTypeRegistryImpl { public static WoodType create(ResourceLocation location) { WoodType woodType = WoodTypeAccessor.callRegister(new WoodTypeImpl(location)); - if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) Sheets.SIGN_MATERIALS.put(woodType, SheetsAccessor.callCreateSignMaterial(woodType)); + if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) + Sheets.SIGN_MATERIALS.put( + woodType, SheetsAccessor.callCreateSignMaterial(woodType) + ); return woodType; } diff --git a/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/worldgen/fabric/BiomeModifierImpl.java b/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/worldgen/fabric/BiomeModifierImpl.java index a134c27..8620c1d 100644 --- a/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/worldgen/fabric/BiomeModifierImpl.java +++ b/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/worldgen/fabric/BiomeModifierImpl.java @@ -8,8 +8,11 @@ import net.minecraft.resources.ResourceLocation; public class BiomeModifierImpl { public static void setup() { - BiomeModifications.create(new ResourceLocation("biome_modifier")).add(ModificationPhase.ADDITIONS, ctx -> true, (selector, modifier) -> { - BiomeModifier.INSTANCE.register(new FabricBiomeWriter().build(selector, modifier)); - }); + BiomeModifications.create(new ResourceLocation("biome_modifier")) + .add(ModificationPhase.ADDITIONS, ctx -> true, (selector, modifier) -> { + BiomeModifier.INSTANCE.register( + new FabricBiomeWriter().build(selector, modifier) + ); + }); } } \ No newline at end of file diff --git a/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/worldgen/fabric/FabricBiomeWriter.java b/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/worldgen/fabric/FabricBiomeWriter.java index e56dc35..14ae591 100644 --- a/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/worldgen/fabric/FabricBiomeWriter.java +++ b/fabric/src/main/java/com/cursedcauldron/wildbackport/core/api/worldgen/fabric/FabricBiomeWriter.java @@ -17,7 +17,8 @@ public class FabricBiomeWriter extends BiomeWriter { private BiomeSelectionContext selection; private BiomeModificationContext modification; - public BiomeWriter build(BiomeSelectionContext selectionCtx, BiomeModificationContext modificationCtx) { + public BiomeWriter + build(BiomeSelectionContext selectionCtx, BiomeModificationContext modificationCtx) { this.selection = selectionCtx; this.modification = modificationCtx; return this; @@ -30,16 +31,31 @@ public class FabricBiomeWriter extends BiomeWriter { @Override public Biome.BiomeCategory category() { - return ((BiomeAccessor)(Object)this.selection.getBiome()).callGetBiomeCategory(); + return ((BiomeAccessor) (Object) this.selection.getBiome()) + .callGetBiomeCategory(); } @Override - public void addFeature(GenerationStep.Decoration step, Holder feature) { - this.modification.getGenerationSettings().addBuiltInFeature(step, feature.value()); + public void + addFeature(GenerationStep.Decoration step, Holder feature) { + this.modification.getGenerationSettings().addBuiltInFeature( + step, feature.value() + ); } @Override - public void addSpawn(MobCategory category, EntityType entityType, int weight, int minGroupSize, int maxGroupSize) { - this.modification.getSpawnSettings().addSpawn(category, new MobSpawnSettings.SpawnerData(entityType, weight, minGroupSize, maxGroupSize)); + public void addSpawn( + MobCategory category, + EntityType entityType, + int weight, + int minGroupSize, + int maxGroupSize + ) { + this.modification.getSpawnSettings().addSpawn( + category, + new MobSpawnSettings.SpawnerData( + entityType, weight, minGroupSize, maxGroupSize + ) + ); } } \ No newline at end of file diff --git a/fabric/src/main/java/com/cursedcauldron/wildbackport/core/mixin/fabric/client/FogRendererMixin.java b/fabric/src/main/java/com/cursedcauldron/wildbackport/core/mixin/fabric/client/FogRendererMixin.java index 9caca61..cdb7aa3 100644 --- a/fabric/src/main/java/com/cursedcauldron/wildbackport/core/mixin/fabric/client/FogRendererMixin.java +++ b/fabric/src/main/java/com/cursedcauldron/wildbackport/core/mixin/fabric/client/FogRendererMixin.java @@ -20,22 +20,38 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; public class FogRendererMixin { @Shadow private static float fogRed; - @Shadow private static float fogGreen; - @Shadow private static float fogBlue; + @Shadow + private static float fogGreen; + @Shadow + private static float fogBlue; private static float fogPartialTicks; @Inject(method = "setupColor", at = @At("TAIL")) - private static void applyDarknessColor(Camera camera, float partialTicks, ClientLevel level, int viewDistance, float skyDarkness, CallbackInfo ci) { + private static void applyDarknessColor( + Camera camera, + float partialTicks, + ClientLevel level, + int viewDistance, + float skyDarkness, + CallbackInfo ci + ) { FogType type = camera.getFluidInCamera(); fogPartialTicks = partialTicks; - double colorModifier = (camera.getPosition().y - (double)level.getMinBuildHeight()) * level.getLevelData().getClearColorScale(); - if (camera.getEntity() instanceof LivingEntity living && living.hasEffect(WBMobEffects.DARKNESS.get())) { + double colorModifier + = (camera.getPosition().y - (double) level.getMinBuildHeight()) + * level.getLevelData().getClearColorScale(); + if (camera.getEntity() instanceof LivingEntity living + && living.hasEffect(WBMobEffects.DARKNESS.get())) { MobEffectInstance effect = living.getEffect(WBMobEffects.DARKNESS.get()); if (effect != null) { EffectFactor.Instance instance = EffectFactor.Instance.of(effect); - colorModifier = instance.getFactorCalculationData().isPresent() ? 1.0F - instance.getFactorCalculationData().get().lerp(living, partialTicks) : 0.0D; + colorModifier = instance.getFactorCalculationData().isPresent() ? 1.0F + - instance.getFactorCalculationData().get().lerp( + living, partialTicks + ) + : 0.0D; } } @@ -45,9 +61,9 @@ public class FogRendererMixin { } colorModifier *= colorModifier; - fogRed = (float)((double)fogRed * colorModifier); - fogGreen = (float)((double)fogGreen * colorModifier); - fogBlue = (float)((double)fogBlue * colorModifier); + fogRed = (float) ((double) fogRed * colorModifier); + fogGreen = (float) ((double) fogGreen * colorModifier); + fogBlue = (float) ((double) fogBlue * colorModifier); } if (skyDarkness > 0.0F) { @@ -60,18 +76,33 @@ public class FogRendererMixin { } @Inject(method = "setupFog", at = @At("TAIL")) - private static void applyDarknessFog(Camera camera, FogRenderer.FogMode mode, float viewDistance, boolean thickFog, CallbackInfo ci) { + private static void applyDarknessFog( + Camera camera, + FogRenderer.FogMode mode, + float viewDistance, + boolean thickFog, + CallbackInfo ci + ) { FogType fogtype = camera.getFluidInCamera(); if (fogtype != FogType.WATER) { - if (camera.getEntity() instanceof LivingEntity living && living.hasEffect(WBMobEffects.DARKNESS.get())) { + if (camera.getEntity() instanceof LivingEntity living + && living.hasEffect(WBMobEffects.DARKNESS.get())) { MobEffectInstance effect = living.getEffect(WBMobEffects.DARKNESS.get()); if (effect != null) { EffectFactor.Instance instance = EffectFactor.Instance.of(effect); if (instance.getFactorCalculationData().isPresent()) { - float modifier = Mth.lerp(instance.getFactorCalculationData().get().lerp(living, fogPartialTicks), viewDistance, 15.0F); - float start = mode == FogRenderer.FogMode.FOG_SKY ? 0.0F : modifier * 0.75F; + float modifier = Mth.lerp( + instance.getFactorCalculationData().get().lerp( + living, fogPartialTicks + ), + viewDistance, + 15.0F + ); + float start = mode == FogRenderer.FogMode.FOG_SKY + ? 0.0F + : modifier * 0.75F; RenderSystem.setShaderFogStart(start); RenderSystem.setShaderFogEnd(modifier); diff --git a/fabric/src/main/java/com/cursedcauldron/wildbackport/core/mixin/fabric/client/SheetsMixin.java b/fabric/src/main/java/com/cursedcauldron/wildbackport/core/mixin/fabric/client/SheetsMixin.java index a40adfa..a92f624 100644 --- a/fabric/src/main/java/com/cursedcauldron/wildbackport/core/mixin/fabric/client/SheetsMixin.java +++ b/fabric/src/main/java/com/cursedcauldron/wildbackport/core/mixin/fabric/client/SheetsMixin.java @@ -13,10 +13,16 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(Sheets.class) public class SheetsMixin { @Inject(method = "createSignMaterial", at = @At("HEAD"), cancellable = true) - private static void wb$createSign(WoodType woodType, CallbackInfoReturnable cir) { + private static void + wb$createSign(WoodType woodType, CallbackInfoReturnable cir) { if (woodType instanceof WoodTypeRegistryImpl.WoodTypeImpl impl) { ResourceLocation location = impl.getLocation(); - cir.setReturnValue(new Material(Sheets.SIGN_SHEET, new ResourceLocation(location.getNamespace(), "entity/signs/" + location.getPath()))); + cir.setReturnValue(new Material( + Sheets.SIGN_SHEET, + new ResourceLocation( + location.getNamespace(), "entity/signs/" + location.getPath() + ) + )); } } } \ No newline at end of file diff --git a/fabric/src/main/java/com/cursedcauldron/wildbackport/fabric/TerrablenderSetup.java b/fabric/src/main/java/com/cursedcauldron/wildbackport/fabric/TerrablenderSetup.java index b29a28b..21a649e 100644 --- a/fabric/src/main/java/com/cursedcauldron/wildbackport/fabric/TerrablenderSetup.java +++ b/fabric/src/main/java/com/cursedcauldron/wildbackport/fabric/TerrablenderSetup.java @@ -1,5 +1,8 @@ package com.cursedcauldron.wildbackport.fabric; +import java.util.List; +import java.util.function.Consumer; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.common.registry.WBBiomes; import com.cursedcauldron.wildbackport.common.worldgen.MangroveSwampSurface; @@ -17,21 +20,39 @@ import terrablender.api.Regions; import terrablender.api.SurfaceRuleManager; import terrablender.api.TerraBlenderApi; -import java.util.List; -import java.util.function.Consumer; - public class TerrablenderSetup implements TerraBlenderApi { @Override public void onTerraBlenderInitialized() { - Regions.register(new Region(new ResourceLocation(WildBackport.MOD_ID, "overworld"), RegionType.OVERWORLD, 2) { - @Override public void addBiomes(Registry registry, Consumer>> mapper) { + Regions.register(new Region( + new ResourceLocation(WildBackport.MOD_ID, "overworld"), + RegionType.OVERWORLD, + 2 + ) { + @Override + public void addBiomes( + Registry registry, + Consumer>> mapper + ) { this.addModifiedVanillaOverworldBiomes(mapper, builder -> { builder.replaceBiome(Biomes.SWAMP, WBBiomes.MANGROVE_SWAMP); - List points = new ParameterUtils.ParameterPointListBuilder().erosion(ParameterUtils.Erosion.span(ParameterUtils.Erosion.EROSION_0, ParameterUtils.Erosion.EROSION_1)).depth(Climate.Parameter.point(1.1F)).build(); - points.forEach(point -> mapper.accept(Pair.of(point, WBBiomes.DEEP_DARK))); + List points + = new ParameterUtils.ParameterPointListBuilder() + .erosion(ParameterUtils.Erosion.span( + ParameterUtils.Erosion.EROSION_0, + ParameterUtils.Erosion.EROSION_1 + )) + .depth(Climate.Parameter.point(1.1F)) + .build(); + points.forEach( + point -> mapper.accept(Pair.of(point, WBBiomes.DEEP_DARK)) + ); }); } }); - SurfaceRuleManager.addSurfaceRules(SurfaceRuleManager.RuleCategory.OVERWORLD, WildBackport.MOD_ID, MangroveSwampSurface.makeRules()); + SurfaceRuleManager.addSurfaceRules( + SurfaceRuleManager.RuleCategory.OVERWORLD, + WildBackport.MOD_ID, + MangroveSwampSurface.makeRules() + ); } } \ No newline at end of file diff --git a/forge/src/main/java/com/cursedcauldron/wildbackport/common/registry/forge/WBItemsImpl.java b/forge/src/main/java/com/cursedcauldron/wildbackport/common/registry/forge/WBItemsImpl.java index 4282cd3..2f0c919 100644 --- a/forge/src/main/java/com/cursedcauldron/wildbackport/common/registry/forge/WBItemsImpl.java +++ b/forge/src/main/java/com/cursedcauldron/wildbackport/common/registry/forge/WBItemsImpl.java @@ -1,17 +1,25 @@ package com.cursedcauldron.wildbackport.common.registry.forge; +import java.util.function.Supplier; + import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; import net.minecraftforge.common.ForgeSpawnEggItem; -import java.util.function.Supplier; - //<> public class WBItemsImpl { - public static Supplier spawnEgg(Supplier> mob, int background, int highlight) { - return () -> new ForgeSpawnEggItem(mob, background, highlight, new Item.Properties().tab(CreativeModeTab.TAB_MISC)); + public static Supplier spawnEgg( + Supplier> mob, int background, int highlight + ) { + return () + -> new ForgeSpawnEggItem( + mob, + background, + highlight, + new Item.Properties().tab(CreativeModeTab.TAB_MISC) + ); } } diff --git a/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/event/forge/InteractionsImpl.java b/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/event/forge/InteractionsImpl.java index 155ddc6..cc72750 100644 --- a/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/event/forge/InteractionsImpl.java +++ b/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/event/forge/InteractionsImpl.java @@ -1,5 +1,9 @@ package com.cursedcauldron.wildbackport.core.api.event.forge; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Consumer; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.core.api.event.Interactions; import net.minecraft.world.item.context.UseOnContext; @@ -7,13 +11,11 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Consumer; - -@Mod.EventBusSubscriber(modid = WildBackport.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) +@Mod. +EventBusSubscriber(modid = WildBackport.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) public class InteractionsImpl { - private static final Set> INTERACTIONS = ConcurrentHashMap.newKeySet(); + private static final Set> INTERACTIONS + = ConcurrentHashMap.newKeySet(); @SubscribeEvent public static void event(PlayerInteractEvent.RightClickBlock event) { @@ -21,6 +23,11 @@ public class InteractionsImpl { } public static void addRightClick(Interactions.Interaction interaction) { - INTERACTIONS.add(event -> event.setCancellationResult(interaction.of(new UseOnContext(event.getPlayer(), event.getHand(), event.getHitVec())))); + INTERACTIONS.add( + event + -> event.setCancellationResult(interaction.of( + new UseOnContext(event.getPlayer(), event.getHand(), event.getHitVec()) + )) + ); } } \ No newline at end of file diff --git a/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/ColorRegistryImpl.java b/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/ColorRegistryImpl.java index dce5612..5d38f6c 100644 --- a/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/ColorRegistryImpl.java +++ b/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/ColorRegistryImpl.java @@ -1,5 +1,10 @@ package com.cursedcauldron.wildbackport.core.api.forge; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Consumer; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.WildBackport; import net.minecraft.client.color.block.BlockColor; import net.minecraft.client.color.item.ItemColor; @@ -10,18 +15,19 @@ import net.minecraftforge.client.event.ColorHandlerEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Consumer; -import java.util.function.Supplier; - -@Mod.EventBusSubscriber(modid = WildBackport.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD) +@Mod.EventBusSubscriber( + modid = WildBackport.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD +) public class ColorRegistryImpl { - private static final Set> ITEM_COLORS = ConcurrentHashMap.newKeySet(); - private static final Set> BLOCK_COLORS = ConcurrentHashMap.newKeySet(); + private static final Set> ITEM_COLORS + = ConcurrentHashMap.newKeySet(); + private static final Set> BLOCK_COLORS + = ConcurrentHashMap.newKeySet(); @SafeVarargs - public static void register(ItemColor itemColor, Supplier... items) { + public static void register( + ItemColor itemColor, Supplier... items + ) { ITEM_COLORS.add(event -> { for (Supplier item : items) { event.getItemColors().register(itemColor, item.get()); @@ -30,7 +36,9 @@ public class ColorRegistryImpl { } @SafeVarargs - public static void register(BlockColor blockColor, Supplier... blocks) { + public static void register( + BlockColor blockColor, Supplier... blocks + ) { BLOCK_COLORS.add(event -> { for (Supplier block : blocks) { event.getBlockColors().register(blockColor, block.get()); diff --git a/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/CoreRegistryImpl.java b/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/CoreRegistryImpl.java index b63ba4d..021ee2d 100644 --- a/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/CoreRegistryImpl.java +++ b/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/CoreRegistryImpl.java @@ -1,13 +1,13 @@ package com.cursedcauldron.wildbackport.core.api.forge; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.core.api.CoreRegistry; import net.minecraft.core.Registry; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.IForgeRegistryEntry; -import java.util.function.Supplier; - public class CoreRegistryImpl> extends CoreRegistry { private final DeferredRegister registry; @@ -28,7 +28,15 @@ public class CoreRegistryImpl> extends CoreRegi @Override public void bootstrap() { - IEventBus bus = EventBuses.getModEventBus(this.modId).orElseThrow(() -> new IllegalStateException("Attempted to register stuff before registering a Mod Event Bus for: " + this.modId)); + IEventBus bus + = EventBuses.getModEventBus(this.modId) + .orElseThrow( + () + -> new IllegalStateException( + "Attempted to register stuff before registering a Mod Event Bus for: " + + this.modId + ) + ); this.registry.register(bus); } } \ No newline at end of file diff --git a/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/EventBuses.java b/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/EventBuses.java index 36404f6..a8d8ab5 100644 --- a/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/EventBuses.java +++ b/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/EventBuses.java @@ -1,7 +1,5 @@ package com.cursedcauldron.wildbackport.core.api.forge; -import net.minecraftforge.eventbus.api.IEventBus; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -9,16 +7,21 @@ import java.util.Map; import java.util.Optional; import java.util.function.Consumer; +import net.minecraftforge.eventbus.api.IEventBus; + //<> public class EventBuses { private static final HashMap MOD_EVENT_BUSES = new HashMap<>(); - private static final Map>> ON_REGISTERED = new HashMap<>(); + private static final Map>> ON_REGISTERED + = new HashMap<>(); public static void registerModEventBus(String modId, IEventBus bus) { IEventBus previousBus = MOD_EVENT_BUSES.put(modId, bus); if (previousBus != null) { - throw new IllegalStateException("Attempted to register a mod event bus for modid '" + modId + "' twice."); + throw new IllegalStateException( + "Attempted to register a mod event bus for modid '" + modId + "' twice." + ); } } @@ -27,7 +30,8 @@ public class EventBuses { busConsumer.accept(MOD_EVENT_BUSES.get(modId)); } else { synchronized (ON_REGISTERED) { - ON_REGISTERED.computeIfAbsent(modId, s -> new ArrayList<>()).add(busConsumer); + ON_REGISTERED.computeIfAbsent(modId, s -> new ArrayList<>()) + .add(busConsumer); } } } @@ -38,7 +42,10 @@ public class EventBuses { public static IEventBus getModEventBusOrThrow(String modId) { return getModEventBus(modId).orElseThrow( - () -> new IllegalStateException("Mod Event Bus for modid '" + modId + "' has not been registered.") + () + -> new IllegalStateException( + "Mod Event Bus for modid '" + modId + "' has not been registered." + ) ); } } \ No newline at end of file diff --git a/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/MobRegistryImpl.java b/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/MobRegistryImpl.java index f0b3556..998a05a 100644 --- a/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/MobRegistryImpl.java +++ b/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/MobRegistryImpl.java @@ -1,15 +1,21 @@ package com.cursedcauldron.wildbackport.core.api.forge; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.WildBackport; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraftforge.event.entity.EntityAttributeCreationEvent; -import java.util.function.Supplier; - public class MobRegistryImpl { - public static void registerAttributes(Supplier> type, Supplier attribute) { - EventBuses.getModEventBusOrThrow("minecraft").addListener(event -> event.put(type.get(), attribute.get().build())); + public static void registerAttributes( + Supplier> type, + Supplier attribute + ) { + EventBuses.getModEventBusOrThrow("minecraft") + .addListener( + event -> event.put(type.get(), attribute.get().build()) + ); } } \ No newline at end of file diff --git a/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/ParticleRegistryImpl.java b/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/ParticleRegistryImpl.java index bb5d985..ed1d3ed 100644 --- a/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/ParticleRegistryImpl.java +++ b/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/ParticleRegistryImpl.java @@ -1,5 +1,10 @@ package com.cursedcauldron.wildbackport.core.api.forge; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Consumer; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.core.api.ParticleRegistry; import net.minecraft.client.Minecraft; @@ -11,27 +16,34 @@ import net.minecraftforge.client.event.ParticleFactoryRegisterEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Consumer; -import java.util.function.Supplier; - //<> -@Mod.EventBusSubscriber(modid = WildBackport.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD) +@Mod.EventBusSubscriber( + modid = WildBackport.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD +) public class ParticleRegistryImpl { - private static final Set> FACTORIES = ConcurrentHashMap.newKeySet(); + private static final Set> FACTORIES + = ConcurrentHashMap.newKeySet(); @SubscribeEvent public static void event(ParticleFactoryRegisterEvent event) { FACTORIES.forEach(consumer -> consumer.accept(event)); } - public static > void create(Supplier

type, ParticleProvider provider) { - FACTORIES.add(event -> Minecraft.getInstance().particleEngine.register(type.get(), provider)); + public static > void + create(Supplier

type, ParticleProvider provider) { + FACTORIES.add( + event -> Minecraft.getInstance().particleEngine.register(type.get(), provider) + ); } - public static > void create(Supplier

type, ParticleRegistry.Factory factory) { - FACTORIES.add(event -> Minecraft.getInstance().particleEngine.register(type.get(), factory::create)); + public static > void + create(Supplier

type, ParticleRegistry.Factory factory) { + FACTORIES.add( + event + -> Minecraft.getInstance().particleEngine.register( + type.get(), factory::create + ) + ); } } \ No newline at end of file diff --git a/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/RenderRegistryImpl.java b/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/RenderRegistryImpl.java index 95c6e6c..2e76ddf 100644 --- a/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/RenderRegistryImpl.java +++ b/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/RenderRegistryImpl.java @@ -1,5 +1,10 @@ package com.cursedcauldron.wildbackport.core.api.forge; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Consumer; +import java.util.function.Supplier; + import com.cursedcauldron.wildbackport.WildBackport; import net.minecraft.client.model.geom.ModelLayerLocation; import net.minecraft.client.model.geom.builders.LayerDefinition; @@ -17,17 +22,16 @@ import net.minecraftforge.client.event.EntityRenderersEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Consumer; -import java.util.function.Supplier; - //<> -@Mod.EventBusSubscriber(modid = WildBackport.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD) +@Mod.EventBusSubscriber( + modid = WildBackport.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD +) public class RenderRegistryImpl { - private static final Set> RENDERERS = ConcurrentHashMap.newKeySet(); - private static final Set> LAYER_DEFINITIONS = ConcurrentHashMap.newKeySet(); + private static final Set> RENDERERS + = ConcurrentHashMap.newKeySet(); + private static final Set> + LAYER_DEFINITIONS = ConcurrentHashMap.newKeySet(); public static void setBlockRenderType(RenderType type, Block... blocks) { for (Block block : blocks) { @@ -45,15 +49,22 @@ public class RenderRegistryImpl { LAYER_DEFINITIONS.forEach(consumer -> consumer.accept(event)); } - public static void setEntityRender(Supplier> type, EntityRendererProvider provider) { + public static void setEntityRender( + Supplier> type, + EntityRendererProvider provider + ) { RENDERERS.add(event -> event.registerEntityRenderer(type.get(), provider)); } - public static void setLayerDefinition(ModelLayerLocation layer, Supplier definition) { + public static void + setLayerDefinition(ModelLayerLocation layer, Supplier definition) { LAYER_DEFINITIONS.add(event -> event.registerLayerDefinition(layer, definition)); } - public static void setBlockEntityRender(Supplier> type, BlockEntityRendererProvider provider) { + public static void setBlockEntityRender( + Supplier> type, + BlockEntityRendererProvider provider + ) { RENDERERS.add(event -> event.registerBlockEntityRenderer(type.get(), provider)); } } \ No newline at end of file diff --git a/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/WoodTypeRegistryImpl.java b/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/WoodTypeRegistryImpl.java index f76f1ff..8153e4f 100644 --- a/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/WoodTypeRegistryImpl.java +++ b/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/forge/WoodTypeRegistryImpl.java @@ -8,7 +8,8 @@ import net.minecraftforge.fml.loading.FMLLoader; public class WoodTypeRegistryImpl { public static WoodType create(ResourceLocation location) { WoodType woodType = WoodType.register(WoodType.create(location.toString())); - if (FMLLoader.getDist().isClient()) Sheets.addWoodType(woodType); + if (FMLLoader.getDist().isClient()) + Sheets.addWoodType(woodType); return woodType; } } \ No newline at end of file diff --git a/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/worldgen/forge/BiomeModifierImpl.java b/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/worldgen/forge/BiomeModifierImpl.java index 0c91949..2550609 100644 --- a/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/worldgen/forge/BiomeModifierImpl.java +++ b/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/worldgen/forge/BiomeModifierImpl.java @@ -6,7 +6,8 @@ import net.minecraftforge.event.world.BiomeLoadingEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -@Mod.EventBusSubscriber(modid = WildBackport.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) +@Mod. +EventBusSubscriber(modid = WildBackport.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) public class BiomeModifierImpl { public static void setup() {} diff --git a/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/worldgen/forge/ForgeBiomeWriter.java b/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/worldgen/forge/ForgeBiomeWriter.java index 9ec3a76..4543483 100644 --- a/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/worldgen/forge/ForgeBiomeWriter.java +++ b/forge/src/main/java/com/cursedcauldron/wildbackport/core/api/worldgen/forge/ForgeBiomeWriter.java @@ -30,12 +30,24 @@ public class ForgeBiomeWriter extends BiomeWriter { } @Override - public void addFeature(GenerationStep.Decoration step, Holder feature) { + public void + addFeature(GenerationStep.Decoration step, Holder feature) { this.event.getGeneration().addFeature(step, feature); } @Override - public void addSpawn(MobCategory category, EntityType entityType, int weight, int minGroupSize, int maxGroupSize) { - this.event.getSpawns().addSpawn(category, new MobSpawnSettings.SpawnerData(entityType, weight, minGroupSize, maxGroupSize)); + public void addSpawn( + MobCategory category, + EntityType entityType, + int weight, + int minGroupSize, + int maxGroupSize + ) { + this.event.getSpawns().addSpawn( + category, + new MobSpawnSettings.SpawnerData( + entityType, weight, minGroupSize, maxGroupSize + ) + ); } } \ No newline at end of file diff --git a/forge/src/main/java/com/cursedcauldron/wildbackport/forge/DarknessSetup.java b/forge/src/main/java/com/cursedcauldron/wildbackport/forge/DarknessSetup.java index b33678f..74feac2 100644 --- a/forge/src/main/java/com/cursedcauldron/wildbackport/forge/DarknessSetup.java +++ b/forge/src/main/java/com/cursedcauldron/wildbackport/forge/DarknessSetup.java @@ -16,8 +16,11 @@ import net.minecraftforge.client.event.EntityViewRenderEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; - -@Mod.EventBusSubscriber(modid = WildBackport.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.FORGE) +@Mod.EventBusSubscriber( + modid = WildBackport.MOD_ID, + value = Dist.CLIENT, + bus = Mod.EventBusSubscriber.Bus.FORGE +) public class DarknessSetup { @SubscribeEvent public static void darknessFogColor(EntityViewRenderEvent.FogColors event) { @@ -25,15 +28,20 @@ public class DarknessSetup { Level level = event.getCamera().getEntity().getLevel(); if (level.isClientSide() && level instanceof ClientLevel client) { - - double colorModifier = (event.getCamera().getPosition().y - (double)client.getMinBuildHeight()) * client.getLevelData().getClearColorScale(); - if (event.getCamera().getEntity() instanceof LivingEntity living && living.hasEffect(WBMobEffects.DARKNESS.get())) { + double colorModifier = (event.getCamera().getPosition().y + - (double) client.getMinBuildHeight()) + * client.getLevelData().getClearColorScale(); + if (event.getCamera().getEntity() instanceof LivingEntity living + && living.hasEffect(WBMobEffects.DARKNESS.get())) { MobEffectInstance effect = living.getEffect(WBMobEffects.DARKNESS.get()); if (effect != null) { EffectFactor.Instance instance = EffectFactor.Instance.of(effect); if (instance.getFactorCalculationData().isPresent()) { - colorModifier = 1.0F - instance.getFactorCalculationData().get().lerp(living, (float)event.getPartialTicks()); + colorModifier = 1.0F + - instance.getFactorCalculationData().get().lerp( + living, (float) event.getPartialTicks() + ); } else { colorModifier = 0.0D; } @@ -46,9 +54,9 @@ public class DarknessSetup { } colorModifier *= colorModifier; - event.setRed((float)((double)event.getRed() * colorModifier)); - event.setGreen((float)((double)event.getGreen() * colorModifier)); - event.setBlue((float)((double)event.getBlue() * colorModifier)); + event.setRed((float) ((double) event.getRed() * colorModifier)); + event.setGreen((float) ((double) event.getGreen() * colorModifier)); + event.setBlue((float) ((double) event.getBlue() * colorModifier)); } } } @@ -58,14 +66,23 @@ public class DarknessSetup { FogType type = event.getCamera().getFluidInCamera(); if (type != FogType.WATER) { - if (event.getCamera().getEntity() instanceof LivingEntity living && living.hasEffect(WBMobEffects.DARKNESS.get())) { + if (event.getCamera().getEntity() instanceof LivingEntity living + && living.hasEffect(WBMobEffects.DARKNESS.get())) { MobEffectInstance effect = living.getEffect(WBMobEffects.DARKNESS.get()); if (effect != null) { EffectFactor.Instance instance = EffectFactor.Instance.of(effect); if (instance.getFactorCalculationData().isPresent()) { - float modifier = Mth.lerp(instance.getFactorCalculationData().get().lerp(living, (float)event.getPartialTicks()), event.getFarPlaneDistance(), 15.0F); - float start = event.getMode() == FogRenderer.FogMode.FOG_SKY ? 0.0F : modifier * 0.75F; + float modifier = Mth.lerp( + instance.getFactorCalculationData().get().lerp( + living, (float) event.getPartialTicks() + ), + event.getFarPlaneDistance(), + 15.0F + ); + float start = event.getMode() == FogRenderer.FogMode.FOG_SKY + ? 0.0F + : modifier * 0.75F; RenderSystem.setShaderFogStart(start); RenderSystem.setShaderFogEnd(modifier); diff --git a/forge/src/main/java/com/cursedcauldron/wildbackport/forge/RemappingSetup.java b/forge/src/main/java/com/cursedcauldron/wildbackport/forge/RemappingSetup.java index d469b08..f2cf621 100644 --- a/forge/src/main/java/com/cursedcauldron/wildbackport/forge/RemappingSetup.java +++ b/forge/src/main/java/com/cursedcauldron/wildbackport/forge/RemappingSetup.java @@ -10,29 +10,43 @@ import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -@Mod.EventBusSubscriber(modid = WildBackport.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) +@Mod. +EventBusSubscriber(modid = WildBackport.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) public class RemappingSetup { @SubscribeEvent - public static void missingBlockEntityMapping(RegistryEvent.MissingMappings> event) { - for (RegistryEvent.MissingMappings.Mapping> mapping : event.getMappings(WildBackport.MOD_ID)) { + public static void + missingBlockEntityMapping(RegistryEvent.MissingMappings> event) { + for (RegistryEvent.MissingMappings.Mapping> mapping : + event.getMappings(WildBackport.MOD_ID)) { ResourceLocation location = mapping.key; - if (location != null) if (location.getPath().equals("wb_sign")) mapping.remap(BlockEntityType.SIGN); + if (location != null) + if (location.getPath().equals("wb_sign")) + mapping.remap(BlockEntityType.SIGN); } } @SubscribeEvent - public static void missingEntityMapping(RegistryEvent.MissingMappings> event) { - for (RegistryEvent.MissingMappings.Mapping> mapping : event.getMappings(WildBackport.MOD_ID)) { + public static void + missingEntityMapping(RegistryEvent.MissingMappings> event) { + for (RegistryEvent.MissingMappings.Mapping> mapping : + event.getMappings(WildBackport.MOD_ID)) { ResourceLocation location = mapping.key; - if (location != null) if (location.getPath().equals("wb_boat")) mapping.remap(WBEntityTypes.MANGROVE_BOAT.get()); + if (location != null) + if (location.getPath().equals("wb_boat")) + mapping.remap(WBEntityTypes.MANGROVE_BOAT.get()); } } @SubscribeEvent - public static void missingPositionSourceMapping(RegistryEvent.MissingMappings> event) { - for (RegistryEvent.MissingMappings.Mapping> mapping : event.getMappings(WildBackport.MOD_ID)) { + public static void + missingPositionSourceMapping(RegistryEvent.MissingMappings> event + ) { + for (RegistryEvent.MissingMappings.Mapping> mapping : + event.getMappings(WildBackport.MOD_ID)) { ResourceLocation location = mapping.key; - if (location != null) if (location.getPath().equals("water_tree_foliage_placer")) mapping.remap(FoliagePlacerType.RANDOM_SPREAD_FOLIAGE_PLACER); + if (location != null) + if (location.getPath().equals("water_tree_foliage_placer")) + mapping.remap(FoliagePlacerType.RANDOM_SPREAD_FOLIAGE_PLACER); } } } \ No newline at end of file diff --git a/forge/src/main/java/com/cursedcauldron/wildbackport/forge/WildBackportForge.java b/forge/src/main/java/com/cursedcauldron/wildbackport/forge/WildBackportForge.java index 37f158b..9c3e76d 100644 --- a/forge/src/main/java/com/cursedcauldron/wildbackport/forge/WildBackportForge.java +++ b/forge/src/main/java/com/cursedcauldron/wildbackport/forge/WildBackportForge.java @@ -1,5 +1,8 @@ package com.cursedcauldron.wildbackport.forge; +import java.util.List; +import java.util.function.Consumer; + import com.cursedcauldron.wildbackport.WildBackport; import com.cursedcauldron.wildbackport.client.ClientSetup; import com.cursedcauldron.wildbackport.common.CommonSetup; @@ -26,9 +29,6 @@ import terrablender.api.RegionType; import terrablender.api.Regions; import terrablender.api.SurfaceRuleManager; -import java.util.List; -import java.util.function.Consumer; - @Mod(WildBackport.MOD_ID) public class WildBackportForge { public WildBackportForge() { @@ -45,15 +45,36 @@ public class WildBackportForge { } private void terrablenderSetup(final FMLCommonSetupEvent event) { - Regions.register(new Region(new ResourceLocation(WildBackport.MOD_ID, "overworld"), RegionType.OVERWORLD, 2) { - @Override public void addBiomes(Registry registry, Consumer>> mapper) { + Regions.register(new Region( + new ResourceLocation(WildBackport.MOD_ID, "overworld"), + RegionType.OVERWORLD, + 2 + ) { + @Override + public void addBiomes( + Registry registry, + Consumer>> mapper + ) { this.addModifiedVanillaOverworldBiomes(mapper, builder -> { builder.replaceBiome(Biomes.SWAMP, WBBiomes.MANGROVE_SWAMP); - List points = new ParameterUtils.ParameterPointListBuilder().erosion(ParameterUtils.Erosion.span(ParameterUtils.Erosion.EROSION_0, ParameterUtils.Erosion.EROSION_1)).depth(Climate.Parameter.point(1.1F)).build(); - points.forEach(point -> mapper.accept(Pair.of(point, WBBiomes.DEEP_DARK))); + List points + = new ParameterUtils.ParameterPointListBuilder() + .erosion(ParameterUtils.Erosion.span( + ParameterUtils.Erosion.EROSION_0, + ParameterUtils.Erosion.EROSION_1 + )) + .depth(Climate.Parameter.point(1.1F)) + .build(); + points.forEach( + point -> mapper.accept(Pair.of(point, WBBiomes.DEEP_DARK)) + ); }); } }); - SurfaceRuleManager.addSurfaceRules(SurfaceRuleManager.RuleCategory.OVERWORLD, WildBackport.MOD_ID, MangroveSwampSurface.makeRules()); + SurfaceRuleManager.addSurfaceRules( + SurfaceRuleManager.RuleCategory.OVERWORLD, + WildBackport.MOD_ID, + MangroveSwampSurface.makeRules() + ); } } \ No newline at end of file