blob: 6608555273a8cf9a1a7ed0c1a408a10a63821456 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
package me.Danker.features.puzzlesolvers;
import me.Danker.commands.ToggleCommand;
import me.Danker.events.ChestSlotClickedEvent;
import me.Danker.events.GuiChestBackgroundDrawnEvent;
import me.Danker.utils.RenderUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.inventory.ContainerChest;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.util.StringUtils;
import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.lwjgl.input.Keyboard;
import java.util.List;
public class UltrasequencerSolver {
static Slot[] clickInOrderSlots = new Slot[36];
static int lastUltraSequencerClicked = 0;
public static int ULTRASEQUENCER_NEXT;
public static int ULTRASEQUENCER_NEXT_TO_NEXT;
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
if (event.phase != TickEvent.Phase.START) return;
Minecraft mc = Minecraft.getMinecraft();
EntityPlayerSP player = mc.thePlayer;
if (mc.currentScreen instanceof GuiChest) {
if (player == null) return;
ContainerChest chest = (ContainerChest) player.openContainer;
List<Slot> invSlots = ((GuiChest) mc.currentScreen).inventorySlots.inventorySlots;
String chestName = chest.getLowerChestInventory().getDisplayName().getUnformattedText().trim();
if (ToggleCommand.ultrasequencerToggled && chestName.startsWith("Ultrasequencer (")) {
if (invSlots.get(49).getStack() != null && invSlots.get(49).getStack().getDisplayName().equals("§aRemember the pattern!")) {
for (int i = 9; i <= 44; i++) {
if (invSlots.get(i) == null || invSlots.get(i).getStack() == null) continue;
String itemName = StringUtils.stripControlCodes(invSlots.get(i).getStack().getDisplayName());
if (itemName.matches("\\d+")) {
int number = Integer.parseInt(itemName);
clickInOrderSlots[number - 1] = invSlots.get(i);
}
}
}
}
}
}
@SubscribeEvent
public void onSlotClick(ChestSlotClickedEvent event) {
if (ToggleCommand.ultrasequencerToggled && event.inventoryName.startsWith("Ultrasequencer (")) {
IInventory inventory = event.inventory;
if (event.item == null) {
if (event.isCancelable() && !Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) && !Keyboard.isKeyDown(Keyboard.KEY_RCONTROL))
event.setCanceled(true);
return;
}
if (inventory.getStackInSlot(49).getDisplayName().equals("§aRemember the pattern!")) {
if (event.isCancelable()) event.setCanceled(true);
} else if (inventory.getStackInSlot(49).getDisplayName().startsWith("§7Timer: §a")) {
if (clickInOrderSlots[lastUltraSequencerClicked] != null && event.slot.getSlotIndex() != clickInOrderSlots[lastUltraSequencerClicked].getSlotIndex()) {
if (event.isCancelable() && !Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) && !Keyboard.isKeyDown(Keyboard.KEY_RCONTROL)) {
event.setCanceled(true);
}
}
}
}
}
@SubscribeEvent
public void onGuiRender(GuiChestBackgroundDrawnEvent event) {
if (ToggleCommand.ultrasequencerToggled && event.displayName.startsWith("Ultrasequencer (")) {
List<Slot> invSlots = event.slots;
if (invSlots.size() > 48 && invSlots.get(49).getStack() != null) {
if (invSlots.get(49).getStack().getDisplayName().startsWith("§7Timer: §a")) {
lastUltraSequencerClicked = 0;
for (Slot slot : clickInOrderSlots) {
if (slot != null && slot.getStack() != null && StringUtils.stripControlCodes(slot.getStack().getDisplayName()).matches("\\d+")) {
int number = Integer.parseInt(StringUtils.stripControlCodes(slot.getStack().getDisplayName()));
if (number > lastUltraSequencerClicked) {
lastUltraSequencerClicked = number;
}
}
}
if (clickInOrderSlots[lastUltraSequencerClicked] != null) {
Slot nextSlot = clickInOrderSlots[lastUltraSequencerClicked];
RenderUtils.drawOnSlot(event.chestSize, nextSlot.xDisplayPosition, nextSlot.yDisplayPosition, ULTRASEQUENCER_NEXT + 0xE5000000);
}
if (lastUltraSequencerClicked + 1 < clickInOrderSlots.length) {
if (clickInOrderSlots[lastUltraSequencerClicked + 1] != null) {
Slot nextSlot = clickInOrderSlots[lastUltraSequencerClicked + 1];
RenderUtils.drawOnSlot(event.chestSize, nextSlot.xDisplayPosition, nextSlot.yDisplayPosition, ULTRASEQUENCER_NEXT_TO_NEXT + 0xD7000000);
}
}
}
}
}
}
@SubscribeEvent
public void onGuiOpen(GuiOpenEvent event) {
clickInOrderSlots = new Slot[36];
}
}
|