Skip to content

Commit

Permalink
Well, I can only overwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
xiewuzhiying committed Jul 27, 2024
1 parent 86d90ec commit 3b06588
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package io.github.xiewuzhiying.vs_addition.mixin.valkyrienskies;

import com.llamalad7.mixinextras.sugar.Local;
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
import org.joml.Vector3d;
import org.joml.Vector3dc;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
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.impl.game.ships.ShipInertiaDataImpl;

@Mixin(ShipInertiaDataImpl.class)
public abstract class MixinShipInertiaDataImpl {
@Shadow public abstract Vector3dc getCenterOfMassInShip();

@Inject(
method = "addMassAt",
at = @At(
value = "INVOKE",
target = "Lorg/joml/Vector3dc;z()D",
ordinal = 1,
shift = At.Shift.AFTER
),
remap = false
)
private void fix(double x, double y, double z, double addedMass, CallbackInfo ci, @Local LocalRef<double[]> var9) {
Vector3dc position = new Vector3d(x, y, z);
Vector3dc center = this.getCenterOfMassInShip();

double new_x = position.sub(center, new Vector3d()).x;
double new_y = position.sub(center, new Vector3d()).y;
double new_z = position.sub(center, new Vector3d()).z;

double[] inertia = var9.get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
import net.minecraft.world.level.block.entity.BlockEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.valkyrienskies.mod.common.VSGameUtilsKt;

@Mixin(IWireNode.class)
public interface MixinIWireNode {
/**
* @author xiewuzhiying
* @reason I can only do overwrite ¯\_(ツ)_/¯
*/
@Overwrite
@Overwrite(remap = false)
static WireConnectResult connect(Level world, BlockPos pos1, int node1, BlockPos pos2, int node2, WireType type) {
BlockEntity te1 = world.getBlockEntity(pos1);
BlockEntity te2 = world.getBlockEntity(pos2);
Expand All @@ -27,7 +28,7 @@ static WireConnectResult connect(Level world, BlockPos pos1, int node1, BlockPos
IWireNode wn2 = (IWireNode)te2;
if (node1 >= 0 && node2 >= 0) {
int maxLength = Math.min(wn1.getMaxWireLength(), wn2.getMaxWireLength());
if (pos1.distSqr(pos2) > (double)(maxLength * maxLength)) {
if (VSGameUtilsKt.squaredDistanceBetweenInclShips(world, pos1.getX(), pos1.getY(), pos1.getZ(), pos2.getX(), pos2.getY(), pos2.getZ()) > (double)(maxLength * maxLength)) {
return WireConnectResult.LONG;
}

Expand Down

0 comments on commit 3b06588

Please sign in to comment.