@@ -10,6 +10,10 @@ import com.lambda.util.BaritoneUtils
1010import com.lambda.util.Communication.info
1111import com.lambda.util.player.MovementUtils.octant
1212import com.lambda.util.extension.Structure
13+ import com.lambda.util.extension.moveY
14+ import com.lambda.util.math.MathUtils.ceilToInt
15+ import com.lambda.util.math.MathUtils.floorToInt
16+ import com.lambda.util.math.VecUtils.rotateClockwise
1317import com.lambda.util.world.StructureUtils.generateDirectionalTube
1418import net.minecraft.block.Blocks
1519import net.minecraft.util.math.BlockPos
@@ -23,22 +27,38 @@ object HighwayTools : Module(
2327 description = " Auto highway builder" ,
2428 defaultTags = setOf(ModuleTag .PLAYER , ModuleTag .AUTOMATION )
2529) {
26- private val height by setting(" Height" , 4 , 1 .. 10 , 1 )
30+ private val height by setting(" Height" , 4 , 2 .. 10 , 1 )
2731 private val width by setting(" Width" , 6 , 1 .. 30 , 1 )
28- private val rimHeight by setting(" Rim Height" , 1 , 0 .. 6 , 1 )
29- private val cornerBlock by setting(" Corner Block" , false , description = " Include corner blocks in the highway" )
30- private val ceiling by setting(" Ceiling" , false , description = " Smooth roof over the highway" )
31- private val ceilingMaterial by setting(" Ceiling Material" , Blocks .OBSIDIAN , description = " Material to build the ceiling with" ) { ceiling }
32- private val distance by setting(" Distance" , - 1 , - 1 .. 1000000 , 1 , description = " Distance to build the highway (negative for infinite)" )
32+ private val pavement by setting(" Pavement" , Material .Block , description = " Material for the pavement" )
33+ private val rimHeight by setting(" Pavement Rim Height" , 1 , 0 .. 6 , 1 ) { pavement != Material .Any }
34+ private val cornerBlock by setting(" Corner" , Corner .None , description = " Include corner blocks in the highway" ) { pavement != Material .Any }
35+ private val pavementMaterial by setting(" Pavement Material" , Blocks .OBSIDIAN , description = " Material to build the highway with" ) { pavement == Material .Block }
36+ private val floor by setting(" Floor" , Material .Any , description = " Material for the floor" )
37+ private val floorMaterial by setting(" Floor Material" , Blocks .NETHERRACK , description = " Material to build the floor with" ) { floor == Material .Block }
38+ private val walls by setting(" Walls" , Material .Any , description = " Material for the walls" )
39+ private val wallMaterial by setting(" Wall Material" , Blocks .NETHERRACK , description = " Material to build the walls with" ) { walls == Material .Block }
40+ private val ceiling by setting(" Ceiling" , Material .Any , description = " Material for the ceiling" )
41+ private val ceilingMaterial by setting(" Ceiling Material" , Blocks .OBSIDIAN , description = " Material to build the ceiling with" ) { ceiling == Material .Block }
42+ private val distance by setting(" Distance" , - 1 , - 1 .. 1000000 , 1 , description = " Distance to build the highway/tunnel (negative for infinite)" )
3343 private val sliceSize by setting(" Slice Size" , 3 , 1 .. 5 , 1 , description = " Number of slices to build at once" )
34- private val material by setting(" Highway Material" , Blocks .OBSIDIAN , description = " Material to build the highway with" )
3544
3645 private var octant = EightWayDirection .NORTH
3746 private var distanceMoved = 0
3847 private var startPos = BlockPos .ORIGIN
3948 private var currentPos = BlockPos .ORIGIN
4049 private var runningTask: Task <* >? = null
4150
51+ enum class Material {
52+ Any ,
53+ Solid ,
54+ Block ,
55+ }
56+
57+ enum class Corner {
58+ None ,
59+ Solid ,
60+ }
61+
4262 init {
4363 onEnable {
4464 octant = player.octant
@@ -58,7 +78,7 @@ object HighwayTools : Module(
5878 distanceMoved + = sliceSize
5979
6080 var structure: Structure = mutableMapOf ()
61- val slice = highwaySlice ()
81+ val slice = generateSlice ()
6282 repeat(sliceSize) {
6383 val vec = Vec3i (octant.offsetX, 0 , octant.offsetZ)
6484 currentPos = currentPos.add(vec)
@@ -77,93 +97,121 @@ object HighwayTools : Module(
7797 }.start(null )
7898 }
7999
80- private fun highwaySlice (): Structure {
100+ private fun generateSlice (): Structure {
81101 val structure = mutableMapOf<BlockPos , TargetState >()
82- val orthogonal = EightWayDirection .entries[( octant.ordinal + 2 ).mod( 8 )]
83- val center = (width / 2.0 ).roundToInt ()
102+ val orthogonal = octant.rotateClockwise( 2 )
103+ val center = (width / 2.0 ).floorToInt ()
84104
85- // Area to clear
105+ // Hole
86106 structure + = generateDirectionalTube(
87107 orthogonal,
88108 width,
89109 height,
90110 - center,
91- - 1 ,
92- ).associateWith { TargetState .Air }
93-
94- // Highway
95- structure + = generateDirectionalTube(
96- orthogonal,
97- width,
98- 1 ,
99- - center,
100- - 1 ,
101- ).associateWith { TargetState .Block (material) }
102-
103- // Left rim
104- structure + = generateDirectionalTube(
105- orthogonal,
106- 1 ,
107- rimHeight,
108- - center + width - 1 ,
109- 0 ,
110- ).associateWith { TargetState .Block (material) }
111-
112- // Right rim
113- structure + = generateDirectionalTube(
114- orthogonal,
115- 1 ,
116- rimHeight,
117- - center,
118111 0 ,
119- ).associateWith { TargetState .Block (material) }
112+ ).associateWith { TargetState .Air }
120113
121- if (! cornerBlock ) {
122- structure - = generateDirectionalTube(
114+ if (pavement != Material . Any ) {
115+ structure + = generateDirectionalTube(
123116 orthogonal,
117+ width,
124118 1 ,
119+ - center,
120+ 0 ,
121+ ).associateWith { target(pavement, pavementMaterial) }
122+
123+ // Left rim
124+ structure + = generateDirectionalTube(
125+ orthogonal,
125126 1 ,
127+ rimHeight,
126128 - center + width - 1 ,
127- - 1 ,
128- )
129+ 1 ,
130+ ).associateWith { target(pavement, pavementMaterial) }
129131
130- structure - = generateDirectionalTube(
132+ // Right rim
133+ structure + = generateDirectionalTube(
131134 orthogonal,
132135 1 ,
136+ rimHeight,
137+ - center,
138+ 1 ,
139+ ).associateWith { target(pavement, pavementMaterial) }
140+
141+ if (cornerBlock == Corner .None ) {
142+ // Support for the left rim
143+ structure + = generateDirectionalTube(
144+ orthogonal,
145+ 1 ,
146+ 1 ,
147+ - center + width - 1 ,
148+ 0 ,
149+ ).associateWith { TargetState .Support (Direction .UP ) }
150+
151+ // Support for the right rim
152+ structure + = generateDirectionalTube(
153+ orthogonal,
154+ 1 ,
155+ 1 ,
156+ - center,
157+ 0 ,
158+ ).associateWith { TargetState .Support (Direction .UP ) }
159+ }
160+ }
161+
162+ if (ceiling != Material .Any ) {
163+ structure + = generateDirectionalTube(
164+ orthogonal,
165+ width,
133166 1 ,
134167 - center,
135- - 1 ,
136- )
168+ height ,
169+ ).associateWith { target(ceiling, ceilingMaterial) }
137170 }
138171
139- // Support for the left corner
140- structure + = generateDirectionalTube(
141- orthogonal,
142- 1 ,
143- 1 ,
144- - center + width - 1 ,
145- - 1 ,
146- ).associateWith { TargetState .Support (Direction .UP ) }
172+ if (walls != Material .Any ) {
173+ // Left wall
174+ structure + = generateDirectionalTube(
175+ orthogonal,
176+ 1 ,
177+ height,
178+ - center + width,
179+ 0 ,
180+ ).associateWith { target(walls, wallMaterial) }
147181
148- // Support for the right corner
149- structure + = generateDirectionalTube(
150- orthogonal,
151- 1 ,
152- 1 ,
153- - center,
154- - 1 ,
155- ).associateWith { TargetState .Support (Direction .UP ) }
182+ // Right wall
183+ structure + = generateDirectionalTube(
184+ orthogonal,
185+ 1 ,
186+ height,
187+ - center - 1 ,
188+ 0 ,
189+ ).associateWith { target(walls, wallMaterial) }
190+ }
156191
157- if (ceiling ) {
192+ if (floor != Material . Any ) {
158193 structure + = generateDirectionalTube(
159194 orthogonal,
160195 width,
161196 1 ,
162197 - center,
163- height - 1 ,
164- ).associateWith { TargetState .Block (ceilingMaterial) }
198+ - 1 ,
199+ ).associateWith { target(floor, floorMaterial) }
200+ }
201+
202+ val transformed = when {
203+ pavement != Material .Any -> structure.moveY(- 1 )
204+ else -> structure
165205 }
166206
167- return structure
207+ return transformed
208+ }
209+
210+ private fun target (target : Material , material : net.minecraft.block.Block ): TargetState {
211+ return when (target) {
212+ Material .Solid -> TargetState .Solid
213+ Material .Block -> TargetState .Block (material)
214+ else -> throw IllegalStateException (" Invalid material" )
215+ }
168216 }
169217}
0 commit comments