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 copyPlayer(EntityPlayer entityplayer) { inventory.copyInventory(entityplayer.inventory); health = entityplayer.health; foodStats = entityplayer.foodStats; playerLevel = entityplayer.playerLevel; totalXP = entityplayer.totalXP; currentXP = entityplayer.currentXP; score = entityplayer.score; }
public float getCurrentPlayerStrVsBlock(Block block) { float f = inventory.getStrVsBlock(block); float f1 = f; int i = EnchantmentHelper.getEfficiencyModifier(inventory); if (i > 0 && inventory.canHarvestBlock(block)) { f1 += i * i + 1; } if (isPotionActive(Potion.digSpeed)) { f1 *= 1.0F + (float) (getActivePotionEffect(Potion.digSpeed).getAmplifier() + 1) * 0.2F; } if (isPotionActive(Potion.digSlowdown)) { f1 *= 1.0F - (float) (getActivePotionEffect(Potion.digSlowdown).getAmplifier() + 1) * 0.2F; } if (isInsideOfMaterial(Material.water) && !EnchantmentHelper.getAquaAffinityModifier(inventory)) { f1 /= 5F; } if (!onGround) { f1 /= 5F; } return f1; }
public void handleBlockItemSwitch(Packet16BlockItemSwitch par1Packet16BlockItemSwitch) { if (par1Packet16BlockItemSwitch.id < 0 || par1Packet16BlockItemSwitch.id >= InventoryPlayer.func_70451_h()) { logger.warning( (new StringBuilder()) .append(playerEntity.username) .append(" tried to set an invalid carried item") .toString()); return; } else { playerEntity.inventory.currentItem = par1Packet16BlockItemSwitch.id; return; } }
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 onDeath(DamageSource damagesource) { super.onDeath(damagesource); setSize(0.2F, 0.2F); setPosition(posX, posY, posZ); motionY = 0.10000000149011612D; if (username.equals("Notch")) { dropPlayerItemWithRandomChoice(new ItemStack(Item.appleRed, 1), true); } inventory.dropAllItems(); if (damagesource != null) { motionX = -MathHelper.cos(((attackedAtYaw + rotationYaw) * 3.141593F) / 180F) * 0.1F; motionZ = -MathHelper.sin(((attackedAtYaw + rotationYaw) * 3.141593F) / 180F) * 0.1F; } else { motionX = motionZ = 0.0D; } yOffset = 0.1F; addStat(StatList.deathsStat, 1); }
public void onLivingUpdate() { if (flyToggleTimer > 0) { flyToggleTimer--; } if (worldObj.difficultySetting == 0 && getEntityHealth() < getMaxHealth() && (ticksExisted % 20) * 12 == 0) { heal(1); } inventory.decrementAnimations(); prevCameraYaw = cameraYaw; super.onLivingUpdate(); landMovementFactor = speedOnGround; jumpMovementFactor = speedInAir; if (isSprinting()) { landMovementFactor += (double) speedOnGround * 0.29999999999999999D; jumpMovementFactor += (double) speedInAir * 0.29999999999999999D; } float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); float f1 = (float) Math.atan(-motionY * 0.20000000298023224D) * 15F; if (f > 0.1F) { f = 0.1F; } if (!onGround || getEntityHealth() <= 0) { f = 0.0F; } if (onGround || getEntityHealth() <= 0) { f1 = 0.0F; } cameraYaw += (f - cameraYaw) * 0.4F; cameraPitch += (f1 - cameraPitch) * 0.8F; if (getEntityHealth() > 0) { List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(1.0D, 0.0D, 1.0D)); if (list != null) { for (int i = 0; i < list.size(); i++) { Entity entity = (Entity) list.get(i); if (!entity.isDead) { collideWithPlayer(entity); } } } } }
/** Handle a creative slot packet. */ public void handleCreativeSetSlot(Packet107CreativeSetSlot par1Packet107CreativeSetSlot) { if (playerEntity.theItemInWorldManager.isCreative()) { boolean flag = par1Packet107CreativeSetSlot.slot < 0; ItemStack itemstack = par1Packet107CreativeSetSlot.itemStack; boolean flag1 = par1Packet107CreativeSetSlot.slot >= 1 && par1Packet107CreativeSetSlot.slot < 36 + InventoryPlayer.func_70451_h(); boolean flag2 = itemstack == null || itemstack.itemID < Item.itemsList.length && itemstack.itemID >= 0 && Item.itemsList[itemstack.itemID] != null; boolean flag3 = itemstack == null || itemstack.getItemDamage() >= 0 && itemstack.getItemDamage() >= 0 && itemstack.stackSize <= 64 && itemstack.stackSize > 0; if (flag1 && flag2 && flag3) { if (itemstack == null) { playerEntity.inventorySlots.putStackInSlot(par1Packet107CreativeSetSlot.slot, null); } else { playerEntity.inventorySlots.putStackInSlot(par1Packet107CreativeSetSlot.slot, itemstack); } playerEntity.inventorySlots.setPlayerIsPresent(playerEntity, true); } else if (flag && flag2 && flag3 && creativeItemCreationSpamThresholdTally < 200) { creativeItemCreationSpamThresholdTally += 20; EntityItem entityitem = playerEntity.dropPlayerItem(itemstack); if (entityitem != null) { entityitem.func_70288_d(); } } } }
public void attackTargetEntityWithCurrentItem(Entity entity) { int i = inventory.getDamageVsEntity(entity); if (isPotionActive(Potion.damageBoost)) { i += 3 << getActivePotionEffect(Potion.damageBoost).getAmplifier(); } if (isPotionActive(Potion.weakness)) { i -= 2 << getActivePotionEffect(Potion.weakness).getAmplifier(); } int j = 0; int k = 0; if (entity instanceof EntityLiving) { k = EnchantmentHelper.getEnchantmentModifierLiving(inventory, (EntityLiving) entity); j += EnchantmentHelper.getKnockbackModifier(inventory, (EntityLiving) entity); } if (isSprinting()) { j++; } if (i > 0 || k > 0) { boolean flag = fallDistance > 0.0F && !onGround && !isOnLadder() && !isInWater() && !isPotionActive(Potion.blindness) && ridingEntity == null && (entity instanceof EntityLiving); if (flag) { i += rand.nextInt(i / 2 + 2); } i += k; boolean flag1 = entity.attackEntityFrom(DamageSource.causePlayerDamage(this), i); if (flag1) { if (j > 0) { entity.addVelocity( -MathHelper.sin((rotationYaw * 3.141593F) / 180F) * (float) j * 0.5F, 0.10000000000000001D, MathHelper.cos((rotationYaw * 3.141593F) / 180F) * (float) j * 0.5F); motionX *= 0.59999999999999998D; motionZ *= 0.59999999999999998D; setSprinting(false); } if (flag) { onCriticalHit(entity); } if (k > 0) { func_40183_c(entity); } if (i >= 18) { triggerAchievement(AchievementList.overkill); } } ItemStack itemstack = getCurrentEquippedItem(); if (itemstack != null && (entity instanceof EntityLiving)) { itemstack.hitEntity((EntityLiving) entity, this); if (itemstack.stackSize <= 0) { itemstack.onItemDestroyedByUse(this); destroyCurrentEquippedItem(); } } if (entity instanceof EntityLiving) { if (entity.isEntityAlive()) { alertWolves((EntityLiving) entity, true); } addStat(StatList.damageDealtStat, i); int l = EnchantmentHelper.getFireAspectModifier(inventory, (EntityLiving) entity); if (l > 0) { entity.setFire(l * 4); } } addExhaustion(0.3F); } }
public void destroyCurrentEquippedItem() { inventory.setInventorySlotContents(inventory.currentItem, null); }
public ItemStack getCurrentEquippedItem() { return inventory.getCurrentItem(); }
public int getTotalArmorValue() { return inventory.getTotalArmorValue(); }
protected void func_40125_g(int i) { inventory.damageArmor(i); }
public boolean canHarvestBlock(Block block) { return inventory.canHarvestBlock(block); }
public void dropCurrentItem() { dropPlayerItemWithRandomChoice(inventory.decrStackSize(inventory.currentItem, 1), false); }
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); } }