Skip to content

Commit

Permalink
Save__G extra sausage
Browse files Browse the repository at this point in the history
  • Loading branch information
Avanatiker committed Jan 7, 2022
1 parent d190e52 commit cab1814
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 23 deletions.
Binary file removed lib/lambda-2.12-dev-api.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion src/main/kotlin/HighwayTools.kt
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ object HighwayTools : PluginModule(
val searchEChest by setting("Search Ender Chest", false, { page == Page.STORAGE_MANAGEMENT && storageManagement }, description = "Allow access to your ender chest.")
val leaveEmptyShulkers by setting("Leave Empty Shulkers", true, { page == Page.STORAGE_MANAGEMENT && storageManagement }, description = "Does not break empty shulkers.")
val grindObsidian by setting("Grind Obsidian", true, { page == Page.STORAGE_MANAGEMENT && storageManagement }, description = "Destroy Ender Chests to obtain Obsidian.")
val preferEnderchests by setting("Prefer Enderchests", false, { page == Page.STORAGE_MANAGEMENT && storageManagement }, description = "Prevent using raw material shulkers.")
val manageFood by setting("Manage Food", true, { page == Page.STORAGE_MANAGEMENT && storageManagement }, description = "Choose to manage food.")
val saveMaterial by setting("Save Material", 12, 0..64, 1, { page == Page.STORAGE_MANAGEMENT && storageManagement }, description = "How many material blocks are saved")
val saveTools by setting("Save Tools", 1, 0..36, 1, { page == Page.STORAGE_MANAGEMENT && storageManagement }, description = "How many tools are saved")
val saveEnder by setting("Save Ender Chests", 1, 0..64, 1, { page == Page.STORAGE_MANAGEMENT && storageManagement }, description = "How many ender chests are saved")
val saveFood by setting("Save Food", 1, 0..64, 1, { page == Page.STORAGE_MANAGEMENT && manageFood && storageManagement}, description = "How many food items are saved")

val disableMode by setting("Disable Mode", DisableMode.NONE, { page == Page.STORAGE_MANAGEMENT }, description = "Choose action when bot is out of materials or tools")
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")
val proxyCommand by setting("Proxy Command", "/dc", { usingProxy && disableMode == DisableMode.LOGOUT && page == Page.STORAGE_MANAGEMENT }, description = "Command to be sent to log out")
Expand Down
51 changes: 30 additions & 21 deletions src/main/kotlin/trombone/handler/Container.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package trombone.handler

import HighwayTools.maxReach
import HighwayTools.preferEnderchests
import HighwayTools.saveEnder
import HighwayTools.searchEChest
import com.lambda.client.event.SafeClientEvent
Expand Down Expand Up @@ -38,6 +39,10 @@ object Container {
var grindCycles = 0

fun SafeClientEvent.handleRestock(item: Item) {
if (preferEnderchests && item.block == Blocks.OBSIDIAN) {
handleEnderChest(item)
return
}
getShulkerWith(player.inventorySlots, item)?.let { slot ->
getRemotePos()?.let { pos ->
containerTask = BlockTask(pos, TaskState.PLACE, slot.stack.item.block, item)
Expand All @@ -46,33 +51,37 @@ object Container {
disableError("Can't find possible container position (Case: 1)")
}
} ?: run {
if (searchEChest) {
if (item.block == Blocks.OBSIDIAN) {
if (player.inventorySlots.countBlock(Blocks.ENDER_CHEST) <= saveEnder) {
getShulkerWith(player.inventorySlots, Blocks.ENDER_CHEST.item)?.let { slot ->
getRemotePos()?.let { pos ->
containerTask = BlockTask(pos, TaskState.PLACE, slot.stack.item.block, Blocks.ENDER_CHEST.item)
containerTask.isShulker = true
} ?: run {
disableError("Can't find possible container position (Case: 2)")
}
} ?: run {
dispatchEnderChest(Blocks.ENDER_CHEST.item)
}
} else {
handleEnderChest(item)
}
}

private fun SafeClientEvent.handleEnderChest(item: Item) {
if (searchEChest) {
if (item.block == Blocks.OBSIDIAN) {
if (player.inventorySlots.countBlock(Blocks.ENDER_CHEST) <= saveEnder) {
getShulkerWith(player.inventorySlots, Blocks.ENDER_CHEST.item)?.let { slot ->
getRemotePos()?.let { pos ->
containerTask = BlockTask(pos, TaskState.PLACE, Blocks.ENDER_CHEST, Blocks.OBSIDIAN.item)
containerTask.destroy = true
if (grindCycles > 1) containerTask.collect = false
containerTask.itemID = Blocks.OBSIDIAN.id
grindCycles--
containerTask = BlockTask(pos, TaskState.PLACE, slot.stack.item.block, Blocks.ENDER_CHEST.item)
containerTask.isShulker = true
} ?: run {
disableError("Can't find possible container position (Case: 3)")
disableError("Can't find possible container position (Case: 2)")
}
} ?: run {
dispatchEnderChest(Blocks.ENDER_CHEST.item)
}
} else {
dispatchEnderChest(item)
getRemotePos()?.let { pos ->
containerTask = BlockTask(pos, TaskState.PLACE, Blocks.ENDER_CHEST, Blocks.OBSIDIAN.item)
containerTask.destroy = true
if (grindCycles > 1) containerTask.collect = false
containerTask.itemID = Blocks.OBSIDIAN.id
grindCycles--
} ?: run {
disableError("Can't find possible container position (Case: 3)")
}
}
} else {
dispatchEnderChest(item)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/trombone/handler/Tasks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ object Tasks {
stack.item == material.item -> 64 - stack.count
else -> 0
}
}
} - 64 // To keep one slot free to collect the shulker

container.getSlots(0..26)
.filterByItem(containerTask.item)
Expand Down

0 comments on commit cab1814

Please sign in to comment.