Skip to content

Commit e7c31a0

Browse files
committed
仍然是修复矿机的bug
1 parent daf018b commit e7c31a0

File tree

1 file changed

+33
-31
lines changed
  • src/main/java/github/kasuminova/novaeng/common/machine/drills

1 file changed

+33
-31
lines changed

src/main/java/github/kasuminova/novaeng/common/machine/drills/Drill.kt

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ abstract class Drill : MachineSpecial {
6868
var j = 0
6969
for (i in tqsz) {
7070
for (ii in tqsz) {
71-
tqdzb.put("" + (i + 1) + (ii + 1), ++j)
71+
tqdzb.put("${i + 1}${ii + 1}", ++j)
7272
}
7373
}
7474
basicMineralMix = Config.IEConfig.Machines.excavator_depletion
@@ -85,17 +85,15 @@ abstract class Drill : MachineSpecial {
8585
return posValue shr 4
8686
}
8787

88-
private fun getOreOutput(ctrl: TileMultiblockMachineController, pos: BlockPos, worldid: Int): IItemStack {
89-
return getOreOutput(ctrl, pos, worldid, 0, 0)
90-
}
91-
9288
private fun getOreOutput(
9389
ctrl: TileMultiblockMachineController,
9490
pos: BlockPos,
9591
worldid: Int,
96-
k: Int,
97-
kk: Int
92+
i: Int,
93+
ii: Int
9894
): IItemStack {
95+
val k: Int = i + 1
96+
val kk: Int = ii + 1
9997
val world = DimensionManager.getWorld(worldid) ?: return errorStone.mutable().copy()
10098
val data = ctrl.customDataTag
10199
val research_progress = data.getByte("research_progress")
@@ -105,26 +103,26 @@ abstract class Drill : MachineSpecial {
105103
.pow(1.6)), 0.0
106104
)
107105
val parallelSize =
108-
data.getInteger("parallelSize" + (k + 1) + (kk + 1)) * (1 + components_amount.toDouble().pow(2.5))
106+
data.getInteger("parallelSize$k$kk") * (1 + components_amount.toDouble().pow(2.5))
109107
val component_raw_ore = data.getByte("additional_component_raw_ore")
110108
var random = ctrl.getWorld().rand.nextInt(10000)
111109
val worldInfo = ExcavatorHandler.getMineralWorldInfo(
112110
world,
113-
(chunkCoord(pos.x) + k),
114-
(chunkCoord(pos.z) + kk)
111+
(chunkCoord(pos.x) + i),
112+
(chunkCoord(pos.z) + ii)
115113
)
116114
if (damage_probability < 10000) {
117115
if (damage_probability > random) {
118116
worldInfo.depletion += parallelSize.toInt()
119-
data.setInteger("depletion" + (k + 1) + (kk + 1), worldInfo.depletion)
117+
data.setInteger("depletion$k$kk", worldInfo.depletion)
120118
}
121119
} else {
122120
val sl = floor(1.0f * damage_probability) / 10000
123121
worldInfo.depletion += (parallelSize * sl).toInt()
124122
if ((damage_probability - (10000 * sl)) > random) {
125123
worldInfo.depletion += parallelSize.toInt()
126124
}
127-
data.setInteger("depletion" + (k + 1) + (kk + 1), worldInfo.depletion)
125+
data.setInteger("depletion$k$kk", worldInfo.depletion)
128126
}
129127
val mineral: MineralMix? = getUsableMix(worldInfo)
130128
if (mineral != null) {
@@ -140,7 +138,7 @@ abstract class Drill : MachineSpecial {
140138
}
141139
return OreHandler.getOre(iore)
142140
} else {
143-
data.setString("veinName" + (k + 1) + (kk + 1), "empty")
141+
data.setString("veinName$k$kk", "empty")
144142
return stone
145143
}
146144
}
@@ -241,22 +239,26 @@ abstract class Drill : MachineSpecial {
241239
return this
242240
}
243241

244-
private fun RecipePrimer.addOutputs(size: Byte): RecipePrimer {
245-
for (i in 0..<size) {
242+
private fun RecipePrimer.addOutputs(size: Int, i: Int, ii: Int): RecipePrimer {
243+
repeat(size) {
246244
this.addOutput(stone)
247-
.addItemModifier { ctrl, item ->
248-
if (this@Drill.isDimensional()) {
249-
val poss = ctrl.controller.customDataTag.getIntArray("pos")
250-
val pos = BlockPos(poss[0], poss[1], poss[2])
251-
return@addItemModifier getOreOutput(ctrl.controller, pos, poss[3])
252-
} else {
253-
return@addItemModifier getOreOutput(
254-
ctrl.controller,
255-
ctrl.controller.getPos(),
256-
ctrl.iWorld.dimension
257-
)
258-
}
245+
if (this@Drill.isDimensional()) {
246+
this.addItemModifier { ctrl, item ->
247+
val poss = ctrl.controller.customDataTag.getIntArray("pos")
248+
val pos = BlockPos(poss[0], poss[1], poss[2])
249+
return@addItemModifier getOreOutput(ctrl.controller, pos, poss[3], i, ii)
259250
}
251+
} else {
252+
this.addItemModifier { ctrl, item ->
253+
return@addItemModifier getOreOutput(
254+
ctrl.controller,
255+
ctrl.controller.getPos(),
256+
ctrl.iWorld.dimension,
257+
i,
258+
ii
259+
)
260+
}
261+
}
260262
}
261263
return this
262264
}
@@ -368,7 +370,7 @@ abstract class Drill : MachineSpecial {
368370
.addPreCheckHandler { checkMineralMix(it, 1, 1) }
369371
.addFactoryStartHandler { startWork(it, 0, 0, 8000) }
370372
.addExInput()
371-
.addOutputs(4)
373+
.addOutputs(4, 1, 1)
372374
.requireComputationPoint(1.5f)
373375
.addOutput(stone)
374376
.addItemModifier { ctrl, item ->
@@ -391,7 +393,7 @@ abstract class Drill : MachineSpecial {
391393
.addPreCheckHandler { checkMineralMix(it, 1, 1) }
392394
.addFactoryStartHandler { startWork(it, 0, 0, 9000) }
393395
.addExInput()
394-
.addOutputs(4)
396+
.addOutputs(4, 1, 1)
395397
.requireComputationPoint(1.5f)
396398
.addOutput(stone)
397399
.addItemModifier { ctrl, item ->
@@ -422,7 +424,7 @@ abstract class Drill : MachineSpecial {
422424
.addPreCheckHandler { checkMineralMix(it, k, kk) }
423425
.addFactoryStartHandler { startWork(it, i, ii, 8000) }
424426
.addInput(circuit_0).setChance(0f)
425-
.addOutputs(3)
427+
.addOutputs(3, i, ii)
426428
.requireComputationPoint(3f)
427429
.addOutput(stone)
428430
.addItemModifier { ctrl, item ->
@@ -447,7 +449,7 @@ abstract class Drill : MachineSpecial {
447449
}
448450
.addFactoryStartHandler { startWork(it, i, ii, 6000) }
449451
.addInput(dust).setChance(0.05f)
450-
.addOutputs(3)
452+
.addOutputs(3, i, ii)
451453
.requireComputationPoint(3f)
452454
.addOutput(stone)
453455
.addItemModifier { ctrl, item ->

0 commit comments

Comments
 (0)