Jump to content

[1.7.10] Stop mob from jumping around?


Eternaldoom

Recommended Posts

Hi,

I'm creating a mob that's supposed to appear as a grass block until the player goes near it. However, this "illusion" is broken by the mob periodically bouncing up. Is there a way to prevent this?

 

A video of the issue I'm having: http://gfycat.com/MeagerDentalBallpython

 

Mob code:

public class EntityKobblin extends EntityDivineRPGMob {

    public EntityKobblin(World par1World) {
        super(par1World);
        this.setSize(0.75F, 1F);
    }

    @Override
    public void entityInit() {
        super.entityInit();
        this.dataWatcher.addObject(17, 0);
        this.dataWatcher.addObject(18, 0);
    }

    @Override
    protected void applyEntityAttributes() {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(net.divinerpg.entities.base.EntityStats.caveCrawlerHealth);
        this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(net.divinerpg.entities.base.EntityStats.caveCrawlerDamage);
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(net.divinerpg.entities.base.EntityStats.caveCrawlerSpeed);
        this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(net.divinerpg.entities.base.EntityStats.caveCrawlerFollowRange);
    }

    @Override
    protected String getLivingSound() {
        return null;
    }

    @Override
    protected void playStepSound(int x, int y, int z, Block b) {}

    @Override
    protected String getHurtSound() {
        return Sounds.getSoundName(Sounds.kobblin);
    }

    @Override
    protected String getDeathSound() {
        return Sounds.getSoundName(Sounds.kobblin);
    }

    @Override
    public void onUpdate() {
        super.onUpdate();
        if(!getProvoked()) {
            this.renderYawOffset=0;
            if(this.worldObj.getClosestVulnerablePlayerToEntity(this, 6) != null) this.setProvoked();
        }
        if(!getGrounded()) {
            if(this.worldObj.getBlock((int) this.posX, MathHelper.floor_double(this.posY) - 1, (int) this.posZ) == Blocks.grass) {
                this.worldObj.setBlock((int)this.posX, MathHelper.floor_double(this.posY)-1, (int)this.posZ, Blocks.air);
                this.setGrounded();
                this.posY--;
            }
        }
    }
    public boolean needsSpecialAI() {
        return true;
    }

    public boolean getGrounded() {
        return this.dataWatcher.getWatchableObjectInt(17)==1;
    }

    public boolean getProvoked() {
        return this.dataWatcher.getWatchableObjectInt(18)==1;
    }

    public void setGrounded() {
        this.dataWatcher.updateObject(17, 1);
    }

    public void setProvoked() {
        this.dataWatcher.updateObject(18, 1);
        addBasicAI();
        addAttackingAI();
    }

    @Override
    protected Item getDropItem() {
        return VanillaItemsOther.realmiteIngot;
    }

    @Override
    protected boolean isValidLightLevel() {
        return true;
    }

    @Override
    public boolean getCanSpawnHere() {
        return this.worldObj.getBlock((int)this.posX, MathHelper.floor_double(this.posY)-1, (int)this.posZ) == Blocks.grass && super.getCanSpawnHere();
    }

    @Override
    public String mobName() {
        return "Kobblin";
    }
}

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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