[Cuboids] Help.

Discussion in 'Plugin Development' started by ThatBox, Feb 20, 2012.

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

    ThatBox

    How can I make a cuboid with two locations? I never worked with them before.
     
  2. Offline

    Milkywayz

    Neither have i but i can kinda throw some words at you to get you thinking.. you need to get the right click and left click block event, you need to use vectors, and lots of math. Ask the dev of Worldedit haha
     
  3. Offline

    Gravity

    I've never dared to try, because I thought it might be really hard, but I thought about it and realized it might just be one big if statement...

    Say someone breaks something, you check if their event is inside a given cubiod.. x is the x position, y is the y, z is the z.

    if (x >= 300 && x <= 400 && y >= 200 && y <= 300 && z >= 400 && z <= 600)
    {
    event.setCancelled(true);
    }

    So, in essence, if x is between 300 and 400, y is between 300 and 400, and z is between 400 and 600, your inside the cuboid. That may not work, but I think it will, when I've done like pong and stuff in java I use something like that to check if the ball has hit boundaries of things, it should work just as well for 3D spaces.
     
    Daniel Heppner likes this.
  4. Offline

    dillyg10

    Acutally, this is somewhat easier than you would think :)

    Just use the BlockPlacedEvent, and the BlockDestroyedEvent.

    Determine if it is the first, or second time the player has called one of these vevents..

    Then, the rest is somewhat of a for look
    I'll show example for the code

    Code:
    //This is very general :D, and assume that these variables lead somerwer.
    int x = youreventlistener.x1,x2=youreventlistner.x2;
    //repeat for y and z...
    int Subx = x2 - x;
    Subx = Math.abs(Subx)
    //this is so that u don't get a negative number.
    //repeat for y and z
    for (int xLoop = 0; xLoop <Subx; xLoop++) {
        for (int yLoop = 0; yLoop < Suby; yLoop++) {
            for (int zLoop = 0; zLoop < Subz; zLoop++) {
              //call a method here with the three points that sets the block, with somthing like this
                setblock(x+xLoop,y+yLoop,z+zLoop);
                }
                }
                }
     
    
    There is still a lot that you would need to do, but you get the gist.
     
  5. Offline

    Firefly

    Are you trying to create a cube of stone, or make a imaginary cube to check if players are doing stuff inside it?
     
  6. Offline

    Gravity

    The latter. That's what a cuboid is, at least that's what most people refer to it as inside the Minecraft community.
     
  7. Offline

    dillyg10

    For me (being someone who has been working with servers since classic) cuboid means to me basically worldedit, except dummed down.
     
  8. Offline

    Fyre

    Well worldedit-style area selection you mean. As cuboids are pretty much what worldedit is based off of.
     
  9. Offline

    Technius

    ThatBox I actually got cuboids working, just skype me! :D
     
Thread Status:
Not open for further replies.

Share This Page