# "Multi Block" Structers

Discussion in 'Plugin Development' started by ICodeMaster, Jun 5, 2013.

Not open for further replies.
1. Offline

### ICodeMaster

So i have had a great idea with using a "multi-block" like structer in bukkit. First question i have is insead of getting if a player clicks then checking every block position in a 3x3x3 cube to make sure they are perfect, can you condesense it into a much simpler and more compact version? The comparing all the booleans after the check is there also a way to condense this? It seems like alot of clutter to do it like that.

Thanks
~ICode

#1
2. Offline

### Hedgehogs4Me

Here's a quick sketching of what I'd do for a rectangular-prismatic region, but I'm still a newbie in the field so I'm sure it can be vastly improved. Note that if you meant that you want to check whether the region is perfectly the same all the time, you can always just check all the blocks once and then write the locations to a file and still use this code. Be careful, though: you'd also have to listen for them destroying or adding to the structure.

Code:
```int minx = XCOORDHERE;
int maxx = XCOORDHERE;
int miny = YCOORDHERE;
int maxy = YCOORDHERE;
int minz = ZCOORDHERE;
int maxz = ZCOORDHERE;

@EventHandler
public void onPlayerInteract(PlayerInteractEvent event){
Action a = event.getAction();
if(a==Action.RIGHT_CLICK_BLOCK || a==Action.LEFT_CLICK_BLOCK){
int bx = event.blockClicked().getx();
int by = event.blockClicked().gety();
int bz = event.blockClicked().getz();
if(bx < maxx && bx > minx && by < maxy && by > miny && bz < maxz && bz > minz){
player.sendMessage("[Region] Stop touching me!");
}
}
}```
You might have to fiddle around a bit to make it work exactly as intended, though, as those coordinate getting things return an int while standing in the middle of a block will return something.5.

Also note that I'm not including the traditional paranoid null checks that I'd do, which is probably good practice considering that I really have no idea what part of that could potentially give a null. Whatever-you-believe help us all if event.getAction() ever spit one out.

#2