Update rendering to use the vanilla renderitem- 3d items in pipes :)
Fixed for recent MCP update in forge as well. Refreshed the TileEntityPickupFX code from the vanilla source. Easier to diff against that source too now.
This commit is contained in:
parent
03a14b6444
commit
d7e06e07a3
5 changed files with 97 additions and 198 deletions
|
@ -67,7 +67,7 @@ public class CoreProxy {
|
|||
|
||||
/* ENTITY HANDLING */
|
||||
public void removeEntity(Entity entity) {
|
||||
entity.setDead();
|
||||
entity.worldObj.removeEntity(entity);
|
||||
}
|
||||
|
||||
/* WRAPPER */
|
||||
|
|
|
@ -421,7 +421,7 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
|
|||
continue;
|
||||
}
|
||||
|
||||
ItemStack mineable = entity.func_92014_d();
|
||||
ItemStack mineable = entity.getEntityItem();
|
||||
if (mineable.stackSize <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -215,7 +215,7 @@ public class PipeItemsObsidian extends Pipe implements IPowerReceptor {
|
|||
|
||||
if (entity instanceof EntityItem) {
|
||||
EntityItem item = (EntityItem) entity;
|
||||
ItemStack contained = item.func_92014_d();
|
||||
ItemStack contained = item.getEntityItem();
|
||||
|
||||
CoreProxy.proxy.obsidianPipePickup(worldObj, item, this.container);
|
||||
|
||||
|
@ -265,7 +265,7 @@ public class PipeItemsObsidian extends Pipe implements IPowerReceptor {
|
|||
if (entity instanceof EntityItem) {
|
||||
EntityItem item = (EntityItem) entity;
|
||||
|
||||
if (item.func_92014_d().stackSize <= 0)
|
||||
if (item.getEntityItem().stackSize <= 0)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < entitiesDropped.length; ++i)
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
package buildcraft.transport.render;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.glScalef;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
|
||||
|
@ -16,6 +18,7 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
|
@ -52,7 +55,9 @@ public class RenderPipe extends TileEntitySpecialRenderer {
|
|||
|
||||
final static private int MAX_ITEMS_TO_RENDER = 10;
|
||||
|
||||
private final static EntityItem dummyEntityItem = new EntityItem(null);
|
||||
private final EntityItem dummyEntityItem = new EntityItem(null);
|
||||
|
||||
private final RenderItem customRenderItem;
|
||||
|
||||
private class DisplayLiquidList {
|
||||
|
||||
|
@ -72,10 +77,16 @@ public class RenderPipe extends TileEntitySpecialRenderer {
|
|||
public int[] displayPowerList = new int[POWER_STAGES];
|
||||
public int[] displayPowerListOverload = new int[POWER_STAGES];
|
||||
|
||||
private RenderBlocks renderBlocks;
|
||||
|
||||
public RenderPipe() {
|
||||
renderBlocks = new RenderBlocks();
|
||||
customRenderItem = new RenderItem() {
|
||||
public boolean shouldBob() {
|
||||
return false;
|
||||
};
|
||||
public boolean shouldSpreadItems() {
|
||||
return false;
|
||||
};
|
||||
};
|
||||
customRenderItem.setRenderManager(RenderManager.instance);
|
||||
}
|
||||
|
||||
private DisplayLiquidList getDisplayLiquidLists(int liquidId, int meta, World world) {
|
||||
|
@ -430,141 +441,14 @@ public class RenderPipe extends TileEntitySpecialRenderer {
|
|||
if (entityitem == null || entityitem.getItemStack() == null)
|
||||
return;
|
||||
|
||||
float renderScale = 0.7f;
|
||||
ItemStack itemstack = entityitem.getItemStack();
|
||||
random.setSeed(187L);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
byte quantity = 1;
|
||||
if (entityitem.getItemStack().stackSize > 1) {
|
||||
quantity = 2;
|
||||
}
|
||||
|
||||
GL11.glTranslatef((float) d, (float) d1, (float) d2);
|
||||
GL11.glEnable(32826 /* GL_RESCALE_NORMAL_EXT */);
|
||||
|
||||
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack, ItemRenderType.ENTITY);
|
||||
|
||||
if (customRenderer != null) {
|
||||
|
||||
GL11.glTranslatef(0, 0.25F, 0); // BC SPECIFIC
|
||||
ForgeHooksClient.bindTexture(itemstack.getItem().getTextureFile(), 0);
|
||||
float f4 = 0.25F;
|
||||
f4 = 0.5F;
|
||||
GL11.glScalef(f4, f4, f4);
|
||||
|
||||
for (int j = 0; j < quantity; j++) {
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
if (j > 0) {
|
||||
float f5 = ((random.nextFloat() * 2.0F - 1.0F) * 0.2F) / f4;
|
||||
float f7 = ((random.nextFloat() * 2.0F - 1.0F) * 0.2F) / f4;
|
||||
float f9 = ((random.nextFloat() * 2.0F - 1.0F) * 0.2F) / f4;
|
||||
GL11.glTranslatef(f5, f7, f9);
|
||||
}
|
||||
|
||||
RenderPipe.dummyEntityItem.func_92013_a(itemstack);
|
||||
|
||||
customRenderer.renderItem(ItemRenderType.ENTITY, itemstack, renderBlocks, RenderPipe.dummyEntityItem);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
} else if (itemstack.itemID < Block.blocksList.length && Block.blocksList[itemstack.itemID] != null && Block.blocksList[itemstack.itemID].blockID != 0) {
|
||||
|
||||
GL11.glTranslatef(0, 0.25F, 0); // BC SPECIFIC
|
||||
|
||||
ForgeHooksClient.bindTexture(Block.blocksList[itemstack.itemID].getTextureFile(), 0);
|
||||
float f4 = 0.25F;
|
||||
int j = Block.blocksList[itemstack.itemID].getRenderType();
|
||||
if (j == 1 || j == 19 || j == 12 || j == 2) {
|
||||
f4 = 0.5F;
|
||||
}
|
||||
|
||||
GL11.glScalef(f4, f4, f4);
|
||||
for (int k = 0; k < quantity; k++) {
|
||||
GL11.glPushMatrix();
|
||||
|
||||
if (k > 0) {
|
||||
float f6 = ((random.nextFloat() * 2.0F - 1.0F) * 0.2F) / f4;
|
||||
float f9 = ((random.nextFloat() * 2.0F - 1.0F) * 0.2F) / f4;
|
||||
float f11 = ((random.nextFloat() * 2.0F - 1.0F) * 0.2F) / f4;
|
||||
GL11.glTranslatef(f6, f9, f11);
|
||||
}
|
||||
|
||||
float f7 = 1.0F;
|
||||
renderBlocks.renderBlockAsItem(Block.blocksList[itemstack.itemID], itemstack.getItemDamage(), f7);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
GL11.glTranslatef(0, 0.10F, 0); // BC SPECIFIC
|
||||
|
||||
if (itemstack.getItem().requiresMultipleRenderPasses()) {
|
||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||
ForgeHooksClient.bindTexture(Item.itemsList[itemstack.itemID].getTextureFile(), 0);
|
||||
|
||||
for (int i = 0; i <= itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++i) {
|
||||
int iconIndex = itemstack.getItem().getIconIndex(itemstack, i);
|
||||
float scale = 1.0F;
|
||||
|
||||
int itemColour = Item.itemsList[itemstack.itemID].getColorFromItemStack(itemstack, i);
|
||||
float rgbR = (itemColour >> 16 & 255) / 255.0F;
|
||||
float rgbG = (itemColour >> 8 & 255) / 255.0F;
|
||||
float rgbB = (itemColour & 255) / 255.0F;
|
||||
GL11.glColor4f(rgbR * scale, rgbG * scale, rgbB * scale, 1.0F);
|
||||
|
||||
this.drawItem(iconIndex, quantity);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||
int i = itemstack.getIconIndex();
|
||||
if (itemstack.itemID < Block.blocksList.length && Block.blocksList[itemstack.itemID] != null && Block.blocksList[itemstack.itemID].blockID != 0) {
|
||||
ForgeHooksClient.bindTexture(Block.blocksList[itemstack.itemID].getTextureFile(), 0);
|
||||
} else {
|
||||
ForgeHooksClient.bindTexture(Item.itemsList[itemstack.itemID].getTextureFile(), 0);
|
||||
}
|
||||
|
||||
drawItem(i, quantity);
|
||||
}
|
||||
|
||||
}
|
||||
GL11.glDisable(32826 /* GL_RESCALE_NORMAL_EXT */);
|
||||
GL11.glTranslatef(0, 0.25F, 0);
|
||||
GL11.glScalef(renderScale, renderScale, renderScale);
|
||||
dummyEntityItem.func_92058_a(itemstack);
|
||||
customRenderItem.doRenderItem(dummyEntityItem, 0, 0, 0, 0, 0);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void drawItem(int iconIndex, int quantity) {
|
||||
Tessellator tesselator = Tessellator.instance;
|
||||
float var4 = (iconIndex % 16 * 16 + 0) / 256.0F;
|
||||
float var5 = (iconIndex % 16 * 16 + 16) / 256.0F;
|
||||
float var6 = (iconIndex / 16 * 16 + 0) / 256.0F;
|
||||
float var7 = (iconIndex / 16 * 16 + 16) / 256.0F;
|
||||
float var8 = 1.0F;
|
||||
float var9 = 0.5F;
|
||||
float var10 = 0.25F;
|
||||
|
||||
for (int var11 = 0; var11 < quantity; ++var11) {
|
||||
GL11.glPushMatrix();
|
||||
|
||||
if (var11 > 0) {
|
||||
float var12 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F;
|
||||
float var13 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F;
|
||||
float var14 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F;
|
||||
GL11.glTranslatef(var12, var13, var14);
|
||||
}
|
||||
|
||||
GL11.glRotatef(180.0F - RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F);
|
||||
tesselator.startDrawingQuads();
|
||||
tesselator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
tesselator.addVertexWithUV((0.0F - var9), (0.0F - var10), 0.0D, var4, var7);
|
||||
tesselator.addVertexWithUV((var8 - var9), (0.0F - var10), 0.0D, var5, var7);
|
||||
tesselator.addVertexWithUV((var8 - var9), (1.0F - var10), 0.0D, var5, var6);
|
||||
tesselator.addVertexWithUV((0.0F - var9), (1.0F - var10), 0.0D, var4, var6);
|
||||
tesselator.draw();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,79 +6,94 @@
|
|||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
/**
|
||||
* Based on {@link EntityPickupFX}
|
||||
*/
|
||||
package buildcraft.transport.render;
|
||||
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.particle.EntityPickupFX;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import buildcraft.core.utils.Utils;
|
||||
|
||||
public class TileEntityPickupFX extends EntityFX {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TileEntityPickupFX extends EntityFX
|
||||
{
|
||||
private Entity entityToPickUp;
|
||||
private TileEntity entityPickingUp;
|
||||
private int age = 0;
|
||||
private int maxAge = 0;
|
||||
|
||||
private double yDestination;
|
||||
/** renamed from yOffset to fix shadowing Entity.yOffset */
|
||||
private double yOffs;
|
||||
|
||||
public TileEntityPickupFX(World world, EntityItem entity, TileEntity entity1) {
|
||||
super(world, entity.posX, entity.posY, entity.posZ, entity.motionX, entity.motionY, entity.motionZ);
|
||||
field_678_p = 0;
|
||||
field_677_q = 0;
|
||||
field_675_a = entity;
|
||||
field_679_o = entity1;
|
||||
field_677_q = 3;
|
||||
public TileEntityPickupFX(World par1World, EntityItem par2Entity, TileEntity par3Entity)
|
||||
{
|
||||
super(par1World, par2Entity.posX, par2Entity.posY, par2Entity.posZ, par2Entity.motionX, par2Entity.motionY, par2Entity.motionZ);
|
||||
this.entityToPickUp = par2Entity;
|
||||
this.entityPickingUp = par3Entity;
|
||||
this.maxAge = 3;
|
||||
this.yOffs = Utils.getPipeFloorOf(par2Entity.getEntityItem());
|
||||
}
|
||||
|
||||
yDestination = Utils.getPipeFloorOf(entity.func_92014_d());
|
||||
}
|
||||
@Override
|
||||
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
|
||||
{
|
||||
float var8 = ((float)this.age + par2) / (float)this.maxAge;
|
||||
var8 *= var8;
|
||||
double var9 = this.entityToPickUp.posX;
|
||||
double var11 = this.entityToPickUp.posY;
|
||||
double var13 = this.entityToPickUp.posZ;
|
||||
double var15 = this.entityPickingUp.xCoord + 0.5;
|
||||
double var17 = this.entityPickingUp.yCoord + yOffs;
|
||||
double var19 = this.entityPickingUp.zCoord + 0.5;
|
||||
double var21 = var9 + (var15 - var9) * (double)var8;
|
||||
double var23 = var11 + (var17 - var11) * (double)var8;
|
||||
double var25 = var13 + (var19 - var13) * (double)var8;
|
||||
int var27 = MathHelper.floor_double(var21);
|
||||
int var28 = MathHelper.floor_double(var23 + (double)(this.yOffset / 2.0F));
|
||||
int var29 = MathHelper.floor_double(var25);
|
||||
int var30 = this.getBrightnessForRender(par2);
|
||||
int var31 = var30 % 65536;
|
||||
int var32 = var30 / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)var31 / 1.0F, (float)var32 / 1.0F);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
var21 -= interpPosX;
|
||||
var23 -= interpPosY;
|
||||
var25 -= interpPosZ;
|
||||
if (RenderManager.instance.renderEngine != null) {
|
||||
RenderManager.instance.renderEntityWithPosYaw(this.entityToPickUp, (double)((float)var21), (double)((float)var23), (double)((float)var25), this.entityToPickUp.rotationYaw, par2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) {
|
||||
float f6 = (field_678_p + f) / field_677_q;
|
||||
f6 *= f6;
|
||||
double d = field_675_a.posX;
|
||||
double d1 = field_675_a.posY;
|
||||
double d2 = field_675_a.posZ;
|
||||
double d3 = field_679_o.xCoord + 0.5;
|
||||
double d4 = field_679_o.yCoord + yDestination;
|
||||
double d5 = field_679_o.zCoord + 0.5;
|
||||
double d6 = d + (d3 - d) * f6;
|
||||
double d7 = d1 + (d4 - d1) * f6;
|
||||
double d8 = d2 + (d5 - d2) * f6;
|
||||
int i = MathHelper.floor_double(d6);
|
||||
int j = MathHelper.floor_double(d7 + (yOffset / 2.0F));
|
||||
int k = MathHelper.floor_double(d8);
|
||||
float f7 = worldObj.getLightBrightness(i, j, k);
|
||||
d6 -= interpPosX;
|
||||
d7 -= interpPosY;
|
||||
d8 -= interpPosZ;
|
||||
GL11.glColor4f(f7, f7, f7, 1.0F);
|
||||
/**
|
||||
* Called to update the entity's position/logic.
|
||||
*/
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
++this.age;
|
||||
|
||||
if (RenderManager.instance.renderEngine != null) {
|
||||
RenderManager.instance.renderEntityWithPosYaw(field_675_a, (float) d6, (float) d7, (float) d8, field_675_a.rotationYaw, f);
|
||||
}
|
||||
}
|
||||
if (this.age == this.maxAge)
|
||||
{
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
field_678_p++;
|
||||
if (field_678_p == field_677_q) {
|
||||
setDead();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
private Entity field_675_a;
|
||||
private TileEntity field_679_o;
|
||||
private int field_678_p;
|
||||
private int field_677_q;
|
||||
@Override
|
||||
public int getFXLayer()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue