Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.20_Crabs' into 1.20_Crabs
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonflame86 committed Dec 3, 2023
2 parents 706bc11 + 8ea4dfd commit d242424
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public class BackgroundRendererMixin {

if (fogData.fogEnd > viewDistance) {
fogData.fogEnd = viewDistance;
fogData.fogShape = FogShape.CYLINDER;
fogData.fogShape = FogShape.SPHERE;
}
fogData.fogEnd = Math.max(fogData.fogEnd, 12.0f);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.hybridlabs.aquatic.client.render.entity

import dev.hybridlabs.aquatic.client.model.entity.*
import dev.hybridlabs.aquatic.client.model.entity.CoconutCrabEntityModel
import dev.hybridlabs.aquatic.entity.critter.HybridAquaticCritterEntity
import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.render.entity.EntityRendererFactory.Context
Expand All @@ -23,4 +23,4 @@ class CoconutCrabEntityRenderer(context: Context) : GeoEntityRenderer<HybridAqua
override fun getMotionAnimThreshold(animatable: HybridAquaticCritterEntity?): Float {
return 0.0025f
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ class KarkinosEntityRenderer(context: Context) : GeoEntityRenderer<HybridAquatic
poseStack!!.scale(size, size, size)
super.render(entity, entityYaw, partialTick, poseStack, bufferSource, packedLight)
}
}

