Skip to content

Commit

Permalink
Fixed jellyfish spawning underground and in the air
Browse files Browse the repository at this point in the history
  • Loading branch information
MysticKoko committed Jun 3, 2024
1 parent e44cd2e commit b769730
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dev.hybridlabs.aquatic.entity

import dev.hybridlabs.aquatic.entity.cephalopod.HybridAquaticCephalopodEntity
import dev.hybridlabs.aquatic.entity.crustacean.HybridAquaticCrustaceanEntity
import dev.hybridlabs.aquatic.entity.critter.HybridAquaticCritterEntity
import dev.hybridlabs.aquatic.entity.crustacean.HybridAquaticCrustaceanEntity
import dev.hybridlabs.aquatic.entity.fish.HybridAquaticFishEntity
import dev.hybridlabs.aquatic.entity.jellyfish.HybridAquaticJellyfishEntity
import dev.hybridlabs.aquatic.entity.shark.HybridAquaticSharkEntity
Expand Down Expand Up @@ -84,6 +84,7 @@ object SpawnRestrictionRegistry {
HybridAquaticEntityTypes.COMPASS_JELLYFISH,
HybridAquaticEntityTypes.LIONS_MANE_JELLYFISH,
HybridAquaticEntityTypes.NOMURA_JELLYFISH,
HybridAquaticEntityTypes.BARREL_JELLYFISH,
).forEach { registerJelly(it) }

setOf(
Expand Down Expand Up @@ -169,7 +170,7 @@ object SpawnRestrictionRegistry {
}

private fun <T : WaterCreatureEntity> registerCritter(entityType: EntityType<T>) {
registerLandWaterCreature(entityType, HybridAquaticCritterEntity::canSpawn)
registerWaterCreature(entityType, HybridAquaticCritterEntity::canSpawn)
}

private fun <T : WaterCreatureEntity> registerWaterCreature(entityType: EntityType<T>, predicate: SpawnPredicate<T>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ open class HybridAquaticFishEntity(
): Boolean {
return pos.y <= world.seaLevel - 32 &&
world.getBaseLightLevel(pos, 0) == 0 &&
world.getFluidState(pos.down()).isIn(FluidTags.WATER) &&
world.getBlockState(pos).isOf(Blocks.WATER)
}

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

import dev.hybridlabs.aquatic.goals.StayInWaterGoal
import net.minecraft.block.Blocks
import net.minecraft.entity.*
import net.minecraft.entity.ai.control.AquaticMoveControl
import net.minecraft.entity.ai.control.YawAdjustingLookControl
Expand Down Expand Up @@ -389,8 +388,9 @@ open class HybridAquaticJellyfishEntity(
val bottomY = world.seaLevel - 24

return pos.y in bottomY..topY &&
world.getFluidState(pos).isIn(FluidTags.WATER) &&
world.getFluidState(pos.down()).isIn(FluidTags.WATER) &&
world.getBlockState(pos.up()).isOf(Blocks.WATER)
world.getFluidState(pos.up()).isIn(FluidTags.WATER)
}

fun canUndergroundSpawn(
Expand All @@ -402,8 +402,9 @@ open class HybridAquaticJellyfishEntity(
): Boolean {
return pos.y <= world.seaLevel - 32 &&
world.getBaseLightLevel(pos, 0) == 0 &&
world.getFluidState(pos).isIn(FluidTags.WATER) &&
world.getFluidState(pos.down()).isIn(FluidTags.WATER) &&
world.getBlockState(pos).isOf(Blocks.WATER)
world.getFluidState(pos.up()).isIn(FluidTags.WATER)
}

fun getScaleAdjustment(jellyfish : HybridAquaticJellyfishEntity, adjustment : Float): Float {
Expand Down

0 comments on commit b769730

Please sign in to comment.