GlowstoneMC / Glowstone-Legacy

An open-source server for the Bukkit Minecraft modding interface
Other
363 stars 122 forks source link

Make bows shoot arrows, but.... #155

Closed dumptruckman closed 7 years ago

dumptruckman commented 10 years ago

Consider making it so they don't consume arrows with itemmeta somehow. I suppose sometimes you want them to be able to so maybe new, specific, itemmeta needs to be added for arrows.

hintss commented 10 years ago

Is the bow-draw animation client-side? If so, the infinity enchantment would replicate this...

nevercast commented 10 years ago

bow animation is client side and uses the eat logic, yes

SonarBeserk commented 10 years ago

Why not just let plugins detect the arrows with item data and deal with the arrows?

dumptruckman commented 10 years ago

Plugins are not what make bows consume arrows...

SonarBeserk commented 10 years ago

I am aware of that. I was meaning why allow plugins to have control over if arrows with itemdata are consumed. Why would they not be consumed?

dumptruckman commented 10 years ago

Maybe you want the arrow to be a special tool instead of ammunition, ex: voxelsniper arrow.

SonarBeserk commented 10 years ago

Which is why a plugin should handle that distinction really. Though im not sure the bukkit api supported that originally.

dumptruckman commented 10 years ago

There isn't a distinction a plugin can make. There will probably need to be arrow specific ItemMeta that has some kind of ammunition flag.

SpaceManiac commented 10 years ago

is the INFINITY enchantment insufficient?

daboross commented 10 years ago

If what you are asking for is a way for plugins to not have bows consume arrows of a specific type, why have ItemMeta logic built into the server instead of adding an event like ArrowConsumeEvent where plugins could do the checks themselves?

dumptruckman commented 10 years ago

Infinity enchantment isn't sufficient cause then it gives you infinite arrows when that could be not intended.

ArrowConsumeEvent would be awkward. Assuming you cancel it, it would not allow the bow to fire, even if there's a different stack of arrows that could be legitimate ammunition. If you're intended to specify which ItemStack to use, there's no way you could know what might be special about other stacks of arrows.

Basically, ItemMeta seems to be the other way to effectively do what I'm asking, which is to effectively make a stack of arrows not function at all like arrows.

turt2live commented 10 years ago

I would personally say that the type of control you are talking about is a special case, and should be handled by the plugin. There is nothing wrong with cancelling the shoot bow event and firing your own arrow afterwards.

dumptruckman commented 10 years ago

I am fine with it being "handled by the plugin" but there is currently no way to do this.

I will attempt to spell out the problems with having an event for this. Say the player has my special non-ammo arrow, a stack of regular arrows, a stack of arrows with some special properties given by another plugin, and finally a stack of special non-ammo arrows from another plugin. If I cancel the event, how do I know which arrow to consume for the arrow I shoot? How do I prevent from using some other plugin's non-ammo arrows? How does the user even select to use the special arrows vs the regular arrows (a problem that exists outside of this issue right?) When the other plugin goes to cancel the arrow shoot event, how do I tell them, "please don't use my plugin's special non-ammo arrow"?

turt2live commented 10 years ago

That's a trivial case. The plugin would store information about the player's selection (how that selection is made is up to the author) and when an arrow is fired, cancel the event, consume the arrow from the selection, and fire an arrow. There of course would be cases where the player may run out of that particular set of arrows, in which case the plugin has multiple options for handling.

In short, the plugin can do all of this. Maybe not right now on Glowstone due to unimplemented API, but the concept is still entirely possible.

Additionally: If there are multiple plugins competing for arrows, that's a problem for the server administrator to solve. They would either want to remove additional plugins or to contact plugin authors to get a solution that handles all of their cases. Again, a trivial problem.

dumptruckman commented 10 years ago

Are you suggesting the plugin that only wants to use the arrow as non-ammo implement a way for the player to select which arrow to fire?

turt2live commented 10 years ago

I'm suggesting that based upon your previous cases, a plugin can handle it with ease.

turt2live commented 10 years ago

Talked about this on IRC a bit.

I personally think that ItemMeta is not a correct solution as of right now because this feels more like an attribute (something that controls how the stack can (not) be used). There are several attributes that are not implemented by Glowstone or accessible in Glowkit, I think that when those become available, this should be looked at and added with them.

I also personally think that attributes should not just be thrown on the item meta classes, but instead have their own set for breaking out the different behaviours (an attribute is not a display property, to me). But that seems like something to be discussed when/if that API is added.

TL;DR: This should be looked at when existing missing attributes about items are missing.

mastercoms commented 7 years ago

We're a bit late on this issue, but a plugin can calculate which arrow will be used next and then check to see if that ammo should cause bow usage to be cancelled.