Skip to content

Commit

Permalink
Increase ticks to drag entities, additionally fix forge server fr thi…
Browse files Browse the repository at this point in the history
…s time
  • Loading branch information
ThePlasticPotato committed Dec 27, 2024
1 parent 851cf6a commit a9e961e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a9e961e

Please sign in to comment.