2025-03-11 00:23:54 +01:00
|
|
|
package game.renderer.layers;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import game.Game;
|
|
|
|
import game.collect.Lists;
|
|
|
|
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;
|
2025-03-11 10:26:48 +01:00
|
|
|
import game.window.WCF;
|
2025-03-11 00:23:54 +01:00
|
|
|
|
|
|
|
public class LayerExtra implements LayerRenderer<EntityNPC>
|
|
|
|
{
|
|
|
|
private final List<ModelRenderer> body;
|
|
|
|
private final List<ModelRenderer> head;
|
|
|
|
private final List<ModelRenderer> larm;
|
|
|
|
private final List<ModelRenderer> rarm;
|
|
|
|
private final List<ModelRenderer> wing;
|
|
|
|
private final List<ModelRenderer> halo;
|
|
|
|
|
|
|
|
private ModelHumanoid model;
|
|
|
|
|
|
|
|
public LayerExtra(List<ModelRenderer> body, List<ModelRenderer> head, List<ModelRenderer> larm, List<ModelRenderer> rarm,
|
|
|
|
List<ModelRenderer> wing, List<ModelRenderer> 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<ModelRenderer> 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<ModelBox> 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<ModelRenderer> body = Lists.newArrayList();
|
|
|
|
List<ModelRenderer> head = Lists.newArrayList();
|
|
|
|
List<ModelRenderer> larm = Lists.newArrayList();
|
|
|
|
List<ModelRenderer> rarm = Lists.newArrayList();
|
|
|
|
List<ModelRenderer> wing = Lists.newArrayList();
|
|
|
|
List<ModelRenderer> 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);
|
|
|
|
}
|
|
|
|
}
|