mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-21 21:02:24 +00:00
88 lines
3.0 KiB
Java
88 lines
3.0 KiB
Java
package team.chisel.client.render;
|
|
|
|
import static org.lwjgl.opengl.GL11.GL_BLEND;
|
|
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
|
|
import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA;
|
|
import static org.lwjgl.opengl.GL11.glBlendFunc;
|
|
import static org.lwjgl.opengl.GL11.glDisable;
|
|
import static org.lwjgl.opengl.GL11.glEnable;
|
|
import static org.lwjgl.opengl.GL11.glPopMatrix;
|
|
import static org.lwjgl.opengl.GL11.glPushMatrix;
|
|
import static org.lwjgl.opengl.GL11.glTranslatef;
|
|
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
|
import net.minecraft.init.Blocks;
|
|
import net.minecraft.world.IBlockAccess;
|
|
import net.minecraftforge.client.ForgeHooksClient;
|
|
|
|
import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
|
|
|
|
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
|
import cpw.mods.fml.client.registry.RenderingRegistry;
|
|
import team.chisel.block.BlockMultiLayerBase;
|
|
import team.chisel.ctmlib.Drawing;
|
|
|
|
@ThreadSafeISBRH(perThread = false)
|
|
public class RendererMultiLayer implements ISimpleBlockRenderingHandler {
|
|
|
|
final static float bot = -0.001f;
|
|
final static float top = 1.0f - bot;
|
|
public static final int id = RenderingRegistry.getNextAvailableRenderId();
|
|
|
|
@Override
|
|
public void renderInventoryBlock(Block blck, int meta, int modelID, RenderBlocks renderer) {
|
|
if (!(blck instanceof BlockMultiLayerBase block)) return;
|
|
|
|
if (block.icon != null) {
|
|
renderer.overrideBlockTexture = block.icon;
|
|
renderer.renderBlockAsItem(Blocks.stone, meta, 1.0f);
|
|
renderer.overrideBlockTexture = null;
|
|
} else if (block.base != null) {
|
|
renderer.renderBlockAsItem(block.base, meta, 1.0f);
|
|
}
|
|
|
|
glPushMatrix();
|
|
glEnable(GL_BLEND);
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
renderer.setRenderBounds(bot, bot, bot, top, top, top);
|
|
glTranslatef(-0.5F, -0.5F, -0.5F);
|
|
Drawing.drawBlock(block, meta, renderer);
|
|
glDisable(GL_BLEND);
|
|
glPopMatrix();
|
|
}
|
|
|
|
@Override
|
|
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block blck, int modelId,
|
|
RenderBlocks renderer) {
|
|
if (!(blck instanceof BlockMultiLayerBase block)) return false;
|
|
|
|
if (ForgeHooksClient.getWorldRenderPass() == 0) {
|
|
if (block.icon != null) {
|
|
renderer.overrideBlockTexture = block.icon;
|
|
renderer.renderStandardBlock(block, x, y, z);
|
|
renderer.overrideBlockTexture = null;
|
|
return true;
|
|
} else if (block.base != null) {
|
|
renderer.renderBlockByRenderType(block.base, x, y, z);
|
|
return true;
|
|
}
|
|
} else {
|
|
renderer.setRenderBounds(0, 0, 0, 1, 1, 1);
|
|
return renderer.renderStandardBlock(block, x, y, z);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean shouldRender3DInInventory(int modelId) {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public int getRenderId() {
|
|
return id;
|
|
}
|
|
}
|