WorldEdit API "CuboidClipboard" questions

Discussion in 'Plugin Development' started by unrealdesign, Jan 12, 2015.

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

    unrealdesign

    So I have a CuboidClipboard and I'm wondering if anyone knows exactly how it works? I've been reading through the API but there isn't much but the obvious for some methods and it's starting to confuse me.


    What I want: I want to load a schematic into CuboidClipboard and I want to paste centered it in the direction the player is facing.

    What I am doing now is working until I use rotate2D(angle) to manipulate the CuboidClipboard to paste in the direction of the player. Currently, I am using the origin as the smallest corner in the CuboidClipboard (so the location with the smallest x value, smallest y value, and smallest z value), and adding a vector to that location with the according to the length, width, and height of the CuboidClipboard. Then I rotate it the correct amount degrees with the method above and translate it accordingly on either the x or z axis, depending on the yaw of the player.

    The problem is after I do these calculations the origin is now NOT the smallest corner in the CuboidClipboard. Now I can't just add the length, width, and height to the origin to get the correct opposing corner. I obviously save the angle at which I rotated the CuboidClipboard and then later calculate the opposing corner by adding either a negative to the width or length, but this just seems like a work around and bad practice for OOP.

    Does anyone know the correct way to do what I am trying to achieve. It looks like the "size" in CuboidClipboard might be what I'm looking for, but that seems like a weird name of a variable that I need and also I don't know if it stores negative values.

    Thanks!
     
  2. Offline

    NathanWolf

    Hm- I'm not sure I can help, but what I do is use the getSize method. This returns a WE Vector class that seems to convey the correct size. I use this to build the schematic at a target location programatically, by walking through each block in the schematic.

    I haven't used the rotation or paste methods, though, so I can't say how that would affect the origin when you paste.
     
  3. Offline

    unrealdesign

    Yeah, that's what I was doing, but like you said, when your rotate it about the origin, the size vector stays positive. What is happening in the code is the data[][][] is being manipulated in someway, that when you paste it, it goes to the correct location. I just can't tell how, because rotating doesn't effect the size.
     
  4. Offline

    NathanWolf

    Hm.. yeah it seems like rotating ought to affect the size, assuming it's not square and you're not rotating 180 degrees. Sounds like maybe a bug in WorldEdit?
     
  5. Offline

    unrealdesign

    What I meant is like when you do rotate it, the x and y axis switch accordingly. Though the problem is, when you rotate it, you can't simply add to the origin vector the length width and height and get the other corner anymore, because after rotating the origin isn't the the block with the lowest x, y, and z value. There are obviously ways to deal with this, but I just would like to do it the best way, similar to how WorldEdit does it, I just can't seem to figure out how they do it hehe
     
Thread Status:
Not open for further replies.

Share This Page