-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added jumping behaviour to threshers, great whites, and manta rays
- Loading branch information
1 parent
83f83dd
commit 3481e46
Showing
22 changed files
with
311 additions
and
561 deletions.
There are no files selected for viewing
46 changes: 0 additions & 46 deletions
46
...ent/kotlin/dev/hybridlabs/aquatic/client/model/entity/fish/HybridAquaticRayEntityModel.kt
This file was deleted.
Oops, something went wrong.
3 changes: 1 addition & 2 deletions
3
src/client/kotlin/dev/hybridlabs/aquatic/client/model/entity/fish/MantaRayEntityModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
package dev.hybridlabs.aquatic.client.model.entity.fish | ||
|
||
import dev.hybridlabs.aquatic.entity.fish.HybridAquaticFishEntity | ||
import dev.hybridlabs.aquatic.entity.fish.ray.HybridAquaticRayEntity | ||
|
||
class MantaRayEntityModel : HybridAquaticRayEntityModel<HybridAquaticRayEntity>("manta_ray") | ||
class MantaRayEntityModel : HybridAquaticFishEntityModel<HybridAquaticFishEntity>("manta_ray") |
4 changes: 2 additions & 2 deletions
4
src/client/kotlin/dev/hybridlabs/aquatic/client/model/entity/fish/StingrayEntityModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package dev.hybridlabs.aquatic.client.model.entity.fish | ||
|
||
import dev.hybridlabs.aquatic.entity.fish.ray.HybridAquaticRayEntity | ||
import dev.hybridlabs.aquatic.entity.fish.HybridAquaticFishEntity | ||
|
||
class StingrayEntityModel : HybridAquaticRayEntityModel<HybridAquaticRayEntity>("stingray") | ||
class StingrayEntityModel : HybridAquaticFishEntityModel<HybridAquaticFishEntity>("stingray") |
32 changes: 0 additions & 32 deletions
32
...kotlin/dev/hybridlabs/aquatic/client/render/entity/fish/HybridAquaticRayEntityRenderer.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
src/main/kotlin/dev/hybridlabs/aquatic/entity/ai/goal/SharkJumpGoal.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package dev.hybridlabs.aquatic.entity.ai.goal | ||
|
||
import dev.hybridlabs.aquatic.entity.shark.HybridAquaticSharkEntity | ||
import net.minecraft.entity.ai.goal.DiveJumpingGoal | ||
import net.minecraft.registry.tag.FluidTags | ||
import net.minecraft.sound.SoundEvents | ||
import net.minecraft.util.math.BlockPos | ||
import net.minecraft.util.math.MathHelper | ||
import kotlin.math.abs | ||
import kotlin.math.atan2 | ||
|
||
@Suppress("DEPRECATION") | ||
class SharkJumpGoal(private val shark: HybridAquaticSharkEntity, chance: Int) : DiveJumpingGoal() { | ||
private val chance: Int = toGoalTicks(chance) | ||
private var inWater = false | ||
|
||
override fun canStart(): Boolean { | ||
return if (shark.random.nextInt(chance) != 0) { | ||
false | ||
} else { | ||
val direction = shark.movementDirection | ||
val i = direction.offsetX | ||
val j = direction.offsetZ | ||
val blockPos = shark.blockPos | ||
val var5 = OFFSET_MULTIPLIERS | ||
val var6 = var5.size | ||
for (var7 in 0 until var6) { | ||
val k = var5[var7] | ||
if (!isWater(blockPos, i, j, k) || !isAirAbove(blockPos, i, j, k)) { | ||
return false | ||
} | ||
} | ||
true | ||
} | ||
} | ||
|
||
private fun isWater(pos: BlockPos, offsetX: Int, offsetZ: Int, multiplier: Int): Boolean { | ||
val blockPos = pos.add(offsetX * multiplier, 0, offsetZ * multiplier) | ||
return shark.world.getFluidState(blockPos).isIn(FluidTags.WATER) && !shark.world.getBlockState(blockPos) | ||
.blocksMovement() | ||
} | ||
|
||
private fun isAirAbove(pos: BlockPos, offsetX: Int, offsetZ: Int, multiplier: Int): Boolean { | ||
return shark.world.getBlockState( | ||
pos.add( | ||
offsetX * multiplier, | ||
1, | ||
offsetZ * multiplier | ||
) | ||
).isAir && shark.world.getBlockState(pos.add(offsetX * multiplier, 2, offsetZ * multiplier)).isAir | ||
} | ||
|
||
override fun shouldContinue(): Boolean { | ||
val d = shark.velocity.y | ||
return (!(d * d < 0.029999999329447746) || shark.pitch == 0.0f || !(abs(shark.pitch) < 10.0f) || !shark.isTouchingWater) && !shark.isOnGround | ||
} | ||
|
||
override fun canStop(): Boolean { | ||
return false | ||
} | ||
|
||
override fun start() { | ||
val direction = shark.movementDirection | ||
shark.velocity = | ||
shark.velocity.add(direction.offsetX.toDouble() * 0.6, 1.4, direction.offsetZ.toDouble() * 0.6) | ||
shark.navigation.stop() | ||
} | ||
|
||
override fun stop() { | ||
shark.pitch = 0.0f | ||
} | ||
|
||
override fun tick() { | ||
val bl = inWater | ||
if (!bl) { | ||
val fluidState = shark.world.getFluidState(shark.blockPos) | ||
inWater = fluidState.isIn(FluidTags.WATER) | ||
} | ||
if (inWater && !bl) { | ||
shark.playSound(SoundEvents.ENTITY_DOLPHIN_JUMP, 1.0f, 1.0f) | ||
} | ||
val vec3d = shark.velocity | ||
if (vec3d.y * vec3d.y < 0.029999999329447746 && shark.pitch != 0.0f) { | ||
shark.pitch = MathHelper.lerpAngleDegrees(0.2f, shark.pitch, 0.0f) | ||
} else if (vec3d.length() > 9.999999747378752E-6) { | ||
val d = vec3d.horizontalLength() | ||
val e = atan2(-vec3d.y, d) * 57.2957763671875 | ||
shark.pitch = e.toFloat() | ||
} | ||
} | ||
|
||
companion object { | ||
private val OFFSET_MULTIPLIERS = intArrayOf(0, 1, 4, 5, 6, 7) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.