use of com.builtbroken.mc.prefab.tile.BlockTile in project Engine by VoltzEngine-Project.
the class ModManager method newBlock.
/**
* Creates a new block based on the Tile class provided
* Handles most common registration and data input tasks for the creation of the block.
* This includes registering the block, tile, built in item & tile renders. It also inits
* the instance used for the block itself.
*
* @param spatialClass - class that will provide all the data to be used when creating the block.
* @param args - arguments needed to create a new instance of the spatial class
*/
public BlockTile newBlock(String name, Class<? extends Tile> spatialClass, Object... args) {
try {
Tile spatial;
if (args != null && args.length > 0) {
List<Class> paramTypes = new ArrayList();
for (Object arg : args) {
paramTypes.add(arg.getClass());
}
spatial = spatialClass.getConstructor(paramTypes.toArray(new Class[paramTypes.size()])).newInstance();
} else {
spatial = spatialClass.newInstance();
}
return newBlock(name, spatial);
} catch (Exception e) {
throw new RuntimeException(name() + " Tile [" + spatialClass.getSimpleName() + "] failed to be created:", e);
}
}
Aggregations