getTargetBlock() How do I make it ignore literally every single block?

Discussion in 'Plugin Development' started by tylersyme, May 15, 2014.

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

    tylersyme

    By default if you use getTargetBlock(null, 100), it will select the closes target block within 100 blocks. But I want it to ignore every single block in the game, so that it simply selects the target block 100 blocks away.

    The purpose of this is that I'm testing with a missile prototype. Basically the player is controlling an arrow's movements with their cursor. When they look around I want the arrow to change it's vector so that it always goes towards the cursor (Basically like a remote controlled missile). I know how to do all the vector stuff, but I figured it would help if everyone knew what this was for.

    Thanks for any help you guys give :)
     
  2. Offline

    AoH_Ruthless

    tylersyme

    getTargetBlock() allows you to ignore every single block. The first parameter is what blocks you want to ignore ... You are setting it to null and therefore not ignoring any blocks. It's a HashSet of all the transparent block Ids, which is why the method is deprecated when you try to use it.
     
  3. Offline

    tylersyme

    AoH_Ruthless Exactly my problem, I don't want to create a HashSet of every single block and stick it in there, it may not be possible to do it any other way, but I would Love to find any other way :p
     
  4. Offline

    NathanWolf

    Using a BlockIterator directly will give you want here, I think.
     
  5. Offline

    coasterman10

    If you want to get the target block 100 blocks away, forgo the use of any costly raycasting iterators and just create a vector in the direction the player is looking, with a length of 100, then add it to their location, and get the block at the resulting location.
     
    NathanWolf likes this.
  6. Offline

    GeorgeeeHD

    tylersyme

    Code:java
    1. List<Block> blocks = p.getLineOfSight(null, 100);
    2. Block b = blocks.get(99); //100th Block away.


    i think this should work
     
  7. Offline

    desht

    No, it will not work - read the Javadocs. A null value for the transparency Set means to treat only AIR as transparent.

    tylersyme do what coasterman10 suggested.
     
    NathanWolf likes this.
  8. Offline

    tylersyme

    coasterman10 Ahh, yes, that's the way to do it, I'll try it out :D
     
Thread Status:
Not open for further replies.

Share This Page