-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d329807
commit c6625c7
Showing
3 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
...in/java/io/github/xiewuzhiying/vs_addition/forge/mixin/createaddition/MixinIWireNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
.../io/github/xiewuzhiying/vs_addition/forge/mixin/createaddition/MixinWireNodeRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters