-
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.
feat: Use SWAP_SHAPE ShapeEvents instead of Mixin for PreventShapeCha…
…ngePower & ActionOnShapeChangePower
- Loading branch information
Showing
4 changed files
with
25 additions
and
32 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
23 changes: 23 additions & 0 deletions
23
src/main/java/com/github/shap_po/shappoli/integration/walkers/events/ShapeEventHandler.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,23 @@ | ||
package com.github.shap_po.shappoli.integration.walkers.events; | ||
|
||
import com.github.shap_po.shappoli.integration.walkers.power.ActionOnShapeChangePower; | ||
import com.github.shap_po.shappoli.integration.walkers.power.PreventShapeChangePower; | ||
import io.github.apace100.apoli.component.PowerHolderComponent; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.util.ActionResult; | ||
import tocraft.walkers.api.events.ShapeEvents; | ||
|
||
public class ShapeEventHandler { | ||
public static void register() { | ||
ShapeEvents.SWAP_SHAPE.register((player, to) -> { | ||
LivingEntity shape = to == null ? player : to; | ||
if (PowerHolderComponent.hasPower(player, PreventShapeChangePower.class, p -> p.doesApply(shape))) { | ||
return ActionResult.FAIL; | ||
} | ||
|
||
PowerHolderComponent.withPowers(player, ActionOnShapeChangePower.class, p -> p.doesApply(shape), p -> p.apply(shape)); | ||
|
||
return ActionResult.PASS; | ||
}); | ||
} | ||
} |
31 changes: 0 additions & 31 deletions
31
src/main/java/com/github/shap_po/shappoli/mixin/integration/walkers/PlayerShapeMixin.java
This file was deleted.
Oops, something went wrong.
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