Skip to content

Commit

Permalink
Merge branch 'dev/0.6.0-port-1.19.2' into dev/0.6.0-port-1.18.2
Browse files Browse the repository at this point in the history
  • Loading branch information
der-fruhling committed Aug 8, 2024
2 parents 994a090 + 584b4ee commit 4a6194c
Show file tree
Hide file tree
Showing 21 changed files with 725 additions and 68 deletions.
12 changes: 7 additions & 5 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
Multiplayer and non-player entity compatibility, along with 1.18.2 support.
Extra smoothness and extra compatibility change.

Changelog:

- **Fixed:** Player camera turns when an unrelated player is on a train.
- **Added:** Ability for non-player entities to be affected by this mod.
- **Technical:** Cleaned up the code a bit.
- **Fixed:** Delayed camera movement when train turns.
- **Added:** Debug option to display new value scales used to fix the aforementioned delayed camera movement.
- **Fixed:** Incompatibility with Figura combined with some mods. [#67](https://github.com/der-fruhling-entertainment/create-train-perspective/issues/67)
- (fixed via possibly temporary workaround. please report any other issues with this mod and mine! it likes to get breaky)
- **Technical:** Cleaned up the code a bit more.

[View full change log.](https://github.com/der-fruhling/create-train-perspective/compare/v0.4.1...v0.5.0)
[View full change log.](https://github.com/der-fruhling/create-train-perspective/compare/v0.5.0...v0.6.0)

---

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
/*
* Part of the Create: Train Perspective project.
*
* The MIT License (MIT)
*
* Copyright (c) 2024 der_frühling
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package net.derfruhling.minecraft.create.trainperspective;

public interface Camera3D {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
/*
* Part of the Create: Train Perspective project.
*
* The MIT License (MIT)
*
* Copyright (c) 2024 der_frühling
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package net.derfruhling.minecraft.create.trainperspective;

import net.minecraft.client.player.LocalPlayer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
/*
* Part of the Create: Train Perspective project.
*
* The MIT License (MIT)
*
* Copyright (c) 2024 der_frühling
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package net.derfruhling.minecraft.create.trainperspective;

import com.simibubi.create.content.trains.entity.CarriageContraptionEntity;
Expand Down Expand Up @@ -33,10 +59,7 @@ public void onEntityMountEvent(boolean isMounting, Entity entityMounting, Entity
public void onEntityMount(Perspective persp, CarriageContraptionEntity contraption) {
if (persp.getRotationState() == null) {
var state = new RotationState(contraption, false);
persp.setRotationState(state);
var carriage = state.getContraption();
assert carriage != null;
persp.enable(carriage.pitch, carriage.yaw);
persp.enable(contraption, state);
} else {
var state = persp.getRotationState();
state.onMounted();
Expand All @@ -57,10 +80,7 @@ public void tickStandingEntity(final CarriageContraptionEntity contraption, fina

if (state == null || !Objects.equals(state.getContraption(), contraption)) {
state = new RotationState(contraption, true);
persp.setRotationState(state);
var carriage = state.getContraption();
assert carriage != null;
persp.enable(carriage.pitch, carriage.yaw);
persp.enable(contraption, state);
} else {
state.update();
}
Expand All @@ -69,16 +89,15 @@ public void tickStandingEntity(final CarriageContraptionEntity contraption, fina
private void tickPerspectiveState(Entity player, Perspective persp, RotationState state) {
var carriage = state.getContraption();
if (carriage == null) return;
persp.setLean(carriage.pitch);
persp.setYaw(carriage.yaw);
persp.setReference(carriage);
player.setYRot(player.getYRot() + state.getYawDelta());
player.setYBodyRot(player.getYRot());

if (state.isStanding() && !state.isSeated()) {
state.tick();

if (state.getTicksSinceLastUpdate() > 5) {
state.setShouldTickState(false);
state.stopTickingState();
}
}
}
Expand All @@ -94,7 +113,6 @@ public void tickEntity(Entity entity, Perspective persp) {
persp.diminish();

if (persp.isDiminished()) {
persp.setRotationState(null);
persp.disable();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
/*
* Part of the Create: Train Perspective project.
*
* The MIT License (MIT)
*
* Copyright (c) 2024 der_frühling
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package net.derfruhling.minecraft.create.trainperspective;

import com.mojang.math.Vector3d;
Expand Down Expand Up @@ -27,7 +53,7 @@ public static float getExtraYRot(Perspective persp, float xRot, float yRot, floa
public static Vector3d applyStandingCameraTranslation(Player player, double x, double y, double z, Perspective persp, float f) {
var lean = persp.getLean(f) * Mth.DEG_TO_RAD;
var yaw = persp.getYaw(f) * Mth.DEG_TO_RAD;
var height = player.getEyeHeight();
var height = y - player.getY();
var newY = y + ((height * Mth.cos(lean)) - height);
var leanSin = Mth.sin(lean);
var newZ = z - (height * Mth.sin(yaw) * leanSin);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
/*
* Part of the Create: Train Perspective project.
*
* The MIT License (MIT)
*
* Copyright (c) 2024 der_frühling
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package net.derfruhling.minecraft.create.trainperspective;

import com.google.gson.Gson;
Expand Down Expand Up @@ -41,6 +67,7 @@ public class ModConfig {
public boolean applyToNonPlayerEntities = true;
public List<ResourceLocation> blockedEntities = new ArrayList<>();
public boolean dbgShowStandingTransforms = false;
public boolean dbgShowValueScales = false;

private ModConfig() {
}
Expand Down Expand Up @@ -188,6 +215,16 @@ public static Screen createConfigScreen(Screen parent) {
.setDefaultValue(false)
.build());


debug.add(entryBuilder
.startBooleanToggle(
Component.translatable("option.create_train_perspective.debug.value_scales"),
INSTANCE.dbgShowValueScales)
.setSaveConsumer(value -> INSTANCE.dbgShowValueScales = value)
.setTooltip(Component.translatable("option.create_train_perspective.debug.value_scales.tooltip"))
.setDefaultValue(false)
.build());

advanced.add(debug.build());
general.addEntry(advanced.build());

Expand Down
Loading

0 comments on commit 4a6194c

Please sign in to comment.