2013-12-04 05:36:06 +01:00
|
|
|
package mekanism.client.render;
|
|
|
|
|
2013-12-15 22:07:30 +01:00
|
|
|
import mekanism.client.model.ModelGasMask;
|
2013-12-04 05:36:06 +01:00
|
|
|
import mekanism.client.model.ModelJetpack;
|
2013-12-15 22:07:30 +01:00
|
|
|
import mekanism.client.model.ModelScubaTank;
|
2013-12-04 05:36:06 +01:00
|
|
|
import mekanism.common.util.MekanismUtils;
|
|
|
|
import mekanism.common.util.MekanismUtils.ResourceType;
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.model.ModelBiped;
|
|
|
|
import net.minecraft.client.model.ModelRenderer;
|
|
|
|
import net.minecraft.entity.Entity;
|
2013-12-16 00:54:43 +01:00
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
2013-12-04 05:36:06 +01:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
2013-12-22 07:49:55 +01:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
2013-12-04 05:36:06 +01:00
|
|
|
public class ModelCustomArmor extends ModelBiped
|
|
|
|
{
|
|
|
|
public static ModelCustomArmor INSTANCE = new ModelCustomArmor();
|
2013-12-16 18:21:49 +01:00
|
|
|
|
|
|
|
public static GlowArmor GLOW_BIG = new GlowArmor(1.0F);
|
|
|
|
public static GlowArmor GLOW_SMALL = new GlowArmor(0.5F);
|
|
|
|
|
2013-12-04 05:36:06 +01:00
|
|
|
public static Minecraft mc = Minecraft.getMinecraft();
|
|
|
|
|
|
|
|
public ArmorModel modelType;
|
|
|
|
|
|
|
|
public ModelCustomArmor()
|
|
|
|
{
|
|
|
|
resetPart(bipedHead, 0, 0, 0);
|
|
|
|
resetPart(bipedBody, 0, 0, 0);
|
|
|
|
resetPart(bipedRightArm, 5, 2, 0);
|
|
|
|
resetPart(bipedLeftArm, -5, 2, 0);
|
|
|
|
resetPart(bipedRightLeg, 2, 12, 0);
|
|
|
|
resetPart(bipedLeftLeg, -2, 12, 0);
|
|
|
|
|
|
|
|
bipedHeadwear.cubeList.clear();
|
|
|
|
bipedEars.cubeList.clear();
|
|
|
|
bipedCloak.cubeList.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void init(Entity entity, float f, float f1, float f2, float f3, float f4, float size)
|
|
|
|
{
|
|
|
|
reset();
|
2013-12-16 00:54:43 +01:00
|
|
|
|
|
|
|
if(entity instanceof EntityLivingBase)
|
|
|
|
{
|
|
|
|
isSneak = ((EntityLivingBase)entity).isSneaking();
|
2013-12-16 18:21:49 +01:00
|
|
|
isRiding = ((EntityLivingBase)entity).isRiding();
|
|
|
|
isChild = ((EntityLivingBase)entity).isChild();
|
2013-12-16 00:54:43 +01:00
|
|
|
}
|
2013-12-04 05:36:06 +01:00
|
|
|
|
|
|
|
if(modelType.armorSlot == 0)
|
2013-12-16 00:54:43 +01:00
|
|
|
{
|
2013-12-04 05:36:06 +01:00
|
|
|
bipedHead.isHidden = false;
|
|
|
|
bipedHead.showModel = true;
|
|
|
|
}
|
|
|
|
else if(modelType.armorSlot == 1)
|
|
|
|
{
|
|
|
|
bipedBody.isHidden = false;
|
|
|
|
bipedBody.showModel = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
setRotationAngles(f, f1, f2, f3, f4, size, entity);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void reset()
|
|
|
|
{
|
|
|
|
bipedHead.isHidden = true;
|
|
|
|
bipedBody.isHidden = true;
|
|
|
|
bipedRightArm.isHidden = true;
|
|
|
|
bipedLeftArm.isHidden = true;
|
|
|
|
bipedRightLeg.isHidden = true;
|
|
|
|
bipedLeftLeg.isHidden = true;
|
|
|
|
|
|
|
|
bipedHead.showModel = false;
|
|
|
|
bipedBody.showModel = false;
|
|
|
|
bipedRightArm.showModel = false;
|
|
|
|
bipedLeftArm.showModel = false;
|
|
|
|
bipedRightLeg.showModel = false;
|
|
|
|
bipedLeftLeg.showModel = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void resetPart(ModelRenderer renderer, float x, float y, float z)
|
|
|
|
{
|
|
|
|
renderer.cubeList.clear();
|
|
|
|
ModelCustom model = new ModelCustom(this, renderer);
|
|
|
|
renderer.addChild(model);
|
|
|
|
setOffset(renderer, x, y, z);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setOffset(ModelRenderer renderer, float x, float y, float z)
|
|
|
|
{
|
|
|
|
renderer.offsetX = x;
|
|
|
|
renderer.offsetY = y;
|
|
|
|
renderer.offsetZ = z;
|
|
|
|
}
|
|
|
|
|
|
|
|
public class ModelCustom extends ModelRenderer
|
|
|
|
{
|
|
|
|
public ModelCustomArmor biped;
|
|
|
|
public ModelRenderer partRender;
|
|
|
|
|
|
|
|
public ModelCustom(ModelCustomArmor base, ModelRenderer renderer)
|
|
|
|
{
|
|
|
|
super(base);
|
|
|
|
biped = base;
|
|
|
|
partRender = renderer;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void render(float size)
|
|
|
|
{
|
|
|
|
if(ModelCustomArmor.this.modelType != null)
|
|
|
|
{
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glTranslatef(0, 0, 0.06F);
|
|
|
|
|
|
|
|
mc.renderEngine.bindTexture(modelType.resource);
|
|
|
|
|
2013-12-06 21:26:44 +01:00
|
|
|
if(useModel(biped.modelType, partRender, biped))
|
2013-12-04 05:36:06 +01:00
|
|
|
{
|
2013-12-06 21:26:44 +01:00
|
|
|
if(biped.modelType == ArmorModel.JETPACK)
|
|
|
|
{
|
|
|
|
ArmorModel.jetpackModel.render(0.0625F);
|
|
|
|
}
|
|
|
|
else if(biped.modelType == ArmorModel.SCUBATANK)
|
|
|
|
{
|
2013-12-15 22:07:30 +01:00
|
|
|
ArmorModel.scubaTankModel.render(0.0625F);
|
2013-12-06 21:26:44 +01:00
|
|
|
}
|
|
|
|
else if(biped.modelType == ArmorModel.GASMASK)
|
|
|
|
{
|
2013-12-15 22:07:30 +01:00
|
|
|
ArmorModel.gasMaskModel.render(0.0625F);
|
2013-12-06 21:26:44 +01:00
|
|
|
}
|
2013-12-04 05:36:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void render(Entity entity, float par2, float par3, float par4, float par5, float par6, float par7)
|
|
|
|
{
|
|
|
|
init(entity, par2, par3, par4, par5, par6, par7);
|
|
|
|
super.render(entity, par2, par3, par4, par5, par6, par7);
|
|
|
|
}
|
2013-12-06 21:26:44 +01:00
|
|
|
|
|
|
|
public static boolean useModel(ArmorModel type, ModelRenderer partRender, ModelCustomArmor biped)
|
|
|
|
{
|
|
|
|
if(type.armorSlot == 0)
|
|
|
|
{
|
|
|
|
return partRender == biped.bipedHead;
|
|
|
|
}
|
|
|
|
else if(type.armorSlot == 1)
|
|
|
|
{
|
|
|
|
return partRender == biped.bipedBody;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2013-12-04 05:36:06 +01:00
|
|
|
|
|
|
|
public static enum ArmorModel
|
|
|
|
{
|
2013-12-06 21:26:44 +01:00
|
|
|
JETPACK(1, MekanismUtils.getResource(ResourceType.RENDER, "Jetpack.png")),
|
2013-12-15 22:07:30 +01:00
|
|
|
SCUBATANK(1, MekanismUtils.getResource(ResourceType.RENDER, "ScubaSet.png")),
|
|
|
|
GASMASK(0, MekanismUtils.getResource(ResourceType.RENDER, "ScubaSet.png"));
|
2013-12-04 05:36:06 +01:00
|
|
|
|
|
|
|
public int armorSlot;
|
|
|
|
public ResourceLocation resource;
|
|
|
|
|
|
|
|
public static ModelJetpack jetpackModel = new ModelJetpack();
|
2013-12-15 22:07:30 +01:00
|
|
|
public static ModelGasMask gasMaskModel = new ModelGasMask();
|
|
|
|
public static ModelScubaTank scubaTankModel = new ModelScubaTank();
|
2013-12-04 05:36:06 +01:00
|
|
|
|
|
|
|
private ArmorModel(int i, ResourceLocation r)
|
|
|
|
{
|
|
|
|
armorSlot = i;
|
|
|
|
resource = r;
|
|
|
|
}
|
|
|
|
}
|
2013-12-16 18:21:49 +01:00
|
|
|
|
|
|
|
public static ModelBiped getGlow(int index)
|
|
|
|
{
|
|
|
|
ModelBiped biped = index != 2 ? GLOW_BIG : GLOW_SMALL;
|
|
|
|
|
|
|
|
biped.bipedHead.showModel = index == 0;
|
|
|
|
biped.bipedHeadwear.showModel = index == 0;
|
|
|
|
biped.bipedBody.showModel = index == 1 || index == 2;
|
|
|
|
biped.bipedRightArm.showModel = index == 1;
|
|
|
|
biped.bipedLeftArm.showModel = index == 1;
|
|
|
|
biped.bipedRightLeg.showModel = index == 2 || index == 3;
|
|
|
|
biped.bipedLeftLeg.showModel = index == 2 || index == 3;
|
|
|
|
|
|
|
|
return biped;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class GlowArmor extends ModelBiped
|
|
|
|
{
|
|
|
|
public GlowArmor(float size)
|
|
|
|
{
|
|
|
|
super(size);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void render(Entity entity, float par2, float par3, float par4, float par5, float par6, float par7)
|
|
|
|
{
|
|
|
|
if(entity instanceof EntityLivingBase)
|
|
|
|
{
|
|
|
|
isSneak = ((EntityLivingBase)entity).isSneaking();
|
|
|
|
isRiding = ((EntityLivingBase)entity).isRiding();
|
|
|
|
isChild = ((EntityLivingBase)entity).isChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
setRotationAngles(par2, par3, par4, par5, par6, par7, entity);
|
|
|
|
|
|
|
|
MekanismRenderer.glowOn();
|
|
|
|
super.render(entity, par2, par3, par4, par5, par6, par7);
|
|
|
|
MekanismRenderer.glowOff();
|
|
|
|
}
|
|
|
|
}
|
2013-12-04 05:36:06 +01:00
|
|
|
}
|