forked from FoundationGames/Splinecart
-
Notifications
You must be signed in to change notification settings - Fork 2
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
62719e7
commit 931ad1e
Showing
10 changed files
with
139 additions
and
14 deletions.
There are no files selected for viewing
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
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
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
53 changes: 53 additions & 0 deletions
53
...nt/java/io/github/implicitsaber/forkcart/clientmixinconfig/ForkcartClientMixinPlugin.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.implicitsaber.forkcart.clientmixinconfig; | ||
|
||
import net.fabricmc.loader.api.FabricLoader; | ||
import org.objectweb.asm.tree.ClassNode; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class ForkcartClientMixinPlugin implements IMixinConfigPlugin { | ||
|
||
@Override | ||
public void onLoad(String mixinPackage) { | ||
|
||
} | ||
|
||
@Override | ||
public String getRefMapperConfig() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { | ||
return switch(mixinClassName) { | ||
case "io.github.implicitsaber.forkcart.mixin.client.GameRendererMixin", | ||
"io.github.implicitsaber.forkcart.mixin.client.CameraMixin" -> !FabricLoader.getInstance().isModLoaded("connectormod"); | ||
case "io.github.implicitsaber.forkcart.mixin.client.CameraMixinForge" -> FabricLoader.getInstance().isModLoaded("connectormod"); | ||
default -> true; | ||
}; | ||
} | ||
|
||
@Override | ||
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) { | ||
|
||
} | ||
|
||
@Override | ||
public List<String> getMixins() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { | ||
|
||
} | ||
|
||
@Override | ||
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { | ||
|
||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
src/client/java/io/github/implicitsaber/forkcart/mixin/client/CameraMixinForge.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,50 @@ | ||
package io.github.implicitsaber.forkcart.mixin.client; | ||
|
||
import com.llamalad7.mixinextras.sugar.Local; | ||
import io.github.implicitsaber.forkcart.ForkcartClient; | ||
import io.github.implicitsaber.forkcart.entity.TrackFollowerEntity; | ||
import net.minecraft.client.render.Camera; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.util.math.RotationAxis; | ||
import net.minecraft.util.math.Vec3d; | ||
import net.minecraft.world.BlockView; | ||
import org.joml.Quaternionf; | ||
import org.joml.Vector3d; | ||
import org.spongepowered.asm.mixin.Final; | ||
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.Redirect; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(Camera.class) | ||
public abstract class CameraMixinForge { | ||
@Shadow protected abstract void setPos(Vec3d pos); | ||
|
||
@Shadow @Final private Quaternionf rotation; | ||
|
||
@Inject(method = "update(Lnet/minecraft/world/BlockView;Lnet/minecraft/entity/Entity;ZZF)V", | ||
at = @At(value = "INVOKE", shift = At.Shift.AFTER, ordinal = 0, target = "Lnet/minecraft/client/render/Camera;setPos(DDD)V")) | ||
private void forkcart$updateCamPosWhileRiding(BlockView area, Entity self, boolean thirdPerson, boolean inverseView, float tickDelta, CallbackInfo info) { | ||
var vehicle = self.getVehicle(); | ||
if (vehicle != null) { | ||
var tf = vehicle.getVehicle(); | ||
if (tf instanceof TrackFollowerEntity trackFollower) { | ||
var world = self.getWorld(); | ||
var diff = self.getPos().add(0, self.getStandingEyeHeight(), 0).subtract(trackFollower.getPos()); | ||
var camPos = new Vector3d(diff.getX(), diff.getY(), diff.getZ()); | ||
if (world.isClient()) { | ||
var rot = new Quaternionf(); | ||
trackFollower.getClientOrientation(rot, tickDelta); | ||
rot.transform(camPos); | ||
|
||
this.setPos(new Vec3d(camPos.x(), camPos.y(), camPos.z()).add(trackFollower.getLerpedPos(tickDelta))); | ||
|
||
// camera rotation is disabled due to glitches | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
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
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
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
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
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