Solved Get all materials put in a hashset?

Discussion in 'Plugin Development' started by Evonoucono, Nov 24, 2015.

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

    Evonoucono

    I am using this code:
    Code:
    Location loc = p.getTargetBlock(null, 20).getLocation();
    and it will search for the block location a player is looking at 20 blocks away, unless it detects a block in front of the 20 block scan, in which it will stop scanning and give the location of the block it first detects. However I am working with vectors and I have it set up so it will get the location of the block/air 20 blocks in front of the player, and send the player towards it. I do not want the velocity of the player to be well reduced because the scan picks up a block closer than 20. The null is for a hashset of blocks that will be "transparent" in the scan, and I want all blocks to be transparent. Is there any way to add all blocks to a hashset in a compact way? Or can I do this differently so I get what I want through doing something else?
     
  2. Offline

    teej107

    You have to create your own method for it. Transparent blocks IDs can only be put in the HashSet from what I assume. I haven't tried putting a non transparent block id in the HashSet but since the HastSet type must be byte and there are well over 255 Materials, you are going to lose information and it won't work 100%.
     
  3. Offline

    mythbusterma

    @Evonoucono

    If you want all blocks to be transparent, you can use an EnumSet, like the following:

    EnumSet<Material> materials = new EnumSet<>(Material.class);

    That will create a new set with all Materials in it.
     
    teej107 likes this.
  4. Offline

    teej107

    mythbusterma likes this.
  5. Offline

    Evonoucono

    Thank you
     
Thread Status:
Not open for further replies.

Share This Page