Block Vectors

Discussion in 'Plugin Development' started by NoLiver92, Aug 26, 2013.

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

    NoLiver92

    Block vectors - what are they? and why are they used?
     
  2. Offline

    ZeusAllMighty11

    Can you elaborate more?

    Generally a vector is much like a location, but with a force attached
     
  3. Offline

    NoLiver92

    TheGreenGamerHD
    Im trying to teach myself some new things But the reason why im doing this is im rewriting my schematic plugin and i looked at world edit's code and they use vectors and block vectors and i dont understand why.
     
  4. Offline

    creatorfromhell

    Vectors in WorldEdit refer to a location in the world. The different types of Vectors are for different purposes. For example, Vector.java is just for a general location in the world, and BlockVector.java is for a block's location in the world.
     
  5. Offline

    NoLiver92

    this

    that is the couboid region class, why do they use vectors?

    so why dont they use locations? what are the benefits of using vectors over locations?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  6. Offline

    creatorfromhell

    It's more customized to the developer's liking. For example, WorldEdit's main Vector class has more methods than Bukkit's Location class, which are used to save the developer time. In my opinion, I think there's not a case of more benefits rather than what the developer prefers, but I could be wrong.
     
  7. Offline

    NoLiver92

    ok so it doesnt matter. in that case ill stick to locations as i know them better. thanks
     
  8. Offline

    metalhedd

    There is one (and afaik ONLY ONE) fundamental difference between a BlockVector and a Location. a Location includes a World. a BlockVector does not.
     
  9. Offline

    SuperOmegaCow

    I'll just leave this here
    Code:java
    1. @EventHandler(priority = EventPriority.NORMAL)
    2. public void onBlockExplode(EntityExplodeEvent e) {
    3. if (e.isCancelled())
    4. return;
    5. if (e.blockList().isEmpty())
    6. return;
    7. e.setYield(0.0F);
    8. double x = 0.0D;
    9. double y = 0.0D;
    10. double z = 0.0D;
    11. Location eLoc = e.getLocation();
    12. World w = eLoc.getWorld();
    13. for (int i = 0; i < e.blockList().size(); i++) {
    14. Block b = (Block) e.blockList().get(i);
    15. Location bLoc = b.getLocation();
    16. if (!this.disallowedBlocks.contains(b.getType())) {
    17. x = bLoc.getX() - eLoc.getX();
    18. y = bLoc.getY() - eLoc.getY() + 0.5D;
    19. z = bLoc.getZ() - eLoc.getZ();
    20. FallingBlock fb = w.spawnFallingBlock(bLoc, b.getType(),
    21. b.getData());
    22. fb.setDropItem(false);
    23. fb.setVelocity(new Vector(x, y, z));
    24. }
    25. }
    26. }
     
Thread Status:
Not open for further replies.

Share This Page