diff --git a/client/src/main/java/client/init/RenderRegistry.java b/client/src/main/java/client/init/RenderRegistry.java index 8445a62..1224082 100644 --- a/client/src/main/java/client/init/RenderRegistry.java +++ b/client/src/main/java/client/init/RenderRegistry.java @@ -21,6 +21,7 @@ import client.renderer.entity.RenderFallingBlock; import client.renderer.entity.RenderFireball; import client.renderer.entity.RenderFish; import client.renderer.entity.RenderFlyingBox; +import client.renderer.entity.RenderFox; import client.renderer.entity.RenderHorse; import client.renderer.entity.RenderHumanoid; import client.renderer.entity.RenderItem; @@ -68,6 +69,7 @@ import common.entity.animal.EntityBat; import common.entity.animal.EntityChicken; import common.entity.animal.EntityCow; import common.entity.animal.EntityDragon; +import common.entity.animal.EntityFox; import common.entity.animal.EntityHorse; import common.entity.animal.EntityMooshroom; import common.entity.animal.EntityMouse; @@ -116,6 +118,7 @@ public abstract class RenderRegistry { map.put(EntityCow.class, new RenderCow(mgr, new ModelCow())); map.put(EntityMooshroom.class, new RenderMooshroom(mgr, new ModelCow())); map.put(EntityWolf.class, new RenderWolf(mgr, new ModelWolf())); + map.put(EntityFox.class, new RenderFox(mgr, new ModelWolf())); map.put(EntityChicken.class, new RenderChicken(mgr, new ModelChicken())); map.put(EntityOcelot.class, new RenderOcelot(mgr, new ModelOcelot())); map.put(EntityRabbit.class, new RenderRabbit(mgr, new ModelRabbit())); diff --git a/client/src/main/java/client/renderer/entity/RenderFox.java b/client/src/main/java/client/renderer/entity/RenderFox.java new file mode 100644 index 0000000..ebcf25f --- /dev/null +++ b/client/src/main/java/client/renderer/entity/RenderFox.java @@ -0,0 +1,20 @@ +package client.renderer.entity; + +import client.renderer.model.ModelBase; +import common.entity.animal.EntityFox; + +public class RenderFox extends RenderLiving { + private static final String FOX_TEXTURE = "textures/entity/fox.png"; + + public RenderFox(RenderManager renderManagerIn, ModelBase modelBaseIn) { + super(renderManagerIn, modelBaseIn); + } + + protected float handleRotationFloat(EntityFox livingBase, float partialTicks) { + return (float)Math.PI / 5F; + } + + protected String getEntityTexture(EntityFox entity) { + return FOX_TEXTURE; + } +} diff --git a/client/src/main/java/client/renderer/model/ModelWolf.java b/client/src/main/java/client/renderer/model/ModelWolf.java index 7bb6909..3b81da7 100755 --- a/client/src/main/java/client/renderer/model/ModelWolf.java +++ b/client/src/main/java/client/renderer/model/ModelWolf.java @@ -110,11 +110,11 @@ public class ModelWolf extends ModelBase * Used for easily adding entity-dependent animations. The second and third float params here are the same second * and third as in the setRotationAngles method. */ - public void setLivingAnimations(EntityLiving entitylivingbaseIn, float p_78086_2_, float p_78086_3_, float partialTickTime) + public void setLivingAnimations(EntityLiving living, float p_78086_2_, float p_78086_3_, float partialTickTime) { - EntityWolf entitywolf = (EntityWolf)entitylivingbaseIn; + EntityWolf wolf = living instanceof EntityWolf ? (EntityWolf)living : null; - if (entitywolf.isAngry()) + if (wolf != null && wolf.isAngry()) { this.wolfTail.rotateAngleY = 0.0F; } @@ -123,7 +123,7 @@ public class ModelWolf extends ModelBase this.wolfTail.rotateAngleY = ExtMath.cos(p_78086_2_ * 0.6662F) * 1.4F * p_78086_3_; } - if (entitywolf.isSitting()) + if (wolf != null && wolf.isSitting()) { this.wolfMane.setRotationPoint(-1.0F, 16.0F, -3.0F); this.wolfMane.rotateAngleX = ((float)Math.PI * 2F / 5F); @@ -157,10 +157,12 @@ public class ModelWolf extends ModelBase this.wolfLeg4.rotateAngleX = ExtMath.cos(p_78086_2_ * 0.6662F) * 1.4F * p_78086_3_; } - this.wolfHeadMain.rotateAngleZ = entitywolf.getInterestedAngle(partialTickTime) + entitywolf.getShakeAngle(partialTickTime, 0.0F); - this.wolfMane.rotateAngleZ = entitywolf.getShakeAngle(partialTickTime, -0.08F); - this.wolfBody.rotateAngleZ = entitywolf.getShakeAngle(partialTickTime, -0.16F); - this.wolfTail.rotateAngleZ = entitywolf.getShakeAngle(partialTickTime, -0.2F); + if(wolf != null) { + this.wolfHeadMain.rotateAngleZ = wolf.getInterestedAngle(partialTickTime) + wolf.getShakeAngle(partialTickTime, 0.0F); + this.wolfMane.rotateAngleZ = wolf.getShakeAngle(partialTickTime, -0.08F); + this.wolfBody.rotateAngleZ = wolf.getShakeAngle(partialTickTime, -0.16F); + this.wolfTail.rotateAngleZ = wolf.getShakeAngle(partialTickTime, -0.2F); + } } /** diff --git a/client/src/main/resources/textures/entity/fox.png b/client/src/main/resources/textures/entity/fox.png new file mode 100755 index 0000000..0ca12a0 Binary files /dev/null and b/client/src/main/resources/textures/entity/fox.png differ diff --git a/common/src/main/java/common/entity/animal/EntityFox.java b/common/src/main/java/common/entity/animal/EntityFox.java new file mode 100644 index 0000000..12fc7c7 --- /dev/null +++ b/common/src/main/java/common/entity/animal/EntityFox.java @@ -0,0 +1,115 @@ +package common.entity.animal; + +import common.ai.EntityAIAttackOnCollide; +import common.ai.EntityAIHurtByTarget; +import common.ai.EntityAILeapAtTarget; +import common.ai.EntityAILookIdle; +import common.ai.EntityAIMate; +import common.ai.EntityAISwimming; +import common.ai.EntityAIWander; +import common.ai.EntityAIWatchClosest; +import common.attributes.Attribute; +import common.entity.DamageSource; +import common.entity.Entity; +import common.entity.npc.Alignment; +import common.entity.types.EntityAnimal; +import common.entity.types.EntityLiving; +import common.init.Items; +import common.init.SoundEvent; +import common.item.Item; +import common.item.ItemStack; +import common.pathfinding.PathNavigateGround; +import common.vars.Vars; +import common.world.World; + +public class EntityFox extends EntityAnimal +{ + public EntityFox(World worldIn) + { + super(worldIn); + this.setSize(0.6F, 0.8F); + ((PathNavigateGround)this.getNavigator()).setAvoidsWater(true); + this.tasks.addTask(1, new EntityAISwimming(this)); + this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F)); + this.tasks.addTask(4, new EntityAIAttackOnCollide(this, 1.0D, true)); + this.tasks.addTask(6, new EntityAIMate(this, 1.0D)); + this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); + this.tasks.addTask(9, new EntityAIWatchClosest(this, null, 8.0F)); + this.tasks.addTask(9, new EntityAILookIdle(this)); + this.targets.addTask(3, new EntityAIHurtByTarget(this, true)); +// this.targets.addTask(5, new EntityAINearestAttackableTarget(this, EntityUndead.class, false)); + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.35D); + + this.setMaxHealth(6); + + this.getAttributeMap().registerAttribute(Attribute.ATTACK_DAMAGE); + this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(2.0D); + } + + protected SoundEvent getHurtSound() + { + return SoundEvent.WOLF_HURT; + } + + protected SoundEvent getDeathSound() + { + return SoundEvent.WOLF_DEATH; + } + + protected float getSoundVolume() + { + return 0.4F; + } + + protected Item getDropItem() + { + return null; + } + + public float getEyeHeight() + { + return this.height * 0.8F; + } + + public boolean attackEntityAsMob(Entity entityIn) + { + if(!this.worldObj.client && !Vars.damageMobs) + return false; + boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), ((int)this.getEntityAttribute(Attribute.ATTACK_DAMAGE).getAttributeValue())); + + if (flag) + { + this.applyEnchantments(this, entityIn); + } + + return flag; + } + + public boolean isBreedingItem(ItemStack stack) + { + return stack != null && stack.getItem() == Items.apple; + } + + public int getMaxChunkSpawns() + { + return 6; + } + + public EntityFox createChild(EntityLiving ageable) + { + return new EntityFox(this.worldObj); + } + + public int getColor() { + return 0xc35d00; + } + + public Alignment getAlignment() { + return Alignment.LAWFUL; + } +} diff --git a/common/src/main/java/common/init/EntityRegistry.java b/common/src/main/java/common/init/EntityRegistry.java index 6fe113e..e0c9b95 100755 --- a/common/src/main/java/common/init/EntityRegistry.java +++ b/common/src/main/java/common/init/EntityRegistry.java @@ -9,6 +9,7 @@ import common.entity.animal.EntityBat; import common.entity.animal.EntityChicken; import common.entity.animal.EntityCow; import common.entity.animal.EntityDragon; +import common.entity.animal.EntityFox; import common.entity.animal.EntityHorse; import common.entity.animal.EntityMooshroom; import common.entity.animal.EntityMouse; @@ -262,6 +263,7 @@ public abstract class EntityRegistry { registerEntity("Horse", EntityHorse.class, "terra", "Pferd", 12623485, 15656192); registerEntity("Rabbit", EntityRabbit.class, "terra", "Kaninchen", 10051392, 7555121); registerEntity("Mouse", EntityMouse.class, "terra", "Maus", 0x606060, 0xb0b0b0); + registerEntity("Fox", EntityFox.class, "terra", "Fuchs", 0xae5300, 0x622f00); for(int z = 0; z < SpeciesRegistry.SPECIMEN.size(); z++) { SpeciesInfo info = SpeciesRegistry.SPECIMEN.get(z);