-
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.
Started work on climbing behaviour for critters and crustaceans, need…
…s refining @dragon@Dragon@Dragon@Dragon@Dragon@Dragon@Dragon@Dragon@Dragon@Dragon@Dragon@Dragon@Dragon@Dragon@Dragon
- Loading branch information
1 parent
f7bb114
commit aa3f9b0
Showing
12 changed files
with
273 additions
and
66 deletions.
There are no files selected for viewing
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
1 change: 0 additions & 1 deletion
1
...client/kotlin/dev/hybridlabs/aquatic/client/model/entity/critter/NudibranchEntityModel.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.critter | ||
|
||
import dev.hybridlabs.aquatic.entity.critter.HybridAquaticCritterEntity | ||
import net.minecraft.util.Identifier | ||
|
||
class NudibranchEntityModel : HybridAquaticCritterEntityModel<HybridAquaticCritterEntity>("nudibranch") |
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
14 changes: 14 additions & 0 deletions
14
src/main/kotlin/dev/hybridlabs/aquatic/entity/ai/WallClimbingLookControl.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,14 @@ | ||
package dev.hybridlabs.aquatic.entity.ai | ||
|
||
import net.minecraft.entity.ai.control.YawAdjustingLookControl | ||
import net.minecraft.entity.mob.MobEntity | ||
|
||
|
||
class WallClimbingLookControl(entity: MobEntity, yawAdjustThreshold: Int) : | ||
YawAdjustingLookControl(entity, yawAdjustThreshold) { | ||
override fun tick() { | ||
if (!entity.isClimbing) { | ||
super.tick() | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
src/main/kotlin/dev/hybridlabs/aquatic/entity/ai/WallClimbingNavigation.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,67 @@ | ||
package dev.hybridlabs.aquatic.entity.ai | ||
|
||
import net.minecraft.entity.Entity | ||
import net.minecraft.entity.ai.pathing.MobNavigation | ||
import net.minecraft.entity.ai.pathing.Path | ||
import net.minecraft.entity.mob.MobEntity | ||
import net.minecraft.util.math.BlockPos | ||
import net.minecraft.world.World | ||
import kotlin.math.max | ||
|
||
|
||
class WallClimbingNavigation(mobEntity: MobEntity?, world: World?) : MobNavigation(mobEntity, world) { | ||
private var targetPos: BlockPos? = null | ||
|
||
override fun findPathTo(target: BlockPos, distance: Int): Path? { | ||
this.targetPos = target | ||
return super.findPathTo(target, distance) | ||
} | ||
|
||
override fun findPathTo(entity: Entity, distance: Int): Path? { | ||
this.targetPos = entity.blockPos | ||
return super.findPathTo(entity, distance) | ||
} | ||
|
||
override fun startMovingTo(entity: Entity, speed: Double): Boolean { | ||
val path: Path? = this.findPathTo(entity, 0) | ||
if (path != null) { | ||
return this.startMovingAlong(path, speed) | ||
} | ||
this.targetPos = entity.blockPos | ||
this.speed = speed | ||
return true | ||
} | ||
|
||
override fun tick() { | ||
if (!this.isIdle) { | ||
super.tick() | ||
return | ||
} | ||
|
||
if (this.targetPos != null) { | ||
if (!targetPos!!.isWithinDistance( | ||
entity.pos, max( | ||
entity.width.toDouble(), 1.0 | ||
) | ||
) | ||
&& (!(entity.y > targetPos!!.y.toDouble()) | ||
|| !BlockPos( | ||
targetPos!!.x, | ||
entity.blockY, targetPos!!.z | ||
).isWithinDistance( | ||
entity.pos, max(entity.width.toDouble(), 1.0) | ||
) | ||
) | ||
) { | ||
entity.moveControl.moveTo( | ||
targetPos!!.x.toDouble(), | ||
targetPos!!.y.toDouble(), | ||
targetPos!!.z.toDouble(), | ||
0.5 | ||
) | ||
} else { | ||
this.targetPos = null | ||
} | ||
} | ||
} | ||
} |
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.