Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
WIP Animals
- Loading branch information
1 parent
7debd84
commit 9c78533
Showing
9 changed files
with
395 additions
and
85 deletions.
There are no files selected for viewing
114 changes: 114 additions & 0 deletions
114
src/main/java/net/dries007/tfc/client/model/animal/ModelSheepBodyTFC.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
package net.dries007.tfc.client.model.animal; | ||
|
||
import net.minecraft.client.model.ModelQuadruped; | ||
import net.minecraft.client.model.ModelRenderer; | ||
import net.minecraft.client.renderer.GlStateManager; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
|
||
import net.dries007.tfc.objects.entity.animal.EntitySheepTFC; | ||
|
||
@SideOnly(Side.CLIENT) | ||
public class ModelSheepBodyTFC extends ModelQuadruped | ||
{ | ||
private ModelRenderer horn1; | ||
private ModelRenderer horn2; | ||
private ModelRenderer horn1b; | ||
private ModelRenderer horn2b; | ||
|
||
public ModelSheepBodyTFC() | ||
{ | ||
super(12, 0.0F); | ||
this.head = new ModelRenderer(this, 0, 0); | ||
this.head.addBox(-3.0F, -4.0F, -6.0F, 6, 6, 8, 0.0F); | ||
this.head.setRotationPoint(0.0F, 6.0F, -8.0F); | ||
this.body = new ModelRenderer(this, 28, 8); | ||
this.body.addBox(-4.0F, -10.0F, -7.0F, 8, 16, 6, 0.0F); | ||
this.body.setRotationPoint(0.0F, 5.0F, 2.0F); | ||
|
||
horn1 = new ModelRenderer(this, 28, 2); | ||
horn1.addBox(0F, 0F, 0F, 2, 4, 2, 0F); | ||
horn1.setRotationPoint(0F, -10F, 0F); | ||
horn1.rotateAngleZ = (float) -Math.PI / 6; | ||
horn1.rotateAngleX = (float) -Math.PI / 6; | ||
horn1.rotateAngleY = (float) -Math.PI / 3; | ||
horn1.setRotationPoint(-5F, -6F, -1F); | ||
|
||
horn1b = new ModelRenderer(this, 38, 4); | ||
horn1b.addBox(0.5F, 1F, 0.5F, 1, 3, 1, 0.25F); | ||
horn1b.setRotationPoint(0F, -2F, 4F); | ||
horn1b.rotateAngleX = (float) -Math.PI / 3; | ||
|
||
horn2 = new ModelRenderer(this, 28, 2); | ||
horn2.addBox(0F, 0F, 0F, 2, 4, 2, 0F); | ||
horn2.setRotationPoint(0F, -10F, 0F); | ||
horn2.rotateAngleZ = (float) Math.PI / 6; | ||
horn2.rotateAngleX = (float) -Math.PI / 6; | ||
horn2.rotateAngleY = (float) Math.PI / 3; | ||
horn2.setRotationPoint(4F, -6.5F, 0.75F); | ||
|
||
horn2b = new ModelRenderer(this, 38, 4); | ||
horn2b.addBox(0.5F, 1F, 0.5F, 1, 3, 1, 0.25F); | ||
horn2b.setRotationPoint(0F, -2F, 4F); | ||
horn2b.rotateAngleX = (float) -Math.PI / 3; | ||
|
||
horn1.addChild(horn1b); | ||
horn2.addChild(horn2b); | ||
|
||
head.addChild(horn1); | ||
head.addChild(horn2); | ||
} | ||
|
||
@Override | ||
public void render(Entity entity, float par2, float par3, float par4, float par5, float par6, float par7) | ||
{ | ||
this.setRotationAngles(par2, par3, par4, par5, par6, par7, entity); | ||
EntitySheepTFC sheep = ((EntitySheepTFC) entity); | ||
|
||
float percent = sheep.getPercentToAdulthood(); | ||
float ageScale = 2.0F - percent; | ||
float ageHeadScale = (float) Math.pow(1 / ageScale, 0.66); | ||
|
||
GlStateManager.pushMatrix(); | ||
|
||
GlStateManager.translate(0.0F, 0.75f - (0.75f * percent), 0f); | ||
GlStateManager.scale(ageHeadScale, ageHeadScale, ageHeadScale); | ||
GlStateManager.translate(0.0F, (ageScale - 1) * -0.125f, 0.1875f - (0.1875f * percent)); | ||
|
||
|
||
if (percent < 0.5) | ||
{ | ||
horn1.isHidden = true; | ||
horn2.isHidden = true; | ||
if (percent < 0.75) | ||
{ | ||
horn1b.isHidden = true; | ||
horn2b.isHidden = true; | ||
} | ||
} | ||
|
||
if (!sheep.getGender()) | ||
{ | ||
horn1.isHidden = true; | ||
horn2.isHidden = true; | ||
} | ||
this.head.render(par7); | ||
|
||
GlStateManager.popMatrix(); | ||
GlStateManager.pushMatrix(); | ||
GlStateManager.translate(0.0F, 0.75f - (0.75f * percent), 0f); | ||
GlStateManager.scale(1 / ageScale, 1 / ageScale, 1 / ageScale); | ||
|
||
this.body.render(par7); | ||
this.leg1.render(par7); | ||
this.leg2.render(par7); | ||
this.leg3.render(par7); | ||
this.leg4.render(par7); | ||
horn1.isHidden = false; | ||
horn1b.isHidden = false; | ||
horn2.isHidden = false; | ||
horn2b.isHidden = false; | ||
GlStateManager.popMatrix(); | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
src/main/java/net/dries007/tfc/client/model/animal/ModelSheepWoolTFC.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package net.dries007.tfc.client.model.animal; | ||
|
||
import net.minecraft.client.model.ModelQuadruped; | ||
import net.minecraft.client.model.ModelRenderer; | ||
import net.minecraft.client.renderer.GlStateManager; | ||
import net.minecraft.entity.Entity; | ||
|
||
import net.dries007.tfc.objects.entity.animal.EntitySheepTFC; | ||
|
||
public class ModelSheepWoolTFC extends ModelQuadruped | ||
{ | ||
public ModelSheepWoolTFC() | ||
{ | ||
super(12, 0.0F); | ||
this.head = new ModelRenderer(this, 0, 0); | ||
this.head.addBox(-3.0F, -4.0F, -4.0F, 6, 6, 6, 0.6F); | ||
this.head.setRotationPoint(0.0F, 6.0F, -8.0F); | ||
this.body = new ModelRenderer(this, 28, 8); | ||
this.body.addBox(-4.0F, -10.0F, -7.0F, 8, 16, 6, 1.75F); | ||
this.body.setRotationPoint(0.0F, 5.0F, 2.0F); | ||
float f = 0.5F; | ||
this.leg1 = new ModelRenderer(this, 0, 16); | ||
this.leg1.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, 0.5F); | ||
this.leg1.setRotationPoint(-3.0F, 12.0F, 7.0F); | ||
this.leg2 = new ModelRenderer(this, 0, 16); | ||
this.leg2.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, 0.5F); | ||
this.leg2.setRotationPoint(3.0F, 12.0F, 7.0F); | ||
this.leg3 = new ModelRenderer(this, 0, 16); | ||
this.leg3.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, 0.5F); | ||
this.leg3.setRotationPoint(-3.0F, 12.0F, -5.0F); | ||
this.leg4 = new ModelRenderer(this, 0, 16); | ||
this.leg4.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, 0.5F); | ||
this.leg4.setRotationPoint(3.0F, 12.0F, -5.0F); | ||
} | ||
|
||
@Override | ||
public void render(Entity entity, float par2, float par3, float par4, float par5, float par6, float par7) | ||
{ | ||
this.setRotationAngles(par2, par3, par4, par5, par6, par7, entity); | ||
EntitySheepTFC sheep = ((EntitySheepTFC) entity); | ||
|
||
float percent = sheep.getPercentToAdulthood(); | ||
float ageScale = 2.0F - percent; | ||
float ageHeadScale = (float) Math.pow(1 / ageScale, 0.66); | ||
|
||
GlStateManager.pushMatrix(); | ||
|
||
GlStateManager.translate(0.0F, 0.75f - (0.75f * percent), 0f); | ||
GlStateManager.scale(ageHeadScale, ageHeadScale, ageHeadScale); | ||
GlStateManager.translate(0.0F, (ageScale - 1) * -0.125f, 0.1875f - (0.1875f * percent)); | ||
|
||
|
||
this.head.render(par7); | ||
|
||
GlStateManager.popMatrix(); | ||
GlStateManager.pushMatrix(); | ||
GlStateManager.translate(0.0F, 0.75f - (0.75f * percent), 0f); | ||
GlStateManager.scale(1 / ageScale, 1 / ageScale, 1 / ageScale); | ||
this.body.render(par7); | ||
this.leg1.render(par7); | ||
this.leg2.render(par7); | ||
this.leg3.render(par7); | ||
this.leg4.render(par7); | ||
GlStateManager.popMatrix(); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/net/dries007/tfc/client/render/animal/LayerSheepWoolTFC.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package net.dries007.tfc.client.render.animal; | ||
|
||
import net.minecraft.client.renderer.GlStateManager; | ||
import net.minecraft.client.renderer.entity.layers.LayerRenderer; | ||
import net.minecraft.entity.passive.EntitySheep; | ||
import net.minecraft.util.ResourceLocation; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
|
||
import net.dries007.tfc.client.model.animal.ModelSheepWoolTFC; | ||
import net.dries007.tfc.objects.entity.animal.EntitySheepTFC; | ||
|
||
@SideOnly(Side.CLIENT) | ||
public class LayerSheepWoolTFC implements LayerRenderer<EntitySheepTFC> | ||
{ | ||
private static final ResourceLocation TEXTURE = new ResourceLocation("minecraft:textures/entity/sheep/sheep_fur.png"); | ||
private final RenderSheepTFC sheepRenderer; | ||
private final ModelSheepWoolTFC sheepModel = new ModelSheepWoolTFC(); | ||
|
||
public LayerSheepWoolTFC(RenderSheepTFC sheepRendererIn) | ||
{ | ||
this.sheepRenderer = sheepRendererIn; | ||
} | ||
|
||
@Override | ||
public void doRenderLayer(EntitySheepTFC sheep, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) | ||
{ | ||
if (sheep.hasWool() && !sheep.isInvisible()) | ||
{ | ||
this.sheepRenderer.bindTexture(TEXTURE); | ||
|
||
float[] afloat = EntitySheep.getDyeRgb(sheep.getDyeColor()); | ||
GlStateManager.color(afloat[0], afloat[1], afloat[2]); | ||
|
||
this.sheepModel.setModelAttributes(this.sheepRenderer.getMainModel()); | ||
this.sheepModel.setLivingAnimations(sheep, limbSwing, limbSwingAmount, partialTicks); | ||
this.sheepModel.render(sheep, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean shouldCombineTextures() | ||
{ | ||
return true; | ||
} | ||
} |
15 changes: 9 additions & 6 deletions
15
src/main/java/net/dries007/tfc/client/render/animal/RenderSheepTFC.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,30 @@ | ||
package net.dries007.tfc.client.render.animal; | ||
|
||
import net.minecraft.client.model.ModelSheep2; | ||
import net.minecraft.client.renderer.entity.RenderLiving; | ||
import net.minecraft.client.renderer.entity.RenderManager; | ||
import net.minecraft.util.ResourceLocation; | ||
|
||
import net.dries007.tfc.client.model.animal.ModelSheepBodyTFC; | ||
import net.dries007.tfc.objects.entity.animal.EntitySheepTFC; | ||
|
||
import static net.dries007.tfc.api.util.TFCConstants.MOD_ID; | ||
|
||
public class RenderSheepTFC extends RenderLiving<EntitySheepTFC> | ||
{ | ||
private static final ResourceLocation SHEARED_SHEEP_TEXTURES = new ResourceLocation("textures/entity/sheep/sheep.png"); | ||
private static final ResourceLocation SHEEP_TEXTURES = new ResourceLocation(MOD_ID, "textures/entity/animal/sheep.png"); | ||
|
||
public RenderSheepTFC(RenderManager p_i47195_1_) | ||
public RenderSheepTFC(RenderManager renderManager) | ||
{ | ||
super(p_i47195_1_, new ModelSheep2(), 0.7F); | ||
//this.addLayer(new LayerSheepWool(this)); | ||
super(renderManager, new ModelSheepBodyTFC(), 0.7F); | ||
this.addLayer(new LayerSheepWoolTFC(this)); | ||
} | ||
|
||
/** | ||
* Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. | ||
*/ | ||
@Override | ||
protected ResourceLocation getEntityTexture(EntitySheepTFC entity) | ||
{ | ||
return SHEARED_SHEEP_TEXTURES; | ||
return SHEEP_TEXTURES; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.