feat: added super basic autotool
This commit is contained in:
parent
d517ad0923
commit
82b57f4de9
3 changed files with 67 additions and 0 deletions
|
@ -65,6 +65,7 @@ public class BoSCoVicino implements ICommons {
|
||||||
BoSCoVicino.mods.add(new Fullbright(cfg, dp).done(cfg));
|
BoSCoVicino.mods.add(new Fullbright(cfg, dp).done(cfg));
|
||||||
BoSCoVicino.mods.add(new AntiHunger(cfg, dp).done(cfg));
|
BoSCoVicino.mods.add(new AntiHunger(cfg, dp).done(cfg));
|
||||||
BoSCoVicino.mods.add(new AutoFish(cfg, dp).done(cfg));
|
BoSCoVicino.mods.add(new AutoFish(cfg, dp).done(cfg));
|
||||||
|
BoSCoVicino.mods.add(new AutoTool(cfg, dp).done(cfg));
|
||||||
BoSCoVicino.mods.add(new Freecam(cfg, dp).done(cfg));
|
BoSCoVicino.mods.add(new Freecam(cfg, dp).done(cfg));
|
||||||
|
|
||||||
BoSCoVicino.spec = cfg.build();
|
BoSCoVicino.spec = cfg.build();
|
||||||
|
|
53
src/main/java/ftbsc/bscv/modules/self/AutoTool.java
Normal file
53
src/main/java/ftbsc/bscv/modules/self/AutoTool.java
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
package ftbsc.bscv.modules.self;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
|
|
||||||
|
import ftbsc.bscv.ICommons;
|
||||||
|
import ftbsc.bscv.modules.Module;
|
||||||
|
import ftbsc.bscv.tools.Inventory;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.command.CommandSource;
|
||||||
|
import net.minecraft.inventory.container.Slot;
|
||||||
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
|
import net.minecraftforge.client.event.InputEvent;
|
||||||
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
|
||||||
|
public class AutoTool extends Module implements ICommons {
|
||||||
|
|
||||||
|
public AutoTool(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
|
||||||
|
super("AutoTool", Group.SELF, builder, dispatcher);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onClick(InputEvent.ClickInputEvent event) {
|
||||||
|
if (MC.player == null) return;
|
||||||
|
// TODO this is fired many times consecutively, can we filter out
|
||||||
|
// some without putting a dumb time cooldown?;
|
||||||
|
if (event.isAttack()) {
|
||||||
|
switch (MC.hitResult.getType()) {
|
||||||
|
case BLOCK:
|
||||||
|
BlockRayTraceResult result = (BlockRayTraceResult) MC.hitResult;
|
||||||
|
BlockState state = MC.level.getBlockState(result.getBlockPos());
|
||||||
|
List<Slot> hotbar = Inventory.hotbar(MC.player);
|
||||||
|
int current_slot = MC.player.inventory.selected;
|
||||||
|
float current_speed = hotbar.get(current_slot).getItem().getDestroySpeed(state);
|
||||||
|
for (int i = 0; i < 9; i++) {
|
||||||
|
float speed = hotbar.get(i).getItem().getDestroySpeed(state);
|
||||||
|
if (speed > current_speed) {
|
||||||
|
current_slot = i;
|
||||||
|
current_speed = speed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MC.player.inventory.selected = current_slot;
|
||||||
|
break;
|
||||||
|
case ENTITY:
|
||||||
|
break;
|
||||||
|
case MISS:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
13
src/main/java/ftbsc/bscv/tools/Inventory.java
Normal file
13
src/main/java/ftbsc/bscv/tools/Inventory.java
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
package ftbsc.bscv.tools;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import ftbsc.bscv.ICommons;
|
||||||
|
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||||
|
import net.minecraft.inventory.container.Slot;
|
||||||
|
|
||||||
|
public class Inventory implements ICommons {
|
||||||
|
public static List<Slot> hotbar(ClientPlayerEntity player) {
|
||||||
|
return player.inventoryMenu.slots.subList(36, 45);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue