mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 07:27:15 +01:00
You spin me right round
- Seated Players now sync their camera rotation to the movement of the contraption (if possible)
This commit is contained in:
parent
2e91e16932
commit
8b782019e0
4 changed files with 83 additions and 4 deletions
|
@ -870,10 +870,11 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
|||
public static class ContraptionRotationState {
|
||||
public static final ContraptionRotationState NONE = new ContraptionRotationState();
|
||||
|
||||
float xRotation = 0;
|
||||
float yRotation = 0;
|
||||
float zRotation = 0;
|
||||
float secondYRotation = 0;
|
||||
public float xRotation = 0;
|
||||
public float yRotation = 0;
|
||||
public float zRotation = 0;
|
||||
public float secondYRotation = 0;
|
||||
|
||||
Matrix3d matrix;
|
||||
|
||||
public Matrix3d asMatrix() {
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
package com.simibubi.create.content.contraptions.actors.seat;
|
||||
|
||||
import com.simibubi.create.content.contraptions.AbstractContraptionEntity;
|
||||
import com.simibubi.create.content.contraptions.AbstractContraptionEntity.ContraptionRotationState;
|
||||
import com.simibubi.create.content.trains.entity.CarriageContraptionEntity;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.infrastructure.config.AllConfigs;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
public class ContraptionPlayerPassengerRotation {
|
||||
|
||||
static boolean active;
|
||||
static int prevId;
|
||||
static float prevYaw;
|
||||
static float prevPitch;
|
||||
|
||||
public static void tick() {
|
||||
active = AllConfigs.client().rotateWhenSeated.get();
|
||||
}
|
||||
|
||||
public static void frame() {
|
||||
Player player = Minecraft.getInstance().player;
|
||||
if (!active)
|
||||
return;
|
||||
if (player == null || !player.isPassenger()) {
|
||||
prevId = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
Entity vehicle = player.getVehicle();
|
||||
if (!(vehicle instanceof AbstractContraptionEntity contraptionEntity))
|
||||
return;
|
||||
|
||||
ContraptionRotationState rotationState = contraptionEntity.getRotationState();
|
||||
|
||||
float yaw = AngleHelper.wrapAngle180((contraptionEntity instanceof CarriageContraptionEntity cce)
|
||||
? cce.getViewYRot(AnimationTickHolder.getPartialTicks())
|
||||
: rotationState.yRotation);
|
||||
|
||||
float pitch = (contraptionEntity instanceof CarriageContraptionEntity cce)
|
||||
? cce.getViewXRot(AnimationTickHolder.getPartialTicks())
|
||||
: 0;
|
||||
|
||||
if (prevId != contraptionEntity.getId()) {
|
||||
prevId = contraptionEntity.getId();
|
||||
prevYaw = yaw;
|
||||
prevPitch = pitch;
|
||||
}
|
||||
|
||||
float yawDiff = AngleHelper.getShortestAngleDiff(yaw, prevYaw);
|
||||
float pitchDiff = AngleHelper.getShortestAngleDiff(pitch, prevPitch);
|
||||
|
||||
prevYaw = yaw;
|
||||
prevPitch = pitch;
|
||||
|
||||
float yawRelativeToTrain = Mth.abs(AngleHelper.getShortestAngleDiff(player.getYRot(), -yaw - 90));
|
||||
if (yawRelativeToTrain > 120)
|
||||
pitchDiff *= -1;
|
||||
else if (yawRelativeToTrain > 60)
|
||||
pitchDiff *= 0;
|
||||
|
||||
player.setYRot((float) (player.getYRot() + yawDiff));
|
||||
player.setXRot((float) (player.getXRot() + pitchDiff));
|
||||
}
|
||||
|
||||
}
|
|
@ -7,6 +7,7 @@ import com.simibubi.create.AllPackets;
|
|||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.CreateClient;
|
||||
import com.simibubi.create.content.contraptions.ContraptionHandler;
|
||||
import com.simibubi.create.content.contraptions.actors.seat.ContraptionPlayerPassengerRotation;
|
||||
import com.simibubi.create.content.contraptions.actors.trainControls.ControlsHandler;
|
||||
import com.simibubi.create.content.contraptions.chassis.ChassisRangeDisplay;
|
||||
import com.simibubi.create.content.contraptions.minecart.CouplingHandlerClient;
|
||||
|
@ -166,6 +167,7 @@ public class ClientEvents {
|
|||
CreateClient.VALUE_SETTINGS_HANDLER.tick();
|
||||
ScrollValueHandler.tick();
|
||||
NetheriteBacktankFirstPersonRenderer.clientTick();
|
||||
ContraptionPlayerPassengerRotation.tick();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
@ -218,6 +220,8 @@ public class ClientEvents {
|
|||
buffer.draw();
|
||||
RenderSystem.enableCull();
|
||||
ms.popPose();
|
||||
|
||||
ContraptionPlayerPassengerRotation.frame();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
@ -33,6 +33,8 @@ public class CClient extends ConfigBase {
|
|||
Comments.ingameMenuConfigButtonOffsetX);
|
||||
public final ConfigBool ignoreFabulousWarning = b(false, "ignoreFabulousWarning",
|
||||
Comments.ignoreFabulousWarning);
|
||||
public final ConfigBool rotateWhenSeated = b(true, "rotateWhenSeated",
|
||||
Comments.rotatewhenSeated);
|
||||
|
||||
// custom fluid fog
|
||||
public final ConfigGroup fluidFogSettings = group(1, "fluidFogSettings", Comments.fluidFogSettings);
|
||||
|
@ -125,6 +127,7 @@ public class CClient extends ConfigBase {
|
|||
"The sign (-/+) of this value determines what side of the row the button appears on (left/right)"
|
||||
};
|
||||
static String ignoreFabulousWarning = "Setting this to true will prevent Create from sending you a warning when playing with Fabulous graphics enabled";
|
||||
static String rotatewhenSeated = "Disable to prevent being rotated while seated on a Moving Contraption";
|
||||
static String overlay = "Settings for the Goggle Overlay";
|
||||
static String overlayOffset = "Offset the overlay from goggle- and hover- information by this many pixels on the respective axis; Use /create overlay";
|
||||
static String overlayCustomColor = "Enable this to use your custom colors for the Goggle- and Hover- Overlay";
|
||||
|
|
Loading…
Reference in a new issue