-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...shappoli/integration/walkers/power/factory/condition/entity/HasShapeAbilityCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/test/resources/data/shappoli/powers/walkers/has_shape_ability.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!" | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/test/resources/data/shappoli/powers/walkers/has_shape_ability_other.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!" | ||
} | ||
} | ||
} | ||
} |