@Override public void onLivingUpdate() { super.onLivingUpdate(); if (!worldObj.isRemote) { opacity.setValue(0.3f); boolean isIdle = getAITarget() == null; // sync a flag that says if we should be flying or not flags.set(FlagKeys.IS_FLYING, shouldBeFlying()); flags.set(FlagKeys.IS_IDLE, isIdle); int sinceIdle = flags.ticksSinceSet(FlagKeys.IS_IDLE); boolean headInHand = flags.get(FlagKeys.HEAD_IN_HAND); int ticksSinceHeadChange = flags.ticksSinceChange(FlagKeys.HEAD_IN_HAND); if (DISABLE_HEAD_ANIMATION) { headInHand = false; } else { // if we're not idle, we dont want the head/hand behaviour if (!isIdle) { headInHand = false; } else { if (!headInHand && Math.min(sinceIdle, ticksSinceHeadChange) > 50 + (20 * worldObj.rand.nextDouble())) { headInHand = true; } else if (headInHand && ticksSinceHeadChange > 50) { headInHand = false; } } } if (flags.get(FlagKeys.IS_FLYING) && worldObj.getHeightValue((int) posX, (int) posZ) + 1 > posY) { /* * Flying up causes the entity onGround to be false, nullifying * any movement. There is one option, override the movement * methods and implement them ourselves. This does provide the * opportunity for the ghost to fly through walls, but does make * life harder. * * Also some research needs to be done regarding how this fits * with AI */ motionY = Math.max(motionY, 0.1D); /* Fly over blocks */ } flags.set(FlagKeys.HEAD_IN_HAND, headInHand); } // send all our data to nearby users syncMap.sync(worldObj, this, posX, posY, posZ); }