package com.acethewildfire.acesbs.mixin;

import com.acethewildfire.acesbs.item.ModItems;
import net.minecraft.entity.Entity;
import net.minecraft.entity.ItemEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(Entity.class)
public abstract class EntityMixin {

    @Inject(method = "hasNoGravity", at = @At("HEAD"), cancellable = true)
    private void reverseGravity(CallbackInfoReturnable<Boolean> cir) {
        Entity entity = (Entity)(Object)this;

        if (entity instanceof ItemEntity itemEntity) {
            if (itemEntity.getStack().isOf(ModItems.MOTE_OF_ORDER)) {
                cir.setReturnValue(true);
            }
        }
    }
}
