diff --git a/Allay-API/src/main/java/org/allaymc/api/entity/Entity.java b/Allay-API/src/main/java/org/allaymc/api/entity/Entity.java index 66343b02f..eca615f47 100644 --- a/Allay-API/src/main/java/org/allaymc/api/entity/Entity.java +++ b/Allay-API/src/main/java/org/allaymc/api/entity/Entity.java @@ -2,6 +2,7 @@ import org.allaymc.api.datastruct.aabbtree.HasAABB; import org.allaymc.api.datastruct.aabbtree.HasLongId; +import org.allaymc.api.entity.component.common.EntityAttributeComponent; import org.allaymc.api.entity.component.common.EntityBaseComponent; import org.joml.primitives.AABBf; @@ -11,7 +12,7 @@ * @author daoge_cmd */ public interface Entity extends - EntityBaseComponent, + EntityBaseComponent, EntityAttributeComponent, HasAABB, HasLongId { @Override diff --git a/Allay-API/src/main/java/org/allaymc/api/entity/component/common/EntityBaseComponent.java b/Allay-API/src/main/java/org/allaymc/api/entity/component/common/EntityBaseComponent.java index 194b774b8..09579f9bf 100644 --- a/Allay-API/src/main/java/org/allaymc/api/entity/component/common/EntityBaseComponent.java +++ b/Allay-API/src/main/java/org/allaymc/api/entity/component/common/EntityBaseComponent.java @@ -379,7 +379,7 @@ default boolean onInteract(EntityPlayer player, ItemStack itemStack) { return false; } - void setAbsorption(float absorption); - float getAbsorption(); + + void setAbsorption(float absorption); } diff --git a/Allay-API/src/main/java/org/allaymc/api/entity/effect/EffectType.java b/Allay-API/src/main/java/org/allaymc/api/entity/effect/EffectType.java index ecd5908ae..52e059a9c 100644 --- a/Allay-API/src/main/java/org/allaymc/api/entity/effect/EffectType.java +++ b/Allay-API/src/main/java/org/allaymc/api/entity/effect/EffectType.java @@ -31,9 +31,9 @@ default boolean isBad() { return false; } + default void onTick(Entity entity, EffectInstance effectInstance) {} + default void onAdd(Entity entity, EffectInstance effectInstance) {} default void onRemove(Entity entity, EffectInstance effectInstance) {} - - default void onTick(Entity entity, EffectInstance effectInstance) {} } diff --git a/Allay-API/src/main/java/org/allaymc/api/entity/effect/type/EffectAbsorptionType.java b/Allay-API/src/main/java/org/allaymc/api/entity/effect/type/EffectAbsorptionType.java index eff028021..386a7f1bd 100644 --- a/Allay-API/src/main/java/org/allaymc/api/entity/effect/type/EffectAbsorptionType.java +++ b/Allay-API/src/main/java/org/allaymc/api/entity/effect/type/EffectAbsorptionType.java @@ -21,8 +21,8 @@ private EffectAbsorptionType() { @Override public void onAdd(Entity entity, EffectInstance effectInstance) { - var amplifier = effectInstance.getAmplifier(); - int newValue = (amplifier + 1) << 2; + var amplifier = effectInstance.getAmplifier() + 1; + var newValue = amplifier * 4; if (newValue > entity.getAbsorption()) { entity.setAbsorption(newValue); } diff --git a/Allay-API/src/main/java/org/allaymc/api/entity/effect/type/EffectHealthBoostType.java b/Allay-API/src/main/java/org/allaymc/api/entity/effect/type/EffectHealthBoostType.java index b96df1beb..aceedf340 100644 --- a/Allay-API/src/main/java/org/allaymc/api/entity/effect/type/EffectHealthBoostType.java +++ b/Allay-API/src/main/java/org/allaymc/api/entity/effect/type/EffectHealthBoostType.java @@ -1,6 +1,8 @@ package org.allaymc.api.entity.effect.type; +import org.allaymc.api.entity.Entity; import org.allaymc.api.entity.effect.AbstractEffectType; +import org.allaymc.api.entity.effect.EffectInstance; import org.allaymc.api.utils.Identifier; import java.awt.*; @@ -16,4 +18,19 @@ public class EffectHealthBoostType extends AbstractEffectType { private EffectHealthBoostType() { super(21, new Identifier("minecraft:health_boost"), new Color(248, 125, 35)); } + + @Override + public void onAdd(Entity entity, EffectInstance effectInstance) { + var amplifier = effectInstance.getAmplifier() + 1; + entity.setMaxHealth(entity.getMaxHealth() + (amplifier * 4)); + } + + @Override + public void onRemove(Entity entity, EffectInstance effectInstance) { + var amplifier = effectInstance.getAmplifier() + 1; + entity.setMaxHealth(entity.getMaxHealth() - (amplifier * 4)); + if (entity.getHealth() > entity.getMaxHealth()) { + entity.setHealth(entity.getMaxHealth()); + } + } } diff --git a/Allay-API/src/main/java/org/allaymc/api/entity/effect/type/EffectInvisibilityType.java b/Allay-API/src/main/java/org/allaymc/api/entity/effect/type/EffectInvisibilityType.java index f0fbda6c0..1d9be7b7e 100644 --- a/Allay-API/src/main/java/org/allaymc/api/entity/effect/type/EffectInvisibilityType.java +++ b/Allay-API/src/main/java/org/allaymc/api/entity/effect/type/EffectInvisibilityType.java @@ -4,7 +4,6 @@ import org.allaymc.api.entity.effect.AbstractEffectType; import org.allaymc.api.entity.effect.EffectInstance; import org.allaymc.api.utils.Identifier; -import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes; import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag; import java.awt.*; diff --git a/Allay-API/src/main/java/org/allaymc/api/entity/interfaces/EntityVillagerV2.java b/Allay-API/src/main/java/org/allaymc/api/entity/interfaces/EntityVillagerV2.java index c5c0a980e..063da1a1c 100644 --- a/Allay-API/src/main/java/org/allaymc/api/entity/interfaces/EntityVillagerV2.java +++ b/Allay-API/src/main/java/org/allaymc/api/entity/interfaces/EntityVillagerV2.java @@ -1,15 +1,11 @@ package org.allaymc.api.entity.interfaces; import org.allaymc.api.entity.Entity; -import org.allaymc.api.entity.component.common.EntityAttributeComponent; import org.allaymc.api.entity.component.common.EntityDamageComponent; /** * @author daoge_cmd
* Allay Project
*/ -public interface EntityVillagerV2 extends - Entity, - EntityAttributeComponent, - EntityDamageComponent { +public interface EntityVillagerV2 extends Entity, EntityDamageComponent { }