use of net.minecraft.entity.attribute.EntityAttributeInstance in project Biome-Makeover by Lemonszz.
the class ToadEntity method mobTick.
public void mobTick() {
eatCooldown--;
if (eatCooldown <= 0 && !hasTongueEntity()) {
List<ToadTargetEntity> targets = world.getEntitiesByClass(ToadTargetEntity.class, getBoundingBox().expand(3, 3, 3), (e) -> canSee(e) && !e.isBeingEaten());
ToadTargetEntity closest = world.getClosestEntity(targets, predicate, this, getX(), getY(), getZ());
if (!canUseTongue() || closest == null || closest.hasVehicle() || targets.isEmpty())
clearTongueEntity();
else {
eatCooldown = 350;
setTongueEntity(closest);
}
} else {
Entity e = world.getEntityById(getTongueEntityID());
if (!canUseTongue() || e == null || !e.isAlive())
clearTongueEntity();
}
if (this.ticksUntilJump > 0) {
--this.ticksUntilJump;
}
if (ticksUntilJump <= 0 && moveControl.isMoving()) {
ticksUntilJump = RandomUtil.randomRange(20, 100);
jump();
EntityAttributeInstance entityAttributeInstance = this.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED);
entityAttributeInstance.removeModifier(JUMP_SPEED_BOOST);
entityAttributeInstance.addTemporaryModifier(JUMP_SPEED_BOOST_MOD);
this.playSound(this.getJumpSound(), this.getSoundVolume(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 0.8F);
}
if (onGround && !onGroundPrev) {
this.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED).removeModifier(JUMP_SPEED_BOOST_MOD);
}
onGroundPrev = onGround;
}
use of net.minecraft.entity.attribute.EntityAttributeInstance in project Biome-Makeover by Lemonszz.
the class BMEnchantment method removeAttributes.
public void removeAttributes(LivingEntity entity, EquipmentSlot slot) {
for (Map.Entry<EntityAttribute, EntityAttributeModifier> attributeEntry : this.attributeModifiers.entrySet()) {
UUID slotID = MathUtils.uuidFromString(slot.toString());
EntityAttributeInstance entityAttributeInstance = entity.getAttributes().getCustomInstance(attributeEntry.getKey());
if (entityAttributeInstance != null) {
EntityAttributeModifier mod = entityAttributeInstance.getModifier(slotID);
if (mod != null)
entityAttributeInstance.removeModifier(mod);
else
System.out.println("ERROR REMOVING MODIFIER: DOESNT EXIST??? : " + entityAttributeInstance.getAttribute().getTranslationKey());
}
}
}
Aggregations