Merge pull request #2281 from ganymedes01/patch-1
Various small rendering tweaks to robots
This commit is contained in:
commit
2971bc95f2
1 changed files with 8 additions and 125 deletions
|
@ -12,23 +12,17 @@ import java.util.Date;
|
|||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
|
||||
import buildcraft.BuildCraftSilicon;
|
||||
import buildcraft.core.EntityLaser;
|
||||
|
@ -72,7 +66,6 @@ public class RenderRobot extends Render implements IItemRenderer {
|
|||
|
||||
private void doRender(EntityRobot robot, double x, double y, double z, float f, float f1) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glTranslated(x, y, z);
|
||||
|
||||
try {
|
||||
|
@ -80,7 +73,6 @@ public class RenderRobot extends Render implements IItemRenderer {
|
|||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// TODO: Figure out why the NPE inside Minecraft happens.
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glPopMatrix();
|
||||
return;
|
||||
}
|
||||
|
@ -166,7 +158,6 @@ public class RenderRobot extends Render implements IItemRenderer {
|
|||
|
||||
}
|
||||
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
|
@ -182,144 +173,36 @@ public class RenderRobot extends Render implements IItemRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,
|
||||
ItemRendererHelper helper) {
|
||||
|
||||
if (helper == ItemRendererHelper.BLOCK_3D) {
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
return true;
|
||||
} else {
|
||||
return helper == ItemRendererHelper.INVENTORY_BLOCK;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
if (RenderManager.instance == null
|
||||
|| RenderManager.instance.renderEngine == null) {
|
||||
if (RenderManager.instance == null || RenderManager.instance.renderEngine == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
RenderBlocks renderBlocks = (RenderBlocks) data[0];
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
|
||||
if (item.getItem() == BuildCraftSilicon.robotItem) {
|
||||
ItemRobot robot = (ItemRobot) item.getItem();
|
||||
RenderManager.instance.renderEngine.bindTexture(robot.getTextureRobot(item));
|
||||
}
|
||||
|
||||
float factor = (float) (1.0 / 16.0);
|
||||
|
||||
if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
|
||||
GL11.glTranslated(0.25F, 0.5F, 0);
|
||||
GL11.glTranslated(-0.0, 1.0, 0.7);
|
||||
} else if (type == ItemRenderType.ENTITY) {
|
||||
GL11.glScaled(0.6, 0.6, 0.6);
|
||||
} else if (type == ItemRenderType.INVENTORY) {
|
||||
GL11.glScaled(1.5, 1.5, 1.5);
|
||||
}
|
||||
|
||||
box.render(1F / 16F);
|
||||
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a refactor from the code of RenderPlayer.
|
||||
*/
|
||||
public void doRenderItemAtHand(EntityRobot robot, ItemStack currentItem) {
|
||||
ItemStack itemstack1 = currentItem;
|
||||
float f3, f5;
|
||||
|
||||
if (itemstack1 != null) {
|
||||
GL11.glPushMatrix();
|
||||
// this.modelBipedMain.bipedRightArm.postRender(0.0625F);
|
||||
GL11.glTranslatef(-0.0625F, 0.4375F, 0.0625F);
|
||||
|
||||
// if (par1AbstractClientPlayer.fishEntity != null)
|
||||
// {
|
||||
// itemstack1 = new ItemStack(Items.stick);
|
||||
// }
|
||||
|
||||
EnumAction enumaction = EnumAction.none;
|
||||
|
||||
// if (par1AbstractClientPlayer.getItemInUseCount() > 0)
|
||||
// {
|
||||
// enumaction = itemstack1.getItemUseAction();
|
||||
// }
|
||||
|
||||
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack1, ItemRenderType.EQUIPPED);
|
||||
boolean is3D = customRenderer != null && customRenderer.shouldUseRenderHelper(ItemRenderType.EQUIPPED,
|
||||
itemstack1,
|
||||
ItemRendererHelper.BLOCK_3D);
|
||||
|
||||
if (is3D || itemstack1.getItem() instanceof ItemBlock
|
||||
&& RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemstack1.getItem()).getRenderType())) {
|
||||
f3 = 0.5F;
|
||||
GL11.glTranslatef(0.0F, 0.1875F, -0.3125F);
|
||||
f3 *= 0.75F;
|
||||
GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glScalef(-f3, -f3, f3);
|
||||
} else if (itemstack1.getItem() == Items.bow) {
|
||||
f3 = 0.625F;
|
||||
GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
|
||||
GL11.glRotatef(-20.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glScalef(f3, -f3, f3);
|
||||
GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
|
||||
} else if (itemstack1.getItem().isFull3D()) {
|
||||
f3 = 0.625F;
|
||||
|
||||
if (itemstack1.getItem().shouldRotateAroundWhenRendering()) {
|
||||
GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glTranslatef(0.0F, -0.125F, 0.0F);
|
||||
}
|
||||
|
||||
/*
|
||||
* if (par1AbstractClientPlayer.getItemInUseCount() > 0 &&
|
||||
* enumaction == EnumAction.block) { GL11.glTranslatef(0.05F,
|
||||
* 0.0F, -0.1F); GL11.glRotatef(-50.0F, 0.0F, 1.0F, 0.0F);
|
||||
* GL11.glRotatef(-10.0F, 1.0F, 0.0F, 0.0F);
|
||||
* GL11.glRotatef(-60.0F, 0.0F, 0.0F, 1.0F); }
|
||||
*/
|
||||
|
||||
GL11.glTranslatef(0.0F, 0.1875F, 0.0F);
|
||||
GL11.glScalef(f3, -f3, f3);
|
||||
GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
|
||||
} else {
|
||||
f3 = 0.375F;
|
||||
GL11.glTranslatef(0.25F, 0.1875F, -0.1875F);
|
||||
GL11.glScalef(f3, f3, f3);
|
||||
GL11.glRotatef(60.0F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(20.0F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
float f4;
|
||||
int k;
|
||||
float f12;
|
||||
|
||||
if (itemstack1.getItem().requiresMultipleRenderPasses()) {
|
||||
for (k = 0; k < itemstack1.getItem().getRenderPasses(itemstack1.getItemDamage()); ++k) {
|
||||
int i = itemstack1.getItem().getColorFromItemStack(itemstack1, k);
|
||||
f12 = (i >> 16 & 255) / 255.0F;
|
||||
f4 = (i >> 8 & 255) / 255.0F;
|
||||
f5 = (i & 255) / 255.0F;
|
||||
GL11.glColor4f(f12, f4, f5, 1.0F);
|
||||
this.renderManager.itemRenderer.renderItem(robot, itemstack1, k);
|
||||
}
|
||||
} else {
|
||||
k = itemstack1.getItem().getColorFromItemStack(itemstack1, 0);
|
||||
float f11 = (k >> 16 & 255) / 255.0F;
|
||||
f12 = (k >> 8 & 255) / 255.0F;
|
||||
f4 = (k & 255) / 255.0F;
|
||||
GL11.glColor4f(f11, f12, f4, 1.0F);
|
||||
this.renderManager.itemRenderer.renderItem(robot, itemstack1, 0);
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
private void doRenderItem(ItemStack stack, float light) {
|
||||
float renderScale = 0.5f;
|
||||
GL11.glPushMatrix();
|
||||
|
|
Loading…
Reference in a new issue