package game.renderer.layers; import java.util.List; import com.google.common.collect.Lists; import game.Game; import game.entity.npc.EntityNPC; import game.init.SpeciesRegistry.ModelType; import game.renderer.GlState; import game.renderer.blockmodel.ModelGenerator; import game.renderer.model.ModelBox; import game.renderer.model.ModelHumanoid; import game.renderer.model.ModelRenderer; import game.window.WCF; public class LayerExtra implements LayerRenderer { private final List body; private final List head; private final List larm; private final List rarm; private final List wing; private final List halo; private ModelHumanoid model; public LayerExtra(List body, List head, List larm, List rarm, List wing, List halo) { this.body = body; this.head = head; this.larm = larm; this.rarm = rarm; this.wing = wing; this.halo = halo; } public void setModel(ModelHumanoid model) { this.model = model; } public void discard() { for(ModelRenderer model : this.body) model.deleteDisplayList(); for(ModelRenderer model : this.head) model.deleteDisplayList(); for(ModelRenderer model : this.larm) model.deleteDisplayList(); for(ModelRenderer model : this.rarm) model.deleteDisplayList(); for(ModelRenderer model : this.wing) model.deleteDisplayList(); for(ModelRenderer model : this.halo) model.deleteDisplayList(); } public void doRenderLayer(EntityNPC entity, float p_177141_2_, float p_177141_3_, float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale) { EntityNPC extended = entity; // if (!entity.isInvisible()) // { GlState.color(1.0F, 1.0F, 1.0F, 1.0F); Game.getGame().getTextureManager().bindTexture(extended.getLocationSkin()); WCF.glPushMatrix(); if (entity.isSneakingVisually()) { WCF.glTranslatef(0.0F, /* entity.isChild() ? 0.0F : */ 0.2F, 0.0F); } // if (entity.isChild()) // { // float f = 2.0F; // float f1 = 1.4F; // SKC.glScalef(1.0F / f, 1.0F / f, 1.0F / f); // SKC.glTranslatef(0.0F, 24.0F * scale, 0.0F); // } WCF.glPushMatrix(); this.model.bipedBody.postRender(0.0625F); for(ModelRenderer model : this.wing) { if(extended.hasDualWings()) { WCF.glPushMatrix(); WCF.glRotatef(model.rotateAngleY < 0.0f ? -10.0f : 10.0f, 0.0f, 1.0f, 0.0f); WCF.glTranslatef(0.0f, 0.125f, -0.0625f); model.render(0.0625F); WCF.glPopMatrix(); WCF.glPushMatrix(); WCF.glRotatef(model.rotateAngleY < 0.0f ? 10.0f : -10.0f, 0.0f, 1.0f, 0.0f); WCF.glTranslatef(model.rotateAngleY < 0.0f ? 0.0625f : -0.0625f, -0.125f, 0.0f); model.render(0.0625F); WCF.glPopMatrix(); } else { model.render(0.0625F); } } for(ModelRenderer model : this.body) { model.render(0.0625F); } WCF.glPopMatrix(); WCF.glPushMatrix(); this.model.bipedLeftArm.postRender(0.0625F); this.model.slimLeftArm.postRender(0.0625F, -1.0f, 0.0f, 0.0f); for(ModelRenderer model : this.larm) { model.render(0.0625F); } WCF.glPopMatrix(); WCF.glPushMatrix(); this.model.bipedRightArm.postRender(0.0625F); this.model.slimRightArm.postRender(0.0625F, 1.0f, 0.0f, 0.0f); for(ModelRenderer model : this.rarm) { model.render(0.0625F); } WCF.glPopMatrix(); WCF.glPushMatrix(); this.model.bipedHead.postRender(0.0625F); for(ModelRenderer model : this.head) { model.render(0.0625F); } for(ModelRenderer model : this.halo) { WCF.glPushMatrix(); WCF.glRotatef((float)(entity.ticksExisted % (360 * 4)) * 0.25f, 0.0f, 1.0f, 0.0f); model.render(0.0625F); WCF.glPopMatrix(); } WCF.glPopMatrix(); WCF.glPopMatrix(); // } } public boolean shouldCombineTextures() { return false; } public static ModelRenderer addLayer(List models, int[] texture, int w, int h, int tx, int ty, int tw, int th, float xs, float ys, float x, float y, float z, float xr, float yr, float zr) { List elems = ModelGenerator.bakeModel(texture, tx, ty, w, h, xs, ys, 0.0f, tw, th, 1); if(!elems.isEmpty()) { ModelRenderer model = new ModelRenderer(); model.addBoxes(elems); model.setRotationPoint(x, y, z); model.rotateAngleX = xr / (180F / (float)Math.PI); model.rotateAngleY = yr / (180F / (float)Math.PI); model.rotateAngleZ = zr / (180F / (float)Math.PI); models.add(model); return model; } return null; } public static LayerExtra getLayer(int[] texture, int w, int h, ModelType model) { if(w < 64 || h < 20 || (model != ModelType.HUMANOID && model != ModelType.ARACHNOID && model != ModelType.DWARF && model != ModelType.HALFLING)) return null; List body = Lists.newArrayList(); List head = Lists.newArrayList(); List larm = Lists.newArrayList(); List rarm = Lists.newArrayList(); List wing = Lists.newArrayList(); List halo = Lists.newArrayList(); if(h >= 64) { addLayer(wing, texture, w, h, 56, 32, 8, 16, 0.0f, 0.0f, 3.5f, -4.0f, 2.0f, 0.0f, -25.0f, 0.0f); addLayer(wing, texture, w, h, 56, 16, 8, 16, -8.0f, 0.0f, -3.5f, -4.0f, 2.0f, 0.0f, 25.0f, 0.0f); } addLayer(head, texture, w, h, 56, 0, 8, 8, 0.0f, 0.0f, 2.0f, -14.0f, -2.0f, 10.0f, 15.0f, 0.0f); addLayer(head, texture, w, h, 0, 0, 8, 8, -8.0f, 0.0f, -2.0f, -14.0f, -2.0f, 10.0f, -15.0f, 0.0f); addLayer(head, texture, w, h, 24, 0, 8, 8, -4.0f, 0.0f, 0.0f, -16.0f, -2.5f, 0.0f, 0.0f, 0.0f); addLayer(head, texture, w, h, 32, 0, 8, 8, -4.0f, 0.0f, 0.0f, -16.0f, 2.5f, 0.0f, 180.0f, 0.0f); if(h >= 64) { addLayer(head, texture, w, h, 12, 16, 8, 4, -4.0f, 0.0f, 0.0f, -12.0f, -5.0f, 0.0f, 0.0f, 0.0f); addLayer(head, texture, w, h, 36, 16, 8, 4, -4.0f, 0.0f, 0.0f, -12.0f, 5.0f, 0.0f, 180.0f, 0.0f); addLayer(head, texture, w, h, 12, 32, 8, 4, -4.0f, 0.0f, -5.0f, -12.0f, 0.0f, 0.0f, 90.0f, 0.0f); addLayer(head, texture, w, h, 36, 32, 8, 4, -4.0f, 0.0f, 5.0f, -12.0f, 0.0f, 0.0f, -90.0f, 0.0f); addLayer(head, texture, w, h, 0, 48, 4, 4, -2.0f, 0.0f, 0.0f, -9.0f, 4.95f, 0.0f, 180.0f, 0.0f); addLayer(head, texture, w, h, 60, 48, 4, 4, -2.0f, 0.0f, 0.0f, -9.0f, 5.95f, 0.0f, 180.0f, 0.0f); addLayer(halo, texture, w, h, 12, 48, 8, 1, -4.0f, 0.0f, 0.0f, -18.0f, -5.0f, 0.0f, 0.0f, 0.0f); addLayer(halo, texture, w, h, 12, 49, 8, 1, -4.0f, 0.0f, 0.0f, -18.0f, 5.0f, 0.0f, 180.0f, 0.0f); addLayer(halo, texture, w, h, 12, 50, 8, 1, -4.0f, 0.0f, -5.0f, -18.0f, 0.0f, 0.0f, 90.0f, 0.0f); addLayer(halo, texture, w, h, 12, 51, 8, 1, -4.0f, 0.0f, 5.0f, -18.0f, 0.0f, 0.0f, -90.0f, 0.0f); } addLayer(head, texture, w, h, h >= 64 ? 44 : 36, h >= 64 ? 48 : 16, 8, 4, 0.0f, 0.0f, 0.0f, -8.0f, -4.0f, 0.0f, 30.0f, -55.0f); addLayer(head, texture, w, h, h >= 64 ? 28 : 12, h >= 64 ? 48 : 16, 8, 4, -8.0f, 0.0f, 0.0f, -8.0f, -4.0f, 0.0f, -30.0f, 55.0f); addLayer(head, texture, w, h, 0, 16, 4, 4, -2.0f, 0.0f, -6.5f, -7.0f, 1.5f, 15.0f, 65.0f, 0.0f); addLayer(head, texture, w, h, 52, 16, 4, 4, -2.0f, 0.0f, 6.5f, -7.0f, 1.5f, 15.0f, -65.0f, 0.0f); addLayer(larm, texture, w, h, h >= 64 ? 52 : 60, h >= 64 ? 32 : 16, 4, 4, -2.0f, 0.0f, 2.0f, 9.5f, 0.0f, -25.0f, 95.0f, 0.0f); addLayer(rarm, texture, w, h, h >= 64 ? 0 : 56, h >= 64 ? 32 : 16, 4, 4, -2.0f, 0.0f, -2.0f, 9.5f, 0.0f, -25.0f, -95.0f, 0.0f); return (body.isEmpty() && head.isEmpty() && larm.isEmpty() && rarm.isEmpty() && wing.isEmpty() && halo.isEmpty()) ? null : new LayerExtra(body, head, larm, rarm, wing, halo); } }