Enchanting a stick, is it possible?

Discussion in 'Plugin Development' started by hpdvs2, Apr 5, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    hpdvs2

    What better way to have a "wand", than an enchanted stick. I know in the game itself, a stick is not enchantable, but is it enchantable by a plugin, will the client respect it, and how would I enchant a stick in the code?

    Thanks for any insight.
     
  2. Offline

    CorrieKay

    im not sure actually. Never thought about enchanting a stick.

    but considering all combat logic is handled within the server itsself, the client doesnt have to respect it. i would expect at most, that the client wouldnt see that its oddly colored, and it wouldnt be able to see which enchantment is on it. but i would bet that minecraft is modular enough to actually let the player see those things

    im gonna go check it out :D
     
  3. Offline

    Soxra

    Is not possible ;) Maybe with Spout.
     
  4. Offline

    CorrieKay

    This is correct, unfortunately..

    Code:
    Caused by: java.lang.IllegalArgumentException: Specified enchantment cannot be applied to this itemstack
    at org.bukkit.inventory.ItemStack.addEnchantment(ItemStack.java:301)
    at me.Corrie.TestPlugin.TestPlugin.onJoin(TestPlugin.java:27)
    :(
     
  5. Try the unsafe method (I think it's addUnsafeEnchantment), it directly adds the enchantment to the item without checking if it's possible.
     
  6. Offline

    CorrieKay

    ... Wow, that works. Ive got a stick with knockback :confused:

    but it doesnt tell you what enchantments it has on it :p just fyi.
     
  7. Well... if you can stack it with other sticks then it's enchantment is not there at all.

    Try a non-stackable item, maybe only stackable items can't be enchanted, I'm just curious :p
     
  8. Offline

    CorrieKay

    aye, i assume as soon as you modify the item stack, or drop it, the enchantment drops.
     
  9. Offline

    Taco

    You should be able to enchant a stick. It won't be able to be put in a stack with other sticks, but it should work. You need to use the Unsafe enchant method for this to work, of course. You also will not be able to see the enchant on the stick itself. You can play around with knockback on random items if you don't feel like doing this yourself by downloading godPowers. My /FusRoDah command has been able to do this for a while now.
     
  10. Offline

    Father Of Time

    The issue that keep rising in this discussion (stacking) is what caused me to stop this pursuit awhile ago, only I was trying to make "sparklers" with sticks using potion effects.

    I got everything working just fine, but the issue that kept coming up was that the sparklers kept turning back into normal sticks when ever they were mixed with other sticks (which happened a lot due to the crafting box automatically stacking them with normal sticks on craft).

    Because of the previously mentioned issue I simply scrapped the project. Now I am not saying this isn't fixable, it likely is; but this project had no importance to my server and was simply a "proof of concept" I was working on, so I quickly abandoned the project...

    I have no point, just sharing my experience with the item stack issue, it's a pain when attempting to re-purpose vanilla items. :(
     
  11. enchanted stick not posible, because the protecol that mc uses to talk to the server, dont have anny code to send enchantments for non tools.
     
  12. Offline

    mushroomhostage

    Any item can be "enchanted". Enchantments are simply NBT tags "ench" with id and lvl integers.

    The only catch is the shimmering glowing effect + descriptive tooltips only appears on the vanilla client for "durable" items, i.e., those with a damage bar (curiously even tools like Flint & Steel and Fishing Rods, which I exploit in my EnchantMore plugin). Sticks won't show up on the client as enchanted but should retain their tags. I've also seen enchanted mob spawners, enchanted crafting tables, enchanted chests, enchanted maps.. you can add ench tags to any item. (SilkSpawners, QuickBench, Chestpack, Courier, etc.)

    Sometimes the effect will even be applied despite the missing client display. When I was testing with an Efficiency 54 enchantment on a crafting table, I observed hitting blocks with the crafting table would cause them to break instantly. Took me a second to realize what was going on :). Other non-vanilla enchantments sometimes work as well, for example Sword + Unbreaking will have a chance not to take damage when used to break blocks.

    Father Of Time, I have not seen this stacking problem myself but it should be possible to fix by changing the stackability of the items (see StackableItems, StackControl, BookWorm, Writable, SilkSpawners spawnersUnstackable).
     
Thread Status:
Not open for further replies.

Share This Page