Zarius / Bukkit-OtherBlocks

OtherBlocks (now known as OtherDrops) plugin for Bukkit (dev build: https://www.mediafire.com/?i6ows1g6kus2o0l)
http://dev.bukkit.org/server-mods/otherdrops/
GNU General Public License v3.0
17 stars 17 forks source link

Working with Tools ID numbers and data values #169

Closed Hecatonchyr closed 11 years ago

Hecatonchyr commented 11 years ago

10% bug report, 90% tutorial which I think could be useful in the Tools reference page When you want to write a config with a specified tool, you can write it in two ways:

STONE:
    - tool: DIAMOND_PICKAXE
      chance: 20%
      drop: STONE
STONE:
    - tool: 278
      chance: 20%
      drop: STONE

Both methods work and you have 20% chance of getting stone instead of cobblestone with a diamond pickaxe, no matter the durability of it. You can also specify multiple tools:

STONE:
    - tool: [IRON_PICKAXE, DIAMOND_PICKAXE]
      chance: 20%
      drop: STONE

But if you want to use ID numbers instead of ID names (because its shorter):

STONE:
    - tool: [257, 278] # This syntax crashes Otherdrops (java.lang.NullPointerException)
      chance: 20%
      drop: STONE

You can't do it this way. I discovered you need to add data values with ID numbers when using 2 or more tools and then Otherdrops does not crash:

STONE:
    - tool: [257@0, 278@0]
      chance: 20%
      drop: STONE

There is one downside: the current config only triggers when the tools are brand new (= durability max), because the data value of a tool is the damage bar. If you want the config to trigger no matter what the durability is, you need to set an interval:

STONE:
    - tool: [257@0-9999, 278@0-9999]
      chance: 20%
      drop: STONE

Or you just put an @ without any number after, to specify you want any data value:

STONE:
    - tool: [257@, 278@]
      chance: 20%
      drop: STONE

Or finally, simply use quotes (") around your ID numbers:

STONE:
    - tool: ["257", "278"]
      chance: 20%
      drop: STONE

Otherdrops doesn't care if the interval is greater than the max data value a tool can get. For example an iron pickaxe has 251 uses. It means that data value can be from 0 (brand new) to 251 (broken). Setting 0-9999 is just being lazy (I don't want to check the max use of each tool, I will just put 0-9999 and it will cover all data values, since not a single tool in vanilla minecraft exceeds 9999 uses (max is 1562 for diamond tools)). But be careful with modded tools as some can exceed 9999 uses depending on the mod. Why is this feature interesting ? Because you can create configs where durability will trigger different results:

STONE:
    - tool: [257@0-63, 278@0-390] # Brand new pickaxe quite efficient
      chance: 20%
      drop: STONE
    - tool: [257@64-128, 278@391-780] # Average pickaxe, possible double drop
      chance: 10%
      drop: COBBLESTONE
      quantity: 2
    - tool: [257@129-192, 278@781-1170] # This pickaxe is damaged and not efficient
      chance: 20%
      drop: NOTHING
    - tool: [257@193-251, 278@1171-1562] # Wasted pickaxe, use with caution
      chance: 3%
      message: "Your pickaxe broke and hurt you."
      damageattacker: 8
      damagetool: 400

CREATURE_UNDEAD: # The killing blow is the 777th use of the sword = insane drop occurs
    - tool: 276@777
      drop: DIAMOND_SWORD@!DAMAGE_UNDEAD#10,FIRE_ASPECT#5@!~Angelic Ray # Use enchantments_ignore_level: true in otherdrops-config.yml to allow any enchantment level to be set
      message: "Lucky ! %p just dropped one of the Legendary Five: Angelic Ray !"
CREATURE_UNDEAD: # Angelic Ray really doesn't like undeads (need Essentials)
    - action: LEFT_CLICK
      tool: DIAMOND_SWORD
      lorename: Angelic Ray
      chance: 50%
      command: "/!*butcher 3" # Unless you are surrounded by mobs, should only kill the undead you fight (kill anything within 3 block radius around you)
      event: LIGHTNING@HARMLESS # Well, its an Angelic ray after all !

This concludes what I tested so far. I will edit in a few hours to add the use of data values to create "virtual" entities.

Zarius commented 11 years ago

Thanks for that. I love the "777th use of sword" & Angelic Ray :)

In regards to the list of ID's I've discovered it's because the code is calling .getStringList() whereas this is a list of numbers so it fails. I'm looking for a way around this but in the meantime note that if you put it in quotes, eg. ["257", "258"] it works fine however the easier way is just putting the @ symbol without a durability, eg. [257@, 258@] as that should work for any durability.

Hecatonchyr commented 11 years ago

Okay thanks for the additional information, I edited to write these.

Zarius commented 11 years ago

Fixed in a local build - [257@, 258] or even [257, 258] now works fine.

Zarius commented 11 years ago

I've moved the tutorial stuff here: https://github.com/Zarius/Bukkit-OtherBlocks/wiki/Hecatonchyr's-Tutorial

You should be able to edit that page - look forward to seeing the data value "virtual" entities stuff.

I'll close this issue now by committing the fix.