-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from der-fruhling-entertainment/dev/v0.2.2
Version v0.2.2
- Loading branch information
Showing
17 changed files
with
260 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,26 @@ | ||
- Fabric: This mod now correctly depends on Create Fabric. Sorry for the issues. | ||
- Updated mod metadata to include info about the project. | ||
- Player camera now leans while their train is on a slope. [View issue.](https://github.com/der-fruhling-entertainment/create-train-perspective/issues/11) | ||
- Also, camera now rolls when facing sideways on a slope. | ||
- (hopefully this feature doesn't break other mods) | ||
- Player legs are now locked forward while seated on a train. [View issue.](https://github.com/der-fruhling-entertainment/create-train-perspective/issues/13) | ||
- Players standing on a train will now be affected the same way as players sitting. [View issue.](https://github.com/der-fruhling-entertainment/create-train-perspective/issues/14) | ||
- This does not fix the Create mod issue where standing players may be ejected from the train if it is traveling at high speeds. | ||
- Players riding taller trains now lean correctly. [View issue.](https://github.com/der-fruhling-entertainment/create-train-perspective/issues/16) | ||
|
||
Full Changelog: https://github.com/der-fruhling/create-train-perspective/compare/v0.2.0...v0.2.1 | ||
Known issues: | ||
- The mod's leaning is a bit jittery. [View issue.](https://github.com/der-fruhling-entertainment/create-train-perspective/issues/22) | ||
- This is probably more of a limitation of Minecraft itself. It might be fixable with a config option to emulate pitch, but that wouldn't make the player appear correctly to other players. | ||
- The easing back to normal posture after jumping off a train on a slope could use some work. [View issue.](https://github.com/der-fruhling-entertainment/create-train-perspective/issues/23) | ||
- The third-person camera is janky while on a train currently on a slope. [View issue.](https://github.com/der-fruhling-entertainment/create-train-perspective/issues/24) | ||
|
||
[View full change log.](https://github.com/der-fruhling/create-train-perspective/compare/v0.2.1...v0.2.2) | ||
|
||
--- | ||
|
||
Issues? | ||
Feature Requests? | ||
[View the issue tracker!](https://github.com/der-fruhling-entertainment/create-train-perspective/issues) | ||
|
||
Questions? | ||
[Join the Discord!](https://discord.gg/AyM66DhPKr) | ||
Or, | ||
[discuss on GitHub!](https://github.com/der-fruhling-entertainment/create-train-perspective/discussions) |
6 changes: 6 additions & 0 deletions
6
common/src/main/java/net/derfruhling/minecraft/create/trainperspective/Camera3D.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,6 @@ | ||
package net.derfruhling.minecraft.create.trainperspective; | ||
|
||
public interface Camera3D { | ||
float getZRot(); | ||
void setRotation3D(float y, float x, float 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
11 changes: 11 additions & 0 deletions
11
common/src/main/java/net/derfruhling/minecraft/create/trainperspective/MixinUtil.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,11 @@ | ||
package net.derfruhling.minecraft.create.trainperspective; | ||
|
||
import net.minecraft.client.Camera; | ||
|
||
public class MixinUtil { | ||
private MixinUtil() {} | ||
|
||
public static Camera3D asCamera3D(Camera camera) { | ||
return (Camera3D) camera; | ||
} | ||
} |
9 changes: 8 additions & 1 deletion
9
...erspective/PlayerPerspectiveBehavior.java → .../create/trainperspective/Perspective.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 |
---|---|---|
@@ -1,8 +1,15 @@ | ||
package net.derfruhling.minecraft.create.trainperspective; | ||
|
||
public interface PlayerPerspectiveBehavior { | ||
public interface Perspective { | ||
void enable(float initialLean, float initialYaw); | ||
void disable(); | ||
void setLean(float lean); | ||
void setYaw(float yaw); | ||
float getLean(); | ||
float getYaw(); | ||
|
||
default void diminish() { | ||
setLean(getLean() * 0.97f); | ||
setYaw(getYaw() * 0.97f); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...on/src/main/java/net/derfruhling/minecraft/create/trainperspective/mixin/CameraMixin.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,56 @@ | ||
package net.derfruhling.minecraft.create.trainperspective.mixin; | ||
|
||
import net.derfruhling.minecraft.create.trainperspective.Camera3D; | ||
import net.derfruhling.minecraft.create.trainperspective.Perspective; | ||
import net.minecraft.client.Camera; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.player.LocalPlayer; | ||
import net.minecraft.util.Mth; | ||
import net.minecraft.world.entity.Entity; | ||
import org.joml.Quaternionf; | ||
import org.joml.Vector3f; | ||
import org.spongepowered.asm.mixin.*; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(Camera.class) | ||
@Implements({@Interface(iface = Camera3D.class, prefix = "ctp$")}) | ||
public abstract class CameraMixin { | ||
@Shadow private Entity entity; | ||
@Shadow private float xRot; | ||
@Shadow private float yRot; | ||
@Unique private float ctp$zRot; | ||
|
||
@Shadow @Final private Quaternionf rotation; | ||
@Shadow @Final private Vector3f forwards; | ||
@Shadow @Final private Vector3f up; | ||
@Shadow @Final private Vector3f left; | ||
|
||
@Shadow protected abstract void setRotation(float f, float g); | ||
|
||
@Unique | ||
public void ctp$setRotation3D(float y, float x, float z) { | ||
this.xRot = x; | ||
this.yRot = y; | ||
this.ctp$zRot = z; | ||
this.rotation.rotationYXZ(-y * 0.017453292F, x * 0.017453292F, z * 0.017453292F); | ||
this.forwards.set(0.0F, 0.0F, 1.0F).rotate(this.rotation); | ||
this.up.set(0.0F, 1.0F, 0.0F).rotate(this.rotation); | ||
this.left.set(1.0F, 0.0F, 0.0F).rotate(this.rotation); | ||
} | ||
|
||
@Unique | ||
public float ctp$getZRot() { | ||
return this.ctp$zRot; | ||
} | ||
|
||
@Redirect(method = "setup", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;setRotation(FF)V")) | ||
public void modifyRotationsPrimary(Camera instance, float y, float x) { | ||
if(entity instanceof LocalPlayer player) { | ||
var persp = (Perspective) Minecraft.getInstance().getEntityRenderDispatcher().getRenderer(player); | ||
ctp$setRotation3D(y, | ||
x - persp.getLean() * Mth.sin((persp.getYaw() - y) * Mth.DEG_TO_RAD), | ||
persp.getLean() * Mth.cos((persp.getYaw() - y) * Mth.DEG_TO_RAD)); | ||
} else setRotation(y, x); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...ava/net/derfruhling/minecraft/create/trainperspective/mixin/ContraptionColliderMixin.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,23 @@ | ||
package net.derfruhling.minecraft.create.trainperspective.mixin; | ||
|
||
import com.simibubi.create.content.contraptions.AbstractContraptionEntity; | ||
import com.simibubi.create.content.contraptions.ContraptionCollider; | ||
import com.simibubi.create.content.trains.entity.CarriageContraptionEntity; | ||
import net.derfruhling.minecraft.create.trainperspective.CreateTrainPerspectiveMod; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(ContraptionCollider.class) | ||
public class ContraptionColliderMixin { | ||
@Inject(method = "collideEntities", at = @At("HEAD"), remap = false) | ||
private static void saveClientPlayerFromClipping( | ||
AbstractContraptionEntity contraptionEntity, | ||
CallbackInfo ci | ||
) { | ||
if(contraptionEntity instanceof CarriageContraptionEntity carriage) { | ||
CreateTrainPerspectiveMod.INSTANCE.tickStandingPlayers(carriage); | ||
} | ||
} | ||
} |
11 changes: 5 additions & 6 deletions
11
...perspective/fabric/mixin/EntityMixin.java → ...e/trainperspective/mixin/EntityMixin.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 |
---|---|---|
@@ -1,29 +1,28 @@ | ||
package net.derfruhling.minecraft.create.trainperspective.fabric.mixin; | ||
package net.derfruhling.minecraft.create.trainperspective.mixin; | ||
|
||
import net.derfruhling.minecraft.create.trainperspective.fabric.ModFabricEntrypoint; | ||
import net.derfruhling.minecraft.create.trainperspective.CreateTrainPerspectiveMod; | ||
import net.minecraft.world.entity.Entity; | ||
import org.jetbrains.annotations.Nullable; | ||
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.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
@Mixin(Entity.class) | ||
public class EntityMixin { | ||
@Shadow @Nullable private Entity vehicle; | ||
|
||
@Inject(method = "startRiding(Lnet/minecraft/world/entity/Entity;Z)Z", at = @At(value = "RETURN", ordinal = 4)) | ||
public void onStartRiding(Entity entity, boolean bl, CallbackInfoReturnable<Boolean> cir) { | ||
ModFabricEntrypoint.getInstance().common.onEntityMount(true, (Entity)(Object)this, entity); | ||
CreateTrainPerspectiveMod.INSTANCE.onEntityMount(true, (Entity)(Object)this, entity); | ||
} | ||
|
||
@Inject(method = "removeVehicle", at = @At("HEAD")) | ||
public void onRemoveVehicle(CallbackInfo ci) { | ||
if(vehicle != null) { | ||
ModFabricEntrypoint.getInstance().common.onEntityMount(false, (Entity)(Object)this, vehicle); | ||
CreateTrainPerspectiveMod.INSTANCE.onEntityMount(false, (Entity)(Object)this, vehicle); | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
.../main/java/net/derfruhling/minecraft/create/trainperspective/mixin/GameRendererMixin.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,23 @@ | ||
package net.derfruhling.minecraft.create.trainperspective.mixin; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.math.Axis; | ||
import net.derfruhling.minecraft.create.trainperspective.MixinUtil; | ||
import net.minecraft.client.Camera; | ||
import net.minecraft.client.renderer.GameRenderer; | ||
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.callback.CallbackInfo; | ||
|
||
@Mixin(GameRenderer.class) | ||
public class GameRendererMixin { | ||
@Shadow @Final private Camera mainCamera; | ||
|
||
@Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;mulPose(Lorg/joml/Quaternionf;)V", ordinal = 3, shift = At.Shift.AFTER)) | ||
public void applyZRotation(float f, long l, PoseStack poseStack, CallbackInfo ci) { | ||
poseStack.mulPose(Axis.ZP.rotationDegrees(MixinUtil.asCamera3D(mainCamera).getZRot())); | ||
} | ||
} |
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
Oops, something went wrong.