Jump to content

Recommended Posts

Posted

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!  :)

Hello everyone! I'm the developer and owner of a mod called MagZ Aquatic Life Experience. Right now it's being worked on, but when it's released, check it out!

 

--[Also Check Out My Website!]--

Posted

Hi

 

I suggest you derive your new Entity from the Squid class, make sure you can spawn it and it acts like a Squid.  Then override one method at a time to implement the new behaviour you want (if any).

 

What specifically are you trying to do that isn't working?

 

-TGG

Posted

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  :)

Hello everyone! I'm the developer and owner of a mod called MagZ Aquatic Life Experience. Right now it's being worked on, but when it's released, check it out!

 

--[Also Check Out My Website!]--

Posted

Well it is very simple actually. If you punch or touch him you need to override the correct function, neither of which I see in your provided code.

Furthermore, if you override a squid it is quite normal it won't do anything as a squid doesn't interact with the player, with the exception of dying of course.

Basically, look at the base class of EntityWaterMob base class.

Have a look at the following functions:

    protected void attackEntity(Entity par1Entity, float par2) 
    {

    }

    protected Entity findPlayerToAttack()
    {
        return null;
    }

    public Entity getEntityToAttack()
    {
        return this.entityToAttack;
    }

    public void setTarget(Entity par1Entity)
    {
        this.entityToAttack = par1Entity;
    }

 

And if you need to right click the entity have a look at the base class EntityLiving(below EntityWaterMob):

 

  protected boolean interact(EntityPlayer par1EntityPlayer)
    {
        return false;
    }

 

So really, all you have to do is go into the classes your mob inherits and look which functions you need, override them and add what you need.

Everyone needs to do that.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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