Solved Overriding Enchantments

Discussion in 'Plugin Development' started by CeramicTitan, Nov 8, 2012.

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

    CeramicTitan

    Is it possible to override the enchantment, Infinity?

    For Example: The normal effects of Infinity I is taken off(so it's not unlimited arrows)?
     
  2. Offline

    Retherz_

    im sure that you can change the enchantments :)
     
  3. Offline

    SirTyler

    Reflection maybe?
     
  4. Offline

    fireblast709

    CeramicTitan what is your goal? What do you want to change?
     
  5. Offline

    Ewe Loon

  6. Offline

    Sanitized

  7. Offline

    CeramicTitan

    I need the bow to be enchanted with infinity but i don't want the effects of it
    fireblast709

    What do you mean by reflection?
    SirTyler
     
  8. Offline

    SirTyler

    If you were trying to overwrite what enchantments already do, then you would need to use reflection (not recommend).
     
  9. Offline

    fireblast709

    might be that you would have to implement a ProjectileLaunchEvent and cancel if the projectile is an Arrow and the user has no arrows in his inventory. Checking for arrows would use an iteration over all the itemstacks in the players inventory, check if the type == Material.Arrow, and check the amount. Then remove a new ItemStack(Material.Arrow, 1). Off for the weekend, so no testing from my side
     
  10. Offline

    CeramicTitan

    have you got an example?
     
  11. Offline

    SirTyler

    What exactly are you trying to do?
     
  12. Offline

    CeramicTitan

    I need the bow to be enchanted with infinity but i don't want the effects of it
     
  13. Offline

    SirTyler

    So you want it to say "Infinity I" but not have Infinity? If I understand correctly then you would do what fireblaster said. Make a Listener and use this to cancel the effects of the Infinity
    Code:java
    1. @EventHandler
    2. public void arrowCheck(ProjectileLaunchEvent event) {
    3. if(event.getEntity() instanceof Arrow) {
    4. if(event.getEntity().getShooter() instanceof Player) {
    5. Player p = event.getEntity().getShooter();
    6. if(p.getInventory().contains(Material.Arrow)) {
    7. p.getInventory().removeItem(new ItemStack(Material.Arrow, 1);
    8. } else event.setCancelled(true);
    9. }
    10. }
    11. }
     
Thread Status:
Not open for further replies.

Share This Page