use of com.builtbroken.mc.framework.block.BlockBase in project Engine by VoltzEngine-Project.
the class JsonBlockProcessor method process.
@Override
public boolean process(JsonElement element, List<IJsonGenObject> objectList) {
debugPrinter.start("BlockProcessor", "Processing entry", Engine.runningAsDev);
//Get object and ensure minimal keys exist
JsonObject blockData = element.getAsJsonObject();
ensureValuesExist(blockData, "name", "id", "mod");
//Load default data
String mod = blockData.getAsJsonPrimitive("mod").getAsString();
String id = blockData.getAsJsonPrimitive("id").getAsString();
String name = blockData.get("name").getAsString();
debugPrinter.log("Name: " + name);
debugPrinter.log("Mod: " + mod);
debugPrinter.log("ID: " + id);
//Generate object
BlockPropertyData blockPropertyData = new BlockPropertyData(this, id, mod, name);
//Load blocks
BlockBase block;
//Meta data loading
if (blockData.has("subtypes")) {
blockPropertyData.localization += "." + BlockMeta.META_LOCAL_KEY;
block = new BlockMeta(blockPropertyData);
//Call to load metadata
readMeta((BlockMeta) block, blockData.get("subtypes").getAsJsonArray(), objectList);
} else //No meta data
{
block = new BlockBase(blockPropertyData);
}
processAdditionalKeys(blockPropertyData, blockData, block, objectList);
//Add block to object list
objectList.add(block);
debugPrinter.end("Done...");
return true;
}
use of com.builtbroken.mc.framework.block.BlockBase in project Engine by VoltzEngine-Project.
the class TileRenderHandler method renderTileEntityAt.
@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float f) {
GL11.glPushMatrix();
try {
GL11.glTranslated(x + 0.5, y, z + 0.5);
RenderData data = getRenderData(tile);
if (data != null && data.renderType.equalsIgnoreCase("tile")) {
//Try to get tile specific state
String key = getRenderStateKey(tile);
//Loop default keys
for (String de : new String[] { key, "tile", "entity", "item.entity" }) {
if (de != null) {
IRenderState state = data.getState(de);
if (state instanceof IModelState && ((IModelState) state).render(false)) {
break;
}
}
}
}
} catch (Exception e) {
Engine.logger().error("TileRenderHandler: Error rendering " + tile, e);
}
GL11.glPopMatrix();
//If BlockBase, iterate listeners
if (tile.getBlockType() instanceof BlockBase) {
ListenerIterator it = new ListenerIterator(tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, (BlockBase) tile.getBlockType(), "tilerender");
while (it.hasNext()) {
ITileEventListener next = it.next();
if (next instanceof ITileRenderListener) {
GL11.glPushMatrix();
try {
((ITileRenderListener) next).renderDynamic(tile, x, y, z, f);
} catch (Exception e) {
Engine.logger().error("TileRenderHandler: Error calling listener[" + next + "] for Tile[" + tile + "]", e);
}
GL11.glPopMatrix();
}
}
}
}
use of com.builtbroken.mc.framework.block.BlockBase in project Engine by VoltzEngine-Project.
the class ClientProxy method postInit.
@Override
public void postInit() {
super.postInit();
//Item that uses a model for all states
registerItemJsonRenders(new ItemJsonRenderer(), "VE-Item", "item", "tile", "block");
List<IJsonGenObject> objects = JsonContentLoader.INSTANCE.generatedObjects.get(JsonBlockProcessor.KEY);
if (objects != null && !objects.isEmpty()) {
for (IJsonGenObject object : objects) {
if (object instanceof BlockBase) {
List<ITileEventListener> listeners = ((BlockBase) object).listeners.get("placement");
if (listeners != null && !listeners.isEmpty()) {
for (ITileEventListener listener : listeners) {
if (listener instanceof RotatableListener) {
((BlockBase) object).addListener(new RotatableIconListener((BlockBase) object));
break;
}
}
}
}
}
}
}
Aggregations