Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
MerchantPug committed Mar 13, 2024
1 parent a4c819c commit ef85404
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import io.github.edwinmindcraft.apoli.api.power.factory.EntityAction;
import io.github.edwinmindcraft.apoli.common.action.configuration.ChangeResourceConfiguration;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.LivingEntity;

public class ChangeResourceAction extends EntityAction<ChangeResourceConfiguration> {
public ChangeResourceAction(Codec<ChangeResourceConfiguration> codec) {
Expand All @@ -17,14 +17,14 @@ public ChangeResourceAction(Codec<ChangeResourceConfiguration> codec) {

@Override
public void execute(ChangeResourceConfiguration configuration, Entity entity) {
if (entity instanceof Player player && configuration.resource().isBound()) {
if (entity instanceof LivingEntity living && configuration.resource().isBound()) {
ConfiguredPower<?, ?> power = configuration.resource().value();
if (IPowerContainer.get(entity).map(x -> x.hasPower(power.getRegistryName())).orElse(false)) {
if (configuration.operation() == ResourceOperation.ADD)
power.change(player, configuration.amount());
power.change(living, configuration.amount());
else if (configuration.operation() == ResourceOperation.SET)
power.assign(player, configuration.amount());
ApoliAPI.synchronizePowerContainer(player);
power.assign(living, configuration.amount());
ApoliAPI.synchronizePowerContainer(living);
}
}
}
Expand Down

0 comments on commit ef85404

Please sign in to comment.