Skip to content

Commit

Permalink
Fix Create, CBC contraption seats (#847)
Browse files Browse the repository at this point in the history
  • Loading branch information
Endalion authored Jun 29, 2024
1 parent b2211ee commit 41ac195
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.joml.Matrix3d;
import org.joml.Matrix4d;
import org.joml.Matrix4dc;
Expand All @@ -43,18 +44,21 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.valkyrienskies.core.api.ships.ContraptionWingProvider;
import org.valkyrienskies.core.api.ships.LoadedServerShip;
import org.valkyrienskies.core.api.ships.LoadedShip;
import org.valkyrienskies.core.api.ships.Ship;
import org.valkyrienskies.core.api.ships.WingManager;
import org.valkyrienskies.mod.common.CompatUtil;
import org.valkyrienskies.mod.common.VSGameUtilsKt;
import org.valkyrienskies.mod.common.entity.ShipMountedToData;
import org.valkyrienskies.mod.common.entity.ShipMountedToDataProvider;
import org.valkyrienskies.mod.common.util.IEntityDraggingInformationProvider;
import org.valkyrienskies.mod.common.util.VectorConversionsMCKt;
import org.valkyrienskies.mod.compat.CreateConversionsKt;
import org.valkyrienskies.mod.mixinducks.mod_compat.create.MixinAbstractContraptionEntityDuck;

@Mixin(AbstractContraptionEntity.class)
public abstract class MixinAbstractContraptionEntity extends Entity implements MixinAbstractContraptionEntityDuck,
ContraptionWingProvider, IEntityDraggingInformationProvider {
ContraptionWingProvider, IEntityDraggingInformationProvider, ShipMountedToDataProvider {

public MixinAbstractContraptionEntity(EntityType<?> entityType, Level level) {
super(entityType, level);
Expand All @@ -81,6 +85,16 @@ public MixinAbstractContraptionEntity(EntityType<?> entityType, Level level) {
@Shadow
public abstract Vec3 getPrevAnchorVec();

@Nullable
@Override
public ShipMountedToData provideShipMountedToData(@NotNull final Entity passenger, @Nullable final Float partialTicks) {
final LoadedShip shipObjectEntityMountedTo = VSGameUtilsKt.getShipObjectManagingPos(passenger.level, toJOML(this.position()));
if (shipObjectEntityMountedTo == null) return null;

final Vector3dc mountedPosInShip = toJOML(this.getPassengerPosition(passenger, partialTicks == null ? 1 : partialTicks));
return new ShipMountedToData(shipObjectEntityMountedTo, mountedPosInShip);
}

//Region start - fix being sent to the ̶s̶h̶a̶d̶o̶w̶r̶e̶a̶l̶m̶ shipyard on ship contraption disassembly
@Redirect(method = "moveCollidedEntitiesOnDisassembly", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setPos(DDD)V"))
private void redirectSetPos(Entity instance, double x, double y, double z) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.valkyrienskies.mod.mixin.mod_compat.create_big_cannons;

import static org.valkyrienskies.mod.common.util.VectorConversionsMCKt.toJOML;

import com.simibubi.create.content.contraptions.OrientedContraptionEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
Expand Down Expand Up @@ -48,4 +50,11 @@ protected void vsProcesssRiderPositionHook(
}
}
}

@Inject(method="getPassengerPosition", at = @At("RETURN"), cancellable = true, remap = false)
protected void vsGetPassengerPosition(Entity passenger, float partialTicks, CallbackInfoReturnable<Vec3> cir) {
if (VSGameUtilsKt.getShipObjectManagingPos(passenger.level, toJOML(this.position())) != null) {
cir.setReturnValue(cir.getReturnValue().add(0,0.1,0));
}
}
}

0 comments on commit 41ac195

Please sign in to comment.