Skip to content

Commit

Permalink
feat: Use SWAP_SHAPE ShapeEvents instead of Mixin for PreventShapeCha…
Browse files Browse the repository at this point in the history
…ngePower & ActionOnShapeChangePower
  • Loading branch information
shap-po committed Oct 9, 2024
1 parent 13e9d40 commit d2677ef
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.shap_po.shappoli.integration.walkers;

import com.github.shap_po.shappoli.integration.walkers.events.ShapeEventHandler;
import com.github.shap_po.shappoli.integration.walkers.power.factory.PowerFactories;
import com.github.shap_po.shappoli.integration.walkers.power.factory.ability.ShapeAbilities;
import com.github.shap_po.shappoli.integration.walkers.power.factory.action.BiEntityActions;
Expand All @@ -15,6 +16,7 @@ public static void register() {
EntityConditions.register();

ShapeAbilities.register();
ShapeEventHandler.register();
ShappoliWalkersShapeAbilityTypeRegistry.register();
}
}
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;
});
}
}

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/shappoli.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"integration.trinkets.TrinketInventoryMixin",
"integration.trinkets.TrinketSlotMixin",
"integration.walkers.PlayerAbilitiesMixin",
"integration.walkers.PlayerShapeMixin",
"integration.walkers.ServerNetworkingMixin"
],
"client": [
Expand Down

0 comments on commit d2677ef

Please sign in to comment.