ToolSwitch not switching to sword when attacking
mkb2091 opened this issue ยท 9 comments
This means after manually switching to sword, if I accidentally hit a block instead of the enemy it switches to that tool instead of the sword, so when I manage to hit the enemy/mob they are hit with like a pickaxe or a shovel
I'll also look into implementing a switch to attack weapon, where you can set your preferred attack weapon (Axe/hoe/shovel).
@maruohon should this be a seperate tweak? e.g. autoSwitchToWeapon
?
Should what entities trigger the switch be configurable (e.g. to exclude your dog/cat you don't want to kill accidentally)?
This is kind of why I don't like adding super complex and configuration heavy features in this mod. Because either you end up with non-user-friendly janky special string configs, or you have to add a bunch of code to make multiple nice configuration screens just for a seemingly small individual feature, in a mod with literally over a hundred different features already, and which is still going to probably double.
So I'd say either it would be a config option for tool switch for whether or not to switch to weapons, or just a simple separate tweak for weapon switch, which selects the highest damage item for a given entity.
So I'd say either it would be a config option for tool switch for whether or not to switch to weapons, or just a simple separate tweak for weapon switch, which selects the highest damage item for a given entity.
Original Plan
- [ ] A string for the preferred weapons, e.g. `[minecraft:netherite_sword, minecraft:diamond_sword...,minecraft:wooden_pickaxe]`. (because the axes have higher damage than the swords, but I would expect most to want to use swords). This could also be hard-coded, but that would mean you could not use this with a mod adding a new sword. - [ ] A list of entity IDs to ignore. Default perhaps `[item_frame, armour_stand, minecarts, boat]`. - [ ] A toggle to enable disable the tweak.Another way would be, I would prefer this as it would give me the possibility to fully configure this to my liking:
- a mapping entity_list โ weapon_list. But that would require either a new config screen or a list of unwieldy strings, e.g.:
[
<default> => minecraft:netherite_sword, ...
,
minecraft:item_frame => <ignored>
,
minecraft:boat, minecraft:mine_cart, ... => minecraft:netherite_axe, ...
]
<default>
โ rule is active if no other rule is defined
<ignored>
โ no weapon switching will happen - A toggle to enable disable the tweak.
For now, I would just use the order in the list to select the best weapon, idk where I would get the damage of the item+entity combination from. We probably would need to calculate that from the enchantment list manually?
The attack damage of an Item can be queried (if it is either a SwordItem
or a MiningToolItem
. Maybe it would also be possible to just test for the existence of a getAttackDamage() -> float
function.
I could implement a StringMapping
type in malilib that would contain a list of string pairs. And has a UI like this:
| ... | | ... | RESET + -
| ... | | ... | RESET + -
...
But if this would only be needed for this tweak probably overkill, and using the strings above would be easier.
Just wanted to write the same comment, so instead my suggestion: If its easier I would be happy if swords are taken out of tool switch, I would prefer having the sword in slot 1 and the other tools in slot 2 and switch manually. Maybe a list for toolswitch which tool should be affected by it or not in the list category.
I would like to implement either a list of items to not switch away from or a list of slots to not switch away from. I just downloaded the source and will have a look.
+1 for this. I think most blocks have a 'preferred tool' or no tool at all. Also, some blocks require silk touch (glass, ice), while others just benefit from it (melons). That leaves just a few edge cases, like do you want to use shears or a hoe for leaves? Those choices seems manageable for configuration. As for weapons, how about sword as default and override with an axe? Would also be great if: "if the target is undead, use smite, else default to sharp".
Also, all these tool/weapon combos require a lot of space. Would it be possible to swap the item being used from inventory rather than requiring it to be present in the hotbar?
@end-user It's already supposed to pick the item from anywhere in the inventory? Although I have no idea how it currently behaves with selecting the hotbar slot to use... this has been tweaked/changed several times, and it's still probably in need of more improvements to the logic of when and what to select from where and where to place it for use.
Just wanted to write the same comment, so instead my suggestion: If its easier I would be happy if swords are taken out of tool switch, I would prefer having the sword in slot 1 and the other tools in slot 2 and switch manually. Maybe a list for toolswitch which tool should be affected by it or not in the list category.