diff --git a/client/src/main/java/client/init/RenderRegistry.java b/client/src/main/java/client/init/RenderRegistry.java index 8445a62..254989d 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; @@ -46,6 +47,7 @@ import client.renderer.entity.RenderWolf; import client.renderer.entity.RenderXpOrb; import client.renderer.model.ModelChicken; import client.renderer.model.ModelCow; +import client.renderer.model.ModelFox; import client.renderer.model.ModelHorse; import client.renderer.model.ModelMouse; import client.renderer.model.ModelOcelot; @@ -68,6 +70,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 +119,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 ModelFox())); 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..d3bc73b --- /dev/null +++ b/client/src/main/java/client/renderer/entity/RenderFox.java @@ -0,0 +1,16 @@ +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 String getEntityTexture(EntityFox entity) { + return FOX_TEXTURE; + } +} diff --git a/client/src/main/java/client/renderer/model/ModelFox.java b/client/src/main/java/client/renderer/model/ModelFox.java new file mode 100644 index 0000000..cedf720 --- /dev/null +++ b/client/src/main/java/client/renderer/model/ModelFox.java @@ -0,0 +1,97 @@ +package client.renderer.model; + +import org.lwjgl.opengl.GL11; + +import common.entity.Entity; +import common.util.ExtMath; + +public class ModelFox extends ModelBase +{ + private final ModelRenderer head; + private final ModelRenderer body; + private final ModelRenderer wolfLeg1; + private final ModelRenderer wolfLeg2; + private final ModelRenderer wolfLeg3; + private final ModelRenderer wolfLeg4; + private final ModelRenderer tail; + + public ModelFox() + { + float f = 0.0F; + this.head = new ModelRenderer(this, 0, 0); + this.head.addBox(-3.0F, -3.0F, -2.0F, 6, 6, 4, f); + this.head.setRotationPoint(-1.0F, 15.5F, -7.0F); + this.body = new ModelRenderer(this, 24, 0); + this.body.addBox(-3.5F, -2.0F, -2.0F, 5, 13, 5, f); + this.body.setRotationPoint(0.0F, 16.0F, -4.0F); + this.wolfLeg1 = new ModelRenderer(this, 0, 18); + this.wolfLeg1.addBox(-1.0F, 0.0F, -1.0F, 2, 6, 2, f); + this.wolfLeg1.setRotationPoint(-2.49F, 18.0F, 5.0F); + this.wolfLeg2 = new ModelRenderer(this, 0, 18); + this.wolfLeg2.addBox(-1.0F, 0.0F, -1.0F, 2, 6, 2, f); + this.wolfLeg2.setRotationPoint(0.49F, 18.0F, 5.0F); + this.wolfLeg3 = new ModelRenderer(this, 0, 18); + this.wolfLeg3.addBox(-1.0F, 0.0F, -1.0F, 2, 6, 2, f); + this.wolfLeg3.setRotationPoint(-2.49F, 18.0F, -4.0F); + this.wolfLeg4 = new ModelRenderer(this, 0, 18); + this.wolfLeg4.addBox(-1.0F, 0.0F, -1.0F, 2, 6, 2, f); + this.wolfLeg4.setRotationPoint(0.49F, 18.0F, -4.0F); + this.tail = new ModelRenderer(this, 9, 18); + this.tail.addBox(-1.5F, 0.0F, -1.0F, 3, 10, 3, f); + this.tail.setRotationPoint(-1.0F, 15.0F, 6.0F); + this.head.setTextureOffset(16, 14).addBox(-3.15F, -4.35F, 0.0F, 2, 2, 1, f); + this.head.setTextureOffset(16, 14).addBox(1.15F, -4.35F, 0.0F, 2, 2, 1, f); + this.head.setTextureOffset(0, 10).addBox(-1.5F, 0.0F, -5.0F, 3, 2, 4, f); + this.head.setTextureOffset(16, 11).addBox(-3.15F, -5.35F, 0.0F, 1, 1, 1, f); + this.head.setTextureOffset(16, 11).addBox(2.15F, -5.35F, 0.0F, 1, 1, 1, f); + } + + public void render(Entity entityIn, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float scale) + { + super.render(entityIn, p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, scale); + this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, scale, entityIn); + + if (this.isChild) + { + float f = 2.0F; + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, 3.5F * scale, 2.0F * scale); + this.head.renderWithRotation(scale); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(1.0F / f, 1.0F / f, 1.0F / f); + GL11.glTranslatef(0.0F, 24.0F * scale, 0.0F); + this.body.render(scale); + this.wolfLeg1.render(scale); + this.wolfLeg2.render(scale); + this.wolfLeg3.render(scale); + this.wolfLeg4.render(scale); + this.tail.renderWithRotation(scale); + GL11.glPopMatrix(); + } + else + { + this.head.renderWithRotation(scale); + this.body.render(scale); + this.wolfLeg1.render(scale); + this.wolfLeg2.render(scale); + this.wolfLeg3.render(scale); + this.wolfLeg4.render(scale); + this.tail.renderWithRotation(scale); + } + } + + public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) + { + super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); + this.tail.rotateAngleY = ExtMath.cos(limbSwing * 0.6662F) * 1.4F * limbSwingAmount; + this.body.rotateAngleX = ((float)Math.PI / 2F); + this.wolfLeg1.rotateAngleX = ExtMath.cos(limbSwing * 0.6662F) * 1.4F * limbSwingAmount; + this.wolfLeg2.rotateAngleX = ExtMath.cos(limbSwing * 0.6662F + (float)Math.PI) * 1.4F * limbSwingAmount; + this.wolfLeg3.rotateAngleX = ExtMath.cos(limbSwing * 0.6662F + (float)Math.PI) * 1.4F * limbSwingAmount; + this.wolfLeg4.rotateAngleX = ExtMath.cos(limbSwing * 0.6662F) * 1.4F * limbSwingAmount; + this.head.rotateAngleX = headPitch / (180F / (float)Math.PI); + this.head.rotateAngleY = netHeadYaw / (180F / (float)Math.PI); + this.tail.rotateAngleX = (float)Math.PI / 2.5F; + } +} diff --git a/client/src/main/java/client/renderer/model/ModelWolf.java b/client/src/main/java/client/renderer/model/ModelWolf.java index 7bb6909..35d8eb2 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 = (EntityWolf)living; - if (entitywolf.isAngry()) + if (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.isSitting()) { this.wolfMane.setRotationPoint(-1.0F, 16.0F, -3.0F); this.wolfMane.rotateAngleX = ((float)Math.PI * 2F / 5F); @@ -157,10 +157,10 @@ 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); + 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/sounds/fox_death.ogg b/client/src/main/resources/sounds/fox_death.ogg new file mode 100644 index 0000000..6619338 Binary files /dev/null and b/client/src/main/resources/sounds/fox_death.ogg differ diff --git a/client/src/main/resources/sounds/fox_hurt1.ogg b/client/src/main/resources/sounds/fox_hurt1.ogg new file mode 100644 index 0000000..52b1335 Binary files /dev/null and b/client/src/main/resources/sounds/fox_hurt1.ogg differ diff --git a/client/src/main/resources/sounds/fox_hurt2.ogg b/client/src/main/resources/sounds/fox_hurt2.ogg new file mode 100644 index 0000000..e54d9a6 Binary files /dev/null and b/client/src/main/resources/sounds/fox_hurt2.ogg differ 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..61ee1a8 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/EntityDragon.java b/common/src/main/java/common/entity/animal/EntityDragon.java index d64a4e2..04bb342 100755 --- a/common/src/main/java/common/entity/animal/EntityDragon.java +++ b/common/src/main/java/common/entity/animal/EntityDragon.java @@ -12,6 +12,7 @@ import common.entity.types.EntityLiving; import common.entity.types.IEntityMultiPart; import common.init.SoundEvent; import common.model.ParticleType; +import common.potion.Potion; import common.util.ExtMath; import common.util.Vec3; import common.vars.Vars; @@ -56,6 +57,10 @@ public class EntityDragon extends EntityLiving implements IEntityMultiPart return true; } + public boolean isPotionApplicable(Potion potion, int amplifier) { + return false; + } + protected void applyEntityAttributes() { super.applyEntityAttributes(); 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..ef58be6 --- /dev/null +++ b/common/src/main/java/common/entity/animal/EntityFox.java @@ -0,0 +1,112 @@ +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.EntityAINearestAttackableTarget; +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, EntityChicken.class, true)); + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.35D); + this.setMaxHealth(6); + } + + protected SoundEvent getHurtSound() + { + return SoundEvent.FOX_HURT; + } + + protected SoundEvent getDeathSound() + { + return SoundEvent.FOX_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), 2); + + 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.CHAOTIC; + } +} diff --git a/common/src/main/java/common/entity/animal/EntityRabbit.java b/common/src/main/java/common/entity/animal/EntityRabbit.java index c93de19..7ed813a 100755 --- a/common/src/main/java/common/entity/animal/EntityRabbit.java +++ b/common/src/main/java/common/entity/animal/EntityRabbit.java @@ -85,6 +85,10 @@ public class EntityRabbit extends EntityAnimal { return this.moveHelper.isUpdating() && this.moveHelper.getY() > this.posY + 0.5D ? 0.5F : this.moveType.getUpwardsMotion(); } + public boolean isPotionApplicable(Potion potion, int amplifier) { + return super.isPotionApplicable(potion, amplifier) || potion == Potion.JUMP; + } + public void setMoveType(EntityRabbit.EnumMoveType type) { this.moveType = type; } diff --git a/common/src/main/java/common/entity/animal/EntityWolf.java b/common/src/main/java/common/entity/animal/EntityWolf.java index 779cf38..383b43e 100755 --- a/common/src/main/java/common/entity/animal/EntityWolf.java +++ b/common/src/main/java/common/entity/animal/EntityWolf.java @@ -87,18 +87,7 @@ public class EntityWolf extends EntityTameable { super.applyEntityAttributes(); this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.30000001192092896D); - - if (this.isTamed()) - { - this.setMaxHealth(20); - } - else - { - this.setMaxHealth(8); - } - - this.getAttributeMap().registerAttribute(Attribute.ATTACK_DAMAGE); - this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(2.0D); + this.setMaxHealth(8); } /** @@ -350,7 +339,7 @@ public class EntityWolf extends EntityTameable { if(!this.worldObj.client && !Vars.damageMobs) return false; - boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), ((int)this.getEntityAttribute(Attribute.ATTACK_DAMAGE).getAttributeValue())); + boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), this.rand.chance(2, 3, 8)); if (flag) { @@ -360,22 +349,6 @@ public class EntityWolf extends EntityTameable return flag; } - public void setTamed(boolean tamed) - { - super.setTamed(tamed); - - if (tamed) - { - this.setMaxHealth(20); - } - else - { - this.setMaxHealth(8); - } - - this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(4.0D); - } - /** * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig. */ diff --git a/common/src/main/java/common/entity/npc/EntityNPC.java b/common/src/main/java/common/entity/npc/EntityNPC.java index cb902ca..ed401c9 100755 --- a/common/src/main/java/common/entity/npc/EntityNPC.java +++ b/common/src/main/java/common/entity/npc/EntityNPC.java @@ -549,6 +549,10 @@ public abstract class EntityNPC extends EntityLiving this.getAttributeMap().registerAttribute(Attribute.MANA_CAPACITY); this.getEntityAttribute(Attribute.MANA_CAPACITY).setBaseValue(20.0D); } + + public boolean isPotionApplicable(Potion potion, int amplifier) { + return true; + } // protected int getExperiencePoints(EntityNPC player) // { diff --git a/common/src/main/java/common/entity/types/EntityLiving.java b/common/src/main/java/common/entity/types/EntityLiving.java index 804dad8..69b4b42 100755 --- a/common/src/main/java/common/entity/types/EntityLiving.java +++ b/common/src/main/java/common/entity/types/EntityLiving.java @@ -828,20 +828,9 @@ public abstract class EntityLiving extends Entity } } - public boolean isPotionApplicable(Potion potion, int amplifier) - { -// if (this.getCreatureType() == CreatureType.UNDEAD) -// { -// int i = potioneffectIn.getPotionID(); -// -// if (i == Potion.regeneration.id || i == Potion.poison.id) -// { -// return false; -// } -// } - - return true; - } + public boolean isPotionApplicable(Potion potion, int amplifier) { + return potion == Potion.SPEED || potion == Potion.SLOWNESS || potion == Potion.HEAL || potion == Potion.DAMAGE || potion == Potion.POISON || potion == Potion.RADIATION; + } public boolean arePotionsInverted() { 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); diff --git a/common/src/main/java/common/init/SoundEvent.java b/common/src/main/java/common/init/SoundEvent.java index b5cb1b9..4ab1d86 100755 --- a/common/src/main/java/common/init/SoundEvent.java +++ b/common/src/main/java/common/init/SoundEvent.java @@ -109,6 +109,9 @@ public enum SoundEvent { WOLF_PANTING("wolf_panting"), WOLF_SHAKE("wolf_shake"), WOLF_WHINE("wolf_whine"), + + FOX_DEATH("fox_death"), + FOX_HURT("fox_hurt1", "fox_hurt2"), SLIME_ATTACK("slime_attack1", "slime_attack2"), SLIME_BIG("slime_big1", "slime_big2", "slime_big3", "slime_big4"), diff --git a/server/src/main/java/server/biome/BiomeForest.java b/server/src/main/java/server/biome/BiomeForest.java index 7d3d03b..23709f9 100755 --- a/server/src/main/java/server/biome/BiomeForest.java +++ b/server/src/main/java/server/biome/BiomeForest.java @@ -3,6 +3,7 @@ package server.biome; import common.biome.Biome; import common.block.foliage.BlockDoublePlant; import common.block.foliage.BlockFlower; +import common.entity.animal.EntityFox; import common.entity.animal.EntityWolf; import common.entity.npc.EntityElf; import common.entity.npc.EntityWoodElf; @@ -67,12 +68,14 @@ public class BiomeForest extends GenBiome if (this.subType == 0) { - this.mobs.add(new RngSpawn(EntityWolf.class, 5, 4, 4)); + this.mobs.add(new RngSpawn(EntityWolf.class, 5, 2, 4)); + this.mobs.add(new RngSpawn(EntityFox.class, 1, 2, 6)); } if (this.subType == 3) { this.treesPerChunk = -999; + this.mobs.add(new RngSpawn(EntityFox.class, 1, 2, 4)); } if(this.subType != 4) { @@ -81,6 +84,7 @@ public class BiomeForest extends GenBiome else { this.mobs.add(new RngSpawn(EntityWoodElf.class, 100, 4, 16)); this.mobs.add(new RngSpawn(EntityElf.class, 12, 4, 16)); + this.mobs.add(new RngSpawn(EntityFox.class, 3, 2, 5)); } }