Skip to content

Commit 6ed9d9f

Browse files
authored
Merge pull request #11 from czho/master
Food management
2 parents fb6ce68 + 213625a commit 6ed9d9f

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

src/main/kotlin/HighwayTools.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import com.lambda.client.util.threads.safeListener
1212
import com.lambda.event.listener.listener
1313
import net.minecraft.block.Block
1414
import net.minecraft.init.Blocks
15+
import net.minecraft.init.Items
16+
import net.minecraft.item.Item
1517
import net.minecraftforge.fml.common.gameevent.TickEvent
1618
import trombone.IO.DebugMessages
1719
import trombone.IO.DisableMode
@@ -68,6 +70,7 @@ object HighwayTools : PluginModule(
6870
val railingHeight by setting("Railing Height", 1, 1..4, 1, { railing && page == Page.BUILD && mode == Mode.HIGHWAY }, description = "Sets height of railing")
6971
private val materialSaved = setting("Material", "minecraft:obsidian", { false })
7072
private val fillerMatSaved = setting("FillerMat", "minecraft:netherrack", { false })
73+
private val foodItem = setting("Food Item", "minecraft:golden_apple", { false })
7174
val ignoreBlocks = setting(CollectionSetting("IgnoreList", defaultIgnoreBlocks, { false }))
7275

7376
// behavior settings
@@ -93,9 +96,12 @@ object HighwayTools : PluginModule(
9396
val storageManagement by setting("Manage Storage", true, { page == Page.STORAGE_MANAGEMENT }, description = "Choose to interact with container using only packets.")
9497
val leaveEmptyShulkers by setting("Leave Empty Shulkers", true, { page == Page.STORAGE_MANAGEMENT && storageManagement }, description = "Does not break empty shulkers.")
9598
val grindObsidian by setting("Grind Obsidian", true, { page == Page.STORAGE_MANAGEMENT }, description = "Destroy Ender Chests to obtain Obsidian.")
99+
val manageFood by setting("Manage Food", true, { page == Page.STORAGE_MANAGEMENT }, description = "Choose to manage food.")
96100
val saveMaterial by setting("Save Material", 12, 0..64, 1, { page == Page.STORAGE_MANAGEMENT }, description = "How many material blocks are saved")
97101
val saveTools by setting("Save Tools", 1, 0..36, 1, { page == Page.STORAGE_MANAGEMENT }, description = "How many tools are saved")
98102
val saveEnder by setting("Save Ender Chests", 1, 0..64, 1, { page == Page.STORAGE_MANAGEMENT }, description = "How many ender chests are saved")
103+
val saveFood by setting("Save Food", 1, 0..64, 1, { page == Page.STORAGE_MANAGEMENT && manageFood}, description = "How many food items are saved")
104+
99105
val disableMode by setting("Disable Mode", DisableMode.NONE, { page == Page.STORAGE_MANAGEMENT }, description = "Choose action when bot is out of materials or tools")
100106
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")
101107
val proxyCommand by setting("Proxy Command", "/dc", { usingProxy && disableMode == DisableMode.LOGOUT && page == Page.STORAGE_MANAGEMENT }, description = "Command to be sent to log out")
@@ -133,6 +139,12 @@ object HighwayTools : PluginModule(
133139
set(value) {
134140
fillerMatSaved.value = value.registryName.toString()
135141
}
142+
var food: Item
143+
get() = Item.getByNameOrId(foodItem.value) ?: Items.GOLDEN_APPLE
144+
set(value) {
145+
foodItem.value = value.registryName.toString()
146+
}
147+
136148

137149
override fun isActive(): Boolean {
138150
return isEnabled && active

src/main/kotlin/HighwayToolsCommand.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ object HighwayToolsCommand : ClientCommand(
8888
}
8989
}
9090

91+
literal("food", "fd") {
92+
item("item") { itemArg ->
93+
execute("Set a block as filler material") {
94+
HighwayTools.food = itemArg.value
95+
sendChatMessage("Set your food item to &7${itemArg.value.registryName}&r.")
96+
}
97+
}
98+
}
99+
91100
execute("Print the settings") {
92101
printSettings()
93102
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ import HighwayTools.debugMessages
66
import HighwayTools.dynamicDelay
77
import HighwayTools.fakeSounds
88
import HighwayTools.fillerMat
9+
import HighwayTools.food
910
import HighwayTools.ignoreBlocks
1011
import HighwayTools.material
1112
import HighwayTools.maxReach
1213
import HighwayTools.mode
1314
import HighwayTools.multiBuilding
1415
import HighwayTools.saveTools
16+
import HighwayTools.saveFood
17+
import HighwayTools.manageFood
1518
import com.lambda.client.event.SafeClientEvent
1619
import com.lambda.client.module.modules.player.InventoryManager
1720
import com.lambda.client.util.items.*
@@ -193,11 +196,19 @@ object Tasks {
193196
}
194197
}
195198
tasks.values.all { it.taskState == TaskState.DONE } -> {
199+
if (manageFood && player.inventorySlots.countItem(food) < saveFood) {
200+
handleRestock(food)
201+
}
202+
196203
updateTasks()
197204
}
198205
else -> {
199206
waitTicks--
200207

208+
if (manageFood && player.inventorySlots.countItem(food) < saveFood) {
209+
handleRestock(food)
210+
}
211+
201212
tasks.values.toList().forEach {
202213
doTask(it, true)
203214
}

0 commit comments

Comments
 (0)