implemented multiblock structure
This commit is contained in:
parent
c5eae6172c
commit
9ce6ebe8e0
@ -0,0 +1,37 @@
|
|||||||
|
package org.kapelle.multiblock;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.util.BlockVector;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MultiblockStructure {
|
||||||
|
|
||||||
|
List<List<List<BlockComponent>>> structure;
|
||||||
|
|
||||||
|
public MultiblockStructure(List<List<List<BlockComponent>>> structure){
|
||||||
|
this.structure = structure;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BlockComponent getComponent(int x, int y, int z){
|
||||||
|
return structure.get(x).get(y).get(z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValid(Location location, BlockVector offset){
|
||||||
|
for (int x = 0; x < structure.size(); x++) {
|
||||||
|
for (int y = 0; y < structure.get(x).size(); y++) {
|
||||||
|
for (int z = 0; z < structure.get(x).get(y).size(); z++) {
|
||||||
|
|
||||||
|
BlockComponent currentComponent = getComponent(x,y,z);
|
||||||
|
Location globalBlockLocation = location.clone().subtract(offset);
|
||||||
|
|
||||||
|
if(!currentComponent.isValidBlock(globalBlockLocation)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user