Solved Give a block a number like an ID.

Discussion in 'Plugin Development' started by JigokuSaru, May 6, 2015.

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

    JigokuSaru

    Okay, What i want to do is when a block is placed give it some kind of number. Thats basically it.
     
  2. Create a Map and put the block's location with an id in it, e.g.:
    Code:
    //Somewhere in your class
    private Map<Location, Integer> blockIds = new HashMap<Location, Integer>();
    
    //In your block place event
    blockIds.put(e.getBlock().getLocation, new Random().nextInt(1000));
     
  3. Offline

    JigokuSaru

    @megamichiel
    "new Random().nextInt(1000)" this part here , what does it mean
     
  4. .nextInt(1000) generated a random generated number from 0 to 999
     
  5. Offline

    JigokuSaru

  6. Offline

    Zombie_Striker

    You can always use UUIDs, even if it's not an entity. Create a UUID for your block and store it in a HashMap.
     
  7. Offline

    JigokuSaru

  8. Offline

    Zombie_Striker

    Code:
    public Hashmap<Object, UUID> thing = new Hashmap<>();
                    public UUID id = UUID.randomUUID();
     
Thread Status:
Not open for further replies.

Share This Page