Jump to content

Recommended Posts

Posted (edited)

Heres my code

 

package com.chestedyt.mod.entity.passive;

import net.minecraft.block.Block;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIFollowParent;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMate;
import net.minecraft.entity.ai.EntityAIPanic;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAITempt;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;

public class EntitySquirtle extends EntityAnimal
{
    public EntitySquirtle(World worldIn)
    {
        super(worldIn);
        this.setSize(1.0F, 1.0F);
    }

    protected void initEntityAI()
    {
        
        this.tasks.addTask(0, new EntityAISwimming(this));
        this.tasks.addTask(1, new EntityAIPanic(this, 1.25D));
        this.tasks.addTask(2, new EntityAIMate(this, 1.0D));
        this.tasks.addTask(3, new EntityAITempt(this, 1.25D, Items.fish, false));
        this.tasks.addTask(4, new EntityAIFollowParent(this, 1.25D));
        this.tasks.addTask(5, new EntityAIWander(this, 1.0D));
        this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 20.0F));
        this.tasks.addTask(7, new EntityAILookIdle(this));
    }
    
    @Override
    public boolean isAIDisabled() {
        return false;
    }

    protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10.0D);
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1.0D);
    }
    
    public boolean isBreedingItem(ItemStack itemstack) {
        return itemstack != null && itemstack.getItem() == Items.fish;
    }
    
    public boolean canBreatheUnderwater() {
        return true;
    }
    
    public boolean isPushedByWater() {
        return false;
    }
    
    public void onLivingUpdate() {
        super.onLivingUpdate();
        
        if(this.isInWater()) {
            this.setAir(300);
            this.limbSwingAmount = 0;
            this.limbSwing = 0;
            this.prevLimbSwingAmount = this.limbSwingAmount;
        }
    }
    
    @Override
    protected String getLivingSound() {
        return "mob.rabbit.idle";
    }
    
    @Override
    protected String getHurtSound() {
        return "mob.rabbit.hurt";
    }
    
    @Override
    protected String getDeathSound() {
        return "mob.rabbit.death";
    }
    
    protected void func_180429_a(BlockPos bp, Block b) {
        this.playSound("mob.cow.step", 0.15f, 2.0f);
    }
    
    protected float getSoundVolume() {
        return 0.4f;
    }
    
    protected Item getDropItem() {
        return Items.leather;
    }
    
    protected void dropFewItems(boolean recentlyhit, int modifier) {
        this.dropItem(Items.leather, 1);
    }
    
    @Override
    public boolean interact(EntityPlayer player) {
        
        return super.interact(player);
        
    }

    public EntitySquirtle createChild(EntityAgeable ageable)
    {
        return new EntitySquirtle(this.worldObj);
    }

    public float getEyeHeight()
    {
        return 1.3F;
    }
    
    public boolean getCanSpawnHere() {
        return super.getCanSpawnHere();
    }
    
    public void moveEntityWithHeading(float x, float z) {
        if(this.isInWater())
        {
            this.moveFlying(x, z, 0.1f);
            this.moveEntity(this.motionX, this.motionY, this.motionZ);
            this.motionX *= 0.8D;
            this.motionY *= 0.8D;
            this.motionZ *= 0.8D;
        }
        else
        {
            super.moveEntityWithHeading(x, z);
        }
    }
}

Edited by Chesy
Enter Code
Posted

Well, what have you done to debug it? Does it have trouble moving both in water and out of water?

 

Have you confirmed whether the wander AI (or swimming if in water) is being called correctly? You can set breakpoints and run Eclipse in debug mode to check.

 

Have you confirmed whether the moveEntityWithHeading() method is being called correctly? You can set breakpoints and run Eclipse in debug mode, or you can add console statements (System.out.println()) to check.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted
18 hours ago, Chesy said:

Still not working!

Still didn't give us any information so we can help you. You need to answer my questions. What did you try for debugging? Did you confirm the AI is being called? Which path of your code is being executed? Is it a problem with swimming or with wandering?

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.