# Create a cube

Discussion in 'Plugin Development' started by FateCan, Sep 26, 2017.

Not open for further replies.
1. Offline

### FateCan

Hello guys, I would to know how to create a Hollow cube, and the center should be where the player placed the block.

For example, When player place a random block on floor will generate a Cube, and the center of this cube need to be where he place de block.

Thanks.

#1
2. Offline

### S1ant

So what dimensions do you want the cube to be?

#2
3. Offline

### FateCan

Like 5 x 1 x 5

#3
4. Offline

### Zombie_Striker

@FateCan
Again, like I posted on spigot:
1. Create three for loops; one for each of the XYZ directions. The will start at the block's location minus some radius, and loop up to the block's location plus some radius.
2. If the X is equal to Block's location minus Radius, or equal to the block's location plus the radius.
3. OR, if the same thing is true for the Y or Z
4. Set the block equal to whatever material you want.

#4
FateCan likes this.
5. Offline

### FateCan

Yeah, I'm trying

bump

EDIT by Moderator: merged posts, please use the edit button instead of double posting.

Last edited by a moderator: Sep 27, 2017
#5
6. Offline

@FateCan What have you tried already?

#6
7. Offline

### FateCan

I was trying to make this "for()" but I don't know cause the center need to be where the player place the block
But I don't know how I can make this for

#7
8. Offline

@FateCan Simple math. x = centerx - radius.

#8
9. Offline

### FateCan

But you can write a little example of the for that I need use?

Thanks I did it to solve the problem:

Code:
```            switch(direction) {
case("X"):
div = (int) (location.getX() - (div/2));
location.setX(div);
break;
case("Z"):
div = (int) (location.getZ() - (div/2));
location.setZ(div);
break;
}```
EDIT by Moderator: merged posts, please use the edit button instead of double posting.

Last edited by a moderator: Sep 27, 2017
#9