Add MiddleClickPearlModule

This commit is contained in:
jvyden 2020-08-08 10:59:40 -04:00
parent c55da2fbfb
commit 599a05bed9
No known key found for this signature in database
GPG Key ID: 0E0E3FA31751954E
2 changed files with 59 additions and 0 deletions

View File

@ -147,6 +147,7 @@ public final class ModuleManager {
add(new HotBarRefillModule());
add(new QuickCraftModule());
add(new TotemNotifierModule());
add(new MiddleClickPearlModule());
// p2w experience
if (Seppuku.INSTANCE.getCapeManager().hasCape())

View File

@ -0,0 +1,58 @@
package me.rigamortis.seppuku.impl.module.misc;
import me.rigamortis.seppuku.api.event.EventStageable;
import me.rigamortis.seppuku.api.event.player.EventPlayerUpdate;
import me.rigamortis.seppuku.api.module.Module;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemEnderPearl;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.RayTraceResult;
import org.lwjgl.input.Mouse;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
public class MiddleClickPearlModule extends Module {
private boolean clicked;
private final Minecraft mc = Minecraft.getMinecraft();
public MiddleClickPearlModule() {
super("MiddleClickPearl", new String[]{"mcp", "autopearl"}, "Throws a pearl if you middle-click pointing in mid-air", "NONE", -1, ModuleType.MISC);
}
@Listener
public void onUpdate(EventPlayerUpdate event) {
if(event.getStage() == EventStageable.EventStage.PRE) {
if(mc.currentScreen == null) {
if(Mouse.isButtonDown(2)) {
if(!this.clicked) {
final RayTraceResult result = mc.objectMouseOver;
if(result != null && result.typeOfHit == RayTraceResult.Type.MISS) {
final int pearlSlot = findPearlInHotbar();
if(pearlSlot != -1) {
final int oldSlot = mc.player.inventory.currentItem;
mc.player.inventory.currentItem = pearlSlot;
mc.playerController.processRightClick(mc.player, mc.world, EnumHand.MAIN_HAND);
mc.player.inventory.currentItem = oldSlot;
}
}
}
this.clicked = true;
} else {
this.clicked = false;
}
}
}
}
private boolean isItemStackPearl(final ItemStack itemStack) {
return itemStack.getItem() instanceof ItemEnderPearl;
}
private int findPearlInHotbar() {
for (int index = 0; InventoryPlayer.isHotbar(index); index++) {
if (isItemStackPearl(mc.player.inventory.getStackInSlot(index))) return index;
}
return -1;
}
}