Java tutorial
/** * Copyright (c) LambdaCraft Modding Team, 2013 * ??LambdaCraft ? 2013. * http://lambdacraft.half-life.cn/ * * LambdaCraft is open-source. It is distributed under the terms of the * LambdaCraft Open Source License. It grants rights to read, modify, compile * or run the code. It does *NOT* grant the right to redistribute this software * or its modifications in any form, binary or source, except if expressively * granted by the copyright holder. * * LambdaCraft???LambdaCraft?????? * ?? ?????????? */ package cn.lambdacraft.terrain.client.model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import org.lwjgl.opengl.GL11; import cn.lambdacraft.core.prop.ClientProps; import cn.liutils.api.client.model.ITileEntityModel; import cn.liutils.api.client.util.RenderUtils; /** * @author WeAthFolD * */ public class ModelXenAmethyst extends ModelBase implements ITileEntityModel { // fields ModelRenderer Shape1; ModelRenderer Shape2; ModelRenderer Shape3; public ModelXenAmethyst() { textureWidth = 64; textureHeight = 32; Shape1 = new ModelRenderer(this, 4, 0); Shape1.addBox(0F, 0F, 0F, 3, 2, 3); Shape1.setRotationPoint(-1F, 21F, -1F); Shape1.setTextureSize(64, 32); Shape1.mirror = true; setRotation(Shape1, 0F, 0F, 0F); Shape2 = new ModelRenderer(this, 0, 10); Shape2.addBox(-1F, 0F, -1F, 5, 3, 5); Shape2.setRotationPoint(-1F, 18F, -1F); Shape2.setTextureSize(64, 32); Shape2.mirror = true; setRotation(Shape2, 0F, 0F, 0F); Shape3 = new ModelRenderer(this, 0, 0); Shape3.addBox(0F, 0F, 0F, 1, 9, 1); Shape3.setRotationPoint(0F, 9F, 0F); Shape3.setTextureSize(64, 32); Shape3.mirror = true; setRotation(Shape3, 0F, 0F, 0F); } @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); Shape1.render(f5); Shape2.render(f5); Shape3.render(f5); } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity e) { super.setRotationAngles(f, f1, f2, f3, f4, f5, e); } @Override public void render(TileEntity is, double x, double y, double z, float f1, float scale, float f) { GL11.glPushMatrix(); // GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5); GL11.glTranslated(x + 0.5, y + 1.6, z + 0.5); GL11.glScalef(-1.0F, -1.0F, 1.0F); RenderUtils.loadTexture(ClientProps.AMETHYST_PATH); Shape1.render(scale); Shape2.render(scale); Shape3.render(scale); GL11.glPopMatrix(); } }