Merge pull request #2291 from ganymedes01/6.3.x
Made robot lights shiny
This commit is contained in:
commit
3f4f30f020
2 changed files with 42 additions and 39 deletions
Binary file not shown.
After Width: | Height: | Size: 200 B |
|
@ -14,23 +14,27 @@ import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import net.minecraft.client.model.ModelBase;
|
import net.minecraft.client.model.ModelBase;
|
||||||
import net.minecraft.client.model.ModelRenderer;
|
import net.minecraft.client.model.ModelRenderer;
|
||||||
|
import net.minecraft.client.renderer.OpenGlHelper;
|
||||||
import net.minecraft.client.renderer.entity.Render;
|
import net.minecraft.client.renderer.entity.Render;
|
||||||
import net.minecraft.client.renderer.entity.RenderItem;
|
import net.minecraft.client.renderer.entity.RenderItem;
|
||||||
import net.minecraft.client.renderer.entity.RenderManager;
|
import net.minecraft.client.renderer.entity.RenderManager;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
import net.minecraftforge.client.IItemRenderer;
|
import net.minecraftforge.client.IItemRenderer;
|
||||||
|
|
||||||
import buildcraft.BuildCraftSilicon;
|
import buildcraft.BuildCraftSilicon;
|
||||||
|
import buildcraft.core.DefaultProps;
|
||||||
import buildcraft.core.EntityLaser;
|
import buildcraft.core.EntityLaser;
|
||||||
import buildcraft.core.ItemRobot;
|
import buildcraft.core.ItemRobot;
|
||||||
import buildcraft.core.robots.EntityRobot;
|
import buildcraft.core.robots.EntityRobot;
|
||||||
|
|
||||||
public class RenderRobot extends Render implements IItemRenderer {
|
public class RenderRobot extends Render implements IItemRenderer {
|
||||||
|
|
||||||
|
private static final ResourceLocation overlay = new ResourceLocation("buildcraft",
|
||||||
|
DefaultProps.TEXTURE_PATH_ENTITIES + "/robot_overlay.png");
|
||||||
|
|
||||||
private final EntityItem dummyEntityItem = new EntityItem(null);
|
private final EntityItem dummyEntityItem = new EntityItem(null);
|
||||||
private final RenderItem customRenderItem;
|
private final RenderItem customRenderItem;
|
||||||
|
|
||||||
|
@ -61,50 +65,38 @@ public class RenderRobot extends Render implements IItemRenderer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doRender(Entity entity, double x, double y, double z, float f, float f1) {
|
public void doRender(Entity entity, double x, double y, double z, float f, float f1) {
|
||||||
doRender((EntityRobot) entity, x, y, z, f, f1);
|
doRender((EntityRobot) entity, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doRender(EntityRobot robot, double x, double y, double z, float f, float f1) {
|
private void doRender(EntityRobot robot, double x, double y, double z) {
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glTranslated(x, y, z);
|
GL11.glTranslated(x, y, z);
|
||||||
|
|
||||||
try {
|
|
||||||
renderManager.renderEngine.bindTexture(robot.getTexture());
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
// TODO: Figure out why the NPE inside Minecraft happens.
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
float factor = (float) (1.0 / 16.0);
|
|
||||||
|
|
||||||
box.render(factor);
|
|
||||||
|
|
||||||
if (robot.getStackInSlot(0) != null) {
|
if (robot.getStackInSlot(0) != null) {
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glTranslatef(-0.125F, 0, -0.125F);
|
GL11.glTranslatef(-0.125F, 0, -0.125F);
|
||||||
doRenderItem(robot.getStackInSlot(0), 1.0F);
|
doRenderItem(robot.getStackInSlot(0));
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (robot.getStackInSlot(1) != null) {
|
if (robot.getStackInSlot(1) != null) {
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glTranslatef(+0.125F, 0, -0.125F);
|
GL11.glTranslatef(+0.125F, 0, -0.125F);
|
||||||
doRenderItem(robot.getStackInSlot(1), 1.0F);
|
doRenderItem(robot.getStackInSlot(1));
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (robot.getStackInSlot(2) != null) {
|
if (robot.getStackInSlot(2) != null) {
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glTranslatef(+0.125F, 0, +0.125F);
|
GL11.glTranslatef(+0.125F, 0, +0.125F);
|
||||||
doRenderItem(robot.getStackInSlot(2), 1.0F);
|
doRenderItem(robot.getStackInSlot(2));
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (robot.getStackInSlot(3) != null) {
|
if (robot.getStackInSlot(3) != null) {
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glTranslatef(-0.125F, 0, +0.125F);
|
GL11.glTranslatef(-0.125F, 0, +0.125F);
|
||||||
doRenderItem(robot.getStackInSlot(3), 1.0F);
|
doRenderItem(robot.getStackInSlot(3));
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,22 +121,15 @@ public class RenderRobot extends Render implements IItemRenderer {
|
||||||
|
|
||||||
if (itemstack1.getItem().requiresMultipleRenderPasses()) {
|
if (itemstack1.getItem().requiresMultipleRenderPasses()) {
|
||||||
for (int k = 0; k < itemstack1.getItem().getRenderPasses(itemstack1.getItemDamage()); ++k) {
|
for (int k = 0; k < itemstack1.getItem().getRenderPasses(itemstack1.getItemDamage()); ++k) {
|
||||||
int i = itemstack1.getItem().getColorFromItemStack(itemstack1, k);
|
RenderUtils.setGLColorFromInt(itemstack1.getItem().getColorFromItemStack(itemstack1, k));
|
||||||
float f12 = (i >> 16 & 255) / 255.0F;
|
|
||||||
float f4 = (i >> 8 & 255) / 255.0F;
|
|
||||||
float f5 = (i & 255) / 255.0F;
|
|
||||||
GL11.glColor4f(f12, f4, f5, 1.0F);
|
|
||||||
this.renderManager.itemRenderer.renderItem(robot, itemstack1, k);
|
this.renderManager.itemRenderer.renderItem(robot, itemstack1, k);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int k = itemstack1.getItem().getColorFromItemStack(itemstack1, 0);
|
RenderUtils.setGLColorFromInt(itemstack1.getItem().getColorFromItemStack(itemstack1, 0));
|
||||||
float f11 = (k >> 16 & 255) / 255.0F;
|
|
||||||
float f12 = (k >> 8 & 255) / 255.0F;
|
|
||||||
float f4 = (k & 255) / 255.0F;
|
|
||||||
GL11.glColor4f(f11, f12, f4, 1.0F);
|
|
||||||
this.renderManager.itemRenderer.renderItem(robot, itemstack1, 0);
|
this.renderManager.itemRenderer.renderItem(robot, itemstack1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GL11.glColor3f(1, 1, 1);
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,12 +139,14 @@ public class RenderRobot extends Render implements IItemRenderer {
|
||||||
robot.laser.head.z = robot.posZ;
|
robot.laser.head.z = robot.posZ;
|
||||||
|
|
||||||
RenderLaser.doRenderLaser(renderManager.renderEngine, robot.laser, EntityLaser.LASER_TEXTURES [1]);
|
RenderLaser.doRenderLaser(renderManager.renderEngine, robot.laser, EntityLaser.LASER_TEXTURES [1]);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if (robot.getTexture() != null) {
|
||||||
|
renderManager.renderEngine.bindTexture(robot.getTexture());
|
||||||
|
doRenderRobot(1F / 16F, renderManager.renderEngine);
|
||||||
}
|
}
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -191,19 +178,19 @@ public class RenderRobot extends Render implements IItemRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
|
if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
|
||||||
GL11.glTranslated(-0.0, 1.0, 0.7);
|
GL11.glTranslated(0.0, 1.0, 0.7);
|
||||||
} else if (type == ItemRenderType.ENTITY) {
|
} else if (type == ItemRenderType.ENTITY) {
|
||||||
GL11.glScaled(0.6, 0.6, 0.6);
|
GL11.glScaled(0.6, 0.6, 0.6);
|
||||||
} else if (type == ItemRenderType.INVENTORY) {
|
} else if (type == ItemRenderType.INVENTORY) {
|
||||||
GL11.glScaled(1.5, 1.5, 1.5);
|
GL11.glScaled(1.5, 1.5, 1.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
box.render(1F / 16F);
|
doRenderRobot(1F / 16F, RenderManager.instance.renderEngine);
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doRenderItem(ItemStack stack, float light) {
|
private void doRenderItem(ItemStack stack) {
|
||||||
float renderScale = 0.5f;
|
float renderScale = 0.5f;
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glTranslatef(0, 0.28F, 0);
|
GL11.glTranslatef(0, 0.28F, 0);
|
||||||
|
@ -212,7 +199,23 @@ public class RenderRobot extends Render implements IItemRenderer {
|
||||||
customRenderItem.doRender(dummyEntityItem, 0, 0, 0, 0, 0);
|
customRenderItem.doRender(dummyEntityItem, 0, 0, 0, 0, 0);
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void doRenderRobot(float factor, TextureManager texManager) {
|
||||||
|
box.render(factor);
|
||||||
|
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
texManager.bindTexture(overlay);
|
||||||
|
GL11.glEnable(GL11.GL_BLEND);
|
||||||
|
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||||
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
|
||||||
|
GL11.glDepthMask(true);
|
||||||
|
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 61680 % 65536, 61680 / 65536);
|
||||||
|
box.render(factor);
|
||||||
|
GL11.glDisable(GL11.GL_BLEND);
|
||||||
|
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||||
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue