This commit is contained in:
GearShocky 2025-03-17 08:12:25 +05:00
parent 7a7139c48c
commit 2d5858bd29
4 changed files with 24 additions and 19 deletions

View File

@ -6,6 +6,7 @@ import net.minecraft.network.syncher.EntityDataSerializers
import net.minecraft.network.syncher.SynchedEntityData import net.minecraft.network.syncher.SynchedEntityData
import net.minecraft.server.level.ServerBossEvent import net.minecraft.server.level.ServerBossEvent
import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerLevel
import net.minecraft.server.level.ServerPlayer
import net.minecraft.sounds.SoundEvent import net.minecraft.sounds.SoundEvent
import net.minecraft.sounds.SoundEvents import net.minecraft.sounds.SoundEvents
import net.minecraft.sounds.SoundSource import net.minecraft.sounds.SoundSource
@ -33,12 +34,9 @@ import net.minecraft.world.entity.projectile.SmallFireball
import net.minecraft.world.level.Level import net.minecraft.world.level.Level
import net.minecraft.world.phys.Vec3 import net.minecraft.world.phys.Vec3
import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.core.isFire
import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.registry.MNames
import ru.dbotthepony.mc.otm.registry.game.MSoundEvents import ru.dbotthepony.mc.otm.registry.game.MSoundEvents
import java.util.* import java.util.*
import kotlin.math.cos
import kotlin.math.sin
class Enforcer(type: EntityType<Enforcer>, level: Level) : Monster(type,level) { class Enforcer(type: EntityType<Enforcer>, level: Level) : Monster(type,level) {
val idleState = AnimationState() val idleState = AnimationState()
@ -75,7 +73,6 @@ class Enforcer(type: EntityType<Enforcer>, level: Level) : Monster(type,level) {
return entityData.get(IS_CHARGING) return entityData.get(IS_CHARGING)
} }
override fun registerGoals() { override fun registerGoals() {
goalSelector.addGoal(7, LookAtPlayerGoal(this, Player::class.java, 8f)) goalSelector.addGoal(7, LookAtPlayerGoal(this, Player::class.java, 8f))
goalSelector.addGoal(3, NearestAttackableTargetGoal(this, LivingEntity::class.java, 10, true, true) { entity -> goalSelector.addGoal(3, NearestAttackableTargetGoal(this, LivingEntity::class.java, 10, true, true) { entity ->
@ -89,6 +86,7 @@ class Enforcer(type: EntityType<Enforcer>, level: Level) : Monster(type,level) {
goalSelector.addGoal(2, RammingGoal(this)) goalSelector.addGoal(2, RammingGoal(this))
goalSelector.addGoal(2, StayNearGoal(this)) goalSelector.addGoal(2, StayNearGoal(this))
goalSelector.addGoal(2, BlazeFireballGoal(this)) goalSelector.addGoal(2, BlazeFireballGoal(this))
targetSelector.addGoal(1, HurtByTargetGoal(this)) targetSelector.addGoal(1, HurtByTargetGoal(this))
} }
@ -98,7 +96,7 @@ class Enforcer(type: EntityType<Enforcer>, level: Level) : Monster(type,level) {
return false return false
} }
override fun getHurtSound(damageSource: net.minecraft.world.damagesource.DamageSource): SoundEvent { override fun getHurtSound(damageSource: DamageSource): SoundEvent {
return SoundEvents.HEAVY_CORE_BREAK return SoundEvents.HEAVY_CORE_BREAK
} }
@ -108,25 +106,20 @@ class Enforcer(type: EntityType<Enforcer>, level: Level) : Monster(type,level) {
//fire inv //fire inv
//there should be a better way //there should be a better way
override fun isInvulnerableTo(source: DamageSource): Boolean { override fun fireImmune(): Boolean {
return source.isFire || super.isInvulnerableTo(source) return true
}
override fun hurt(source: DamageSource, amount: Float): Boolean {
if (source.isFire) return false
return super.hurt(source, amount)
} }
///boss healthbar ///boss healthbar
private val bossEvent: ServerBossEvent = private val bossEvent: ServerBossEvent =
ServerBossEvent(TranslatableComponent(MNames.ENFORCER), BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.PROGRESS) ServerBossEvent(TranslatableComponent(MNames.ENFORCER), BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.PROGRESS)
override fun startSeenByPlayer(player: net.minecraft.server.level.ServerPlayer) { override fun startSeenByPlayer(player: ServerPlayer) {
super.startSeenByPlayer(player) super.startSeenByPlayer(player)
bossEvent.addPlayer(player) bossEvent.addPlayer(player)
} }
override fun stopSeenByPlayer(player: net.minecraft.server.level.ServerPlayer) { override fun stopSeenByPlayer(player: ServerPlayer) {
super.stopSeenByPlayer(player) super.stopSeenByPlayer(player)
bossEvent.removePlayer(player) bossEvent.removePlayer(player)
} }
@ -134,9 +127,13 @@ class Enforcer(type: EntityType<Enforcer>, level: Level) : Monster(type,level) {
override fun aiStep() { override fun aiStep() {
super.aiStep() super.aiStep()
bossEvent.progress = this.health / this.maxHealth bossEvent.progress = this.health / this.maxHealth
if (!this.isOnFire) {
this.clearFire()
}
} }
override fun die(cause: net.minecraft.world.damagesource.DamageSource) { override fun die(cause: DamageSource) {
super.die(cause) super.die(cause)
bossEvent.removeAllPlayers() bossEvent.removeAllPlayers()
} }
@ -198,7 +195,7 @@ class Enforcer(type: EntityType<Enforcer>, level: Level) : Monster(type,level) {
level().addFreshEntity(fireball) level().addFreshEntity(fireball)
} }
//charge attack, could possibly leave a smoke trail too idk //charge attack
class RammingGoal(private val mob: Enforcer) : Goal() { class RammingGoal(private val mob: Enforcer) : Goal() {
private var target: LivingEntity? = null private var target: LivingEntity? = null
@ -211,7 +208,7 @@ class Enforcer(type: EntityType<Enforcer>, level: Level) : Monster(type,level) {
private val maxChargeTime = 40 private val maxChargeTime = 40
private var chargeDir: Vec3? = null private var chargeDir: Vec3? = null
private var cooldown = 0 private var cooldown = 0
private val minCooldown = 20 private val minCooldown = 35
private val maxCooldown = 60 private val maxCooldown = 60
private var isCharging = false private var isCharging = false
@ -281,7 +278,7 @@ class Enforcer(type: EntityType<Enforcer>, level: Level) : Monster(type,level) {
stop() stop()
return return
} }
mob.playSound(MSoundEvents.ANDROID_JUMP_BOOST, 1.0f, 1.0f) mob.playSound(MSoundEvents.ENFORCER_CHARGE, 1.0f, 1.0f)
} }
val dir = chargeDir ?: return val dir = chargeDir ?: return
@ -310,7 +307,7 @@ class Enforcer(type: EntityType<Enforcer>, level: Level) : Monster(type,level) {
target.push(knockback.x, 0.5, knockback.z) target.push(knockback.x, 0.5, knockback.z)
val damageAmount = 10.0f val damageAmount = 14.0f
target.hurt(mob.damageSources().mobAttack(mob), damageAmount) target.hurt(mob.damageSources().mobAttack(mob), damageAmount)
stop() stop()
@ -400,6 +397,12 @@ class Enforcer(type: EntityType<Enforcer>, level: Level) : Monster(type,level) {
if (fireTick > 0){ if (fireTick > 0){
fireTick -- fireTick --
if (fireTick >= 19){
mob.playSound(MSoundEvents.ENFORCER_BEEP, 1.0f, 1.0f)
}
if (fireTick == 15){ if (fireTick == 15){
mob.shootFireball(0.5f) mob.shootFireball(0.5f)
//could have a better firing sound //could have a better firing sound

View File

@ -28,6 +28,8 @@ object MSoundEvents {
val LOADER_AMBIENT by make("loader_ambient") val LOADER_AMBIENT by make("loader_ambient")
val ENFORCER_ALERT by make("enforcer_alert") val ENFORCER_ALERT by make("enforcer_alert")
val ENFORCER_CHARGE by make("enforcer_charge")
val ENFORCER_BEEP by make("enforcer_beep")
fun register(bus: IEventBus) { fun register(bus: IEventBus) {
registry.register(bus) registry.register(bus)