Skip to content

Commit

Permalink
Add: HasShapeAbilityCondition
Browse files Browse the repository at this point in the history
  • Loading branch information
shap-po committed Sep 25, 2024
1 parent d71280a commit b150761
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.shap_po.shappoli.integration.walkers.power.factory.condition;

import com.github.shap_po.shappoli.integration.walkers.power.factory.condition.entity.CanUseShapeAbilityCondition;
import com.github.shap_po.shappoli.integration.walkers.power.factory.condition.entity.HasShapeAbilityCondition;
import com.github.shap_po.shappoli.integration.walkers.power.factory.condition.entity.ShapeAbilityCooldownCondition;
import com.github.shap_po.shappoli.integration.walkers.power.factory.condition.entity.ShapeCondition;
import io.github.apace100.apoli.power.factory.condition.ConditionFactory;
Expand All @@ -11,6 +12,7 @@
public class EntityConditions {
public static void register() {
register(CanUseShapeAbilityCondition.getFactory());
register(HasShapeAbilityCondition.getFactory());
register(ShapeAbilityCooldownCondition.getFactory());
register(ShapeCondition.getFactory());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.github.shap_po.shappoli.integration.walkers.power.factory.condition.entity;

import com.github.shap_po.shappoli.Shappoli;
import com.github.shap_po.shappoli.integration.walkers.util.WalkersUtil;
import io.github.apace100.apoli.power.factory.condition.ConditionFactory;
import io.github.apace100.calio.data.SerializableData;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import tocraft.walkers.ability.AbilityRegistry;

public class HasShapeAbilityCondition {
public static boolean condition(SerializableData.Instance data, Entity entity) {
if (!(entity instanceof LivingEntity livingEntity)) {
return false;
}
if (entity instanceof PlayerEntity player) {
LivingEntity shape = WalkersUtil.getShape(player);
return AbilityRegistry.has(shape);
}
return AbilityRegistry.has(livingEntity);
}

public static ConditionFactory<Entity> getFactory() {
return new ConditionFactory<>(
Shappoli.identifier("has_shape_ability"),
new SerializableData(),
HasShapeAbilityCondition::condition
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"type": "apoli:active_self",
"key": "key.attack",

"entity_action": {
"type": "apoli:if_else",
"condition": {
"type": "shappoli:has_shape_ability"
},
"if_action": {
"type": "apoli:execute_command",
"command": "say I have a shape ability!"
},
"else_action": {
"type": "apoli:execute_command",
"command": "say I don't have a shape ability!"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"type": "apoli:action_on_hit",

"bientity_action": {
"type": "apoli:target_action",
"action": {
"type": "apoli:if_else",
"condition": {
"type": "shappoli:has_shape_ability"
},
"if_action": {
"type": "apoli:execute_command",
"command": "say I have a shape ability!"
},
"else_action": {
"type": "apoli:execute_command",
"command": "say I don't have a shape ability!"
}
}
}
}

0 comments on commit b150761

Please sign in to comment.