Skip to content

Commit cab1814

Browse files
committed
Save__G extra sausage
1 parent d190e52 commit cab1814

File tree

4 files changed

+32
-23
lines changed

4 files changed

+32
-23
lines changed

lib/lambda-2.12-dev-api.jar

-3.36 MB
Binary file not shown.

src/main/kotlin/HighwayTools.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ object HighwayTools : PluginModule(
9898
val searchEChest by setting("Search Ender Chest", false, { page == Page.STORAGE_MANAGEMENT && storageManagement }, description = "Allow access to your ender chest.")
9999
val leaveEmptyShulkers by setting("Leave Empty Shulkers", true, { page == Page.STORAGE_MANAGEMENT && storageManagement }, description = "Does not break empty shulkers.")
100100
val grindObsidian by setting("Grind Obsidian", true, { page == Page.STORAGE_MANAGEMENT && storageManagement }, description = "Destroy Ender Chests to obtain Obsidian.")
101+
val preferEnderchests by setting("Prefer Enderchests", false, { page == Page.STORAGE_MANAGEMENT && storageManagement }, description = "Prevent using raw material shulkers.")
101102
val manageFood by setting("Manage Food", true, { page == Page.STORAGE_MANAGEMENT && storageManagement }, description = "Choose to manage food.")
102103
val saveMaterial by setting("Save Material", 12, 0..64, 1, { page == Page.STORAGE_MANAGEMENT && storageManagement }, description = "How many material blocks are saved")
103104
val saveTools by setting("Save Tools", 1, 0..36, 1, { page == Page.STORAGE_MANAGEMENT && storageManagement }, description = "How many tools are saved")
104105
val saveEnder by setting("Save Ender Chests", 1, 0..64, 1, { page == Page.STORAGE_MANAGEMENT && storageManagement }, description = "How many ender chests are saved")
105106
val saveFood by setting("Save Food", 1, 0..64, 1, { page == Page.STORAGE_MANAGEMENT && manageFood && storageManagement}, description = "How many food items are saved")
106-
107107
val disableMode by setting("Disable Mode", DisableMode.NONE, { page == Page.STORAGE_MANAGEMENT }, description = "Choose action when bot is out of materials or tools")
108108
val usingProxy by setting("Proxy", false, { disableMode == DisableMode.LOGOUT && page == Page.STORAGE_MANAGEMENT }, description = "Enable this if you are using a proxy to call the given command")
109109
val proxyCommand by setting("Proxy Command", "/dc", { usingProxy && disableMode == DisableMode.LOGOUT && page == Page.STORAGE_MANAGEMENT }, description = "Command to be sent to log out")

src/main/kotlin/trombone/handler/Container.kt

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package trombone.handler
22

33
import HighwayTools.maxReach
4+
import HighwayTools.preferEnderchests
45
import HighwayTools.saveEnder
56
import HighwayTools.searchEChest
67
import com.lambda.client.event.SafeClientEvent
@@ -38,6 +39,10 @@ object Container {
3839
var grindCycles = 0
3940

4041
fun SafeClientEvent.handleRestock(item: Item) {
42+
if (preferEnderchests && item.block == Blocks.OBSIDIAN) {
43+
handleEnderChest(item)
44+
return
45+
}
4146
getShulkerWith(player.inventorySlots, item)?.let { slot ->
4247
getRemotePos()?.let { pos ->
4348
containerTask = BlockTask(pos, TaskState.PLACE, slot.stack.item.block, item)
@@ -46,33 +51,37 @@ object Container {
4651
disableError("Can't find possible container position (Case: 1)")
4752
}
4853
} ?: run {
49-
if (searchEChest) {
50-
if (item.block == Blocks.OBSIDIAN) {
51-
if (player.inventorySlots.countBlock(Blocks.ENDER_CHEST) <= saveEnder) {
52-
getShulkerWith(player.inventorySlots, Blocks.ENDER_CHEST.item)?.let { slot ->
53-
getRemotePos()?.let { pos ->
54-
containerTask = BlockTask(pos, TaskState.PLACE, slot.stack.item.block, Blocks.ENDER_CHEST.item)
55-
containerTask.isShulker = true
56-
} ?: run {
57-
disableError("Can't find possible container position (Case: 2)")
58-
}
59-
} ?: run {
60-
dispatchEnderChest(Blocks.ENDER_CHEST.item)
61-
}
62-
} else {
54+
handleEnderChest(item)
55+
}
56+
}
57+
58+
private fun SafeClientEvent.handleEnderChest(item: Item) {
59+
if (searchEChest) {
60+
if (item.block == Blocks.OBSIDIAN) {
61+
if (player.inventorySlots.countBlock(Blocks.ENDER_CHEST) <= saveEnder) {
62+
getShulkerWith(player.inventorySlots, Blocks.ENDER_CHEST.item)?.let { slot ->
6363
getRemotePos()?.let { pos ->
64-
containerTask = BlockTask(pos, TaskState.PLACE, Blocks.ENDER_CHEST, Blocks.OBSIDIAN.item)
65-
containerTask.destroy = true
66-
if (grindCycles > 1) containerTask.collect = false
67-
containerTask.itemID = Blocks.OBSIDIAN.id
68-
grindCycles--
64+
containerTask = BlockTask(pos, TaskState.PLACE, slot.stack.item.block, Blocks.ENDER_CHEST.item)
65+
containerTask.isShulker = true
6966
} ?: run {
70-
disableError("Can't find possible container position (Case: 3)")
67+
disableError("Can't find possible container position (Case: 2)")
7168
}
69+
} ?: run {
70+
dispatchEnderChest(Blocks.ENDER_CHEST.item)
7271
}
7372
} else {
74-
dispatchEnderChest(item)
73+
getRemotePos()?.let { pos ->
74+
containerTask = BlockTask(pos, TaskState.PLACE, Blocks.ENDER_CHEST, Blocks.OBSIDIAN.item)
75+
containerTask.destroy = true
76+
if (grindCycles > 1) containerTask.collect = false
77+
containerTask.itemID = Blocks.OBSIDIAN.id
78+
grindCycles--
79+
} ?: run {
80+
disableError("Can't find possible container position (Case: 3)")
81+
}
7582
}
83+
} else {
84+
dispatchEnderChest(item)
7685
}
7786
}
7887
}

src/main/kotlin/trombone/handler/Tasks.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ object Tasks {
437437
stack.item == material.item -> 64 - stack.count
438438
else -> 0
439439
}
440-
}
440+
} - 64 // To keep one slot free to collect the shulker
441441

442442
container.getSlots(0..26)
443443
.filterByItem(containerTask.item)

0 commit comments

Comments
 (0)