use of net.minecraft.entity.ai.attributes.AttributeModifier in project Bewitchment by Um-Mitternacht.
the class BrewAttributeModifier method applyAttributeModifiers.
public void applyAttributeModifiers(AbstractAttributeMap attributeMap, int amplifier) {
for (Map.Entry<IAttribute, AttributeModifier> entry : modifierMap.entrySet()) {
IAttributeInstance attribute = attributeMap.getAttributeInstance(entry.getKey());
if (attribute == null)
continue;
AttributeModifier modifier = entry.getValue();
attribute.removeModifier(modifier);
attribute.applyModifier(new AttributeModifier(modifier.getID(), this.getName() + " " + amplifier, modifier.getAmount() * (amplifier + 1), modifier.getOperation()));
}
}
use of net.minecraft.entity.ai.attributes.AttributeModifier in project ClaySoldiersMod by SanAndreasP.
the class UpgradeShearBlade method onAdded.
@Override
public void onAdded(ISoldier<?> soldier, ItemStack stack, ISoldierUpgradeInst upgradeInst) {
if (!soldier.getEntity().world.isRemote) {
upgradeInst.getNbtData().setByte("uses", MAX_USAGES);
AttributeModifier modifier = upgradeInst.getUpgradeType() == EnumUpgradeType.MAIN_HAND ? BLADE_DMG_1 : BLADE_DMG_2;
soldier.getEntity().getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).applyModifier(modifier);
soldier.getEntity().playSound(SoundEvents.ENTITY_ITEM_PICKUP, 0.2F, ((MiscUtils.RNG.randomFloat() - MiscUtils.RNG.randomFloat()) * 0.7F + 1.0F) * 2.0F);
stack.shrink(1);
}
}
use of net.minecraft.entity.ai.attributes.AttributeModifier in project ClaySoldiersMod by SanAndreasP.
the class UpgradeShearBlade method resetFirstHit.
private void resetFirstHit(ISoldier<?> soldier, ISoldierUpgradeInst upgInstance) {
upgInstance.getNbtData().setBoolean("firstHit", false);
AttributeModifier modifier = upgInstance.getUpgradeType() == EnumUpgradeType.MAIN_HAND ? BLADE_FH_DMG_1 : BLADE_FH_DMG_2;
soldier.getEntity().getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).removeModifier(modifier);
}
use of net.minecraft.entity.ai.attributes.AttributeModifier in project ClaySoldiersMod by SanAndreasP.
the class UpgradeShearBlade method onTick.
@Override
public void onTick(ISoldier<?> soldier, ISoldierUpgradeInst upgradeInst) {
EntityLivingBase attackTgt = soldier.getEntity().getAttackTarget();
if (!upgradeInst.getNbtData().getBoolean("firstHit")) {
if (attackTgt == null) {
upgradeInst.getNbtData().setBoolean("firstHit", true);
AttributeModifier modifier = upgradeInst.getUpgradeType() == EnumUpgradeType.MAIN_HAND ? BLADE_FH_DMG_1 : BLADE_FH_DMG_2;
soldier.getEntity().getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).applyModifier(modifier);
}
} else {
if (attackTgt instanceof EntityLiving && ((EntityLiving) attackTgt).getAttackTarget() == soldier) {
this.resetFirstHit(soldier, upgradeInst);
}
}
}
use of net.minecraft.entity.ai.attributes.AttributeModifier in project takumicraft by TNTModders.
the class EntityZombieCreeper method onInitialSpawn.
/**
* Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called
* when entity is reloaded from nbt. Mainly used for initializing attributes and inventory
*/
@Override
@Nullable
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) {
livingdata = super.onInitialSpawn(difficulty, livingdata);
float f = difficulty.getClampedAdditionalDifficulty();
this.setCanPickUpLoot(this.rand.nextFloat() < 0.55F * f);
if (livingdata == null) {
livingdata = new GroupData(this.world.rand.nextFloat() < ForgeModContainer.zombieBabyChance);
}
if (livingdata instanceof GroupData && !(this instanceof EntityGiantCreeper)) {
GroupData entityzombie$groupdata = (GroupData) livingdata;
if (entityzombie$groupdata.isChild) {
this.setChild(true);
if (this.world.rand.nextFloat() < 0.05D) {
List<EntityChicken> list = this.world.getEntitiesWithinAABB(EntityChicken.class, this.getEntityBoundingBox().grow(5.0D, 3.0D, 5.0D), EntitySelectors.IS_STANDALONE);
if (!list.isEmpty()) {
EntityChicken entitychicken = list.get(0);
entitychicken.setChickenJockey(true);
this.startRiding(entitychicken);
}
} else if (this.world.rand.nextFloat() < 0.05D) {
EntityChicken entitychicken1 = new EntityChicken(this.world);
entitychicken1.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
entitychicken1.onInitialSpawn(difficulty, null);
entitychicken1.setChickenJockey(true);
this.world.spawnEntity(entitychicken1);
this.startRiding(entitychicken1);
}
}
}
this.setBreakDoorsAItask(this.rand.nextBoolean());
this.setEquipmentBasedOnDifficulty(difficulty);
this.setEnchantmentBasedOnDifficulty(difficulty);
if (this.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty() && this.getClass() != EntityZombieVillagerCreeper.class) {
Calendar calendar = this.world.getCurrentDate();
if (calendar.get(Calendar.MONTH) + 1 == 10 && calendar.get(Calendar.DATE) == 31) {
this.setItemStackToSlot(EntityEquipmentSlot.HEAD, new ItemStack(this.rand.nextFloat() < 0.1F ? Blocks.LIT_PUMPKIN : Blocks.PUMPKIN));
this.inventoryArmorDropChances[EntityEquipmentSlot.HEAD.getIndex()] = 0.0F;
}
}
this.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextDouble() * 0.05000000074505806D, 0));
double d0 = this.rand.nextDouble() * 1.5D * f;
if (d0 > 1.0D) {
this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).applyModifier(new AttributeModifier("Random zombie-spawn bonus", d0, 2));
}
if (this.rand.nextFloat() < f * 0.05F) {
this.getEntityAttribute(SPAWN_REINFORCEMENTS_CHANCE).applyModifier(new AttributeModifier("Leader zombie bonus", this.rand.nextDouble() * 0.25D + 0.5D, 0));
this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).applyModifier(new AttributeModifier("Leader zombie bonus", this.rand.nextDouble() * 3.0D + 1.0D, 2));
this.setBreakDoorsAItask(true);
}
return livingdata;
}
Aggregations