Skip to content

Commit

Permalink
I'm making the slot priority tomorrow
Browse files Browse the repository at this point in the history
  • Loading branch information
Spigey committed May 1, 2024
1 parent 1705ac3 commit 96f1a61
Showing 1 changed file with 43 additions and 5 deletions.
48 changes: 43 additions & 5 deletions src/main/java/spigey/asteroide/modules/AutoSlotSwitchModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@
import spigey.asteroide.AsteroideAddon;
import spigey.asteroide.util;

import java.util.List;

public class AutoSlotSwitchModule extends Module {
public AutoSlotSwitchModule() {
super(AsteroideAddon.CATEGORY, "", "");
super(AsteroideAddon.CATEGORY, "auto-hotbar", "Automatically swaps between slots in the hotbar");
}
private final SettingGroup sgGeneral = settings.getDefaultGroup();
private final Setting<Integer> delay = sgGeneral.add(new IntSetting.Builder()
.name("delay")
.description("The delay before switching slots again")
.defaultValue(5)
.defaultValue(0)
.min(0)
.sliderMax(200)
.build()
Expand Down Expand Up @@ -46,6 +48,7 @@ public AutoSlotSwitchModule() {
);
// slot priority
private boolean SlotActivated = false;
private int remainingDelay = -1;
@Override
public void onActivate() {
if(!SlotActivated){return;}
Expand All @@ -54,8 +57,45 @@ public void onActivate() {
}
@EventHandler
private void onTick(TickEvent.Post event){
InvUtils.swap(util.randomNum(0,8), false);
if(remainingDelay > 0){remainingDelay--; return;}
int num = 9;
if(slotmode.get() == SlotMode.Custom){
boolean[] slots = {slot1.get(), slot2.get(), slot3.get(), slot4.get(), slot5.get(), slot6.get(), slot7.get(), slot8.get(), slot9.get(), false};
if(!util.BoolContains(slots,true)){toggle(); error("No Slots enabled"); return;}
while(!slots[num]){
if(switchmode.get() == SwitchMode.Random) {
num = util.randomNum(0, 8);
} else{
assert mc.player != null;
int temp = mc.player.getInventory().selectedSlot + 1;
for(int i = 0; i < 10; i++){
if(temp > 9){temp = 0;}
if(!slots[temp]){temp++;}
}
num = temp;
// Custom Switch Mode done
}
}
} else{
if(switchmode.get() == SwitchMode.Random) {
num = util.randomNum(0, 8);
} else{
assert mc.player != null;
num = mc.player.getInventory().selectedSlot + 1;
if(num == 9){num = 0;}
}
}
// Custom slot mode done
InvUtils.swap(num, false);
remainingDelay = delay.get();
}

//////////////////////////////////////////////
// //
// code end thingy //
// //
//////////////////////////////////////////////

public enum SlotMode{
All,
Custom
Expand All @@ -65,5 +105,3 @@ public enum SwitchMode{
Next
}
}


0 comments on commit 96f1a61

Please sign in to comment.