Jump to content

Recommended Posts

Posted

Hello guys,

 

I got a problem with my swimming mob, you see, I tried editing the code of the squid to fit it but instead of swimming it stays frozen in one spot and just spins around like a moron. I tried alot, but nothing happend and there are 0 tutorials on it. Help would really be appreciated.

 

package modfile;

import net.minecraft.block.material.Material;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.passive.EntityWaterMob;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class EntitySwimmingMobextends EntityWaterMob
{
    private float randomMotionVecX = 0.0F;
    private float randomMotionVecY = 0.0F;
    private float randomMotionVecZ = 0.0F;
    private float randomMotionSpeed = 1.0F;
    
public EntitySwimmingMobWorld par1World)
{
super(par1World);
    this.texture = "/Mob.png";
    this.canBreatheUnderwater();
}

public int getMaxHealth() 
{
	return 10;
}
    public void moveEntityWithHeading(float par1, float par2)
    {
        this.moveEntity(this.motionX, this.motionY, this.motionZ);
    }
    public boolean isInWater()
    {
        return this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(0.0D, 0.0D, 0.0D), Material.water, this);
    }
    public void onLivingUpdate()
    {
        {       	
            this.motionX = (double)(this.randomMotionVecX * this.randomMotionSpeed);
            this.motionY = (double)(this.randomMotionVecY * this.randomMotionSpeed);
            this.motionZ = (double)(this.randomMotionVecZ * this.randomMotionSpeed);
            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.renderYawOffset += (-((float)Math.atan2(this.motionX, this.motionZ)) * 180.0F / (float)Math.PI - this.renderYawOffset) * 0.1F;
            this.rotationYaw = this.renderYawOffset;
        }
    }
    
    /**
     * Checks if the entity's current position is a valid location to spawn this entity.
     */
    public boolean getCanSpawnHere()
    {
            return posY > 45D && posY < 63D && super.getCanSpawnHere();
    }
}

Posted

Hello guys,

 

I got a problem with my swimming mob, you see, I tried editing the code of the squid to fit it but instead of swimming it stays frozen in one spot and just spins around like a moron. I tried alot, but nothing happend and there are 0 tutorials on it. Help would really be appreciated.

 

package modfile;

import net.minecraft.block.material.Material;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.passive.EntityWaterMob;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class EntitySwimmingMobextends EntityWaterMob
{
    private float randomMotionVecX = 0.0F;
    private float randomMotionVecY = 0.0F;
    private float randomMotionVecZ = 0.0F;
    private float randomMotionSpeed = 1.0F;
    
public EntitySwimmingMobWorld par1World)
{
super(par1World);
    this.texture = "/Mob.png";
    this.canBreatheUnderwater();
}

public int getMaxHealth() 
{
	return 10;
}
    public void moveEntityWithHeading(float par1, float par2)
    {
        this.moveEntity(this.motionX, this.motionY, this.motionZ);
    }
    public boolean isInWater()
    {
        return this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(0.0D, 0.0D, 0.0D), Material.water, this);
    }
    public void onLivingUpdate()
    {
        {       	
            this.motionX = (double)(this.randomMotionVecX * this.randomMotionSpeed);
            this.motionY = (double)(this.randomMotionVecY * this.randomMotionSpeed);
            this.motionZ = (double)(this.randomMotionVecZ * this.randomMotionSpeed);
            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.renderYawOffset += (-((float)Math.atan2(this.motionX, this.motionZ)) * 180.0F / (float)Math.PI - this.renderYawOffset) * 0.1F;
            this.rotationYaw = this.renderYawOffset;
        }
    }
    
    /**
     * Checks if the entity's current position is a valid location to spawn this entity.
     */
    public boolean getCanSpawnHere()
    {
            return posY > 45D && posY < 63D && super.getCanSpawnHere();
    }
}

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.