The Calcinator now renders as a 3D object when dropped in world, held in hand, or in the players inventory. Thanks Soaryn for the help!

This commit is contained in:
pahimar 2012-10-09 15:03:19 -04:00
parent a985fc9bac
commit c211e0ab2e
3 changed files with 134 additions and 54 deletions

View file

@ -12,9 +12,11 @@ import ee3.client.core.handlers.KeyBindingHandler;
import ee3.client.core.handlers.SoundHandler;
import ee3.client.lib.KeyBindings;
import ee3.client.render.RenderCalcinator;
import ee3.client.render.RenderItemCalcinator;
import ee3.client.render.TextureRedWaterFX;
import ee3.client.render.TextureRedWaterFlowFX;
import ee3.common.core.CommonProxy;
import ee3.common.lib.BlockIds;
import ee3.common.lib.Reference;
import ee3.common.lib.RenderIds;
import ee3.common.tile.TileCalcinator;
@ -74,6 +76,8 @@ public class ClientProxy extends CommonProxy {
FMLClientHandler.instance().getClient().renderEngine.registerTextureFX(new TextureRedWaterFX());
FMLClientHandler.instance().getClient().renderEngine.registerTextureFX(new TextureRedWaterFlowFX());
MinecraftForgeClient.registerItemRenderer(BlockIds.CALCINATOR, new RenderItemCalcinator());
}
@Override

View file

