mcsuggestions
Minecraft Suggestions TitaniumBrain 1 year ago 100%
Dispensers "use" any item, if possible

Introduction ---------- Throughout the years, I've seen many posts suggesting that "dispensers should use X item on Y mob/block" and some functionality *has* been added already, like using shears on sheep. However, what dispensers can and can't use is somewhat arbitrary: dispensers can shear sheep yet can't take water from a cauldron. To a new player, there's no way to know which items can be used by a dispenser except by trial and error. *New Player: "Oh, dispensers can wax copper blocks? Surely they can also unwax/deoxidise them if I put an axe in them, right?"* *Narrator: "They can't."* In my opinion, dispensers should be able to use any item with a right-click use. The Suggestion ---------- In order to make dispensers more intuitive and turn them into a general "item user" (as opposed to just a slightly more expensive dropper except in some cases), I came up with a simple algorithm for determining what a dispenser should do with an item. While some initial bugs are to be expected, this is more maintainable than the current code, which has the current uses hardcoded and must be expanded each time a new use is added, i.e. something that should be avoided when possible. Below is the **pseudocode** for an hypothetical function that gets called when a dispenser is activated and should use/dispense an item: ``` if item has use: # can be right-clicked if item is projectile: # more accurately, summons a projectile entity shoot projectile entity return if item targets user: # when the item is used on the player who uses it, like armour if has valid target: try using as entity # behaves like the entity used the item return if item targets an entity: # when an item is used by right-clicking an entity, like shears on sheep if has valid target: try using item on target return if item targets block: # when an item is used on a block, like a shovel on dirt try using on block in front return if item is placeable: # places a block or entity try placing in front else: drop item ``` *If you don't understand what anything of this means, I'm happy to clarify, just leave a comment.* The way this works is: pick an item, follow the structure of the code and stop when you reach a `return` or the end. For example, a pumpkin would be equipped on a mob (like a zombie) if one is on front, otherwise places the pumpkin. ### Some things to note ### * One of Mojang's concerns with this is straying from their design principle about not automating everything. However, we already have quite a bit of automation and some new uses for dispensers are already automatable via other means (like villagers). I believe this still adheres to that principle while allowing a reasonable level of automation. * I included placing blocks, since I don't think that would be a problem. Dispensers can already place water and lava, which can flow and create many blocks. This is especially true in Java Edition, where dispensers aren't movable by pistons. * There are many items with many different functions, so there may be some type of item I forgot to account for or something where the resulting behaviour may be undesired. As such, I'd like you to choose an item and follow the pseudocode and tell me if you find any situation that would be undesirable. --- *Tell me what cool things could be done if this was implemented.*

1
0