@@ -7,6 +7,7 @@ import me.zeroeightsix.kami.process.AutoObsidianProcess
7
7
import me.zeroeightsix.kami.setting.Settings
8
8
import me.zeroeightsix.kami.util.BaritoneUtils
9
9
import me.zeroeightsix.kami.util.BlockUtils.isPlaceableForChest
10
+ import me.zeroeightsix.kami.util.EntityUtils
10
11
import me.zeroeightsix.kami.util.EntityUtils.getDroppedItem
11
12
import me.zeroeightsix.kami.util.InventoryUtils
12
13
import me.zeroeightsix.kami.util.math.RotationUtils.getRotationTo
@@ -58,8 +59,6 @@ object AutoObsidian : Module() {
58
59
private var playerPos = BlockPos (0 , - 1 , 0 )
59
60
private var placingPos = BlockPos (0 , - 1 , 0 )
60
61
private var shulkerBoxId = 0
61
- private var enderChestCount = - 1
62
- private var obsidianCount = - 1
63
62
private var tickCount = 0
64
63
private var openTime = 0L
65
64
@@ -154,12 +153,6 @@ object AutoObsidian : Module() {
154
153
}
155
154
}
156
155
157
- /* Updates ender chest and obsidian counts before placing and mining ender chest */
158
- if (state == State .SEARCHING ) {
159
- enderChestCount = InventoryUtils .countItem(0 , 35 , 130 )
160
- obsidianCount = countObsidian()
161
- }
162
-
163
156
/* Updates main state */
164
157
updateMainState()
165
158
@@ -172,16 +165,16 @@ object AutoObsidian : Module() {
172
165
}
173
166
174
167
private fun updateMainState () {
175
- val placedEnderChest = enderChestCount - InventoryUtils .countItem( 0 , 35 , 130 )
176
- val targetEnderChest = (targetStacks.value * 64 - obsidianCount) / 8
168
+ val obbyCount = countObby( )
169
+
177
170
state = when {
178
- state == State .DONE && autoRefill.value && InventoryUtils .countItem( 0 , 35 , 49 ) <= threshold.value -> {
171
+ state == State .DONE && autoRefill.value && InventoryUtils .countItemAll( 49 ) <= threshold.value -> {
179
172
State .SEARCHING
180
173
}
181
- state == State .COLLECTING && getDroppedItem(49 , 16 .0f ) == null -> {
174
+ state == State .COLLECTING && getDroppedItem(49 , 8 .0f ) == null -> {
182
175
State .DONE
183
176
}
184
- state != State .DONE && mc.world.isAirBlock(placingPos) && placedEnderChest >= targetEnderChest -> {
177
+ state != State .DONE && mc.world.isAirBlock(placingPos) && obbyCount >= targetStacks.value -> {
185
178
State .COLLECTING
186
179
}
187
180
state == State .MINING && mc.world.isAirBlock(placingPos) -> {
@@ -190,7 +183,7 @@ object AutoObsidian : Module() {
190
183
state == State .PLACING && ! mc.world.isAirBlock(placingPos) -> {
191
184
State .PRE_MINING
192
185
}
193
- state == State .SEARCHING && searchingState == SearchingState .DONE && placedEnderChest < targetEnderChest -> {
186
+ state == State .SEARCHING && searchingState == SearchingState .DONE && obbyCount < targetStacks.value -> {
194
187
State .PLACING
195
188
}
196
189
else -> state
@@ -199,20 +192,20 @@ object AutoObsidian : Module() {
199
192
200
193
private fun updateSearchingState () {
201
194
searchingState = when {
202
- searchingState == SearchingState .PLACING && InventoryUtils .countItem( 0 , 35 , 130 ) > 0 -> {
195
+ searchingState == SearchingState .PLACING && InventoryUtils .countItemAll( 130 ) > 0 -> {
203
196
SearchingState .DONE
204
197
}
205
- searchingState == SearchingState .COLLECTING && getDroppedItem(shulkerBoxId, 16 .0f ) == null -> {
198
+ searchingState == SearchingState .COLLECTING && getDroppedItem(shulkerBoxId, 8 .0f ) == null -> {
206
199
SearchingState .DONE
207
200
}
208
201
searchingState == SearchingState .MINING && mc.world.isAirBlock(placingPos) -> {
209
- if (InventoryUtils .countItem( 0 , 35 , 130 ) > 0 ) {
202
+ if (InventoryUtils .countItemAll( 130 ) > 0 ) {
210
203
SearchingState .COLLECTING
211
204
} else { /* In case if the shulker wasn't placed due to server lag */
212
205
SearchingState .PLACING
213
206
}
214
207
}
215
- searchingState == SearchingState .OPENING && (InventoryUtils .countItem( 0 , 35 , 130 ) >= 64 || InventoryUtils .getSlots(0 , 35 , 0 ) == null ) -> {
208
+ searchingState == SearchingState .OPENING && (InventoryUtils .countItemAll( 130 ) >= 64 || InventoryUtils .getSlots(0 , 35 , 0 ) == null ) -> {
216
209
SearchingState .PRE_MINING
217
210
}
218
211
searchingState == SearchingState .PLACING && ! mc.world.isAirBlock(placingPos) -> {
@@ -226,21 +219,23 @@ object AutoObsidian : Module() {
226
219
}
227
220
}
228
221
222
+ private fun countObby (): Int {
223
+ val inventory = InventoryUtils .countItemAll(49 )
224
+ val dropped = EntityUtils .getDroppedItems(49 , 8.0f ).sumBy { it.item.count }
225
+ return ceil((inventory + dropped) / 8.0f ).toInt() / 8
226
+ }
227
+
229
228
private fun setPlacingPos () {
230
229
if (getPlacingPos().y != - 1 ) {
231
230
placingPos = getPlacingPos()
232
231
} else {
233
232
sendChatMessage(" $chatName No valid position for placing shulker box / ender chest nearby, disabling." )
234
- mc.getSoundHandler() .playSound(PositionedSoundRecord .getRecord(SoundEvents .ENTITY_EXPERIENCE_ORB_PICKUP , 1.0f , 1.0f ))
233
+ mc.soundHandler .playSound(PositionedSoundRecord .getRecord(SoundEvents .ENTITY_EXPERIENCE_ORB_PICKUP , 1.0f , 1.0f ))
235
234
this .disable()
236
235
return
237
236
}
238
237
}
239
238
240
- private fun countObsidian (): Int {
241
- return ceil(InventoryUtils .countItem(0 , 35 , 49 ).toDouble() / 8.0 ).toInt() * 8
242
- }
243
-
244
239
private fun getPlacingPos (): BlockPos {
245
240
val pos = playerPos
246
241
var facing = EnumFacing .NORTH
@@ -271,7 +266,7 @@ object AutoObsidian : Module() {
271
266
if (InventoryUtils .getSlotsHotbar(i) == null ) {
272
267
if (i != 234 ) continue else {
273
268
sendChatMessage(" $chatName No shulker box was found in hotbar, disabling." )
274
- mc.getSoundHandler() .playSound(PositionedSoundRecord .getRecord(SoundEvents .ENTITY_EXPERIENCE_ORB_PICKUP , 1.0f , 1.0f ))
269
+ mc.soundHandler .playSound(PositionedSoundRecord .getRecord(SoundEvents .ENTITY_EXPERIENCE_ORB_PICKUP , 1.0f , 1.0f ))
275
270
this .disable()
276
271
return
277
272
}
@@ -299,7 +294,7 @@ object AutoObsidian : Module() {
299
294
state = State .SEARCHING
300
295
} else {
301
296
sendChatMessage(" $chatName No ender chest was found in inventory, disabling." )
302
- mc.getSoundHandler() .playSound(PositionedSoundRecord .getRecord(SoundEvents .ENTITY_EXPERIENCE_ORB_PICKUP , 1.0f , 1.0f ))
297
+ mc.soundHandler .playSound(PositionedSoundRecord .getRecord(SoundEvents .ENTITY_EXPERIENCE_ORB_PICKUP , 1.0f , 1.0f ))
303
298
this .disable()
304
299
return
305
300
}
@@ -328,15 +323,15 @@ object AutoObsidian : Module() {
328
323
val currentContainer = mc.player.openContainer
329
324
var enderChestSlot = - 1
330
325
for (i in 0 .. 26 ) {
331
- if (getIdFromItem(currentContainer.inventory[i].getItem() ) == 130 ) {
326
+ if (getIdFromItem(currentContainer.inventory[i].item ) == 130 ) {
332
327
enderChestSlot = i
333
328
}
334
329
}
335
330
if (enderChestSlot != - 1 ) {
336
331
mc.playerController.windowClick(currentContainer.windowId, enderChestSlot, 0 , ClickType .QUICK_MOVE , mc.player)
337
332
} else {
338
333
sendChatMessage(" $chatName No ender chest was found in shulker, disabling." )
339
- mc.getSoundHandler() .playSound(PositionedSoundRecord .getRecord(SoundEvents .ENTITY_EXPERIENCE_ORB_PICKUP , 1.0f , 1.0f ))
334
+ mc.soundHandler .playSound(PositionedSoundRecord .getRecord(SoundEvents .ENTITY_EXPERIENCE_ORB_PICKUP , 1.0f , 1.0f ))
340
335
this .disable()
341
336
}
342
337
}, delayTicks.value * 50L , TimeUnit .MILLISECONDS )
@@ -349,7 +344,7 @@ object AutoObsidian : Module() {
349
344
return
350
345
} else if (InventoryUtils .getSlots(0 , 35 , 278 ) == null ) {
351
346
sendChatMessage(" $chatName No pickaxe was found in inventory, disabling." )
352
- mc.getSoundHandler() .playSound(PositionedSoundRecord .getRecord(SoundEvents .ENTITY_EXPERIENCE_ORB_PICKUP , 1.0f , 1.0f ))
347
+ mc.soundHandler .playSound(PositionedSoundRecord .getRecord(SoundEvents .ENTITY_EXPERIENCE_ORB_PICKUP , 1.0f , 1.0f ))
353
348
this .disable()
354
349
return
355
350
}
@@ -379,8 +374,6 @@ object AutoObsidian : Module() {
379
374
searchingState = SearchingState .PLACING
380
375
playerPos = BlockPos (0 , - 1 , 0 )
381
376
placingPos = BlockPos (0 , - 1 , 0 )
382
- enderChestCount = - 1
383
- obsidianCount = - 1
384
377
tickCount = 0
385
378
}
386
379
/* End of tasks */
0 commit comments