net.minecraft.entity.ai.attributes.IAttributeInstance Java Examples
The following examples show how to use
net.minecraft.entity.ai.attributes.IAttributeInstance.
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 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 #2
Source File: CraftPlayer.java From Kettle with GNU General Public License v3.0 | 6 votes |
public void injectScaledMaxHealth(Collection<IAttributeInstance> collection, boolean force) { if (!scaledHealth && !force) { return; } for (IAttributeInstance genericInstance : collection) { if (genericInstance.getAttribute().getName().equals("generic.maxHealth")) { collection.remove(genericInstance); break; } } // Spigot start double healthMod = scaledHealth ? healthScale : getMaxHealth(); if (healthMod >= Float.MAX_VALUE || healthMod <= 0) { healthMod = 20; // Reset health server.getLogger().warning(getName() + " tried to crash the server with a large health attribute"); } collection.add(new ModifiableAttributeInstance(getHandle().getAttributeMap(), (new RangedAttribute(null, "generic.maxHealth", healthMod, 0.0D, Float.MAX_VALUE)).setDescription("Max Health").setShouldWatch(true))); // Spigot end }
Example #3
Source File: EntityMage.java From ToroQuest with GNU General Public License v3.0 | 6 votes |
protected void handleAttackLogicUpdate() { PotionType potiontype = null; if (this.rand.nextFloat() < 0.15F && this.isInsideOfMaterial(Material.WATER) && !this.isPotionActive(MobEffects.WATER_BREATHING)) { potiontype = PotionTypes.WATER_BREATHING; } else if (this.rand.nextFloat() < 0.15F && this.isBurning() && !this.isPotionActive(MobEffects.FIRE_RESISTANCE)) { potiontype = PotionTypes.FIRE_RESISTANCE; } else if (this.rand.nextFloat() < 0.05F && this.getHealth() < this.getMaxHealth()) { potiontype = PotionTypes.HEALING; } else if (this.rand.nextFloat() < 0.5F && this.getAttackTarget() != null && !this.isPotionActive(MobEffects.SPEED) && this.getAttackTarget().getDistanceSq(this) > 121.0D) { potiontype = PotionTypes.SWIFTNESS; } if (potiontype != null) { this.world.playSound(null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_DRINK, this.getSoundCategory(), 1.0F, 0.8F + this.rand.nextFloat() * 0.4F); this.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), potiontype)); this.attackTimer = 10; this.setAggressive(true); IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED); iattributeinstance.removeModifier(MODIFIER); iattributeinstance.applyModifier(MODIFIER); } }
Example #4
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 #5
Source File: PotionBuffGolem.java From Gadomancy with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void applyAttributesModifiersToEntity(EntityLivingBase entity, BaseAttributeMap attrMap, int amplifier) { super.applyAttributesModifiersToEntity(entity, attrMap, amplifier); if(entity instanceof EntityGolemBase) { EntityGolemBase golem = (EntityGolemBase) entity; IAttributeInstance inst = golem.getEntityAttribute(SharedMonsterAttributes.movementSpeed); if(inst.getModifier(SPEED_INC_PERCENT.getID()) != null) { inst.applyModifier(SPEED_INC_PERCENT); } inst = golem.getEntityAttribute(SharedMonsterAttributes.maxHealth); if(inst.getModifier(HEALTH_INC_PERCENT.getID()) != null) { inst.applyModifier(HEALTH_INC_PERCENT); } inst = golem.getEntityAttribute(SharedMonsterAttributes.attackDamage); if(inst.getModifier(DAMAGE_INC_PERCENT.getID()) != null) { inst.applyModifier(DAMAGE_INC_PERCENT); } } }
Example #6
Source File: PotionBuffGolem.java From Gadomancy with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void removeAttributesModifiersFromEntity(EntityLivingBase entity, BaseAttributeMap attrMap, int amplifier) { super.removeAttributesModifiersFromEntity(entity, attrMap, amplifier); if(entity instanceof EntityGolemBase) { EntityGolemBase golem = (EntityGolemBase) entity; IAttributeInstance inst = golem.getEntityAttribute(SharedMonsterAttributes.movementSpeed); if(inst.getModifier(SPEED_INC_PERCENT.getID()) != null) { inst.removeModifier(SPEED_INC_PERCENT); } inst = golem.getEntityAttribute(SharedMonsterAttributes.maxHealth); if(inst.getModifier(HEALTH_INC_PERCENT.getID()) != null) { inst.removeModifier(HEALTH_INC_PERCENT); } inst = golem.getEntityAttribute(SharedMonsterAttributes.attackDamage); if(inst.getModifier(DAMAGE_INC_PERCENT.getID()) != null) { inst.removeModifier(DAMAGE_INC_PERCENT); } } }
Example #7
Source File: EntityEndermanFighter.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void setAttackTarget(@Nullable EntityLivingBase target) { super.setAttackTarget(target); IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED); if (target == null) { this.setScreaming(false); iattributeinstance.removeModifier(ATTACKING_SPEED_BOOST); } else { if (iattributeinstance.hasModifier(ATTACKING_SPEED_BOOST) == false) { iattributeinstance.applyModifier(ATTACKING_SPEED_BOOST); } if (target instanceof EntityPlayer && this.isScreaming() == false) { this.setScreaming(true); } } }
Example #8
Source File: EntityEnderminy.java From EnderZoo with Creative Commons Zero v1.0 Universal | 6 votes |
/** * Updates the task */ public void updateTask() { if(targetPlayer != null) { if(--stareTimer <= 0) { targetEntity = targetPlayer; targetPlayer = null; super.startExecuting(); enderminy.playSound(SoundEvents.ENTITY_ENDERMEN_STARE, 1.0F, 1.0F); enderminy.setScreaming(true); IAttributeInstance iattributeinstance = enderminy.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED); iattributeinstance.applyModifier(EntityEnderminy.attackingSpeedBoostModifier); } } else { if(targetEntity != null) { if(targetEntity instanceof EntityPlayer && enderminy.shouldAttackPlayer((EntityPlayer) this.targetEntity)) { if(targetEntity.getDistanceSqToEntity(enderminy) < 16.0D) { enderminy.teleportRandomly(); } teleportDelay = 0; } else if(targetEntity.getDistanceSqToEntity(enderminy) > 256.0D && this.teleportDelay++ >= 30 && enderminy.teleportToEntity(targetEntity)) { teleportDelay = 0; } } super.updateTask(); } }
Example #9
Source File: MobSpawnEventHandler.java From EnderZoo with Creative Commons Zero v1.0 Universal | 6 votes |
protected void addjustBaseHealth(EntityLivingBase ent, double healthModifier) { IAttributeInstance att = ent.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH); if (att == null) { return; } double curValue = att.getBaseValue(); // only change in incs of 2 so we dont have 1/2 hearts double newValue = (curValue * healthModifier) / 2; if (healthModifier >= 1) { newValue = Math.ceil(newValue); } else { newValue = Math.floor(newValue); } newValue = Math.floor(newValue * 2.0); if (newValue < 2) { newValue = curValue; } att.setBaseValue(newValue); ent.setHealth((float) newValue); // System.out.println("MobSpawnEventHandler.addjustBaseHealth: Base health // changed from: " + curValue + " to " + newValue); }
Example #10
Source File: DebugUtil.java From EnderZoo with Creative Commons Zero v1.0 Universal | 6 votes |
@SideOnly(Side.CLIENT) @SubscribeEvent public void onPlayerTickClient(PlayerTickEvent evt) { if (evt.side != Side.CLIENT || evt.phase != Phase.END) { return; } RayTraceResult mo = Minecraft.getMinecraft().objectMouseOver; if (mo != null && mo.entityHit != null && mo.entityHit instanceof EntityLivingBase) { EntityLivingBase el = (EntityLivingBase) mo.entityHit; if (el != lastMouseOver) { double baseAttack = 0; double attack = 0; IAttributeInstance damAtt = el.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.ATTACK_DAMAGE); if (damAtt != null) { baseAttack = damAtt.getBaseValue(); attack = damAtt.getAttributeValue(); } System.out.println("DebugUtil.onPlayerTickClient: Health: " + el.getMaxHealth() + " Base Damage: " + baseAttack + " Damage: " + attack); } lastMouseOver = el; } else { lastMouseOver = null; } }
Example #11
Source File: CraftPlayer.java From Kettle with GNU General Public License v3.0 | 5 votes |
public void updateScaledHealth() { AttributeMap attributemapserver = (AttributeMap) getHandle().getAttributeMap(); Collection<IAttributeInstance> set = attributemapserver.getWatchedAttributes(); // PAIL: Rename injectScaledMaxHealth(set, true); // SPIGOT-3813: Attributes before health if (getHandle().connection != null) { getHandle().connection.sendPacket(new SPacketEntityProperties(getHandle().getEntityId(), set)); sendHealthUpdate(); } getHandle().getDataManager().set(EntityLiving.HEALTH, (float) getScaledHealth()); getHandle().maxHealthCache = getMaxHealth(); }
Example #12
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); } }
Example #13
Source File: MobSpawnEventHandler.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
protected void adjustBaseAttack(EntityLivingBase ent, double attackModifier) { IAttributeInstance att = ent.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.ATTACK_DAMAGE); if (att == null) { return; } double curValue = att.getBaseValue(); double newValue = curValue * attackModifier; att.setBaseValue(newValue); // System.out.println("MobSpawnEventHandler.adjustBaseAttack: base attack // changed from " + curValue + " to " + newValue); }
Example #14
Source File: EntityWitherCat.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
protected void updateHealth(float growthRatio) { IAttributeInstance att = EntityUtil.removeModifier(this, SharedMonsterAttributes.MAX_HEALTH, HEALTH_BOOST_MOD_UID); if (growthRatio == 0) { return; } double currentRatio = getHealth() / getMaxHealth(); double healthDif = Config.witherCatAngryHealth - Config.witherCatHealth; double toAdd = healthDif * growthRatio; AttributeModifier mod = new AttributeModifier(HEALTH_BOOST_MOD_UID, "Transformed Attack Modifier", toAdd, 0); att.applyModifier(mod); double newHealth = currentRatio * getMaxHealth(); setHealth((float) newHealth); }
Example #15
Source File: EntityWitherCat.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
protected void updateAttackDamage(float growthRatio) { IAttributeInstance att = EntityUtil.removeModifier(this, SharedMonsterAttributes.ATTACK_DAMAGE, ATTACK_BOOST_MOD_UID); if (growthRatio == 0) { return; } double damageInc = EntityUtil.isHardDifficulty(world) ? Config.witherCatAngryAttackDamageHardModifier : 0; double attackDif = (damageInc + Config.witherCatAngryAttackDamage) - Config.witherCatAttackDamage; double toAdd = attackDif * growthRatio; AttributeModifier mod = new AttributeModifier(ATTACK_BOOST_MOD_UID, "Transformed Attack Modifier", toAdd, 0); att.applyModifier(mod); }
Example #16
Source File: EntityUtil.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
public static IAttributeInstance removeModifier(EntityLivingBase ent, IAttribute p, UUID u) { IAttributeInstance att = ent.getEntityAttribute(p); AttributeModifier curmod = att.getModifier(u); if (curmod != null) { att.removeModifier(curmod); } return att; }
Example #17
Source File: EntityEnderminy.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
/** * Resets the task */ public void resetTask() { targetPlayer = null; enderminy.setScreaming(false); IAttributeInstance iattributeinstance = enderminy.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED); iattributeinstance.removeModifier(EntityEnderminy.attackingSpeedBoostModifier); super.resetTask(); }
Example #18
Source File: BodyguardGolemCore.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
@Override public IAttributeInstance getEntityAttribute(IAttribute p_110148_1_) { if(golem != null) { return golem.getEntityAttribute(p_110148_1_); } return super.getEntityAttribute(p_110148_1_); }
Example #19
Source File: MixinAbstractClientPlayer.java From Hyperium with GNU Lesser General Public License v3.0 | 5 votes |
/** * @author asbyth * @reason update fov event */ @Overwrite public float getFovModifier() { float f = 1.0F; if (capabilities.isFlying) { f *= 1.1F; } IAttributeInstance iAttributeInstance = getEntityAttribute(SharedMonsterAttributes.movementSpeed); f = (float) ((double) f * ((iAttributeInstance.getAttributeValue() / (double) capabilities.getWalkSpeed() + 1.0D) / 2.0D)); if (capabilities.getWalkSpeed() == 0.0F || Float.isNaN(f) || Float.isInfinite(f)) { f = 1.0F; } if (isUsingItem() && getItemInUse().getItem() == Items.bow) { int duration = getItemInUseDuration(); float f1 = (float) duration / 20.0F; if (f1 > 1.0F) { f1 = 1.0F; } else { f1 = f1 * f1; } f *= 1.0F - f1 * 0.15F; } FovUpdateEvent event = new FovUpdateEvent((AbstractClientPlayer) (Object) this, f); EventBus.INSTANCE.post(event); return event.getNewFov(); }
Example #20
Source File: EntityAIRangedAttack.java From EnderZoo with Creative Commons Zero v1.0 Universal | 4 votes |
protected double getTargetDistance() { IAttributeInstance iattributeinstance = entityHost.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE); return iattributeinstance == null ? 16.0D : iattributeinstance.getAttributeValue(); }