From 494a48c53839a0423ff5c828d24ddcf4f5dbdd2a Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Thu, 30 Jun 2022 13:07:22 +0200 Subject: [PATCH] Pose a Problem - Fixed Track curves not rendering when optifine is present - Fixed /c killTrain not removing stale contraption entities from the server --- .../logistics/trains/BezierConnection.java | 30 ++++++++----------- .../entity/CarriageContraptionEntity.java | 14 ++++----- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/BezierConnection.java b/src/main/java/com/simibubi/create/content/logistics/trains/BezierConnection.java index 1ed3751e3..5c543536d 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/BezierConnection.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/BezierConnection.java @@ -449,8 +449,6 @@ public class BezierConnection implements Iterable { if (bakedSegments != null) return bakedSegments; - PoseStack poseStack = new PoseStack(); - TransformStack tstack = TransformStack.cast(poseStack); int segmentCount = getSegmentCount(); bakedSegments = new SegmentAngles[segmentCount + 1]; Couple previousOffsets = null; @@ -477,16 +475,16 @@ public class BezierConnection implements Iterable { .scale(.5); Vec3 tieAngles = TrackRenderer.getModelAngles(segment.normal, railMiddle.subtract(prevMiddle)); angles.lightPosition = new BlockPos(railMiddle); + angles.railTransforms = Couple.create(null, null); - poseStack.pushPose(); - tstack.translate(prevMiddle) + PoseStack poseStack = new PoseStack(); + TransformStack.cast(poseStack) + .translate(prevMiddle) .rotateYRadians(tieAngles.y) .rotateXRadians(tieAngles.x) .rotateZRadians(tieAngles.z) .translate(-1 / 2f, -2 / 16f - 1 / 256f, 0); angles.tieTransform = poseStack.last(); - angles.railTransforms = Couple.create(null, null); - poseStack.popPose(); // Rails float scale = end ? 2.2f : 2.1f; @@ -496,15 +494,15 @@ public class BezierConnection implements Iterable { Vec3 diff = railI.subtract(prevI); Vec3 anglesI = TrackRenderer.getModelAngles(segment.normal, diff); - poseStack.pushPose(); - tstack.translate(prevI) + poseStack = new PoseStack(); + TransformStack.cast(poseStack) + .translate(prevI) .rotateYRadians(anglesI.y) .rotateXRadians(anglesI.x) .rotateZRadians(anglesI.z) .translate(0, -2 / 16f + (i % 2 == 0 ? 1 : -1) / 2048f - 1 / 256f, -1 / 32f) .scale(1, 1, (float) diff.length() * scale); angles.railTransforms.set(first, poseStack.last()); - poseStack.popPose(); } previousOffsets = railOffsets; @@ -518,8 +516,6 @@ public class BezierConnection implements Iterable { if (bakedGirders != null) return bakedGirders; - PoseStack poseStack = new PoseStack(); - TransformStack tstack = TransformStack.cast(poseStack); int segmentCount = getSegmentCount(); bakedGirders = new GirderAngles[segmentCount + 1]; Couple> previousOffsets = null; @@ -573,15 +569,15 @@ public class BezierConnection implements Iterable { Vec3 beamDiff = currentBeam.subtract(previousBeam); Vec3 beamAngles = TrackRenderer.getModelAngles(segment.normal, beamDiff); - poseStack.pushPose(); - tstack.translate(previousBeam) + PoseStack poseStack = new PoseStack(); + TransformStack.cast(poseStack) + .translate(previousBeam) .rotateYRadians(beamAngles.y) .rotateXRadians(beamAngles.x) .rotateZRadians(beamAngles.z) .translate(0, 2 / 16f + (segment.index % 2 == 0 ? 1 : -1) / 2048f - 1 / 1024f, -1 / 32f) .scale(1, 1, (float) beamDiff.length() * scale); angles.beams.set(first, poseStack.last()); - poseStack.popPose(); // Caps for (boolean top : Iterate.trueAndFalse) { @@ -592,8 +588,9 @@ public class BezierConnection implements Iterable { Vec3 diff = current.subtract(previous); Vec3 capAngles = TrackRenderer.getModelAngles(segment.normal, diff); - poseStack.pushPose(); - tstack.translate(previous) + poseStack = new PoseStack(); + TransformStack.cast(poseStack) + .translate(previous) .rotateYRadians(capAngles.y) .rotateXRadians(capAngles.x) .rotateZRadians(capAngles.z) @@ -602,7 +599,6 @@ public class BezierConnection implements Iterable { .scale(1, 1, (float) diff.length() * scale); angles.beamCaps.get(top) .set(first, poseStack.last()); - poseStack.popPose(); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageContraptionEntity.java b/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageContraptionEntity.java index 8886ab3b1..2cf684ebc 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageContraptionEntity.java @@ -31,7 +31,6 @@ import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.VecHelper; -import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; @@ -221,6 +220,11 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity { return; } + if (!Create.RAILWAYS.sided(level).trains.containsKey(carriage.train.id)) { + discard(); + return; + } + tickActors(); boolean isStalled = isStalled(); carriage.stalled = isStalled; @@ -266,10 +270,6 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity { carriageData.approach(this, carriage, 1f / getType().updateInterval()); - if (!Create.RAILWAYS.sided(null).trains.containsKey(carriage.train.id)) { - discard(); - return; - } if (!carriage.train.derailed) carriage.updateContraptionAnchors(); @@ -588,7 +588,7 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity { GlobalStation currentStation = carriage.train.getCurrentStation(); if (currentStation != null && spaceDown) { sendPrompt(player, Lang.translate("train.arrived_at", - new TextComponent(currentStation.name).withStyle(ChatFormatting.DARK_GREEN)), false); + new TextComponent(currentStation.name).withStyle(s -> s.withColor(0x704630))), false); return true; } @@ -600,7 +600,7 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity { if (currentStation != null && targetSpeed != 0) { stationMessage = false; sendPrompt(player, Lang.translate("train.departing_from", - new TextComponent(currentStation.name).withStyle(ChatFormatting.DARK_GREEN)), false); + new TextComponent(currentStation.name).withStyle(s -> s.withColor(0x704630))), false); } if (currentStation == null) {