package wtf.levinov.modules.impl.util;
import net.minecraft.network.play.client.CHeldItemChangePacket;
import net.minecraft.network.play.client.CPlayerTryUseItemPacket;
import net.minecraft.util.Hand;
import wtf.levinov.events.Event;
import wtf.levinov.events.impl.game.EventMouseTick;
import wtf.levinov.modules.Function;
import wtf.levinov.modules.FunctionAnnotation;
import wtf.levinov.modules.Type;
import wtf.levinov.util.world.InventoryUtil;
/**
* @author levinov
* @since 07.06.2023
*/
@FunctionAnnotation(name = "LegitPearl", type = Type.SelfCode)
public class LegitPearl extends Function {
@Override
public void onEvent(final Event event) {
if (event instanceof EventMouseTick mouseTick) {
if (mouseTick.getButton() == 2) {
int inventorySLot = InventoryUtil.getPearls();
if (inventorySLot != -1) {
mc.playerController.pickItem(inventorySLot);
useItem(Hand.MAIN_HAND);
}
}
}
}
private void useItem(Hand hand) {
mc.player.connection.sendPacket(new CPlayerTryUseItemPacket(hand));
mc.player.swingArm(hand);
}
}