Pose a Problem

- Fixed Track curves not rendering when optifine is present
- Fixed /c killTrain not removing stale contraption entities from the server
This commit is contained in:
simibubi 2022-06-30 13:07:22 +02:00
parent 1d1cf8e289
commit 494a48c538
2 changed files with 20 additions and 24 deletions

View file

@ -449,8 +449,6 @@ public class BezierConnection implements Iterable<BezierConnection.Segment> {
if (bakedSegments != null) if (bakedSegments != null)
return bakedSegments; return bakedSegments;
PoseStack poseStack = new PoseStack();
TransformStack tstack = TransformStack.cast(poseStack);
int segmentCount = getSegmentCount(); int segmentCount = getSegmentCount();
bakedSegments = new SegmentAngles[segmentCount + 1]; bakedSegments = new SegmentAngles[segmentCount + 1];
Couple<Vec3> previousOffsets = null; Couple<Vec3> previousOffsets = null;
@ -477,16 +475,16 @@ public class BezierConnection implements Iterable<BezierConnection.Segment> {
.scale(.5); .scale(.5);
Vec3 tieAngles = TrackRenderer.getModelAngles(segment.normal, railMiddle.subtract(prevMiddle)); Vec3 tieAngles = TrackRenderer.getModelAngles(segment.normal, railMiddle.subtract(prevMiddle));
angles.lightPosition = new BlockPos(railMiddle); angles.lightPosition = new BlockPos(railMiddle);
angles.railTransforms = Couple.create(null, null);
poseStack.pushPose(); PoseStack poseStack = new PoseStack();
tstack.translate(prevMiddle) TransformStack.cast(poseStack)
.translate(prevMiddle)
.rotateYRadians(tieAngles.y) .rotateYRadians(tieAngles.y)
.rotateXRadians(tieAngles.x) .rotateXRadians(tieAngles.x)
.rotateZRadians(tieAngles.z) .rotateZRadians(tieAngles.z)
.translate(-1 / 2f, -2 / 16f - 1 / 256f, 0); .translate(-1 / 2f, -2 / 16f - 1 / 256f, 0);
angles.tieTransform = poseStack.last(); angles.tieTransform = poseStack.last();
angles.railTransforms = Couple.create(null, null);
poseStack.popPose();
// Rails // Rails
float scale = end ? 2.2f : 2.1f; float scale = end ? 2.2f : 2.1f;
@ -496,15 +494,15 @@ public class BezierConnection implements Iterable<BezierConnection.Segment> {
Vec3 diff = railI.subtract(prevI); Vec3 diff = railI.subtract(prevI);
Vec3 anglesI = TrackRenderer.getModelAngles(segment.normal, diff); Vec3 anglesI = TrackRenderer.getModelAngles(segment.normal, diff);
poseStack.pushPose(); poseStack = new PoseStack();
tstack.translate(prevI) TransformStack.cast(poseStack)
.translate(prevI)
.rotateYRadians(anglesI.y) .rotateYRadians(anglesI.y)
.rotateXRadians(anglesI.x) .rotateXRadians(anglesI.x)
.rotateZRadians(anglesI.z) .rotateZRadians(anglesI.z)
.translate(0, -2 / 16f + (i % 2 == 0 ? 1 : -1) / 2048f - 1 / 256f, -1 / 32f) .translate(0, -2 / 16f + (i % 2 == 0 ? 1 : -1) / 2048f - 1 / 256f, -1 / 32f)
.scale(1, 1, (float) diff.length() * scale); .scale(1, 1, (float) diff.length() * scale);
angles.railTransforms.set(first, poseStack.last()); angles.railTransforms.set(first, poseStack.last());
poseStack.popPose();
} }
previousOffsets = railOffsets; previousOffsets = railOffsets;
@ -518,8 +516,6 @@ public class BezierConnection implements Iterable<BezierConnection.Segment> {
if (bakedGirders != null) if (bakedGirders != null)
return bakedGirders; return bakedGirders;
PoseStack poseStack = new PoseStack();
TransformStack tstack = TransformStack.cast(poseStack);
int segmentCount = getSegmentCount(); int segmentCount = getSegmentCount();
bakedGirders = new GirderAngles[segmentCount + 1]; bakedGirders = new GirderAngles[segmentCount + 1];
Couple<Couple<Vec3>> previousOffsets = null; Couple<Couple<Vec3>> previousOffsets = null;
@ -573,15 +569,15 @@ public class BezierConnection implements Iterable<BezierConnection.Segment> {
Vec3 beamDiff = currentBeam.subtract(previousBeam); Vec3 beamDiff = currentBeam.subtract(previousBeam);
Vec3 beamAngles = TrackRenderer.getModelAngles(segment.normal, beamDiff); Vec3 beamAngles = TrackRenderer.getModelAngles(segment.normal, beamDiff);
poseStack.pushPose(); PoseStack poseStack = new PoseStack();
tstack.translate(previousBeam) TransformStack.cast(poseStack)
.translate(previousBeam)
.rotateYRadians(beamAngles.y) .rotateYRadians(beamAngles.y)
.rotateXRadians(beamAngles.x) .rotateXRadians(beamAngles.x)
.rotateZRadians(beamAngles.z) .rotateZRadians(beamAngles.z)
.translate(0, 2 / 16f + (segment.index % 2 == 0 ? 1 : -1) / 2048f - 1 / 1024f, -1 / 32f) .translate(0, 2 / 16f + (segment.index % 2 == 0 ? 1 : -1) / 2048f - 1 / 1024f, -1 / 32f)
.scale(1, 1, (float) beamDiff.length() * scale); .scale(1, 1, (float) beamDiff.length() * scale);
angles.beams.set(first, poseStack.last()); angles.beams.set(first, poseStack.last());
poseStack.popPose();
// Caps // Caps
for (boolean top : Iterate.trueAndFalse) { for (boolean top : Iterate.trueAndFalse) {
@ -592,8 +588,9 @@ public class BezierConnection implements Iterable<BezierConnection.Segment> {
Vec3 diff = current.subtract(previous); Vec3 diff = current.subtract(previous);
Vec3 capAngles = TrackRenderer.getModelAngles(segment.normal, diff); Vec3 capAngles = TrackRenderer.getModelAngles(segment.normal, diff);
poseStack.pushPose(); poseStack = new PoseStack();
tstack.translate(previous) TransformStack.cast(poseStack)
.translate(previous)
.rotateYRadians(capAngles.y) .rotateYRadians(capAngles.y)
.rotateXRadians(capAngles.x) .rotateXRadians(capAngles.x)
.rotateZRadians(capAngles.z) .rotateZRadians(capAngles.z)
@ -602,7 +599,6 @@ public class BezierConnection implements Iterable<BezierConnection.Segment> {
.scale(1, 1, (float) diff.length() * scale); .scale(1, 1, (float) diff.length() * scale);
angles.beamCaps.get(top) angles.beamCaps.get(top)
.set(first, poseStack.last()); .set(first, poseStack.last());
poseStack.popPose();
} }
} }

View file

@ -31,7 +31,6 @@ import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;
@ -221,6 +220,11 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity {
return; return;
} }
if (!Create.RAILWAYS.sided(level).trains.containsKey(carriage.train.id)) {
discard();
return;
}
tickActors(); tickActors();
boolean isStalled = isStalled(); boolean isStalled = isStalled();
carriage.stalled = isStalled; carriage.stalled = isStalled;
@ -266,10 +270,6 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity {
carriageData.approach(this, carriage, 1f / getType().updateInterval()); carriageData.approach(this, carriage, 1f / getType().updateInterval());
if (!Create.RAILWAYS.sided(null).trains.containsKey(carriage.train.id)) {
discard();
return;
}
if (!carriage.train.derailed) if (!carriage.train.derailed)
carriage.updateContraptionAnchors(); carriage.updateContraptionAnchors();
@ -588,7 +588,7 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity {
GlobalStation currentStation = carriage.train.getCurrentStation(); GlobalStation currentStation = carriage.train.getCurrentStation();
if (currentStation != null && spaceDown) { if (currentStation != null && spaceDown) {
sendPrompt(player, Lang.translate("train.arrived_at", 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; return true;
} }
@ -600,7 +600,7 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity {
if (currentStation != null && targetSpeed != 0) { if (currentStation != null && targetSpeed != 0) {
stationMessage = false; stationMessage = false;
sendPrompt(player, Lang.translate("train.departing_from", 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) { if (currentStation == null) {