override fun getMotionAnimThreshold(animatable: HybridAquaticCritterEntity?): Float {
return 0.0025f
}
}
6 changes: 6 additions & 0 deletions src/main/kotlin/dev/hybridlabs/aquatic/HybridAquatic.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import dev.hybridlabs.aquatic.item.HybridAquaticItems
import dev.hybridlabs.aquatic.loot.LootTableModifications
import dev.hybridlabs.aquatic.loot.entry.HybridAquaticLootPoolEntryTypes
import dev.hybridlabs.aquatic.network.HybridAquaticNetworking
import dev.hybridlabs.aquatic.potions.HybridAquaticPotions
import dev.hybridlabs.aquatic.potions.HybridAquaticPotions.registerPotions
import dev.hybridlabs.aquatic.potions.HybridAquaticPotions.registerPotionsRecipes
import dev.hybridlabs.aquatic.registry.HybridAquaticRegistryKeys
import dev.hybridlabs.aquatic.tag.HybridAquaticBiomeTags
import dev.hybridlabs.aquatic.world.EntityBiomeModifications
Expand Down Expand Up @@ -41,6 +44,7 @@ object HybridAquatic : ModInitializer {

HybridAquaticEntityTypes

HybridAquaticPotions
HybridAquaticStatusEffects

HybridAquaticItems
Expand All @@ -62,6 +66,8 @@ object HybridAquatic : ModInitializer {

registerDynamicRegistries()
registerWanderingTraderTrades()
registerPotionsRecipes()
registerPotions()
}

private fun registerDynamicRegistries() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.hybridlabs.aquatic.entity.critter

import dev.hybridlabs.aquatic.entity.ai.goal.CrabDigGoal
import dev.hybridlabs.aquatic.tag.HybridAquaticBlockTags
import net.minecraft.block.Blocks
import net.minecraft.entity.EntityGroup
Expand All @@ -18,8 +17,8 @@ import net.minecraft.world.WorldAccess
import software.bernie.geckolib.core.animatable.GeoAnimatable
import software.bernie.geckolib.core.animation.Animation
import software.bernie.geckolib.core.animation.AnimationState
import software.bernie.geckolib.core.`object`.PlayState
import software.bernie.geckolib.core.animation.RawAnimation
import software.bernie.geckolib.core.`object`.PlayState

@Suppress("DEPRECATION")
open class HybridAquaticCrabEntity(type: EntityType<out HybridAquaticCritterEntity>, world: World, variantCount: Int = 1) :
Expand Down Expand Up @@ -109,8 +108,8 @@ open class HybridAquaticCrabEntity(type: EntityType<out HybridAquaticCritterEnti
pos: BlockPos,
random: Random?
): Boolean {
val topY = world.seaLevel + 12
val bottomY = world.seaLevel - 40
val topY = world.seaLevel + 6
val bottomY = world.seaLevel - 48

return pos.y in bottomY..topY &&
world.getBlockState(pos.down()).isIn(HybridAquaticBlockTags.CRABS_SPAWN_ON) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ class KarkinosEntity(entityType: EntityType<out HybridAquaticCritterEntity>, wor
HybridAquaticCrabEntity(entityType, world) {

private var isFlipped: Boolean = false
private var flipCooldown: Int = 0
private var flipResetCooldown: Int = 0
private var flipTimer: Int = 0

companion object {
fun createMobAttributes(): DefaultAttributeContainer.Builder {
Expand All @@ -31,19 +30,22 @@ class KarkinosEntity(entityType: EntityType<out HybridAquaticCritterEntity>, wor
}
}

private fun beFlipped() {
isFlipped = true
flipTimer = 100
}

override fun damage(source: net.minecraft.entity.damage.DamageSource?, amount: Float): Boolean {
val damaged = super.damage(source, amount)

if (damaged && source?.source is PlayerEntity) {
if (damaged && source?.source is PlayerEntity && !isFlipped) {
val player = source.source as PlayerEntity
val heldItem = player.mainHandStack

if (EnchantmentHelper.getLevel(Enchantments.BANE_OF_ARTHROPODS, heldItem) > 0 ||
(heldItem.item is net.minecraft.item.TridentItem && EnchantmentHelper.getLevel(Enchantments.RIPTIDE, heldItem) > 0)
if (EnchantmentHelper.getLevel(Enchantments.BANE_OF_ARTHROPODS, heldItem) > 2 ||
(EnchantmentHelper.getLevel(Enchantments.RIPTIDE, heldItem) > 0)
) {
isFlipped = true
flipCooldown = 100
flipResetCooldown = 300
beFlipped()
}
}

Expand All @@ -58,25 +60,9 @@ class KarkinosEntity(entityType: EntityType<out HybridAquaticCritterEntity>, wor
}
}

override fun tick() {
super.tick()

if (isFlipped) {
flipCooldown--
override fun isPushable(): Boolean =
this.isFlipped

if (flipCooldown <= 0) {
isFlipped = false
}
}

if (flipResetCooldown > 0) {
flipResetCooldown--
}

if (flipResetCooldown == 0) {
flipCooldown = 0
}
}


override fun <E : GeoAnimatable> predicate(event: AnimationState<E>): PlayState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class LionfishEntity(entityType: EntityType<out LionfishEntity>, world: World) :
if (!source.isIn(DamageTypeTags.AVOIDS_GUARDIAN_THORNS) && !source.isOf(DamageTypes.THORNS)) {
val attacker = source.source
if (attacker is LivingEntity) {
attacker.addStatusEffect(StatusEffectInstance(StatusEffects.POISON, 400, 0), this)
attacker.addStatusEffect(StatusEffectInstance(StatusEffects.NAUSEA, 200, 0), this)
attacker.addStatusEffect(StatusEffectInstance(StatusEffects.POISON, 200, 0), this)
}
}
super.damage(source, amount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ open class HybridAquaticJellyfishEntity(type: EntityType<out HybridAquaticJellyf
moistness = nbt.getInt(MOISTNESS_KEY)
variant = nbt.getInt(VARIANT_KEY).coerceAtLeast(0).coerceAtMost(variantCount-1)
size = nbt.getInt(JELLYFISH_SIZE_KEY)
spawnedY = if (!nbt.contains(SPAWNED_ON_Y_KEY)) (this.y - 1).toInt()
spawnedY = if (!nbt.contains(SPAWNED_ON_Y_KEY)) (this.y - 4).toInt()
else nbt.getInt(SPAWNED_ON_Y_KEY)
}

Expand Down Expand Up @@ -228,7 +228,7 @@ open class HybridAquaticJellyfishEntity(type: EntityType<out HybridAquaticJellyf
random: Random?
): Boolean {
val topY = world.seaLevel - 6
val bottomY = world.seaLevel - 24
val bottomY = world.seaLevel - 48

return pos.y in bottomY..topY &&
world.getFluidState(pos.down()).isIn(FluidTags.WATER) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import net.fabricmc.fabric.api.item.v1.FabricItemSettings
import net.minecraft.block.Block
import net.minecraft.entity.EntityType
import net.minecraft.entity.mob.MobEntity
import net.minecraft.item.BlockItem
import net.minecraft.item.FoodComponent
import net.minecraft.item.Item
import net.minecraft.item.SpawnEggItem
import net.minecraft.item.*
import net.minecraft.registry.Registries
import net.minecraft.registry.Registry
import net.minecraft.util.Identifier
Expand Down Expand Up @@ -463,6 +460,10 @@ object HybridAquaticItems {
return register(id, SpawnEggItem(type, primaryColor, secondaryColor, FabricItemSettings()))
}

private fun registerPotionItem(id: String, item: PotionItem): Item {
return register(id, item)
}

private fun registerBlockItem(id: String, block: Block): Item {
return register(id, BlockItem(block, FabricItemSettings()))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package dev.hybridlabs.aquatic.potions

import dev.hybridlabs.aquatic.item.HybridAquaticItems
import net.minecraft.entity.effect.StatusEffectInstance
import net.minecraft.entity.effect.StatusEffects
import net.minecraft.potion.Potion
import net.minecraft.potion.Potions
import net.minecraft.recipe.BrewingRecipeRegistry
import net.minecraft.registry.Registries.POTION
import net.minecraft.registry.Registry
import net.minecraft.util.Identifier

object HybridAquaticPotions {
val GLOWING_POTION = Potion(StatusEffectInstance(StatusEffects.GLOWING, 3600, 0))

fun registerPotions() {
Registry.register(POTION, Identifier("glowing", "glowing_potion"), GLOWING_POTION)
}

fun registerPotionsRecipes() {
BrewingRecipeRegistry.registerPotionRecipe(
Potions.AWKWARD,
HybridAquaticItems.GLOW_SLIME,
GLOWING_POTION
)
}
}

0 comments on commit d242424

Please sign in to comment.