Skip to content

Commit

Permalink
what the fuck am I doing with my life
Browse files Browse the repository at this point in the history
  • Loading branch information
Spigey committed May 3, 2024
1 parent f4ec0e0 commit 9455350
Showing 1 changed file with 69 additions and 15 deletions.
84 changes: 69 additions & 15 deletions src/main/java/spigey/asteroide/modules/AutoSlotSwitchModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
import meteordevelopment.orbit.EventHandler;
import spigey.asteroide.AsteroideAddon;
import spigey.asteroide.util;
import net.minecraft.command.StorageDataObject;
import net.minecraft.stat.StatHandler;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class AutoSlotSwitchModule extends Module {
Expand Down Expand Up @@ -41,6 +43,21 @@ public AutoSlotSwitchModule() {
private final Setting<Boolean> slot7 = sgGeneral.add(new BoolSetting.Builder().name("Slot 7").description("Whether it should also switch to this slot").defaultValue(true).visible(() -> slotmode.get() == SlotMode.Custom).build());
private final Setting<Boolean> slot8 = sgGeneral.add(new BoolSetting.Builder().name("Slot 8").description("Whether it should also switch to this slot").defaultValue(true).visible(() -> slotmode.get() == SlotMode.Custom).build());
private final Setting<Boolean> slot9 = sgGeneral.add(new BoolSetting.Builder().name("Slot 9").description("Whether it should also switch to this slot").defaultValue(true).visible(() -> slotmode.get() == SlotMode.Custom).build());
private final Setting<Boolean> PriorityEnabled = sgGeneral.add(new BoolSetting.Builder()
.name("Enable Slot Priority")
.description("Whether it should also switch to this slot")
.defaultValue(true)
.build()
);
private final Setting<Integer> slot1p = sgGeneral.add(new IntSetting.Builder().name("Slot 1 Priority").description("Priority to switch to slot 1").defaultValue(1).min(0).sliderMax(10).visible(() -> PriorityEnabled.get()).build());
private final Setting<Integer> slot2p = sgGeneral.add(new IntSetting.Builder().name("Slot 2 Priority").description("Priority to switch to slot 2").defaultValue(1).min(0).sliderMax(10).visible(() -> PriorityEnabled.get()).build());
private final Setting<Integer> slot3p = sgGeneral.add(new IntSetting.Builder().name("Slot 3 Priority").description("Priority to switch to slot 3").defaultValue(1).min(0).sliderMax(10).visible(() -> PriorityEnabled.get()).build());
private final Setting<Integer> slot4p = sgGeneral.add(new IntSetting.Builder().name("Slot 4 Priority").description("Priority to switch to slot 4").defaultValue(1).min(0).sliderMax(10).visible(() -> PriorityEnabled.get()).build());
private final Setting<Integer> slot5p = sgGeneral.add(new IntSetting.Builder().name("Slot 5 Priority").description("Priority to switch to slot 5").defaultValue(1).min(0).sliderMax(10).visible(() -> PriorityEnabled.get()).build());
private final Setting<Integer> slot6p = sgGeneral.add(new IntSetting.Builder().name("Slot 6 Priority").description("Priority to switch to slot 6").defaultValue(1).min(0).sliderMax(10).visible(() -> PriorityEnabled.get()).build());
private final Setting<Integer> slot7p = sgGeneral.add(new IntSetting.Builder().name("Slot 7 Priority").description("Priority to switch to slot 7").defaultValue(1).min(0).sliderMax(10).visible(() -> PriorityEnabled.get()).build());
private final Setting<Integer> slot8p = sgGeneral.add(new IntSetting.Builder().name("Slot 8 Priority").description("Priority to switch to slot 8").defaultValue(1).min(0).sliderMax(10).visible(() -> PriorityEnabled.get()).build());
private final Setting<Integer> slot9p = sgGeneral.add(new IntSetting.Builder().name("Slot 9 Priority").description("Priority to switch to slot 9").defaultValue(1).min(0).sliderMax(10).visible(() -> PriorityEnabled.get()).build());
private final Setting<AutoSlotSwitchModule.SwitchMode> switchmode = sgGeneral.add(new EnumSetting.Builder<AutoSlotSwitchModule.SwitchMode>()
.name("Switching Mode")
.description("Mode of the slot Switching")
Expand All @@ -57,34 +74,71 @@ public void onActivate() {
SlotActivated = true;
}
@EventHandler
private void onTick(TickEvent.Post event){
if(remainingDelay > 0){remainingDelay--; return;}
private void onTick(TickEvent.Post event) {
if (remainingDelay > 0) {
remainingDelay--;
return;
}
int num = 9;
if(slotmode.get() == SlotMode.Custom){
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) {
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{
} 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++;}
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) {
} else {
if (switchmode.get() == SwitchMode.Random) {
num = util.randomNum(0, 8);
} else{
} else {
assert mc.player != null;
num = mc.player.getInventory().selectedSlot + 1;
if(num == 9){num = 0;}
if (num == 9) {
num = 0;
}
}
}
if (PriorityEnabled.get()) { // what the actual fuck am i doing
List<Integer> priorityList = new ArrayList<>();
for (int i = 1; i <= 10; i++) {
int slotPriority = switch (i) {
case 1 -> slot1p.get();
case 2 -> slot2p.get();
case 3 -> slot3p.get();
case 4 -> slot4p.get();
case 5 -> slot5p.get();
case 6 -> slot6p.get();
case 7 -> slot7p.get();
case 8 -> slot8p.get();
case 9 -> slot9p.get();
default -> 0;
};
for (int j = 0; j < slotPriority && j < 10; j++) {
priorityList.add(i);
}
}
int[] priorityArray = priorityList.stream().mapToInt(Integer::intValue).toArray();
// no like literally what the literal fucking fuck is this fucking ass spaghetti code please just fucking kill me
assert priorityArray.length > 0;
num = priorityArray[util.randomNum(0, priorityArray.length - 1)] - 1;
}
// Custom slot mode done
InvUtils.swap(num, false);
Expand Down

0 comments on commit 9455350

Please sign in to comment.