upside down bogeys work in nether portals

fixed coupling anchor offsets
This commit is contained in:
techno-sam 2023-05-05 07:06:02 -07:00
parent da26c0ccbf
commit d556f08876
4 changed files with 19 additions and 8 deletions

View file

@ -374,7 +374,13 @@ public class Carriage {
TrackNodeLocation pivot = dce.findPivot(dimension, start == getLeadingPoint());
if (pivot == null)
return null;
Vec3 startVec = start.getPosition(start != getLeadingPoint() && (leadingBogey().isUpsideDown() != trailingBogey().isUpsideDown()));
boolean flipped = false;
if (!leadingUpsideDown && trailingUpsideDown) { // nu // fixme this code sucks and needs to be better
flipped = start != getLeadingPoint() && (leadingBogey().isUpsideDown() != trailingBogey().isUpsideDown());
} else if (leadingUpsideDown && !trailingUpsideDown) { // un
flipped = start != getLeadingPoint() && (leadingBogey().isUpsideDown() != trailingBogey().isUpsideDown());
}
Vec3 startVec = start.getPosition(flipped);
Vec3 portalVec = pivot.getLocation()
.add(0, DebugValueCommand.tmpPortalOffset(leadingUpsideDown, trailingUpsideDown, isLeading), 0);
// same side - other side

View file

@ -151,7 +151,9 @@ public class CarriageBogey {
public void updateCouplingAnchor(Vec3 entityPos, float entityXRot, float entityYRot, int bogeySpacing,
float partialTicks, boolean leading) {
Vec3 thisOffset = type.getConnectorAnchorOffset(isUpsideDown());
boolean selfUpsideDown = isUpsideDown();
boolean leadingUpsideDown = carriage.leadingBogey().isUpsideDown();
Vec3 thisOffset = type.getConnectorAnchorOffset(selfUpsideDown);
thisOffset = thisOffset.multiply(1, 1, leading ? -1 : 1);
thisOffset = VecHelper.rotate(thisOffset, pitch.getValue(partialTicks), Axis.X);
@ -163,6 +165,8 @@ public class CarriageBogey {
thisOffset = VecHelper.rotate(thisOffset, 180, Axis.Y);
thisOffset = VecHelper.rotate(thisOffset, -entityXRot, Axis.X);
thisOffset = VecHelper.rotate(thisOffset, entityYRot + 90, Axis.Y);
if (selfUpsideDown != leadingUpsideDown)
thisOffset = thisOffset.add(0, selfUpsideDown ? -2 : 2, 0);
couplingAnchors.set(leading, entityPos.add(thisOffset));
}

View file

@ -82,7 +82,7 @@ public class CarriageCouplingRenderer {
float margin = 3 / 16f;
double couplingDistance = train.carriageSpacing.get(i) - 2 * margin
- bogey1.type.getConnectorAnchorOffset(bogey1.isUpsideDown()).z - bogey2.type.getConnectorAnchorOffset(bogey1.isUpsideDown()).z;
- bogey1.type.getConnectorAnchorOffset(bogey1.isUpsideDown()).z - bogey2.type.getConnectorAnchorOffset(bogey2.isUpsideDown()).z;
int couplingSegments = (int) Math.round(couplingDistance * 4);
double stretch = ((anchor2.distanceTo(anchor) - 2 * margin) * 4) / couplingSegments;
for (int j = 0; j < couplingSegments; j++) {

View file

@ -23,7 +23,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.CommandBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
public class DebugValueCommand {
public class DebugValueCommand { //fixme this is *very* temporary
public static float value = 0;
@ -41,8 +41,9 @@ public class DebugValueCommand {
// same side - other side
// n(ormal)-n(ormal)
// u(pside down)-u(pside down) what about un ? not tested yet un doesn't work with + 1 or -1. HALP
// 1 works for: nn n nu
// u(pside down)-u(pside down)
// nu works with special handling, now to get un to work!
// 1 works for: nn n
//-1 works for: uu u
public static double tmpPortalOffset(boolean leadingUpsideDown, boolean trailingUpsideDown, boolean isLeading) {
double portalOffset = 0.0;
@ -52,9 +53,9 @@ public class DebugValueCommand {
return -1.0;
} else if (leadingUpsideDown && !trailingUpsideDown) { // un
if (isLeading) {
return 0.1;
return -1.0;
} else {
return 0.2;
return -1.0;
}
} else if (!leadingUpsideDown && trailingUpsideDown) { // nu
if (isLeading) {