@ -13,11 +13,12 @@ public class ModelCalcinator extends ModelBase {
private static final int TEXTURE_HEIGHT = 128;
private static final int TEXTURE_WIDTH = 128;
private ModelRenderer firePotBottom, firePotLeft, firePotRight, firePotFront, firePotBack;
private ModelRenderer legFrontLeft, legFrontRight, legBackLeft, legBackRight;
private ModelRenderer armFrontLeft, armFrontRight, armBackLeft, armBackRight;
private ModelRenderer firePlate;
private ModelRenderer bowlBottom, bowlLeft, bowlRight, bowlFront, bowlBack;
private ModelRenderer ashLayer;
private ModelRenderer firePotEmbers, bowlEmbers;
private float scale;
public ModelCalcinator(float scale) {
@ -25,67 +26,94 @@ public class ModelCalcinator extends ModelBase {
this.textureHeight = TEXTURE_HEIGHT;
this.textureWidth = TEXTURE_WIDTH;
this.firePotLeft = new ModelRenderer(this, 0, 36);
this.firePotLeft.addBox(-0.5F, -1.5F, -4F, 1, 3, 8, scale);
this.firePotLeft.setRotationPoint(3.5F, 1F, 0F);
this.firePotRight = new ModelRenderer(this, 0, 36);
this.firePotRight.addBox(-0.5F, -1.5F, -4F, 1, 3, 8, scale);
this.firePotRight.setRotationPoint(-3.5F, 1F, 0F);
this.firePotBack = new ModelRenderer(this, 0, 36);
this.firePotBack.addBox(-3F, -1.5F, -0.5F, 6, 3, 1, scale);
this.firePotBack.setRotationPoint(0F, 1F, -3.5F);
this.firePotFront = new ModelRenderer(this, 0, 36);
this.firePotFront.addBox(-3F, -1.5F, -0.5F, 6, 3, 1, scale);
this.firePotFront.setRotationPoint(0F, 1F, 3.5F);
this.firePotBottom = new ModelRenderer(this, 0, 36);
this.firePotBottom.addBox(-3F, -0.5F, -3F, 6, 1, 6, scale);
this.firePotBottom.setRotationPoint(8, 2, 8);
this.firePotBottom.addChild(this.firePotBack);
this.firePotBottom.addChild(this.firePotFront);
this.firePotBottom.addChild(this.firePotLeft);
this.firePotBottom.addChild(this.firePotRight);
this.legFrontLeft = new ModelRenderer(this, 0, 0);
this.legFrontLeft.addBox(-1F, -8F, -1F, 2, 8, 2, scale);
this.legFrontLeft.setRotationPoint(-9F, 4, 0);
this.legFrontLeft.setRotationPoint(-9F, 6, 0);
this.legFrontRight = new ModelRenderer(this, 0, 0);
this.legFrontRight.addBox(-1F, -8F, -1F, 2, 8, 2, scale);
this.legFrontRight.setRotationPoint(9F, 4, 0);
this.legFrontRight.setRotationPoint(9F, 6, 0);
this.legBackLeft = new ModelRenderer(this, 0, 0);
this.legBackLeft.addBox(-1F, -8F, -1F, 2, 8, 2, scale);
this.legBackLeft.setRotationPoint(0, 4, -9F);
this.legBackLeft.setRotationPoint(0, 6, -9F);
this.legBackRight = new ModelRenderer(this, 0, 0);
this.legBackRight.addBox(-1F, -8F, -1F, 2, 8, 2, scale);
this.legBackRight.setRotationPoint(0, 4, 9F);
this.legBackRight.setRotationPoint(0, 6, 9F);
this.armFrontLeft = new ModelRenderer(this, 0, 10);
this.armFrontLeft.addBox(-2F, -1F, -1F, 4, 2, 2, scale);
this.armFrontLeft.setRotationPoint(6, 0, 0);
this.armFrontLeft.addBox(-2F, -0.5F, -1F, 4, 1, 2, scale);
this.armFrontLeft.setRotationPoint(6, 1, 0);
this.armFrontRight = new ModelRenderer(this, 0, 10);
this.armFrontRight.addBox(-2F, -1F, -1F, 4, 2, 2, scale);
this.armFrontRight.setRotationPoint(-6, 0, 0);
this.armFrontRight.addBox(-2F, -0.5F, -1F, 4, 1, 2, scale);
this.armFrontRight.setRotationPoint(-6, 1, 0);
this.armBackLeft = new ModelRenderer(this, 12, 10);
this.armBackLeft.addBox(-1F, -1F, -2.0F, 2, 2, 4, scale);
this.armBackLeft.setRotationPoint(0, 0, 6);
this.armBackLeft.addBox(-1F, -0.5F, -2.0F, 2, 1, 4, scale);
this.armBackLeft.setRotationPoint(0, 1, 6);
this.armBackRight = new ModelRenderer(this, 12, 10);
this.armBackRight.addBox(-1F, -1F, -2.0F, 2, 2, 4, scale);
this.armBackRight.setRotationPoint(0, 0, -6);
this.armBackRight.addBox(-1F, -0.5F, -2.0F, 2, 1, 4, scale);
this.armBackRight.setRotationPoint(0, 1, -6);
this.firePlate = new ModelRenderer(this, 8, 0);
this.firePlate.addBox(-4F, -1F, -4F, 8, 2, 8, scale);
this.firePlate.setRotationPoint(8, 4, 8);
this.firePlate.rotateAngleY = ((float) Math.PI / 4F);
this.firePlate.addChild(this.legFrontLeft);
this.firePlate.addChild(this.legFrontRight);
this.firePlate.addChild(this.legBackLeft);
this.firePlate.addChild(this.legBackRight);
this.firePlate.addChild(this.armFrontLeft);
this.firePlate.addChild(this.armFrontRight);
this.firePlate.addChild(this.armBackLeft);
this.firePlate.addChild(this.armBackRight);
this.firePotBottom.addChild(this.legFrontLeft);
this.firePotBottom.addChild(this.legFrontRight);
this.firePotBottom.addChild(this.legBackLeft);
this.firePotBottom.addChild(this.legBackRight);
this.firePotBottom.addChild(this.armFrontLeft);
this.firePotBottom.addChild(this.armFrontRight);
this.firePotBottom.addChild(this.armBackLeft);
this.firePotBottom.addChild(this.armBackRight);
this.firePotBottom.rotateAngleY = (float)(Math.PI / 4F);
this.bowlBack = new ModelRenderer(this, 0, 36);
this.bowlBack.addBox(-8F, -3.5F, -0.5F, 16, 7, 1, scale);
this.bowlBack.setRotationPoint(0F, 3.6F, 7.5F);
this.bowlFront = new ModelRenderer(this, 0, 36);
this.bowlFront.addBox(-8F, -3.5F, -0.5F, 16, 7, 1, scale);
this.bowlFront.setRotationPoint(0, 3.6F, -7.5F);
this.bowlLeft = new ModelRenderer(this, 0, 44);
this.bowlLeft.addBox(-0.5F, -3.5F, -7F, 1, 7, 14, scale);
this.bowlLeft.setRotationPoint(7.5F, 3.6F, 0);
this.bowlRight = new ModelRenderer(this, 0, 44);
this.bowlRight.addBox(-0.5F, -3.5F, -7F, 1, 7, 14, scale);
this.bowlRight.setRotationPoint(-7.5F, 3.6F, 0);
this.bowlBottom = new ModelRenderer(this, 0, 19);
this.bowlBottom.addBox(-8F, -1F, -8F, 16, 1, 16, scale);
this.bowlBottom.setRotationPoint(8, 9, 8);
this.bowlBack = new ModelRenderer(this, 0, 36);
this.bowlBack.addBox(-8F, -3.5F, -0.5F, 16, 7, 1, scale);
this.bowlBack.setRotationPoint(8F, 12.5F, 0.5F);
this.bowlFront = new ModelRenderer(this, 0, 36);
this.bowlFront.addBox(-8F, -3.5F, -0.5F, 16, 7, 1, scale);
this.bowlFront.setRotationPoint(8, 12.5F, 15.5F);
this.bowlLeft = new ModelRenderer(this, 0, 44);
this.bowlLeft.addBox(-0.5F, -3.5F, -7F, 1, 7, 14, scale);
this.bowlLeft.setRotationPoint(0.5F, 12.5F, 8);
this.bowlRight = new ModelRenderer(this, 0, 44);
this.bowlRight.addBox(-0.5F, -3.5F, -7F, 1, 7, 14, scale);
this.bowlRight.setRotationPoint(15.5F, 12.5F, 8);
this.bowlBottom.addChild(this.bowlBack);
this.bowlBottom.addChild(this.bowlFront);
this.bowlBottom.addChild(this.bowlLeft);
this.bowlBottom.addChild(this.bowlRight);
this.bowlEmbers = new ModelRenderer(this, 0, 65);
this.bowlEmbers.addBox(-7F, -0.5F, -7F, 14, 1, 14, scale);
this.bowlEmbers.setRotationPoint(8, 9, 8);
this.bowlEmbers.mirror = true;
this.firePotEmbers = new ModelRenderer(this, 0, 65);
this.firePotEmbers.addBox(-3F, -0.5F, -3F, 6, 1, 6, scale);
this.firePotEmbers.setRotationPoint(8, 3, 8);
this.firePotEmbers.rotateAngleY = (float)(Math.PI / 4F);
this.ashLayer = new ModelRenderer(this, 0, 65);
this.ashLayer.addBox(-7F, -0.5F, -7F, 14, 1, 14, scale);
this.ashLayer.setRotationPoint(8, 9, 8);
this.ashLayer.mirror = true;
}
public void render(TileCalcinator calcinator, double x, double y, double z) {
@ -95,21 +123,20 @@ public class ModelCalcinator extends ModelBase {
GL11.glTranslated(x, y, z);
ForgeHooksClient.bindTexture(Reference.SPRITE_SHEET_LOCATION + "calcinator.png", 0);
// TODO Make a fire pot instead of a plate
firePlate.render(scale);
// TODO Merge this together better
firePotBottom.render(scale);
bowlBottom.render(scale);
bowlBack.render(scale);
bowlFront.render(scale);
bowlLeft.render(scale);
bowlRight.render(scale);
ashLayer.render(scale);
firePotEmbers.render(scale);
bowlEmbers.render(scale);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
}
public void render(float scale) {
firePotBottom.render(scale);
bowlBottom.render(scale);
firePotEmbers.render(scale);
bowlEmbers.render(scale);
}
}

View file

@ -0,0 +1,49 @@
package ee3.client.render;
import org.lwjgl.opengl.GL11;
import ee3.common.lib.Reference;
import net.minecraft.src.ItemStack;
import net.minecraft.src.Tessellator;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.client.IItemRenderer;
public class RenderItemCalcinator implements IItemRenderer {
private ModelCalcinator calcinatorModel;
public RenderItemCalcinator() {
calcinatorModel = new ModelCalcinator(1/16F);
}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return true;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return true;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
switch (type) {
case ENTITY: renderCalcinator(-0.5F, 0.5F, -0.5F); break;
case EQUIPPED: renderCalcinator(0F, 0.4F, 0F); break;
case INVENTORY: renderCalcinator(1F, 0.65F, 1F); break;
default: break;
}
}
private void renderCalcinator(float x, float y, float z) {
Tessellator tesselator = Tessellator.instance;
ForgeHooksClient.bindTexture(Reference.SPRITE_SHEET_LOCATION + "calcinator.png", 0);
GL11.glPushMatrix(); //start
GL11.glTranslatef(x, y, z); //size
calcinatorModel.render(0.0625F);
GL11.glPopMatrix(); //end
}
}