Jump to content

MagnumMike55

Members
  • Posts

    30
  • Joined

  • Last visited

Everything posted by MagnumMike55

  1. Quick question coolAlias. When you said "create a custom AI class and add it as a task for your fish" does that mean make the custom ai class and in my entityfishmob class, extend it? Ex: public class EntityFishMob extends CustomAI() { } I think i'm just confused on what you're saying, even if it is obvious. Anyway thanks for the help!
  2. Thanks for the reply! But yeah I can't find any open source code for fish mobs . Could you possibly help me work things out? Like how to make it pathfind and such. I'm a little new to how mob AI's work for minecraft. I was mainly focused on gui's, tile entities and such. So could anyone help me out? Please don't post code, just tell me how to work things out. Thanks
  3. What I mean is my water mob is jumping in the water like regular mobs do. Here is my code and yes I did extend the entitywatermob class. If things look like they shoudn't be there, it's becuase im trying to write my own AI since the entitysquid class isn't helping. My entityfishmob class: package com.MagZAquaticLifeExperience.common.entity; import com.MagZAquaticLifeExperience.common.MagzAquaticLifeExperience; import net.minecraft.block.material.Material; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.passive.EntityWaterMob; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class EntityFishMob extends EntityWaterMob { private float randomMotionSpeed; private float randomMotionVecX; private float randomMotionVecY; private float randomMotionVecZ; public EntityFishMob(World par1World) { super(par1World); this.setSize(1.0F, 0.5F); } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(4.0D); } public boolean canBreatheUnderwater() { return true; } public void moveEntityWithHeading(float par1, float par2) { this.moveEntity(this.motionX, this.motionY, this.motionZ); } @Override public boolean isInWater() { return this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(1.0D, 0.0D, 0.0D), Material.water, this); } @Override public void onLivingUpdate() { super.onLivingUpdate(); if(this.isInWater()) { this.randomMotionSpeed = 2.0F; } if(!this.isInWater()) { this.randomMotionSpeed = 0.0F; } } protected String getLivingSound() { return ""; } protected String getDeathSound() { return ""; } }
  4. Hello everyone. I know i've been asking this for a while now, but still even without asking for help, I still cant get my fish mob working the way I want it to. My fish mob will float like regular mobs would. So can anyone help me? How can I make a water mob? Should I make my own AI for it or something? I really need help guys becuase I have no clue what to do. Any help is appretiated like always .
  5. Well for some reason my mob just sits there and when i punch him or move him, he doesn't stop moving. Could you help me with that? EntityFishMob class: package com.MagZAquaticLifeExperience.common.entity; import com.MagZAquaticLifeExperience.common.MagzAquaticLifeExperience; import net.minecraft.block.material.Material; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.passive.EntityWaterMob; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class EntityFishMob extends EntityWaterMob { private float randomMotionSpeed; private float randomMotionVecX; private float randomMotionVecY; private float randomMotionVecZ; public EntityFishMob(World par1World) { super(par1World); this.setSize(1.0F, 0.5F); } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(200.0D); } @Override protected boolean canTriggerWalking() { return false; } @Override public boolean isInWater() { return this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(0.0D, -0.6000000238418579D, 0.0D), Material.water, this); } @Override public void onLivingUpdate() { super.onLivingUpdate(); if (this.isInWater()) { this.randomMotionSpeed = 4.0F; this.randomMotionVecX = 1.0F; this.randomMotionVecY = 1.0F; this.randomMotionVecZ = 1.0F; this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(0.0D, -0.6000000238418579D, 0.0D), Material.water, this); }else{ this.randomMotionSpeed = 0.0F; this.randomMotionVecX = 0.0F; this.randomMotionVecY = 0.0F; this.randomMotionVecZ = 0.0F; } } @Override public void moveEntityWithHeading(float par1, float par2) { this.moveEntity(this.motionX, this.motionY, this.motionZ); } @Override protected void updateEntityActionState() { ++this.entityAge; if (this.entityAge > 100) { this.randomMotionVecX = this.randomMotionVecY = this.randomMotionVecZ = 0.0F; } else if (this.rand.nextInt(50) == 0 || !this.inWater || this.randomMotionVecX == 0.0F && this.randomMotionVecY == 0.0F && this.randomMotionVecZ == 0.0F) { float f = this.rand.nextFloat() * (float)Math.PI * 2.0F; this.randomMotionVecX = MathHelper.cos(f) * 0.2F; this.randomMotionVecY = -0.1F + this.rand.nextFloat() * 0.2F; this.randomMotionVecZ = MathHelper.sin(f) * 0.2F; } this.despawnEntity(); } @Override public boolean getCanSpawnHere() { return this.posY > 45.0D && this.posY < 63.0D && super.getCanSpawnHere(); } @Override protected void dropFewItems(boolean par1, int par2) { int j = this.rand.nextInt(3 + par2) + 1; for (int k = 0; k < j; ++k) { this.entityDropItem(new ItemStack(MagzAquaticLifeExperience.SaltwaterFish, 1, 0), 0.0F); } } protected String getLivingSound() { return ""; } protected String getDeathSound() { return ""; } } Like I said before, any help is appretiated
  6. Hello everyone. I've been asking and trying to find an answer, but with no avail. I'm still trying to find an answer, but really, no one cares about water mobs and my mod is all about water mobs. So can anyone please show me how to make a water mob, like a tutorial or something, becuase mine doesn't work. I'm actually pretty experienced with java, but I have no idea how to make a water mob. And yes I have checked the entitysquid class and I have copied and pasted code and switched it around, but it still doesn't work. Really i'm sick of trying to find an answer, becuase no one cares about water mobs or bothers to make a tutorial on it. So can anyone help me? Could anyone point me in a direction to go in to learn how water mobs work or something? Anything is appretiated!
  7. Ok so now I edited and switched around a couple things in my entityfishmob class, but now when I spawn the mob, it just flies straight up and never dies. Can anyone help me out? Here is my code: package com.MagZAquaticLifeExperience.common.entity; import com.MagZAquaticLifeExperience.common.MagzAquaticLifeExperience; import net.minecraft.block.material.Material; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.passive.EntityWaterMob; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class EntityFishMob extends EntityWaterMob { private float randomMotionSpeed; private float randomMotionVecX; private float randomMotionVecY; private float randomMotionVecZ; public EntityFishMob(World par1World) { super(par1World); this.setSize(1.0F, 0.5F); } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(200.0D); } @Override protected boolean canTriggerWalking() { return false; } @Override public boolean isInWater() { return true; //this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(0.0D, -0.6000000238418579D, 0.0D), Material.water, this) } @Override public void onLivingUpdate() { super.onLivingUpdate(); if (this.isInWater()) { this.randomMotionSpeed = 4.0F; this.randomMotionVecX = 1.0F; this.randomMotionVecY = 1.0F; this.randomMotionVecZ = 1.0F; this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(0.0D, -0.6000000238418579D, 0.0D), Material.water, this); }else{ this.randomMotionSpeed = 0.0F; this.randomMotionVecX = 0.0F; this.randomMotionVecY = 0.0F; this.randomMotionVecZ = 0.0F; } if (!this.worldObj.isRemote) { this.motionX = (double)(this.randomMotionVecX * this.randomMotionSpeed); this.motionY = (double)(this.randomMotionVecY * this.randomMotionSpeed); this.motionZ = (double)(this.randomMotionVecZ * this.randomMotionSpeed); } if (!this.worldObj.isRemote) { this.motionX = 0.0D; this.motionY -= 0.08D; this.motionY *= 0.9800000190734863D; this.motionZ = 0.0D; } } @Override public void moveEntityWithHeading(float par1, float par2) { this.moveEntity(this.motionX, this.motionY, this.motionZ); } @Override protected void updateEntityActionState() { ++this.entityAge; if (this.entityAge > 100) { this.randomMotionVecX = this.randomMotionVecY = this.randomMotionVecZ = 0.0F; } else if (this.rand.nextInt(50) == 0 || !this.inWater || this.randomMotionVecX == 0.0F && this.randomMotionVecY == 0.0F && this.randomMotionVecZ == 0.0F) { float f = this.rand.nextFloat() * (float)Math.PI * 2.0F; this.randomMotionVecX = MathHelper.cos(f) * 0.2F; this.randomMotionVecY = -0.1F + this.rand.nextFloat() * 0.2F; this.randomMotionVecZ = MathHelper.sin(f) * 0.2F; } this.despawnEntity(); } @Override public boolean getCanSpawnHere() { return this.posY > 45.0D && this.posY < 63.0D && super.getCanSpawnHere(); } @Override protected void dropFewItems(boolean par1, int par2) { int j = this.rand.nextInt(3 + par2) + 1; for (int k = 0; k < j; ++k) { this.entityDropItem(new ItemStack(MagzAquaticLifeExperience.SaltwaterFish, 1, 0), 0.0F); } } protected String getLivingSound() { return ""; } protected String getDeathSound() { return ""; } }
  8. Ok, so now my mob doesn't die after a little bit of time, but it doesn't matter if he is in the water or not. Im thinking I could just do this to make it move: this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.5D); and put this under the applyEntityAttributes method. Would that make it actually move or is there something else I have to do? Also what could I do so my fish mob dies on land but not in water? Any help would be appretiated!
  9. It's illegal to post Mojang code? woops. Sorry if I seem desperate, but thanks for the reply!
  10. I guess i'm back to bumping . Can anyone help me? I've been trying all day to try and get this to work, I would search around the minecraft forge forums and find nothing. I would look deeply into any code that involves underwater entity methods and or the entitysquid class and end up with no success. I'm not a noob(even though I kinda sound like one), I know how to code with java, but I have no experience on how underwater mobs work. So even if you don't know how to fix this, can you please point me out in some direction to learning how water mobs work? Any help would be appretiated.
  11. I've been looking around in the entity squid class and copying and pasting important info and changing it up a little bit. But my mob still doesn't do anything and it still dies even in water. Here is my entity class: package com.MagZAquaticLifeExperience.common.entity; import com.MagZAquaticLifeExperience.common.MagzAquaticLifeExperience; import net.minecraft.block.material.Material; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.passive.EntityWaterMob; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class EntityFishMob extends EntityWaterMob { private float randomMotionSpeed; private float randomMotionVecX; private float randomMotionVecY; private float randomMotionVecZ; public EntityFishMob(World par1World) { super(par1World); this.setSize(1.0F, 0.5F); } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(2.0D); } protected boolean canTriggerWalking() { return false; } public boolean isInWater() { return this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(0.0D, -0.6000000238418579D, 0.0D), Material.water, this); } public void onLivingUpdate() { super.onLivingUpdate(); if (this.isInWater()) { float f= 0; if ((double)f > 0.75D) { this.randomMotionSpeed = 1.0F; } else { } } else { this.randomMotionSpeed *= 0.9F; } if (!this.worldObj.isRemote) { this.motionX = (double)(this.randomMotionVecX * this.randomMotionSpeed); this.motionY = (double)(this.randomMotionVecY * this.randomMotionSpeed); this.motionZ = (double)(this.randomMotionVecZ * this.randomMotionSpeed); } float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); } { if (!this.worldObj.isRemote) { this.motionX = 0.0D; this.motionY -= 0.08D; this.motionY *= 0.9800000190734863D; this.motionZ = 0.0D; } } public void moveEntityWithHeading(float par1, float par2) { this.moveEntity(this.motionX, this.motionY, this.motionZ); } protected void updateEntityActionState() { ++this.entityAge; if (this.entityAge > 100) { this.randomMotionVecX = this.randomMotionVecY = this.randomMotionVecZ = 0.0F; } else if (this.rand.nextInt(50) == 0 || !this.inWater || this.randomMotionVecX == 0.0F && this.randomMotionVecY == 0.0F && this.randomMotionVecZ == 0.0F) { float f = this.rand.nextFloat() * (float)Math.PI * 2.0F; this.randomMotionVecX = MathHelper.cos(f) * 0.2F; this.randomMotionVecY = -0.1F + this.rand.nextFloat() * 0.2F; this.randomMotionVecZ = MathHelper.sin(f) * 0.2F; } this.despawnEntity(); } public boolean getCanSpawnHere() { return this.posY > 45.0D && this.posY < 63.0D && super.getCanSpawnHere(); } protected void dropFewItems(boolean par1, int par2) { int j = this.rand.nextInt(3 + par2) + 1; for (int k = 0; k < j; ++k) { this.entityDropItem(new ItemStack(MagzAquaticLifeExperience.SaltwaterFish, 1, 0), 0.0F); } } protected Item getDropItem() { return Item.getItemById(349); } protected String getLivingSound() { return ""; } protected String getDeathSound() { return ""; } } Is there a specific part i'm missing in my entityfishmob class that i don't have that the entitySquid class has? or what? Please help.
  12. I'm still having trouble understanding this. My mob won't move and it dies after a certain amount of time becuase the entity id isn't registered? Or what? I'm completly lost. I think if I know whats wrong, i'll understand my situation a little bit more.
  13. Well I have this in my main mod class: private static int startEntityId = 300; EntityRegistry.registerGlobalEntityID(EntityFishMob.class, "Fish", EntityRegistry.findGlobalUniqueEntityId()); EntityRegistry.addSpawn(EntityFishMob.class, 10, 2, 4, EnumCreatureType.waterCreature); EntityRegistry.findGlobalUniqueEntityId(); registerEntityEgg(EntityFishMob.class, 0x0033FF, 0x003399); That and this to register a unique entity id and to register an entity egg: private void registerEntityEgg(Class<? extends Entity> entity, int primaryColor, int secondaryColor) { int id = getUniqueEntityId(); EntityList.IDtoClassMapping.put(id, entity); EntityList.entityEggs.put(id, new EntityEggInfo(id, primaryColor, secondaryColor)); } private int getUniqueEntityId() { do { startEntityId++; } while(EntityList.getStringFromID(startEntityId) != null); return startEntityId++; } } Can anyone tell me what is wrong?
  14. Is this what your talking about? private static int startEntityId = 300; Because if it is, then that's not the problem
  15. I already put it in my client proxy. Do you have to put it in the common proxy or not?
  16. Because I didn't have the code inserts so the post was extremly long.
  17. Hello everyone. I'm having difficulties with my water mob. For some reason it will just stand there and after a little bit, they'll just die. Here is all the code for my fish mob: Model Class: // Date: 7/11/2014 10:29:28 PM // Template version 1.1 // Java generated by Techne // Keep in mind that you still need to fill in some blanks // - ZeuX package com.MagZAquaticLifeExperience.common.model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelFish extends ModelBase { //fields ModelRenderer body001; ModelRenderer mouth001; ModelRenderer top001; ModelRenderer body002; ModelRenderer body003; ModelRenderer mouth002; ModelRenderer body004; ModelRenderer body005; ModelRenderer body006; ModelRenderer body007; ModelRenderer sidefin001; ModelRenderer sidefin002; ModelRenderer topfin001; ModelRenderer bottomfin001; public ModelFish() { textureWidth = 64; textureHeight = 32; body001 = new ModelRenderer(this, 0, 0); body001.addBox(-1F, 0F, 0F, 3, 3, 6); body001.setRotationPoint(0F, 20F, -3F); body001.setTextureSize(64, 32); body001.mirror = true; setRotation(body001, 0F, 0F, 0F); mouth001 = new ModelRenderer(this, 56, 0); mouth001.addBox(0F, 0F, 0F, 3, 2, 1); mouth001.setRotationPoint(-1F, 20.5F, -3.6F); mouth001.setTextureSize(64, 32); mouth001.mirror = true; setRotation(mouth001, 0F, 0F, 0F); top001 = new ModelRenderer(this, 41, 0); top001.addBox(0F, -1F, 0F, 3, 1, 4); top001.setRotationPoint(-1F, 20.6F, -2F); top001.setTextureSize(64, 32); top001.mirror = true; setRotation(top001, 0F, 0F, 0F); body002 = new ModelRenderer(this, 56, 4); body002.addBox(0F, 0F, 0F, 3, 2, 1); body002.setRotationPoint(-1F, 20.5F, 2.7F); body002.setTextureSize(64, 32); body002.mirror = true; setRotation(body002, 0F, 0F, 0F); body003 = new ModelRenderer(this, 47, 6); body003.addBox(0F, 0F, 0F, 3, 2, 1); body003.setRotationPoint(-1F, 20.5F, 3.2F); body003.setTextureSize(64, 32); body003.mirror = true; setRotation(body003, 0F, 0F, 0F); mouth002 = new ModelRenderer(this, 56, ; mouth002.addBox(0F, 0F, 0F, 3, 1, 1); mouth002.setRotationPoint(-1F, 21F, -4F); mouth002.setTextureSize(64, 32); mouth002.mirror = true; setRotation(mouth002, 0F, 0F, 0F); body004 = new ModelRenderer(this, 56, 11); body004.addBox(0F, 0F, 0F, 3, 1, 1); body004.setRotationPoint(-1F, 21F, 3.7F); body004.setTextureSize(64, 32); body004.mirror = true; setRotation(body004, 0F, 0F, 0F); body005 = new ModelRenderer(this, 49, 10); body005.addBox(0F, 0F, 0F, 2, 1, 1); body005.setRotationPoint(-0.5F, 20F, 2.6F); body005.setTextureSize(64, 32); body005.mirror = true; setRotation(body005, 0F, 0F, 0F); body006 = new ModelRenderer(this, 51, 13); body006.addBox(0F, 0F, 0F, 1, 1, 1); body006.setRotationPoint(0F, 19.6F, 2F); body006.setTextureSize(64, 32); body006.mirror = true; setRotation(body006, 0F, 0F, 0F); body007 = new ModelRenderer(this, 60, 14); body007.addBox(0F, -1F, 0F, 1, 1, 1); body007.setRotationPoint(0F, 20.6F, -2.6F); body007.setTextureSize(64, 32); body007.mirror = true; setRotation(body007, 0F, 0F, 0F); sidefin001 = new ModelRenderer(this, 34, 0); sidefin001.addBox(0F, 0F, 0F, 0, 3, 3); sidefin001.setRotationPoint(2F, 19.9F, -2F); sidefin001.setTextureSize(64, 32); sidefin001.mirror = true; setRotation(sidefin001, 0F, 0.4461433F, 0F); sidefin002 = new ModelRenderer(this, 27, 0); sidefin002.addBox(0F, 0F, 0F, 0, 3, 3); sidefin002.setRotationPoint(-1F, 19.9F, -2F); sidefin002.setTextureSize(64, 32); sidefin002.mirror = true; setRotation(sidefin002, 0F, -0.4461411F, 0F); topfin001 = new ModelRenderer(this, 32, 7); topfin001.addBox(0F, -3F, 0F, 0, 3, 4); topfin001.setRotationPoint(0.5F, 20.5F, -2F); topfin001.setTextureSize(64, 32); topfin001.mirror = true; setRotation(topfin001, 0F, 0F, 0F); bottomfin001 = new ModelRenderer(this, 20, 0); bottomfin001.addBox(0F, -1F, 0F, 0, 3, 3); bottomfin001.setRotationPoint(0.5F, 21F, 4.5F); bottomfin001.setTextureSize(64, 32); bottomfin001.mirror = true; setRotation(bottomfin001, 0F, 0F, 0F); } public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) { setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); body001.render(par7); mouth001.render(par7); top001.render(par7); body002.render(par7); body003.render(par7); mouth002.render(par7); body004.render(par7); body005.render(par7); body006.render(par7); body007.render(par7); sidefin001.render(par7); sidefin002.render(par7); topfin001.render(par7); bottomfin001.render(par7); } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } public void setRotationAngles(float par2, float par3, float par4, float par5, float par6, Entity par7Entity) { } } Render Class: package com.MagZAquaticLifeExperience.common.render; import com.MagZAquaticLifeExperience.common.entity.EntityFishMob; import com.MagZAquaticLifeExperience.common.model.ModelFish; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.util.ResourceLocation; public class RenderFish extends RenderLiving { private static final ResourceLocation EntityTexture = new ResourceLocation("magzaquaticlifeexperience:/textures/mobs/Fish.png"); protected ModelFish model; public RenderFish(ModelBase par1ModelBase, float par2) { super(par1ModelBase, par2); model = ((ModelFish)mainModel); } public void RenderFish(EntityFishMob entity, double par2, double par4, double par6, float par8, float par9) { super.doRender(entity, par2, par4, par6, par8, par9); } public void doRenderLiving(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) { RenderFish((EntityFishMob)par1EntityLiving, par2, par4, par6, par8, par9); } public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { RenderFish((EntityFishMob)par1Entity, par2, par4, par6, par8, par9); } @Override protected ResourceLocation getEntityTexture(Entity entity) { return EntityTexture; } } Entity Class: package com.MagZAquaticLifeExperience.common.entity; import com.MagZAquaticLifeExperience.common.MagzAquaticLifeExperience; import net.minecraft.block.material.Material; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.passive.EntityWaterMob; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class EntityFishMob extends EntityWaterMob { private float randomMotionSpeed; private float randomMotionVecX; private float randomMotionVecY; private float randomMotionVecZ; public EntityFishMob(World par1World) { super(par1World); this.setSize(1.0F, 0.5F); } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(2.0D); } protected boolean canTriggerWalking() { return false; } public boolean isInWater() { return this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(0.0D, -0.6000000238418579D, 0.0D), Material.water, this); } public void onLivingUpdate() { super.onLivingUpdate(); if (this.isInWater()) { float f= 0; if ((double)f > 0.75D) { this.randomMotionSpeed = 1.0F; } else { } } else { this.randomMotionSpeed *= 0.9F; } if (!this.worldObj.isRemote) { this.motionX = (double)(this.randomMotionVecX * this.randomMotionSpeed); this.motionY = (double)(this.randomMotionVecY * this.randomMotionSpeed); this.motionZ = (double)(this.randomMotionVecZ * this.randomMotionSpeed); } float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); } { if (!this.worldObj.isRemote) { this.motionX = 0.0D; this.motionY -= 0.08D; this.motionY *= 0.9800000190734863D; this.motionZ = 0.0D; } } public void moveEntityWithHeading(float par1, float par2) { this.moveEntity(this.motionX, this.motionY, this.motionZ); } protected void updateEntityActionState() { ++this.entityAge; if (this.entityAge > 100) { this.randomMotionVecX = this.randomMotionVecY = this.randomMotionVecZ = 0.0F; } else if (this.rand.nextInt(50) == 0 || !this.inWater || this.randomMotionVecX == 0.0F && this.randomMotionVecY == 0.0F && this.randomMotionVecZ == 0.0F) { float f = this.rand.nextFloat() * (float)Math.PI * 2.0F; this.randomMotionVecX = MathHelper.cos(f) * 0.2F; this.randomMotionVecY = -0.1F + this.rand.nextFloat() * 0.2F; this.randomMotionVecZ = MathHelper.sin(f) * 0.2F; } this.despawnEntity(); } public boolean getCanSpawnHere() { return this.posY > 45.0D && this.posY < 63.0D && super.getCanSpawnHere(); } protected void dropFewItems(boolean par1, int par2) { int j = this.rand.nextInt(3 + par2) + 1; for (int k = 0; k < j; ++k) { this.entityDropItem(new ItemStack(MagzAquaticLifeExperience.SaltwaterFish, 1, 0), 0.0F); } } protected Item getDropItem() { return Item.getItemById(349); } protected String getLivingSound() { return ""; } protected String getDeathSound() { return ""; } } ProxyClient Class: package com.MagZAquaticLifeExperience.common.lib; import com.MagZAquaticLifeExperience.common.entity.EntityFishMob; import com.MagZAquaticLifeExperience.common.model.ModelFish; import com.MagZAquaticLifeExperience.common.render.RenderFish; import cpw.mods.fml.client.registry.RenderingRegistry; public class ProxyClient extends ProxyCommon{ public void RegisterInformation() { RenderingRegistry.registerEntityRenderingHandler(EntityFishMob.class, new RenderFish(new ModelFish(), 0.2F)); } }
  18. Hello, everyone. I was wondering how could I make a water mob. I'm having an extremely hard time trying to get my fish mob to swim in the water. It just stays in place and after a little bit, it just dies. I even extended my FishEntityMob class to EntityWaterMob and took some methods from the squid class that looked like it would make the fish move. Here are my classes. (Sorry if some parts of the code look like they shouldn't be their or what. I just have no idea what to do.) [Also sorry for having the code put out. For some reason it wont let me insert those code things ] RENDER CLASS: --------------------- package com.MagZAquaticLifeExperience.common.render; import com.MagZAquaticLifeExperience.common.entity.EntityFishMob; import com.MagZAquaticLifeExperience.common.model.ModelFish; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.util.ResourceLocation; public class RenderFish extends RenderLiving { private static final ResourceLocation EntityTexture = new ResourceLocation("magzaquaticlifeexperience:/textures/mobs/Fish.png"); protected ModelFish model; public RenderFish(ModelBase par1ModelBase, float par2) { super(par1ModelBase, par2); model = ((ModelFish)mainModel); } public void RenderFish(EntityFishMob entity, double par2, double par4, double par6, float par8, float par9) { super.doRender(entity, par2, par4, par6, par8, par9); } public void doRenderLiving(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) { RenderFish((EntityFishMob)par1EntityLiving, par2, par4, par6, par8, par9); } public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { RenderFish((EntityFishMob)par1Entity, par2, par4, par6, par8, par9); } @Override protected ResourceLocation getEntityTexture(Entity entity) { return EntityTexture; } } --------------------------------------------------------- MODEL CLASS ----------------------------------------------------- // Date: 7/11/2014 10:29:28 PM // Template version 1.1 // Java generated by Techne // Keep in mind that you still need to fill in some blanks // - ZeuX package com.MagZAquaticLifeExperience.common.model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelFish extends ModelBase { //fields ModelRenderer body001; ModelRenderer mouth001; ModelRenderer top001; ModelRenderer body002; ModelRenderer body003; ModelRenderer mouth002; ModelRenderer body004; ModelRenderer body005; ModelRenderer body006; ModelRenderer body007; ModelRenderer sidefin001; ModelRenderer sidefin002; ModelRenderer topfin001; ModelRenderer bottomfin001; public ModelFish() { textureWidth = 64; textureHeight = 32; body001 = new ModelRenderer(this, 0, 0); body001.addBox(-1F, 0F, 0F, 3, 3, 6); body001.setRotationPoint(0F, 20F, -3F); body001.setTextureSize(64, 32); body001.mirror = true; setRotation(body001, 0F, 0F, 0F); mouth001 = new ModelRenderer(this, 56, 0); mouth001.addBox(0F, 0F, 0F, 3, 2, 1); mouth001.setRotationPoint(-1F, 20.5F, -3.6F); mouth001.setTextureSize(64, 32); mouth001.mirror = true; setRotation(mouth001, 0F, 0F, 0F); top001 = new ModelRenderer(this, 41, 0); top001.addBox(0F, -1F, 0F, 3, 1, 4); top001.setRotationPoint(-1F, 20.6F, -2F); top001.setTextureSize(64, 32); top001.mirror = true; setRotation(top001, 0F, 0F, 0F); body002 = new ModelRenderer(this, 56, 4); body002.addBox(0F, 0F, 0F, 3, 2, 1); body002.setRotationPoint(-1F, 20.5F, 2.7F); body002.setTextureSize(64, 32); body002.mirror = true; setRotation(body002, 0F, 0F, 0F); body003 = new ModelRenderer(this, 47, 6); body003.addBox(0F, 0F, 0F, 3, 2, 1); body003.setRotationPoint(-1F, 20.5F, 3.2F); body003.setTextureSize(64, 32); body003.mirror = true; setRotation(body003, 0F, 0F, 0F); mouth002 = new ModelRenderer(this, 56, ; mouth002.addBox(0F, 0F, 0F, 3, 1, 1); mouth002.setRotationPoint(-1F, 21F, -4F); mouth002.setTextureSize(64, 32); mouth002.mirror = true; setRotation(mouth002, 0F, 0F, 0F); body004 = new ModelRenderer(this, 56, 11); body004.addBox(0F, 0F, 0F, 3, 1, 1); body004.setRotationPoint(-1F, 21F, 3.7F); body004.setTextureSize(64, 32); body004.mirror = true; setRotation(body004, 0F, 0F, 0F); body005 = new ModelRenderer(this, 49, 10); body005.addBox(0F, 0F, 0F, 2, 1, 1); body005.setRotationPoint(-0.5F, 20F, 2.6F); body005.setTextureSize(64, 32); body005.mirror = true; setRotation(body005, 0F, 0F, 0F); body006 = new ModelRenderer(this, 51, 13); body006.addBox(0F, 0F, 0F, 1, 1, 1); body006.setRotationPoint(0F, 19.6F, 2F); body006.setTextureSize(64, 32); body006.mirror = true; setRotation(body006, 0F, 0F, 0F); body007 = new ModelRenderer(this, 60, 14); body007.addBox(0F, -1F, 0F, 1, 1, 1); body007.setRotationPoint(0F, 20.6F, -2.6F); body007.setTextureSize(64, 32); body007.mirror = true; setRotation(body007, 0F, 0F, 0F); sidefin001 = new ModelRenderer(this, 34, 0); sidefin001.addBox(0F, 0F, 0F, 0, 3, 3); sidefin001.setRotationPoint(2F, 19.9F, -2F); sidefin001.setTextureSize(64, 32); sidefin001.mirror = true; setRotation(sidefin001, 0F, 0.4461433F, 0F); sidefin002 = new ModelRenderer(this, 27, 0); sidefin002.addBox(0F, 0F, 0F, 0, 3, 3); sidefin002.setRotationPoint(-1F, 19.9F, -2F); sidefin002.setTextureSize(64, 32); sidefin002.mirror = true; setRotation(sidefin002, 0F, -0.4461411F, 0F); topfin001 = new ModelRenderer(this, 32, 7); topfin001.addBox(0F, -3F, 0F, 0, 3, 4); topfin001.setRotationPoint(0.5F, 20.5F, -2F); topfin001.setTextureSize(64, 32); topfin001.mirror = true; setRotation(topfin001, 0F, 0F, 0F); bottomfin001 = new ModelRenderer(this, 20, 0); bottomfin001.addBox(0F, -1F, 0F, 0, 3, 3); bottomfin001.setRotationPoint(0.5F, 21F, 4.5F); bottomfin001.setTextureSize(64, 32); bottomfin001.mirror = true; setRotation(bottomfin001, 0F, 0F, 0F); } public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) { setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); body001.render(par7); mouth001.render(par7); top001.render(par7); body002.render(par7); body003.render(par7); mouth002.render(par7); body004.render(par7); body005.render(par7); body006.render(par7); body007.render(par7); sidefin001.render(par7); sidefin002.render(par7); topfin001.render(par7); bottomfin001.render(par7); } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } public void setRotationAngles(float par2, float par3, float par4, float par5, float par6, Entity par7Entity) { } } ----------------------------------------------- ENTITY CLASS ------------------------------------------------ package com.MagZAquaticLifeExperience.common.entity; import net.minecraft.block.material.Material; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.passive.EntityWaterMob; import net.minecraft.item.Item; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class EntityFishMob extends EntityWaterMob { private float randomMotionSpeed; private float randomMotionVecX; private float randomMotionVecY; private float randomMotionVecZ; public EntityFishMob(World par1World) { super(par1World); this.setSize(1.0F, 0.5F); } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(2.0D); } protected boolean canTriggerWalking() { return false; } public boolean isInWater() { return this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(0.0D, -0.6000000238418579D, 0.0D), Material.water, this); } public void onLivingUpdate() { super.onLivingUpdate(); if (this.isInWater()) { float f= 0; if ((double)f > 0.75D) { this.randomMotionSpeed = 1.0F; } else { } } else { this.randomMotionSpeed *= 0.9F; } if (!this.worldObj.isRemote) { this.motionX = (double)(this.randomMotionVecX * this.randomMotionSpeed); this.motionY = (double)(this.randomMotionVecY * this.randomMotionSpeed); this.motionZ = (double)(this.randomMotionVecZ * this.randomMotionSpeed); } float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); } { if (!this.worldObj.isRemote) { this.motionX = 0.0D; this.motionY -= 0.08D; this.motionY *= 0.9800000190734863D; this.motionZ = 0.0D; } } public void moveEntityWithHeading(float par1, float par2) { this.moveEntity(this.motionX, this.motionY, this.motionZ); } protected void updateEntityActionState() { ++this.entityAge; if (this.entityAge > 100) { this.randomMotionVecX = this.randomMotionVecY = this.randomMotionVecZ = 0.0F; } else if (this.rand.nextInt(50) == 0 || !this.inWater || this.randomMotionVecX == 0.0F && this.randomMotionVecY == 0.0F && this.randomMotionVecZ == 0.0F) { float f = this.rand.nextFloat() * (float)Math.PI * 2.0F; this.randomMotionVecX = MathHelper.cos(f) * 0.2F; this.randomMotionVecY = -0.1F + this.rand.nextFloat() * 0.2F; this.randomMotionVecZ = MathHelper.sin(f) * 0.2F; } this.despawnEntity(); } public boolean getCanSpawnHere() { return this.posY > 45.0D && this.posY < 63.0D && super.getCanSpawnHere(); } protected Item getDropItem() { return Item.getItemById(349); } protected String getLivingSound() { return ""; } protected String getDeathSound() { return ""; } } -------------------------------------------------------- PROXYCLIENT CLASS -------------------------------------------------------- package com.MagZAquaticLifeExperience.common.lib; import com.MagZAquaticLifeExperience.common.entity.EntityFishMob; import com.MagZAquaticLifeExperience.common.model.ModelFish; import com.MagZAquaticLifeExperience.common.render.RenderFish; import cpw.mods.fml.client.registry.RenderingRegistry; public class ProxyClient extends ProxyCommon{ public void RegisterInformation() { RenderingRegistry.registerEntityRenderingHandler(EntityFishMob.class, new RenderFish(new ModelFish(), 0.2F)); } }
  19. Thanks! I will get back to you if it works! Thanks for the reply !
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.