diff --git a/common/biomesoplenty/ClientProxy.java b/common/biomesoplenty/ClientProxy.java index 7f80e7c87..fdd5a5bdf 100644 --- a/common/biomesoplenty/ClientProxy.java +++ b/common/biomesoplenty/ClientProxy.java @@ -16,6 +16,7 @@ import biomesoplenty.blocks.renderers.PuddleRender; import biomesoplenty.blocks.renderers.RenderUtils; import biomesoplenty.blocks.renderers.SmallBlockRenderer; import biomesoplenty.configuration.configfile.BOPConfigurationIDs; +import biomesoplenty.entities.EntityBird; import biomesoplenty.entities.EntityGlob; import biomesoplenty.entities.EntityJungleSpider; import biomesoplenty.entities.EntityPhantom; @@ -23,6 +24,7 @@ import biomesoplenty.entities.EntityRosester; import biomesoplenty.entities.EntityWasp; import biomesoplenty.entities.projectiles.EntityDart; import biomesoplenty.entities.projectiles.EntityMudball; +import biomesoplenty.entities.render.RenderBird; import biomesoplenty.entities.render.RenderDart; import biomesoplenty.entities.render.RenderGlob; import biomesoplenty.entities.render.RenderJungleSpider; @@ -76,6 +78,11 @@ public class ClientProxy extends CommonProxy { { RenderingRegistry.registerEntityRenderingHandler(EntityWasp.class, new RenderWasp()); } + + if (BOPConfigurationIDs.birdID > 0) + { + RenderingRegistry.registerEntityRenderingHandler(EntityBird.class, new RenderBird()); + } RenderingRegistry.registerBlockHandler(new FoliageRenderer()); RenderingRegistry.registerBlockHandler(new PlantsRenderer()); diff --git a/common/biomesoplenty/api/Entities.java b/common/biomesoplenty/api/Entities.java index dd4eb4910..3ae8ed632 100644 --- a/common/biomesoplenty/api/Entities.java +++ b/common/biomesoplenty/api/Entities.java @@ -7,6 +7,8 @@ public class Entities { public static Class JungleSpider = getClass("biomesoplenty.entities.EntityJungleSpider"); public static Class Rosester = getClass("biomesoplenty.entities.EntityRosester"); public static Class Glob = getClass("biomesoplenty.entities.EntityGlob"); + public static Class Wasp = getClass("biomesoplenty.entities.EntityWasp"); + public static Class Bird = getClass("biomesoplenty.entities.EntityBird"); public static Class getClass(String inputstring) { diff --git a/common/biomesoplenty/configuration/BOPEntities.java b/common/biomesoplenty/configuration/BOPEntities.java index e791090f7..05f2fa8f7 100644 --- a/common/biomesoplenty/configuration/BOPEntities.java +++ b/common/biomesoplenty/configuration/BOPEntities.java @@ -7,6 +7,7 @@ import net.minecraft.entity.EnumCreatureType; import biomesoplenty.BiomesOPlenty; import biomesoplenty.api.Biomes; import biomesoplenty.configuration.configfile.BOPConfigurationIDs; +import biomesoplenty.entities.EntityBird; import biomesoplenty.entities.EntityGlob; import biomesoplenty.entities.EntityJungleSpider; import biomesoplenty.entities.EntityPhantom; @@ -98,5 +99,17 @@ public class BOPEntities { registerEntityEgg(EntityWasp.class, 16434729, 2500135); } + + if (BOPConfigurationIDs.birdID > 0) + { + EntityRegistry.registerModEntity(EntityBird.class, "Bird", BOPConfigurationIDs.birdID, BiomesOPlenty.instance, 80, 3, true); + + registerEntityEgg(EntityBird.class, 16434729, 2500135); + + if (Biomes.promisedLandForest.isPresent() && Biomes.promisedLandSwamp.isPresent() && Biomes.promisedLandPlains.isPresent()) + { + EntityRegistry.addSpawn(EntityBird.class, 8, 1, 1, EnumCreatureType.ambient, Biomes.promisedLandForest.get(), Biomes.promisedLandSwamp.get(), Biomes.promisedLandPlains.get()); + } + } } } diff --git a/common/biomesoplenty/configuration/configfile/BOPConfigurationIDs.java b/common/biomesoplenty/configuration/configfile/BOPConfigurationIDs.java index 6c34c2e7a..4b2a3e9ca 100644 --- a/common/biomesoplenty/configuration/configfile/BOPConfigurationIDs.java +++ b/common/biomesoplenty/configuration/configfile/BOPConfigurationIDs.java @@ -298,6 +298,7 @@ public class BOPConfigurationIDs public static int globID; public static int phantomID; public static int waspID; + public static int birdID; public static void init(File configFile) { @@ -478,6 +479,7 @@ public class BOPConfigurationIDs globID = config.get("Mob IDs", "Glob ID", 106, null).getInt(); phantomID = config.get("Mob IDs", "Phantom ID", 107, null).getInt(); waspID = config.get("Mob IDs", "Wasp ID", 108, null).getInt(); + birdID = config.get("Mob IDs", "Bird ID", 109, null).getInt(); //Projectile IDs entityMudballID = config.get("Entity IDs", "Mudball ID", 103, null).getInt();; diff --git a/common/biomesoplenty/entities/EntityBird.java b/common/biomesoplenty/entities/EntityBird.java new file mode 100644 index 000000000..0ce0a03ac --- /dev/null +++ b/common/biomesoplenty/entities/EntityBird.java @@ -0,0 +1,94 @@ +package biomesoplenty.entities; + +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class EntityBird extends EntityFlyingMob +{ + public int courseChangeCooldown; + public double waypointX; + public double waypointY; + public double waypointZ; + + public EntityBird(World world) + { + super(world); + this.setSize(1.0F, 1.0F); + } + + @Override + protected void updateEntityActionState() + { + double d0 = this.waypointX - this.posX; + double d1 = this.waypointY - this.posY; + double d2 = this.waypointZ - this.posZ; + double d3 = d0 * d0 + d1 * d1 + d2 * d2; + + if (d3 < 1.0D || d3 > 3600.0D) + { + this.waypointX = this.posX + (double)((this.rand.nextFloat() * 2.0F - 1.0F) * 4.0F); + this.waypointY = this.posY + (double)((this.rand.nextFloat() * 2.0F - 1.0F) * 4.0F); + this.waypointZ = this.posZ + (double)((this.rand.nextFloat() * 2.0F - 1.0F) * 4.0F); + } + + if (this.courseChangeCooldown-- <= 0) + { + this.courseChangeCooldown += this.rand.nextInt(2) + 2; + d3 = (double)MathHelper.sqrt_double(d3); + + if (this.isCourseTraversable(this.waypointX, this.waypointY, this.waypointZ, d3)) + { + this.motionX += d0 / d3 * 0.1D; + this.motionY += d1 / d3 * 0.1D; + this.motionZ += d2 / d3 * 0.1D; + } + else + { + this.waypointX = this.posX; + this.waypointY = this.posY; + this.waypointZ = this.posZ; + } + } + + this.renderYawOffset = this.rotationYaw = -((float)Math.atan2(this.motionX, this.motionZ)) * 180.0F / (float)Math.PI; + } + + private boolean isCourseTraversable(double par1, double par3, double par5, double par7) + { + double d4 = (this.waypointX - this.posX) / par7; + double d5 = (this.waypointY - this.posY) / par7; + double d6 = (this.waypointZ - this.posZ) / par7; + AxisAlignedBB axisalignedbb = this.boundingBox.copy(); + + for (int i = 1; (double)i < par7; ++i) + { + axisalignedbb.offset(d4, d5, d6); + + if (!this.worldObj.getCollidingBoundingBoxes(this, axisalignedbb).isEmpty()) + { + return false; + } + } + + return true; + } + + @Override + protected String getLivingSound() + { + return "biomesoplenty:mob.wasp.say"; + } + + @Override + protected String getHurtSound() + { + return "biomesoplenty:mob.wasp.hurt"; + } + + @Override + protected String getDeathSound() + { + return "biomesoplenty:mob.wasp.hurt"; + } +} diff --git a/common/biomesoplenty/entities/models/ModelBird.java b/common/biomesoplenty/entities/models/ModelBird.java index dbc3fffea..b48b0ba6a 100644 --- a/common/biomesoplenty/entities/models/ModelBird.java +++ b/common/biomesoplenty/entities/models/ModelBird.java @@ -93,6 +93,7 @@ public class ModelBird extends ModelBase setRotation(LegRight, 0F, 0F, 0F); } + @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); @@ -117,6 +118,7 @@ public class ModelBird extends ModelBase model.rotateAngleZ = z; } + @Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); diff --git a/common/biomesoplenty/entities/render/RenderBird.java b/common/biomesoplenty/entities/render/RenderBird.java new file mode 100644 index 000000000..a2040157c --- /dev/null +++ b/common/biomesoplenty/entities/render/RenderBird.java @@ -0,0 +1,28 @@ +package biomesoplenty.entities.render; + +import net.minecraft.client.renderer.entity.RenderLiving; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + +import biomesoplenty.entities.models.ModelBird; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class RenderBird extends RenderLiving +{ + public RenderBird() + { + super(new ModelBird(), 0.25F); + this.shadowSize = 0.0F; + } + + @Override + protected ResourceLocation getEntityTexture(Entity entity) + { + return new ResourceLocation("biomesoplenty:textures/mobs/bird.png"); + } +} diff --git a/resources/assets/biomesoplenty/textures/mobs/bird.png b/resources/assets/biomesoplenty/textures/mobs/bird.png index 3cd2bbe4b..1f5b80245 100644 Binary files a/resources/assets/biomesoplenty/textures/mobs/bird.png and b/resources/assets/biomesoplenty/textures/mobs/bird.png differ