Skip to content

Commit

Permalink
try again?
Browse files Browse the repository at this point in the history
  • Loading branch information
xiewuzhiying committed Jul 27, 2024
1 parent d329807 commit c6625c7
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.github.xiewuzhiying.vs_addition.forge.mixin.createaddition;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import com.mrh0.createaddition.energy.IWireNode;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Vec3i;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.valkyrienskies.mod.common.VSGameUtilsKt;

@Mixin(IWireNode.class)
public interface MixinIWireNode {
@WrapOperation(
method = "connect",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/core/BlockPos;distSqr(Lnet/minecraft/core/Vec3i;)D"
)
)
private static double man(BlockPos instance, Vec3i vec3i, Operation<Double> original, @Local(argsOnly = true) Level level) {
return VSGameUtilsKt.squaredDistanceBetweenInclShips(level, instance.getX(), instance.getY(), instance.getZ(), vec3i.getX(), vec3i.getY(), vec3i.getZ());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package io.github.xiewuzhiying.vs_addition.forge.mixin.createaddition;

import com.llamalad7.mixinextras.sugar.Local;
import com.llamalad7.mixinextras.sugar.Share;
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
import com.mrh0.createaddition.energy.IWireNode;
import com.mrh0.createaddition.rendering.WireNodeRenderer;
import io.github.xiewuzhiying.vs_addition.util.TransformUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArgs;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
import org.valkyrienskies.mod.common.VSGameUtilsKt;

@Mixin(WireNodeRenderer.class)
public abstract class MixinWireNodeRenderer {
@ModifyArgs(
method = "render",
at = @At(
value = "INVOKE",
target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(FFF)V",
ordinal = 0
)
)
private void man(Args args, @Local(ordinal = 0) IWireNode te, @Local(ordinal = 0) BlockPos other, @Local(ordinal = 0) Vec3 d1, @Local(ordinal = 1) Vec3 d2, @Share("tePos") LocalRef<Vec3> tePos, @Share("otherPos") LocalRef<Vec3> otherPos) {
tePos.set(VSGameUtilsKt.toWorldCoordinates(Minecraft.getInstance().level, te.getPos().getCenter().add(d1)));
otherPos.set(VSGameUtilsKt.toWorldCoordinates(Minecraft.getInstance().level, other.getCenter().add(d2)));

final Vec3 diff = otherPos.get().subtract(TransformUtils.toVec3(te.getPos()));
args.set(0, (float)diff.x);
args.set(1, (float)diff.y);
args.set(2, (float)diff.z);
}

@ModifyArgs(
method = "render",
at = @At(
value = "INVOKE",
target = "Lcom/mrh0/createaddition/rendering/WireNodeRenderer;wireRender(Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/core/BlockPos;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;FFFLcom/mrh0/createaddition/energy/WireType;F)V",
ordinal = 0
),
remap = false
)
private void man2(Args args, @Share("tePos") LocalRef<Vec3> tePos, @Share("otherPos") LocalRef<Vec3> otherPos) {
final Vec3 diff = otherPos.get().subtract(tePos.get());
args.set(3, (float)diff.x);
args.set(4, (float)diff.y);
args.set(5, (float)diff.z);
}
}
2 changes: 2 additions & 0 deletions forge/src/main/resources/vs_addition.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"create.hose_pulley.MixinFluidDrainingBehaviour",
"create.hose_pulley.MixinFluidFillingBehaviour",
"create.hose_pulley.MixinHosePulleyBlockEntity",
"createaddition.MixinIWireNode",
"createaddition.MixinPortableEnergyInterfaceMovement",
"tacz.MixinEntityKineticBullet"
],
Expand All @@ -25,6 +26,7 @@
"minVersion": "0.8",
"client": [
"computercraft.client.MixinSpeakerSound",
"createaddition.MixinWireNodeRenderer",
"embeddium.client.MixinDefaultChunkRenderer",
"embeddiumplus.client.MixinEmbyTools",
"netmusic.MixinMusicToClientMessage",
Expand Down

0 comments on commit c6625c7

Please sign in to comment.