Baritone AI pathfinder

Baritone AI pathfinder

72.7k Downloads

Command "#set add" to add an item to a list in settings

NatoBoram opened this issue ยท 10 comments

commented

Describe your suggestion

With as much detail as possible, describe what your suggestion would do for Baritone.

New commands : #set add, #set remove, #set clear.

Those commands would serve to add or remove items in a list in the settings.

Examples

#set remove acceptableThrowawayItems stone
#set add acceptableThrowawayItems andesite,diorite,granite

Settings

If applicable, what settings/customizability should be offered to tweak the functionality of your suggestion.

Context

Describe how your suggestion would improve Baritone, or the reason behind it being added.

In USAGE.md, acceptableThrowawayItems is listed as a setting that's "fun / interesting / important that you might want to look at changing in normal usage of Baritone".

However, during "normal usage of Baritone", using #acceptableThrowawayItems dirt,cobblestone,netherrack is a bit clunky if you want to add or modify your list.

Even in abnormal usage while editing settings.txt, it looks like this :

acceptableThrowawayItems Optional[ResourceKey[minecraft:item / minecraft:dirt]],Optional[ResourceKey[minecraft:item / minecraft:cobblestone]],Optional[ResourceKey[minecraft:item / minecraft:netherrack]]
Off-topic I'd suggest using JSON or YAML to store settings. No, seriously, I mean it. It's so much easier for both developers and users to work with an established standard rather than trying to parse programmatically or mentally a format that no one else ever uses.

The problem is that there's no way to add/modify a list, only to override it. And copying old values has to be done manually, which is tedious if there's many, many items in that list. I think a command to add/remove items from a list in the settings would be very appropriate. This way, during normal usage of Baritone, one could add/remove an item from the list without having to copy everything.

Final checklist

  • I know how to properly use check boxes
  • I have not used any OwO's or UwU's in this issue.
commented

Most likely they need more time and contributors.

Existing contributors probably have other priorities, like 1.17 and Fabric. I'm much more interested in those than this issue tbh.

If I was decent at Java, I probably would've submitted a PR by now, but unfortunately I'm very bad at it.

commented

Why isn't this implemented so far? Would be rather useful, also for blocks to avoid breaking.

commented

Reason is that lists and maps annoyingly don't share any useful baseclass, leading to either messy or duplicated code and that the setting parsers are not accessible from the api and I haven't thought of a good way to expose them.

commented

public final Setting<List<Block>> blocksToAvoidBreaking = new Setting<>(new ArrayList<>(Arrays.asList( // TODO can this be a HashSet or ImmutableSet?

I think I'll go for immutable and then actually turn this into an ImmutableSet in a seperate pr.

commented

they're done similarly to copy on write so immutable, but that doesn't mean this isn't still doable... see https://github.com/cabaletta/baritone/blob/master/src/api/java/baritone/api/utils/SettingsUtil.java#L71

commented

Are potentially mutable setting values thought to be mutable or immutable?

commented

I know how they are dealt with and so far there is nothing that alters setting values so I wasn't sure whether to use setting.value.add(newVal) or setting.value = valueWithNewValAdded.
Immutable seems to be more likely because if you mutate the values you need to copy the defaults to prevent side effects on them, which is currently not done.

commented

i think to keep things threadsafe it would be best to treat them as immutable

commented

maybe you should add sel clear <setting> to this

commented

I think this would be a good addition