kami-blue/src/main/java/me/zeroeightsix/kami/module/modules/combat/Fastuse.java

70 lines
3.1 KiB
Java
Raw Normal View History

2020-01-26 06:29:07 +00:00
package me.zeroeightsix.kami.module.modules.combat;
2019-10-15 01:40:39 +00:00
import me.zeroeightsix.kami.module.Module;
import me.zeroeightsix.kami.setting.Setting;
import me.zeroeightsix.kami.setting.Settings;
import net.minecraft.item.*;
import net.minecraft.network.play.client.CPacketPlayerDigging;
import net.minecraft.network.play.client.CPacketPlayerTryUseItem;
import net.minecraft.util.math.BlockPos;
2019-10-25 22:05:12 +00:00
/**
2020-04-18 15:20:04 +00:00
* Created by dominikaaaa on 23/10/2019
* @author dominikaaaa
* Updated by dominikaaaa on 03/12/19
2019-12-04 01:56:39 +00:00
* Updated by d1gress/Qther on 4/12/19
*
2020-04-02 18:56:44 +00:00
* Bowspam code from https://github.com/seppukudevelopment/seppuku/blob/5586365/src/main/java/me/rigamortis/seppuku/impl/module/combat/FastBowModule.java
*/
@Module.Info(
category = Module.Category.COMBAT,
description = "Use items faster", name = "FastUse"
)
2019-10-24 15:15:13 +00:00
public class Fastuse extends Module {
2019-10-15 01:40:39 +00:00
2020-03-05 14:35:22 +00:00
private Setting<Integer> delay = register(Settings.integerBuilder("Delay").withMinimum(0).withMaximum(20).withValue(0).build());
private Setting<Boolean> all = register(Settings.b("All", false));
private Setting<Boolean> bow = register(Settings.booleanBuilder().withName("Bow").withValue(true).withVisibility(v -> !all.getValue()).build());
private Setting<Boolean> expBottles = register(Settings.booleanBuilder().withName("Exp Bottles").withValue(true).withVisibility(v -> !all.getValue()).build());
private Setting<Boolean> endCrystals = register(Settings.booleanBuilder().withName("End Crystals").withValue(true).withVisibility(v -> !all.getValue()).build());
private Setting<Boolean> fireworks = register(Settings.booleanBuilder().withName("Fireworks").withValue(false).withVisibility(v -> !all.getValue()).build());
private static long time = 0;
2019-12-04 15:31:56 +00:00
2019-12-13 03:59:59 +00:00
@Override
public void onDisable() {
mc.rightClickDelayTimer = 4;
}
2019-12-03 14:01:16 +00:00
2019-12-13 03:59:59 +00:00
@Override
public void onUpdate() {
if (mc.player == null) return;
2020-03-22 14:16:11 +00:00
if (all.getValue() || bow.getValue() && mc.player.getHeldItemMainhand().getItem() instanceof ItemBow && mc.player.isHandActive() && mc.player.getItemInUseMaxCount() >= 3) {
mc.player.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, mc.player.getHorizontalFacing()));
mc.player.connection.sendPacket(new CPacketPlayerTryUseItem(mc.player.getActiveHand()));
mc.player.stopActiveHand();
}
2019-12-13 03:59:59 +00:00
if (!(delay.getValue() <= 0)) {
if (time <= 0) time = Math.round((2 * (Math.round((float) delay.getValue() / 2))));
2019-12-13 03:59:59 +00:00
else {
time--;
mc.rightClickDelayTimer = 1;
return;
}
}
2020-03-22 14:07:18 +00:00
if (passItemCheck(mc.player.getHeldItemMainhand().getItem()) || passItemCheck(mc.player.getHeldItemOffhand().getItem())) {
mc.rightClickDelayTimer = 0;
2019-12-13 03:59:59 +00:00
}
}
private boolean passItemCheck(Item item) {
if (all.getValue()) return true;
if (expBottles.getValue() && item instanceof ItemExpBottle) return true;
if (endCrystals.getValue() && item instanceof ItemEndCrystal) return true;
if (fireworks.getValue() && item instanceof ItemFirework) return true;
return false;
}
2019-10-23 17:56:23 +00:00
}