Skip to content

Commit

Permalink
File organization and such
Browse files Browse the repository at this point in the history
  • Loading branch information
MysticKoko committed Apr 8, 2024
1 parent 0d994b8 commit db42c1b
Show file tree
Hide file tree
Showing 26 changed files with 125 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import dev.hybridlabs.aquatic.enchantment.HybridAquaticEnchantments;
import dev.hybridlabs.aquatic.enchantment.LiveCatchEnchantment;
import dev.hybridlabs.aquatic.entity.HybridAquaticEntityTypes;
import dev.hybridlabs.aquatic.entity.critter.KarkinosEntity;
import dev.hybridlabs.aquatic.item.HybridAquaticItems;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
Expand All @@ -28,7 +27,6 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dev.hybridlabs.aquatic.entity

import dev.hybridlabs.aquatic.HybridAquatic
import dev.hybridlabs.aquatic.entity.critter.*
import dev.hybridlabs.aquatic.entity.crustacean.*
import dev.hybridlabs.aquatic.entity.fish.*
import dev.hybridlabs.aquatic.entity.jellyfish.*
import dev.hybridlabs.aquatic.entity.shark.*
Expand Down Expand Up @@ -55,7 +56,7 @@ object HybridAquaticEntityTypes {
"clownfish",
::ClownfishEntity,
EntityDimensions.fixed(0.4f, 0.35f),
ClownfishEntity.createClownfishAttributes()
ClownfishEntity.createMobAttributes()
)

