Metadata material vs itemstack

Discussion in 'Plugin Development' started by To175, May 31, 2015.

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

    To175

    Hi, I'm very angry, spigot's users are dumb x)
    no ok, please read my code and help me :p
    I can't see anyway to implement log(2) for example to my code.
    I'm generating a 5*5*5 cube with random blocs. I have to put log(2) and log(3) instead of stone for example !
    How to do :'(
    Please read before say "use itemstack" .......... Don't forget there are a "list" and a "shuffle".
    http://pastebin.com/juww6J6H

    thanks
     
  2. Offline

    To175

    @AdamQpzm Thanks, so with MaterialData I can use STONE for example ? (even if it has data 0)
    And I can use of course this ?
    Code:
    .setType(MaterialData);
     
    Last edited: Jun 1, 2015
  3. Offline

    I Al Istannen

    @To175 @AdamQpzm
    I don't know if this is the way to go, but "block.setData((byte) 2);" will set the block to Birch. If it is a log of course.
     
  4. Offline

    To175

    Just read my code, which "block" are you talking about ? Where it is ? There is a list of Materials which is SHUFFLED ! How do you know when you have to change the data ? Surely not in the forforfor loop
     
  5. @To175 I'd suggest reading the Javadocs for the relevant methods. Think of a MaterialData as a combination of both the Material and the data (hence the name), so yeah it can work even for data of 0. MaterialData cannot be used directly when using setType(), but it does have a method to retrieve the material used.
     
  6. Offline

    To175

    Ok thanks, because there is a Material list, I can't find MaterialData list...
     
  7. @To175 There isn't one. MaterialData is something you make yourself.
     
  8. Offline

    To175

    @AdamQpzm What ? with material I can do Material_LOG, but with MaterialData I can"t ...

    Edit : I search for setData or setMetadata ... I still don't understand how to use this.
    This is not working in my code !!

    I can't set anything ! I have not any block. Don't read 1 line of code but whole code. Blocks are randomly placed. Then are you magician to know which block to change ?
     
    Last edited: Jun 1, 2015
  9. @To175 I think you need to learn the basics of Java. You clearly don't know the difference between an enum, and a class where you make your own instances. MaterialData is the latter. Bukkit is written in Java, so learning it is compulsory if you want to make plugins. I recommend the Oracle tutorials or a Java book.
     
    KingFaris11 likes this.
  10. Offline

    To175

    I did a plugin, I have algorithm, I don't understand how to do this algorithm because I'm generating types of blocks randomly... I can't modify them after. I don't know how to do a good list of material data.
     
  11. Well are you saying you can't understand the code you've written? Line 39 is where you set the block. It doesn't matter whether it's random or not. You're already changing the type, so why don't you understand this? And you'd have a list of MaterialData the same way you'd have a list of anything (Strings, for example)
     
Thread Status:
Not open for further replies.

Share This Page