package nivia.modules.exploits;
 
import net.minecraft.init.Blocks;
import net.minecraft.network.play.client.C03PacketPlayer;
import net.minecraft.util.BlockPos;
import nivia.events.EventTarget;
import nivia.events.events.EventPacketSend;
import nivia.managers.PropertyManager.Property;
import nivia.modules.Module;
import nivia.utils.Helper;
 
public class NoFall extends Module {
    public Property<Mode> mode = new Property<>(this, "Mode", Mode.NORMAL);
   
    public NoFall() {
        super("NoFall", 0, 0x005C00, Category.EXPLOITS, "Makes you take no fall damage.", new String[] { "nf", "nof" }, true);
    }
   
    @EventTarget
    public void packetSend(EventPacketSend event) {
        this.setSuffix(this.mode.value.toString());
        if (this.mode.value == Mode.NORMAL) {
            if (event.getPacket() instanceof C03PacketPlayer) {
                if (Helper.player().fallDistance > 3.0F) {
                    C03PacketPlayer packet = (C03PacketPlayer) event.getPacket();
                    packet.field_149474_g = true;
                }
            }  
        }
        if (this.mode.value == Mode.AAC) {
            if (Helper.world().getBlockState(new BlockPos(Helper.player().posX, Helper.player().posY - 2, Helper.player().posZ)).getBlock() != Blocks.air && Helper.player().fallDistance >= 3.0F) {
                Helper.player().setPosition(Helper.player().posX, Helper.player().posY - 2.5, Helper.player().posZ);
                Helper.player().motionX *= 0.0F;
                Helper.player().fallDistance = 0.0F;
                Helper.player().isInWeb = true;
                Helper.player().motionZ *= 0.0F;
            }  
        }
    }
 
    public enum Mode {
        NORMAL, AAC
    }
}