Skip to content

Commit

Permalink
Make it possible to disable Contraption positionRider changes
Browse files Browse the repository at this point in the history
  • Loading branch information
StewStrong committed Dec 24, 2023
1 parent cbbadd3 commit fbad5cb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.valkyrienskies.mod.common.util.VectorConversionsMCKt.toJOML;
import static org.valkyrienskies.mod.common.util.VectorConversionsMCKt.toMinecraft;
import static org.valkyrienskies.mod.mixinducks.mod_compat.create.MixinAbstractContraptionEntityDuckFlags.ENABLE_DEFAULT_VS_CONTRAPTION_FIX;

import com.simibubi.create.AllMovementBehaviours;
import com.simibubi.create.content.contraptions.AbstractContraptionEntity;
Expand Down Expand Up @@ -106,21 +107,24 @@ private void redirectTeleportTo(Entity instance, double x, double y, double z) {

//Region end
//Region start - fix entity rider position on ship contraptions
@Override
public void positionRider(@NotNull Entity passenger) {
if (!hasPassenger(passenger))
return;
Vec3 riderPos = getPassengerPosition(passenger, 1);
if (riderPos == null)
return;
if (!(passenger instanceof OrientedContraptionEntity)) {
Ship ship = VSGameUtilsKt.getShipManagingPos(passenger.level, riderPos.x, riderPos.y, riderPos.z);
riderPos.add(0, SeatEntity.getCustomEntitySeatOffset(passenger) - 1 / 8f, 0);
if (ship != null) {
riderPos = toMinecraft(ship.getShipToWorld().transformPosition(toJOML(riderPos)));
@Inject(method = "positionRider", at = @At("HEAD"), cancellable = true)
public void prePositionRider(final Entity passenger, final MoveFunction callback, final CallbackInfo ci) {
if (ENABLE_DEFAULT_VS_CONTRAPTION_FIX) {
ci.cancel();
if (!hasPassenger(passenger))
return;
Vec3 riderPos = getPassengerPosition(passenger, 1);
if (riderPos == null)
return;
if (!(passenger instanceof OrientedContraptionEntity)) {
final Ship ship = VSGameUtilsKt.getShipManagingPos(passenger.level, riderPos.x, riderPos.y, riderPos.z);
riderPos.add(0, SeatEntity.getCustomEntitySeatOffset(passenger) - 1 / 8f, 0);
if (ship != null) {
riderPos = toMinecraft(ship.getShipToWorld().transformPosition(toJOML(riderPos)));
}
}
passenger.setPos(riderPos);
}
passenger.setPos(riderPos);
}

@Inject(method = "toGlobalVector(Lnet/minecraft/world/phys/Vec3;FZ)Lnet/minecraft/world/phys/Vec3;",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.valkyrienskies.mod.mixinducks.mod_compat.create;

public class MixinAbstractContraptionEntityDuckFlags {
public static boolean ENABLE_DEFAULT_VS_CONTRAPTION_FIX = true;
}

0 comments on commit fbad5cb

Please sign in to comment.