Skip to content

Commit

Permalink
Fix entity rendering, but screw up all the animations n stuff.. sigh
Browse files Browse the repository at this point in the history
  • Loading branch information
bonii-xx committed Oct 10, 2014
1 parent 2988b75 commit 69fad3c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 31 deletions.
54 changes: 26 additions & 28 deletions src/main/java/tconstruct/client/FlexibleToolRenderer.java
Expand Up @@ -101,6 +101,8 @@ public void renderItem (ItemRenderType type, ItemStack item, Object... data) {

specialAnimation(type, item);
}
else
GL11.glTranslatef(-0.5f, -0.25f, 0); // why? because.. minecraft.

// prepare colors
int[] color = new int[iconParts];
Expand All @@ -113,10 +115,10 @@ public void renderItem (ItemRenderType type, ItemStack item, Object... data) {
for (int i = 0; i < iconParts; ++i)
{
tess.setColorOpaque_I(color[i]);
tess.addVertexWithUV(-0.5, -0.5, +depth, xMax[i], yMax[i]);
tess.addVertexWithUV(+0.5, -0.5, +depth, xMin[i], yMax[i]);
tess.addVertexWithUV(+0.5, +0.5, +depth, xMin[i], yMin[i]);
tess.addVertexWithUV(-0.5, +0.5, +depth, xMax[i], yMin[i]);
tess.addVertexWithUV(0, 0, +depth, xMax[i], yMax[i]);
tess.addVertexWithUV(1, 0, +depth, xMin[i], yMax[i]);
tess.addVertexWithUV(1, 1, +depth, xMin[i], yMin[i]);
tess.addVertexWithUV(0, 1, +depth, xMax[i], yMin[i]);
}
tess.draw();

Expand All @@ -126,10 +128,10 @@ public void renderItem (ItemRenderType type, ItemStack item, Object... data) {
for (int i = 0; i < iconParts; ++i)
{
tess.setColorOpaque_I(color[i]);
tess.addVertexWithUV(-0.5, +0.5, -depth, xMax[i], yMin[i]);
tess.addVertexWithUV(+0.5, +0.5, -depth, xMin[i], yMin[i]);
tess.addVertexWithUV(+0.5, -0.5, -depth, xMin[i], yMax[i]);
tess.addVertexWithUV(-0.5, -0.5, -depth, xMax[i], yMax[i]);
tess.addVertexWithUV(0, 1, -depth, xMax[i], yMin[i]);
tess.addVertexWithUV(1, 1, -depth, xMin[i], yMin[i]);
tess.addVertexWithUV(1, 0, -depth, xMin[i], yMax[i]);
tess.addVertexWithUV(0, 0, -depth, xMax[i], yMax[i]);
}
tess.draw();

Expand All @@ -147,11 +149,10 @@ public void renderItem (ItemRenderType type, ItemStack item, Object... data) {
{
pos = k / w;
iconPos = m + d * pos - s;
pos -= 0.5f;
tess.addVertexWithUV(pos, -0.5, -depth, iconPos, yMax[i]);
tess.addVertexWithUV(pos, -0.5, +depth, iconPos, yMax[i]);
tess.addVertexWithUV(pos, +0.5, +depth, iconPos, yMin[i]);
tess.addVertexWithUV(pos, +0.5, -depth, iconPos, yMin[i]);
tess.addVertexWithUV(pos, 0, -depth, iconPos, yMax[i]);
tess.addVertexWithUV(pos, 0, +depth, iconPos, yMax[i]);
tess.addVertexWithUV(pos, 1, +depth, iconPos, yMin[i]);
tess.addVertexWithUV(pos, 1, -depth, iconPos, yMin[i]);
}
}

Expand All @@ -169,12 +170,11 @@ public void renderItem (ItemRenderType type, ItemStack item, Object... data) {
{
pos = k / w;
iconPos = m + d * pos - s;
pos -= 0.5f;
posEnd = pos + d2;
tess.addVertexWithUV(posEnd, +0.5, -depth, iconPos, yMin[i]);
tess.addVertexWithUV(posEnd, +0.5, +depth, iconPos, yMin[i]);
tess.addVertexWithUV(posEnd, -0.5, +depth, iconPos, yMax[i]);
tess.addVertexWithUV(posEnd, -0.5, -depth, iconPos, yMax[i]);
tess.addVertexWithUV(posEnd, 1, -depth, iconPos, yMin[i]);
tess.addVertexWithUV(posEnd, 1, +depth, iconPos, yMin[i]);
tess.addVertexWithUV(posEnd, 0, +depth, iconPos, yMax[i]);
tess.addVertexWithUV(posEnd, 0, -depth, iconPos, yMax[i]);
}
}

Expand All @@ -191,12 +191,11 @@ public void renderItem (ItemRenderType type, ItemStack item, Object... data) {
{
pos = k / h;
iconPos = m + d * pos - s;
pos -= 0.5f;
posEnd = pos + d2;
tess.addVertexWithUV(-0.5, posEnd, +depth, xMax[i], iconPos);
tess.addVertexWithUV(+0.5, posEnd, +depth, xMin[i], iconPos);
tess.addVertexWithUV(+0.5, posEnd, -depth, xMin[i], iconPos);
tess.addVertexWithUV(-0.5, posEnd, -depth, xMax[i], iconPos);
tess.addVertexWithUV(0, posEnd, +depth, xMax[i], iconPos);
tess.addVertexWithUV(1, posEnd, +depth, xMin[i], iconPos);
tess.addVertexWithUV(1, posEnd, -depth, xMin[i], iconPos);
tess.addVertexWithUV(0, posEnd, -depth, xMax[i], iconPos);
}
}

Expand All @@ -212,11 +211,10 @@ public void renderItem (ItemRenderType type, ItemStack item, Object... data) {
{
pos = k / h;
iconPos = m + d * pos - s;
pos -= 0.5f;
tess.addVertexWithUV(+0.5, pos, +depth, xMin[i], iconPos);
tess.addVertexWithUV(-0.5, pos, +depth, xMax[i], iconPos);
tess.addVertexWithUV(-0.5, pos, -depth, xMax[i], iconPos);
tess.addVertexWithUV(+0.5, pos, -depth, xMin[i], iconPos);
tess.addVertexWithUV(1, pos, +depth, xMin[i], iconPos);
tess.addVertexWithUV(0, pos, +depth, xMax[i], iconPos);
tess.addVertexWithUV(0, pos, -depth, xMax[i], iconPos);
tess.addVertexWithUV(1, pos, -depth, xMin[i], iconPos);
}
}

Expand Down
Expand Up @@ -33,7 +33,7 @@ public void doRender(T entity, double x, double y, double z, float p_76986_8_, f
GL11.glEnable(GL12.GL_RESCALE_NORMAL);

// last step: translate from 0/0/0 to correct position in world
GL11.glTranslatef((float) x, (float) y, (float) z);
GL11.glTranslated(x, y, z);
// mkae it smaller
GL11.glScalef(0.5F, 0.5F, 0.5F);

Expand All @@ -50,7 +50,9 @@ public void doRender(T entity, double x, double y, double z, float p_76986_8_, f
// draw correct texture. not some weird block fragments.
renderManager.renderEngine.bindTexture(TextureMap.locationItemsTexture);
// rendering code has been optimized to be exactly at the center and without translation
GL11.glTranslatef(0.0f, -0.25f, 0);
toolCoreRenderer.renderItem(IItemRenderer.ItemRenderType.ENTITY, entity.getEntityItem());
GL11.glTranslatef(0.0f, 0.25f, 0);

GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/tconstruct/weaponry/entity/ShurikenEntity.java
Expand Up @@ -43,13 +43,14 @@ public void readSpawnData(ByteBuf data) {
super.readSpawnData(data);

// this is only relevant clientside only, so we don't actually have it on the server
rollAngle = (TinkerWeaponry.random.nextInt(3)-1)*45 + TinkerWeaponry.random.nextInt(30)-15;
//rollAngle = (TinkerWeaponry.random.nextInt(3)-1)*45 + TinkerWeaponry.random.nextInt(30)-15;
spin = TinkerWeaponry.random.nextInt(360);
}

@Override
protected double getGravity() {
return (this.ticksExisted/8) * 0.018d; // integer division. so the first 20 ticks it will have no gravity at all.
return 0;
//return (this.ticksExisted/8) * 0.018d; // integer division. so the first 20 ticks it will have no gravity at all.
}

@Override
Expand Down

0 comments on commit 69fad3c

Please sign in to comment.