Skip to content

Commit

Permalink
Merge branch 'latest' of https://github.com/hybridlabs/hybrid-aquatic
Browse files Browse the repository at this point in the history
…into latest
  • Loading branch information
MysticKoko committed Jan 23, 2025
2 parents 2f9fb09 + 1f8d5e3 commit 1e05f8f
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package dev.hybridlabs.aquatic.client.model.entity.crustacean
import dev.hybridlabs.aquatic.HybridAquatic
import dev.hybridlabs.aquatic.entity.crustacean.HybridAquaticCrustaceanEntity
import net.minecraft.client.render.entity.model.EntityModelPartNames
import net.minecraft.text.Text
import net.minecraft.util.Identifier
import net.minecraft.util.math.MathHelper
import software.bernie.geckolib.core.animation.AnimationState
import software.bernie.geckolib.model.GeoModel
import kotlin.math.round
import kotlin.math.sin

abstract class HybridAquaticCrustaceanEntityModel<T : HybridAquaticCrustaceanEntity>(private val id: String) :
Expand Down Expand Up @@ -54,20 +56,20 @@ abstract class HybridAquaticCrustaceanEntityModel<T : HybridAquaticCrustaceanEnt
if (animatable.isClimbing) {
body.rotX = Math.toRadians(90.0).toFloat()

when (entityYaw) {
in 135.01f..225.0f -> {
body.rotY = Math.toRadians(180.0).toFloat()
}
in 225.01f..315.0f -> {
body.rotY = Math.toRadians(270.0).toFloat()
}
in 315.01f..360.0f, in 0.0f..45.0f -> {
body.rotY = Math.toRadians(0.0).toFloat()
}
in 45.01f..135.0f -> {
body.rotY = Math.toRadians(90.0).toFloat()
}
}
//
val snappedAngle = snapAngle(entityYaw, 4);

// animatable.isCustomNameVisible = true;
// animatable.customName = Text.literal("Snapped angle: $snappedAngle");
body.rotY = snappedAngle;
}
}

private fun snapAngle(angle : Float, slices : Int) : Float {
val normalized = angle % 360;
val sliceSize = 360 / slices;

val sliceCenter = round(normalized / sliceSize) * sliceSize;
return sliceCenter;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ import dev.hybridlabs.aquatic.entity.crustacean.*
import dev.hybridlabs.aquatic.entity.fish.*
import dev.hybridlabs.aquatic.entity.jellyfish.*
import dev.hybridlabs.aquatic.entity.miniboss.KarkinosEntity
import dev.hybridlabs.aquatic.entity.miscellaneous.ThrowingStarEntity
import dev.hybridlabs.aquatic.entity.shark.*
import dev.hybridlabs.aquatic.utils.HybridAquaticSpawnGroup
import net.fabricmc.fabric.api.`object`.builder.v1.entity.FabricDefaultAttributeRegistry
import net.fabricmc.fabric.api.`object`.builder.v1.entity.FabricEntityTypeBuilder
import net.minecraft.entity.*
import net.minecraft.entity.EntityType.EntityFactory
import net.minecraft.entity.attribute.DefaultAttributeContainer
import net.minecraft.entity.projectile.ProjectileEntity
import net.minecraft.registry.Registries
import net.minecraft.registry.Registry
import net.minecraft.util.Identifier
Expand Down Expand Up @@ -706,6 +708,11 @@ object HybridAquaticEntityTypes {
WhaleSharkEntity.createMobAttributes()
)

val THROWING_STAR = registerProjectile("throwing_star",
::ThrowingStarEntity,
EntityDimensions.fixed(0.25f,0.25f)
)

private fun <T : LivingEntity> registerShark(
id: String,
entityFactory: EntityFactory<T>,
Expand Down Expand Up @@ -850,6 +857,15 @@ object HybridAquaticEntityTypes {
return register(id, entityType)
}

private fun <T: ProjectileEntity> registerProjectile(
id: String,
entityFactory: EntityFactory<T>,
dimensions: EntityDimensions
) : EntityType<T> {
val entityType = FabricEntityTypeBuilder.create(SpawnGroup.MISC, entityFactory).dimensions(dimensions).build();
return register(id, entityType)
}

/**
* Registers an entity type to the entity type registry.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package dev.hybridlabs.aquatic.entity.miscellaneous

import net.minecraft.entity.Entity
import net.minecraft.entity.EntityType
import net.minecraft.entity.projectile.ProjectileEntity
import net.minecraft.item.ItemStack
import net.minecraft.item.Items
import net.minecraft.world.World

/**
*
*/
class ThrowingStarEntity(entityType: EntityType<out ProjectileEntity>, world: World?) :
ProjectileEntity(
entityType,
world
) {

var DisplayItem : ItemStack = Items.COOKED_COD.defaultStack;

override fun initDataTracker() {}

override fun tick() {

super.tick()
}

companion object {
fun spawnThrowingStar(player : Entity, magnitude: Float) {

}
}
}

0 comments on commit 1e05f8f

Please sign in to comment.