From f0da7102c9e39aa13ef2ea626b66147137fdafa5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 23 Mar 2025 09:56:39 +0700 Subject: [PATCH] More fixes for RammingGoal --- .../ru/dbotthepony/mc/otm/entity/Enforcer.kt | 51 ++++++++++--------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/Enforcer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/Enforcer.kt index 7349ef3d1..6fc65dba3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/Enforcer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/Enforcer.kt @@ -16,6 +16,7 @@ import net.minecraft.world.damagesource.DamageSource import net.minecraft.world.entity.AnimationState import net.minecraft.world.entity.EntityType import net.minecraft.world.entity.LivingEntity +import net.minecraft.world.entity.MoverType import net.minecraft.world.entity.ai.attributes.AttributeSupplier import net.minecraft.world.entity.ai.attributes.Attributes import net.minecraft.world.entity.ai.goal.Goal @@ -243,40 +244,39 @@ class Enforcer(type: EntityType, level: Level) : Monster(type,level) { val leftPartic_z = mob.z - mob.lookAngle.z * 2 + 0.8f * mob.lookAngle.x val rightPartic_z = mob.z - mob.lookAngle.z * 2 - 0.8f * mob.lookAngle.x - if (mob.level() is ServerLevel) { - (mob.level() as ServerLevel).sendParticles( - ParticleTypes.LARGE_SMOKE, - leftPartic_x, smoke_y, leftPartic_z, - 2, - 0.0, 0.07, 0.0, - 0.01 - ) + val level = mob.level() as ServerLevel - (mob.level() as ServerLevel).sendParticles( - ParticleTypes.LARGE_SMOKE, - rightPartic_x, smoke_y, rightPartic_z, - 2, - 0.0, 0.07, 0.0, - 0.01 - ) + level.sendParticles( + ParticleTypes.LARGE_SMOKE, + leftPartic_x, smoke_y, leftPartic_z, + 2, + 0.0, 0.07, 0.0, + 0.01 + ) + + level.sendParticles( + ParticleTypes.LARGE_SMOKE, + rightPartic_x, smoke_y, rightPartic_z, + 2, + 0.0, 0.07, 0.0, + 0.01 + ) + + if (chargeDir == null || chargeDir!!.length() < 0.1) { + stop() + return } - if (chargeTime == windupTime) { - if (chargeDir == null || chargeDir!!.length() < 0.1) { - stop() - return - } - mob.playSound(MSoundEvents.ENFORCER_CHARGE, 1.0f, 1.0f) - } + mob.playSound(MSoundEvents.ENFORCER_CHARGE, 1.0f, 1.0f) val dir = chargeDir ?: return - mob.yRot = (-Mth.atan2(dir.x, dir.z) * (180f / Math.PI)).toFloat() + mob.yRot = Math.toDegrees(-Mth.atan2(dir.x, dir.z)).toFloat() mob.yHeadRot = mob.yRot - mob.move(net.minecraft.world.entity.MoverType.SELF, dir.scale(1.8)) + mob.move(MoverType.SELF, dir.scale(1.8)) if (mob.horizontalCollision) { - mob.level().playSound( + level.playSound( null, mob.x, mob.y, mob.z, SoundEvents.GENERIC_EXPLODE, @@ -284,6 +284,7 @@ class Enforcer(type: EntityType, level: Level) : Monster(type,level) { 1.0f, 1.0f ) + stop() return }