Java Code Examples for net.minecraft.entity.player.EntityPlayer#getEntityAttribute()
The following examples show how to use
net.minecraft.entity.player.EntityPlayer#getEntityAttribute() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArtifactTickHandler.java From Artifacts with MIT License | 6 votes |
private void updateKnockbackResistance(int artifactKnockbackCount, EntityPlayer player) { NBTTagCompound playerData = player.getEntityData(); int oldKnockbackCount = playerData.getInteger("artifactKnockbackCount"); if(oldKnockbackCount != artifactKnockbackCount) { String uu = playerData.getString("artifactKnockbackUUID"); UUID knockbackID; if(uu.equals("")) { knockbackID = UUID.randomUUID(); playerData.setString("artifactKnockbackUUID", knockbackID.toString()); } else { knockbackID = UUID.fromString(uu); } IAttributeInstance atinst = player.getEntityAttribute(SharedMonsterAttributes.knockbackResistance); atinst.removeModifier(new AttributeModifier(knockbackID, "KnockbackComponent", 0.2F * oldKnockbackCount, 0)); atinst.applyModifier(new AttributeModifier(knockbackID, "KnockbackComponent", 0.2F * artifactKnockbackCount, 0)); playerData.setInteger("artifactKnockbackCount", artifactKnockbackCount); } }
Example 2
Source File: ArtifactTickHandler.java From Artifacts with MIT License | 6 votes |
private void updateSpeedBoost(int artifactSpeedBoostCount, EntityPlayer player) { NBTTagCompound playerData = player.getEntityData(); int oldSpeedBoostCount = playerData.getInteger("artifactSpeedBoostCount"); if(oldSpeedBoostCount != artifactSpeedBoostCount) { String uu = playerData.getString("artifactSpeedBoostUUID"); UUID speedID; if(uu.equals("")) { speedID = UUID.randomUUID(); playerData.setString("artifactSpeedBoostUUID", speedID.toString()); } else { speedID = UUID.fromString(uu); } IAttributeInstance atinst = player.getEntityAttribute(SharedMonsterAttributes.movementSpeed); atinst.removeModifier(new AttributeModifier(speedID, "SpeedBoostComponent", 0.05F * oldSpeedBoostCount, 2)); atinst.applyModifier(new AttributeModifier(speedID, "SpeedBoostComponent", 0.05F * artifactSpeedBoostCount, 2)); playerData.setInteger("artifactSpeedBoostCount", artifactSpeedBoostCount); } }
Example 3
Source File: ArtifactTickHandler.java From Artifacts with MIT License | 5 votes |
private void updateHealthBoost(int artifactHealthBoostCount, EntityPlayer player) { NBTTagCompound playerData = player.getEntityData(); int oldHealthBoostCount = playerData.getInteger("artifactHealthBoostCount"); if(oldHealthBoostCount != artifactHealthBoostCount) { String uu = playerData.getString("artifactHealthBoostUUID"); UUID healthID; if(uu.equals("")) { healthID = UUID.randomUUID(); playerData.setString("artifactHealthBoostUUID", healthID.toString()); } else { healthID = UUID.fromString(uu); } IAttributeInstance atinst = player.getEntityAttribute(SharedMonsterAttributes.maxHealth); atinst.removeModifier(new AttributeModifier(healthID, "HealthBoostComponent", 5F * oldHealthBoostCount, 0)); atinst.applyModifier(new AttributeModifier(healthID, "HealthBoostComponent", 5F * artifactHealthBoostCount, 0)); if(player.getHealth() > player.getMaxHealth()) { player.setHealth(player.getMaxHealth()); } int diff = (artifactHealthBoostCount - oldHealthBoostCount); if(diff > 0 && player.getHealth() < player.getMaxHealth()) { player.heal(5*diff); } playerData.setInteger("artifactHealthBoostCount", artifactHealthBoostCount); } }