Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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!

  • Author

Never mind. I suppose

this.posY--

was creating a client->server position difference.

Check out my mod, Realms of Chaos, here.

 

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

Guest
This topic is now closed to further replies.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.