From a9e961e59f0a4c8ac4478ac56af71b5beabf63b3 Mon Sep 17 00:00:00 2001 From: ThePlasticPotato Date: Fri, 27 Dec 2024 16:54:56 -0500 Subject: [PATCH] Increase ticks to drag entities, additionally fix forge server fr this time --- .../feature/entity_collision/MixinLivingEntity.java | 5 ++--- .../mod/common/util/EntityDraggingInformation.kt | 2 +- .../valkyrienskies/mod/common/util/EntityLerper.kt | 12 ++++++++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/entity_collision/MixinLivingEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/entity_collision/MixinLivingEntity.java index bb6574bd..07b0930c 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/entity_collision/MixinLivingEntity.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/entity_collision/MixinLivingEntity.java @@ -1,6 +1,5 @@ package org.valkyrienskies.mod.mixin.feature.entity_collision; -import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; @@ -10,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.valkyrienskies.core.api.ships.ClientShip; +import org.valkyrienskies.core.api.ships.Ship; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.util.EntityDraggingInformation; import org.valkyrienskies.mod.common.util.EntityLerper; @@ -37,7 +36,7 @@ private void preAiStep(CallbackInfo ci) { if (this.isControlledByLocalInstance() || (((Entity) this instanceof Player player) && player.isLocalPlayer())) return; EntityDraggingInformation dragInfo = ((IEntityDraggingInformationProvider) this).getDraggingInformation(); if (dragInfo != null && dragInfo.getLastShipStoodOn() != null) { - final ClientShip ship = VSGameUtilsKt.getShipObjectWorld((ClientLevel) level).getAllShips().getById(dragInfo.getLastShipStoodOn()); + final Ship ship = VSGameUtilsKt.getShipObjectWorld(level).getAllShips().getById(dragInfo.getLastShipStoodOn()); if (ship != null) { EntityLerper.INSTANCE.lerpStep(dragInfo, ship, (LivingEntity) (Object) this); EntityLerper.INSTANCE.lerpHeadStep(dragInfo, ship, (LivingEntity) (Object) this); diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDraggingInformation.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDraggingInformation.kt index d130c187..915f9a0d 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDraggingInformation.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDraggingInformation.kt @@ -57,7 +57,7 @@ class EntityDraggingInformation { companion object { // Max number of ticks we will drag an entity after the entity has jumped off the ship - private const val TICKS_TO_DRAG_ENTITIES = 20 + private const val TICKS_TO_DRAG_ENTITIES = 40 } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityLerper.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityLerper.kt index facb37bb..53562a0f 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityLerper.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityLerper.kt @@ -16,7 +16,11 @@ object EntityLerper { /** * Called from preAiStep. This function lerps the entity's movement while keeping it locked relative to the ship. */ - fun lerpStep(dragInfo: EntityDraggingInformation, ship: ClientShip, entity: Entity) { + fun lerpStep(dragInfo: EntityDraggingInformation, refship: Ship, entity: Entity) { + if (refship !is ClientShip) { + return + } + val ship = refship as ClientShip if (dragInfo.lerpSteps > 0) { val currentX: Double = dragInfo.relativePositionOnShip?.x() ?: return val currentY: Double = dragInfo.relativePositionOnShip!!.y() @@ -54,7 +58,11 @@ object EntityLerper { /** * Additional function to lerp head separately, as it's a separate packet. */ - fun lerpHeadStep(dragInfo: EntityDraggingInformation, ship: ClientShip, entity: Entity) { + fun lerpHeadStep(dragInfo: EntityDraggingInformation, refship: Ship, entity: Entity) { + if (refship !is ClientShip) { + return + } + val ship = refship as ClientShip if (dragInfo.headLerpSteps > 0) { val currentHeadYaw: Double = dragInfo.relativeHeadYawOnShip ?: return val lerpHeadYaw: Double = dragInfo.lerpHeadYawOnShip ?: return