|
21 | 21 | import dev.engine_room.flywheel.lib.instance.FlatLit; |
22 | 22 | import dev.engine_room.flywheel.lib.instance.InstanceTypes; |
23 | 23 | import dev.engine_room.flywheel.lib.instance.TransformedInstance; |
24 | | -import dev.engine_room.flywheel.lib.model.Models; |
25 | 24 | import dev.engine_room.flywheel.lib.transform.TransformStack; |
26 | 25 | import dev.engine_room.flywheel.lib.visual.AbstractBlockEntityVisual; |
27 | 26 | import it.unimi.dsi.fastutil.longs.LongArraySet; |
|
30 | 29 | import net.createmod.catnip.data.Iterate; |
31 | 30 | import net.minecraft.core.BlockPos; |
32 | 31 | import net.minecraft.core.SectionPos; |
| 32 | +import net.minecraft.util.Mth; |
33 | 33 | import net.minecraft.world.level.Level; |
34 | 34 | import net.minecraft.world.level.LightLayer; |
35 | 35 |
|
@@ -98,14 +98,15 @@ public LongSet collectLightSections() { |
98 | 98 | int maxY = Integer.MIN_VALUE; |
99 | 99 | int maxZ = Integer.MIN_VALUE; |
100 | 100 | for (BezierConnection connection : blockEntity.connections.values()) { |
101 | | - for (BlockPos pos : connection.bePositions) { |
102 | | - minX = Math.min(minX, pos.getX()); |
103 | | - minY = Math.min(minY, pos.getY()); |
104 | | - minZ = Math.min(minZ, pos.getZ()); |
105 | | - maxX = Math.max(maxX, pos.getX()); |
106 | | - maxY = Math.max(maxY, pos.getY()); |
107 | | - maxZ = Math.max(maxZ, pos.getZ()); |
108 | | - } |
| 101 | + // The start and end positions are not enough to enclose the entire curve. |
| 102 | + // Check the computed bounds but expand by one for safety. |
| 103 | + var bounds = connection.getBounds(); |
| 104 | + minX = Math.min(minX, Mth.floor(bounds.minX) - 1); |
| 105 | + minY = Math.min(minY, Mth.floor(bounds.minY) - 1); |
| 106 | + minZ = Math.min(minZ, Mth.floor(bounds.minZ) - 1); |
| 107 | + maxX = Math.max(maxX, Mth.ceil(bounds.maxX) + 1); |
| 108 | + maxY = Math.max(maxY, Mth.ceil(bounds.maxY) + 1); |
| 109 | + maxZ = Math.max(maxZ, Mth.ceil(bounds.maxZ) + 1); |
109 | 110 | } |
110 | 111 |
|
111 | 112 | var minSectionX = ContraptionVisual.minLightSection(minX); |
@@ -230,9 +231,9 @@ private GirderVisual(BezierConnection bc) { |
230 | 231 | beams = Couple.create(() -> new TransformedInstance[segCount]); |
231 | 232 | beamCaps = Couple.create(() -> Couple.create(() -> new TransformedInstance[segCount])); |
232 | 233 | lightPos = new BlockPos[segCount]; |
233 | | - beams.forEach(instancerProvider().instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.GIRDER_SEGMENT_MIDDLE))::createInstances); |
| 234 | + beams.forEach(instancerProvider().instancer(InstanceTypes.TRANSFORMED, SpecialModels.flatChunk(AllPartialModels.GIRDER_SEGMENT_MIDDLE))::createInstances); |
234 | 235 | beamCaps.forEachWithContext((c, top) -> { |
235 | | - var partialModel = Models.partial(top ? AllPartialModels.GIRDER_SEGMENT_TOP : AllPartialModels.GIRDER_SEGMENT_BOTTOM); |
| 236 | + var partialModel = SpecialModels.flatChunk(top ? AllPartialModels.GIRDER_SEGMENT_TOP : AllPartialModels.GIRDER_SEGMENT_BOTTOM); |
236 | 237 | c.forEach(instancerProvider().instancer(InstanceTypes.TRANSFORMED, partialModel)::createInstances); |
237 | 238 | }); |
238 | 239 |
|
|
0 commit comments