public void readEntityFromNBT(NBTTagCompound nbttagcompound) { super.readEntityFromNBT(nbttagcompound); NBTTagList nbttaglist = nbttagcompound.getTagList("Inventory"); inventory.readFromNBT(nbttaglist); dimension = nbttagcompound.getInteger("Dimension"); sleeping = nbttagcompound.getBoolean("Sleeping"); sleepTimer = nbttagcompound.getShort("SleepTimer"); currentXP = nbttagcompound.getFloat("XpP"); playerLevel = nbttagcompound.getInteger("XpLevel"); totalXP = nbttagcompound.getInteger("XpTotal"); if (sleeping) { bedChunkCoordinates = new ChunkCoordinates( MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)); wakeUpPlayer(true, true, false); } if (nbttagcompound.hasKey("SpawnX") && nbttagcompound.hasKey("SpawnY") && nbttagcompound.hasKey("SpawnZ")) { playerSpawnCoordinate = new ChunkCoordinates( nbttagcompound.getInteger("SpawnX"), nbttagcompound.getInteger("SpawnY"), nbttagcompound.getInteger("SpawnZ")); } foodStats.readStatsFromNBT(nbttagcompound); capabilities.readCapabilitiesFromNBT(nbttagcompound); }
public void addExhaustion(float f) { if (capabilities.disableDamage) { return; } if (!worldObj.multiplayerWorld) { foodStats.addExhaustion(f); } }
public void writeEntityToNBT(NBTTagCompound nbttagcompound) { super.writeEntityToNBT(nbttagcompound); nbttagcompound.setTag("Inventory", inventory.writeToNBT(new NBTTagList())); nbttagcompound.setInteger("Dimension", dimension); nbttagcompound.setBoolean("Sleeping", sleeping); nbttagcompound.setShort("SleepTimer", (short) sleepTimer); nbttagcompound.setFloat("XpP", currentXP); nbttagcompound.setInteger("XpLevel", playerLevel); nbttagcompound.setInteger("XpTotal", totalXP); if (playerSpawnCoordinate != null) { nbttagcompound.setInteger("SpawnX", playerSpawnCoordinate.posX); nbttagcompound.setInteger("SpawnY", playerSpawnCoordinate.posY); nbttagcompound.setInteger("SpawnZ", playerSpawnCoordinate.posZ); } foodStats.writeStatsToNBT(nbttagcompound); capabilities.writeCapabilitiesToNBT(nbttagcompound); }
public void onUpdate() { if (itemInUse != null) { ItemStack itemstack = inventory.getCurrentItem(); if (itemstack != itemInUse) { clearItemInUse(); } else { if (itemInUseCount <= 25 && itemInUseCount % 4 == 0) { func_35201_a(itemstack, 5); } if (--itemInUseCount == 0 && !worldObj.multiplayerWorld) { func_35208_ae(); } } } if (xpCooldown > 0) { xpCooldown--; } if (isPlayerSleeping()) { sleepTimer++; if (sleepTimer > 100) { sleepTimer = 100; } if (!worldObj.multiplayerWorld) { if (!isInBed()) { wakeUpPlayer(true, true, false); } else if (worldObj.isDaytime()) { wakeUpPlayer(false, true, true); } } } else if (sleepTimer > 0) { sleepTimer++; if (sleepTimer >= 110) { sleepTimer = 0; } } super.onUpdate(); if (!worldObj.multiplayerWorld && craftingInventory != null && !craftingInventory.canInteractWith(this)) { closeScreen(); craftingInventory = inventorySlots; } if (capabilities.isFlying) { for (int i = 0; i < 8; i++) {} } if (isBurning() && capabilities.disableDamage) { extinguish(); } field_20066_r = field_20063_u; field_20065_s = field_20062_v; field_20064_t = field_20061_w; double d = posX - field_20063_u; double d1 = posY - field_20062_v; double d2 = posZ - field_20061_w; double d3 = 10D; if (d > d3) { field_20066_r = field_20063_u = posX; } if (d2 > d3) { field_20064_t = field_20061_w = posZ; } if (d1 > d3) { field_20065_s = field_20062_v = posY; } if (d < -d3) { field_20066_r = field_20063_u = posX; } if (d2 < -d3) { field_20064_t = field_20061_w = posZ; } if (d1 < -d3) { field_20065_s = field_20062_v = posY; } field_20063_u += d * 0.25D; field_20061_w += d2 * 0.25D; field_20062_v += d1 * 0.25D; addStat(StatList.minutesPlayedStat, 1); if (ridingEntity == null) { startMinecartRidingCoordinate = null; } if (!worldObj.multiplayerWorld) { foodStats.onUpdate(this); } }
public boolean canEat(boolean flag) { return (flag || foodStats.needFood()) && !capabilities.disableDamage; }