use of com.builtbroken.mc.api.tile.multiblock.IMultiTile in project Engine by VoltzEngine-Project.
the class MultiBlockHelper method canBuild.
public static boolean canBuild(World world, int x, int y, int z, Map<IPos3D, String> map, boolean offset) {
if (world != null && Engine.multiBlock != null) {
//Ensure the map is not null or empty in case there is no structure to generate
if (map != null && !map.isEmpty()) {
//Loop all blocks and start placement
for (Map.Entry<IPos3D, String> entry : map.entrySet()) {
IPos3D location = entry.getKey();
String type = entry.getValue();
String dataString = null;
if (location == null || type == null || type.isEmpty()) {
return false;
}
if (type.contains("#")) {
dataString = type.substring(type.indexOf("#") + 1, type.length());
type = type.substring(0, type.indexOf("#"));
}
EnumMultiblock enumType = EnumMultiblock.get(type);
if (enumType != null) {
//Moves the position based on the location of the host
if (offset) {
location = new Location(world, x, y, z).add(location);
}
Block block = world.getBlock(location.xi(), location.yi(), location.zi());
if (!block.isAir(world, location.xi(), location.yi(), location.zi()) && !block.isReplaceable(world, location.xi(), location.yi(), location.zi())) {
return false;
} else if (block == Engine.multiBlock) {
TileEntity tileEntity = world.getTileEntity(location.xi(), location.yi(), location.zi());
if (tileEntity instanceof IMultiTile && ((IMultiTile) tileEntity).getHost() != null) {
return false;
}
}
}
}
return true;
}
}
return false;
}
Aggregations