@@ -41,36 +41,44 @@ class ExtendonRenderer(context: BlockEntityRendererProvider.Context?) : SmartBlo
4141
4242 if (be.connectedBe != null ) {
4343 val thisShip = be.level!! .getShipManagingPos(be.blockPos) as ClientShip ?
44- val thisPos = if (thisShip == null ) be.blockPos.toJOMLD()!! + 0.5 else thisShip.renderTransform.shipToWorld.transformPosition(be.blockPos.toJOMLD() + 0.5 )!!
44+ val thisPos = if (thisShip == null ) be.blockPos.toJOMLD() + 0.5 else thisShip.renderTransform.shipToWorld.transformPosition(be.blockPos.toJOMLD() + 0.5 )!!
4545
4646 val otherShip = be.level!! .getShipManagingPos(be.connectedBe!! .pos) as ClientShip ?
4747 val otherPos = if (otherShip == null )be.connectedBe!! .pos.toJOMLD() + 0.5 else otherShip.renderTransform.shipToWorld.transformPosition(be.connectedBe!! .pos.toJOMLD() + 0.5 )!!
4848
49- var direction = otherPos - thisPos
49+ val direction = otherPos - thisPos
5050
51- var angleTriple = getEulerAngles(direction)
52- axis0 = axis0.rotateCentered(Direction .UP , angleTriple.second.toFloat())
51+ val angles = if (thisShip == null ) getEulerAngles(direction) else getEulerAngles(thisShip.renderTransform.worldToShip.transformDirection(direction, Vector3d ()))
5352
54- axis1 = axis1.rotateCentered( Direction . UP , angleTriple.second.toFloat())
55- axis1 = axis1 .rotateCentered(Direction .WEST , angleTriple.first .toFloat())
53+ // Rotate Partials
54+ axis0 = axis0 .rotateCentered(Direction .UP , angles.second .toFloat())
5655
57- val minX = thisPos.x - 0.25
58- val minY = thisPos.y - 0.25
59- val minZ = thisPos.z - 0.25
60- val maxX = thisPos.x - 0.25 + thisPos.distance(otherPos)
61- val maxY = thisPos.y + 0.25
62- val maxZ = thisPos.z + 0.25
56+ axis1 = axis1.rotateCentered(Direction .UP , angles.second.toFloat())
57+ axis1 = axis1.rotateCentered(Direction .WEST , angles.first.toFloat())
6358
64- val aabb = AABB (minX, minY, minZ, maxX, maxY, maxZ)
6559
66- // Create and configure the outline
67- val outline = RotatedAABBOutline (aabb, direction)
60+ if (be.main) {
61+ // Rotated AABB creation
62+ val minX = thisPos.x - 0.25
63+ val minY = thisPos.y - 0.25
64+ val minZ = thisPos.z - 0.25
65+ val maxX = thisPos.x - 0.25 + thisPos.distance(otherPos)
66+ val maxY = thisPos.y + 0.25
67+ val maxZ = thisPos.z + 0.25
6868
69- if (! outliner.getOutlines().containsKey(be) || (outliner.getOutlines()[be]?.outline !is RotatedAABBOutline )) outliner.showCustomOutline(be, outline)
70- else outliner.editCustomOutline(be, outline)
71-
72- // Keep the outline alive for next frame
73- outliner.keep(be)
69+ val aabb = AABB (minX, minY, minZ, maxX, maxY, maxZ)
70+
71+ // Create and configure the outline
72+ val outline = RotatedAABBOutline (aabb, direction)
73+
74+ if (! outliner.getOutlines()
75+ .containsKey(be) || (outliner.getOutlines()[be]?.outline !is RotatedAABBOutline )
76+ ) outliner.showCustomOutline(be, outline)
77+ else outliner.editCustomOutline(be, outline)
78+
79+ // Keep the outline alive for next frame
80+ outliner.keep(be)
81+ }
7482 } else {
7583 // Remove outline if no connection
7684 outliner.remove(be)
@@ -122,3 +130,9 @@ public fun Outliner.editCustomOutline(key: Any, outline: Outline) {
122130 .let { it as MutableMap <Any , Outliner .OutlineEntry > }[key] = Outliner .OutlineEntry (outline)
123131}
124132
133+ public fun Outline.OutlineParams.disableFadeLineWidth () {
134+ this ::class .java.getDeclaredField(" fadeLineWidth" )
135+ .apply { isAccessible = true }
136+ .set(this , false )
137+
138+ }
0 commit comments