val COWFISH = registerFish(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.hybridlabs.aquatic.entity

import dev.hybridlabs.aquatic.entity.critter.HybridAquaticCrabEntity
import dev.hybridlabs.aquatic.entity.crustacean.HybridAquaticCrabEntity
import dev.hybridlabs.aquatic.entity.critter.HybridAquaticCritterEntity
import dev.hybridlabs.aquatic.entity.fish.HybridAquaticFishEntity
import dev.hybridlabs.aquatic.entity.jellyfish.HybridAquaticJellyfishEntity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package dev.hybridlabs.aquatic.entity.ai.goal

import dev.hybridlabs.aquatic.entity.critter.HybridAquaticCrabEntity
import dev.hybridlabs.aquatic.entity.crustacean.HybridAquaticCrabEntity
import dev.hybridlabs.aquatic.loot.HybridAquaticLootTables
import dev.hybridlabs.aquatic.tag.HybridAquaticBlockTags
import net.minecraft.block.BlockState
import net.minecraft.entity.Entity
import net.minecraft.entity.ItemEntity
import net.minecraft.entity.ai.goal.Goal
import net.minecraft.item.ItemStack
Expand All @@ -13,8 +12,6 @@ import net.minecraft.loot.context.LootContextParameters
import net.minecraft.loot.context.LootContextTypes
import net.minecraft.particle.ParticleTypes
import net.minecraft.server.world.ServerWorld
import net.minecraft.util.math.Vec3d
import net.minecraft.world.World
import java.util.*

class CrabDigGoal(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,11 @@ open class HybridAquaticCritterEntity(type: EntityType<out HybridAquaticCritterE
override fun tickWaterBreathingAir(air: Int) {}

open fun <E : GeoAnimatable> predicate(event: AnimationState<E>): PlayState {
if (event.isMoving && isOnGround) {
if (event.isMoving) {
event.controller.setAnimation(WALK_ANIMATION)
} else {
event.controller.setAnimation(IDLE_ANIMATION)
}

return PlayState.CONTINUE
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.hybridlabs.aquatic.entity.critter
package dev.hybridlabs.aquatic.entity.crustacean

import dev.hybridlabs.aquatic.entity.critter.HybridAquaticCritterEntity
import net.minecraft.entity.EntityType
import net.minecraft.entity.attribute.DefaultAttributeContainer
import net.minecraft.entity.attribute.EntityAttributes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.hybridlabs.aquatic.entity.critter
package dev.hybridlabs.aquatic.entity.crustacean

import dev.hybridlabs.aquatic.entity.critter.HybridAquaticCritterEntity
import net.minecraft.entity.EntityType
import net.minecraft.entity.attribute.DefaultAttributeContainer
import net.minecraft.entity.attribute.EntityAttributes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.hybridlabs.aquatic.entity.critter
package dev.hybridlabs.aquatic.entity.crustacean

import dev.hybridlabs.aquatic.entity.critter.HybridAquaticCritterEntity
import net.minecraft.entity.EntityType
import net.minecraft.entity.attribute.DefaultAttributeContainer
import net.minecraft.entity.attribute.EntityAttributes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.hybridlabs.aquatic.entity.critter
package dev.hybridlabs.aquatic.entity.crustacean

import dev.hybridlabs.aquatic.entity.critter.HybridAquaticCritterEntity
import net.minecraft.entity.EntityGroup
import net.minecraft.entity.EntityType
import net.minecraft.entity.attribute.DefaultAttributeContainer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.hybridlabs.aquatic.entity.critter
package dev.hybridlabs.aquatic.entity.crustacean

import dev.hybridlabs.aquatic.entity.critter.HybridAquaticCritterEntity
import net.minecraft.entity.EntityType
import net.minecraft.entity.attribute.DefaultAttributeContainer
import net.minecraft.entity.attribute.EntityAttributes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.hybridlabs.aquatic.entity.critter
package dev.hybridlabs.aquatic.entity.crustacean

import dev.hybridlabs.aquatic.entity.critter.HybridAquaticCritterEntity
import net.minecraft.entity.EntityType
import net.minecraft.entity.attribute.DefaultAttributeContainer
import net.minecraft.entity.attribute.EntityAttributes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.hybridlabs.aquatic.entity.critter
package dev.hybridlabs.aquatic.entity.crustacean

import dev.hybridlabs.aquatic.entity.critter.HybridAquaticCritterEntity
import net.minecraft.entity.EntityType
import net.minecraft.entity.attribute.DefaultAttributeContainer
import net.minecraft.entity.attribute.EntityAttributes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.hybridlabs.aquatic.entity.critter
package dev.hybridlabs.aquatic.entity.crustacean

import dev.hybridlabs.aquatic.entity.ai.goal.CrabDigGoal
import dev.hybridlabs.aquatic.entity.critter.HybridAquaticCritterEntity
import net.minecraft.entity.EntityGroup
import net.minecraft.entity.EntityType
import net.minecraft.entity.attribute.DefaultAttributeContainer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.hybridlabs.aquatic.entity.critter
package dev.hybridlabs.aquatic.entity.crustacean

import dev.hybridlabs.aquatic.entity.critter.HybridAquaticCritterEntity
import net.minecraft.entity.EntityType
import net.minecraft.entity.attribute.DefaultAttributeContainer
import net.minecraft.entity.attribute.EntityAttributes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.hybridlabs.aquatic.entity.critter
package dev.hybridlabs.aquatic.entity.crustacean

import dev.hybridlabs.aquatic.entity.critter.HybridAquaticCritterEntity
import dev.hybridlabs.aquatic.tag.HybridAquaticBlockTags
import net.minecraft.block.Blocks
import net.minecraft.entity.EntityGroup
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.hybridlabs.aquatic.entity.critter
package dev.hybridlabs.aquatic.entity.crustacean

import dev.hybridlabs.aquatic.entity.critter.HybridAquaticCritterEntity
import net.minecraft.enchantment.EnchantmentHelper
import net.minecraft.enchantment.Enchantments
import net.minecraft.entity.EntityType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.hybridlabs.aquatic.entity.critter
package dev.hybridlabs.aquatic.entity.crustacean

import dev.hybridlabs.aquatic.entity.critter.HybridAquaticCritterEntity
import net.minecraft.entity.EntityType
import net.minecraft.entity.attribute.DefaultAttributeContainer
import net.minecraft.entity.attribute.EntityAttributes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.hybridlabs.aquatic.entity.critter
package dev.hybridlabs.aquatic.entity.crustacean

import dev.hybridlabs.aquatic.entity.critter.HybridAquaticCritterEntity
import net.minecraft.entity.EntityType
import net.minecraft.entity.attribute.DefaultAttributeContainer
import net.minecraft.entity.attribute.EntityAttributes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.hybridlabs.aquatic.entity.critter
package dev.hybridlabs.aquatic.entity.crustacean

import dev.hybridlabs.aquatic.entity.critter.HybridAquaticCritterEntity
import net.minecraft.entity.EntityType
import net.minecraft.entity.attribute.DefaultAttributeContainer
import net.minecraft.entity.attribute.EntityAttributes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.hybridlabs.aquatic.entity.critter
package dev.hybridlabs.aquatic.entity.crustacean

import dev.hybridlabs.aquatic.entity.critter.HybridAquaticCritterEntity
import net.minecraft.entity.EntityType
import net.minecraft.entity.attribute.DefaultAttributeContainer
import net.minecraft.entity.attribute.EntityAttributes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.hybridlabs.aquatic.entity.critter
package dev.hybridlabs.aquatic.entity.crustacean

import dev.hybridlabs.aquatic.entity.critter.HybridAquaticCritterEntity
import net.minecraft.entity.EntityType
import net.minecraft.entity.attribute.DefaultAttributeContainer
import net.minecraft.entity.attribute.EntityAttributes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.hybridlabs.aquatic.entity.critter
package dev.hybridlabs.aquatic.entity.crustacean

import dev.hybridlabs.aquatic.block.HybridAquaticBlocks
import dev.hybridlabs.aquatic.entity.critter.HybridAquaticCritterEntity
import net.minecraft.entity.EntityType
import net.minecraft.entity.attribute.DefaultAttributeContainer
import net.minecraft.entity.attribute.EntityAttributes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class BlueSpottedStingrayEntity(entityType: EntityType<out BlueSpottedStingrayEn
fun createMobAttributes(): DefaultAttributeContainer.Builder {
return WaterCreatureEntity.createMobAttributes()
.add(EntityAttributes.GENERIC_MAX_HEALTH, 6.0)
.add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 1.0)
.add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.7)
}
}

Expand Down
106 changes: 40 additions & 66 deletions src/main/kotlin/dev/hybridlabs/aquatic/entity/fish/ClownfishEntity.kt
Original file line number Diff line number Diff line change
@@ -1,97 +1,71 @@
package dev.hybridlabs.aquatic.entity.fish

import dev.hybridlabs.aquatic.block.HybridAquaticBlocks.ANEMONE
import dev.hybridlabs.aquatic.block.HybridAquaticBlocks
import net.minecraft.entity.EntityType
import net.minecraft.entity.ai.goal.Goal
import net.minecraft.entity.attribute.DefaultAttributeContainer
import net.minecraft.entity.attribute.EntityAttributes
import net.minecraft.entity.mob.WaterCreatureEntity
import net.minecraft.util.math.BlockPos
import net.minecraft.world.World
import java.util.*

class ClownfishEntity(entityType: EntityType<out ClownfishEntity>, world: World) :
HybridAquaticFishEntity(entityType, world) {

private val isAttacked = false
private var targetAnemonePos: BlockPos? = null

override fun initGoals() {
goalSelector.add(2, GoalHideInAnemone(this))
super.initGoals()
companion object {
fun createMobAttributes(): DefaultAttributeContainer.Builder {
return WaterCreatureEntity.createMobAttributes()
.add(EntityAttributes.GENERIC_MAX_HEALTH, 2.0)
.add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.6)
}
}

class GoalHideInAnemone(private val clownfish: ClownfishEntity) : Goal() {
private var targetAnemonePos: BlockPos? = null
override fun getMaxSize(): Int {
return 5
}

init {
controls = EnumSet.of(Control.MOVE)
}
override fun getMinSize(): Int {
return -5
}

override fun canStart(): Boolean {
return clownfish.attacker != null
}
override fun tick() {
super.tick()

override fun start() {
findNearestAnemone()?.let { nearestAnemonePos ->
targetAnemonePos = nearestAnemonePos
clownfish.getNavigation().startMovingTo(
nearestAnemonePos.x.toDouble(),
nearestAnemonePos.y.toDouble(),
nearestAnemonePos.z.toDouble(),
1.0
)
}
if (targetAnemonePos == null || world.getBlockState(targetAnemonePos).isOf(HybridAquaticBlocks.ANEMONE)) {
targetAnemonePos = findNearbyAnemone()
}

override fun shouldContinue(): Boolean {
return targetAnemonePos != null && clownfish.isAlive && clownfish.isAttacked
}
if (targetAnemonePos != null) {
val distanceToAnemone = distanceTo(targetAnemonePos!!)

override fun tick() {
targetAnemonePos?.let { pos ->
clownfish.getNavigation().startMovingTo(
pos.x.toDouble(),
pos.y.toDouble(),
pos.z.toDouble(),
1.0
)
if (distanceToAnemone > 5.0) {
navigateToAnemone(targetAnemonePos!!)
}
}
}

override fun stop() {
targetAnemonePos = null
clownfish.getNavigation().stop()
}
private fun navigateToAnemone(ventBlockPos: BlockPos) {
this.navigation.startMovingTo(ventBlockPos.x.toDouble(), ventBlockPos.y.toDouble(), ventBlockPos.z.toDouble(), this.getAttributeValue(EntityAttributes.GENERIC_MOVEMENT_SPEED))
}

private fun findNearestAnemone(): BlockPos? {
val currentPos = clownfish.blockPos
for (i in -8..8) {
for (j in -8..8) {
for (k in -8..8) {
val checkPos = currentPos.add(i, j, k)
val block = clownfish.world.getBlockState(checkPos).block
if (block === ANEMONE) {
return checkPos
}
private fun findNearbyAnemone(): BlockPos? {
for (i in -5..5) {
for (j in -5..5) {
for (k in -5..5) {
val blockPos = BlockPos((x + i).toInt(), (y + j).toInt(), (z + k).toInt())
val blockState = world.getBlockState(blockPos)

if (blockState.isOf(HybridAquaticBlocks.ANEMONE)) {
return blockPos
}
}
}
return null
}
}

companion object {
fun createClownfishAttributes(): DefaultAttributeContainer.Builder {
return createMobAttributes()
.add(EntityAttributes.GENERIC_MAX_HEALTH, 4.0)
.add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.6)
}
return null
}

override fun getMaxSize(): Int {
return 5
}

override fun getMinSize(): Int {
return -5
private fun distanceTo(pos: BlockPos): Double {
return this.blockPos.getSquaredDistance(pos.x.toDouble(), pos.y.toDouble(), pos.z.toDouble())
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ open class HybridAquaticFishEntity(

init {
moveControl = FishMoveControl(this)
lookControl = YawAdjustingLookControl(this, 5)
lookControl = YawAdjustingLookControl(this, 20)
}

override fun tickMovement() {
Expand Down
Loading

0 comments on commit db42c1b

Please sign in to comment.