2026-03-05 15:40:44 +01:00

99 lines
2.6 KiB
Java

package com.hbm.render.tileentity;
import org.lwjgl.opengl.GL11;
import com.hbm.lib.RefStrings;
import com.hbm.main.ResourceManager;
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKRod;
import com.hbm.util.ColorUtil;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
public class RenderRBMKFuelChannel extends TileEntitySpecialRenderer {
private static final ResourceLocation texture_rods = new ResourceLocation(RefStrings.MODID + ":textures/blocks/rbmk/rbmk_element_fuel.png");
@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float i) {
boolean hasRod = false;
boolean cherenkov = false;
int color = 0;
if(te instanceof TileEntityRBMKRod) {
TileEntityRBMKRod rod = (TileEntityRBMKRod) te;
if(rod.hasRod) hasRod = true;
if(rod.fluxQuantity > 5) cherenkov = true;
color = rod.rodColor;
}
GL11.glPushMatrix();
GL11.glTranslated(x + 0.5, y, z + 0.5);
int offset = 1;
for(int o = 1; o < 16; o++) {
if(te.getWorldObj().getBlock(te.xCoord, te.yCoord + o, te.zCoord) == te.getBlockType()) {
offset = o;
int meta = te.getWorldObj().getBlockMetadata(te.xCoord, te.yCoord + o, te.zCoord);
if(meta > 5 && meta < 12) break;
} else {
break;
}
}
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_CULL_FACE);
if(hasRod) {
GL11.glPushMatrix();
bindTexture(texture_rods);
GL11.glColor3f(ColorUtil.fr(color), ColorUtil.fg(color), ColorUtil.fb(color));
for(int j = 0; j <= offset; j++) {
ResourceManager.rbmk_element_rods_vbo.renderPart("Rods");
GL11.glTranslated(0, 1, 0);
}
GL11.glColor3f(1F, 1F, 1F);
GL11.glPopMatrix();
}
if(cherenkov) {
GL11.glTranslated(0, 0.75, 0);
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
tess.setColorRGBA_F(0.4F, 0.9F, 1.0F, 0.1F);
for(double j = 0; j <= offset; j += 0.25) {
tess.addVertex(-0.5, j, -0.5);
tess.addVertex(-0.5, j, 0.5);
tess.addVertex(0.5, j, 0.5);
tess.addVertex(0.5, j, -0.5);
}
tess.draw();
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_CULL_FACE);
}
GL11.glPopMatrix();
}
}