blob: e967623ac9c6e2a521150414d3586b49900a4b4f (
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
112
|
package me.Danker.features.puzzlesolvers;
import me.Danker.commands.ToggleCommand;
import me.Danker.events.ChestSlotClickedEvent;
import me.Danker.utils.Utils;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StringUtils;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.lwjgl.input.Keyboard;
public class BlockWrongTerminalClicks {
@SubscribeEvent
public void onSlotClick(ChestSlotClickedEvent event) {
if (ToggleCommand.blockWrongTerminalClicksToggled && Utils.inDungeons) {
IInventory inventory = event.inventory;
String inventoryName = event.inventoryName;
Slot slot = event.slot;
ItemStack item = event.item;
boolean shouldCancel = false;
if (item == null) return;
//most of these are extra but who cares
switch (inventoryName) {
case "Correct all the panes!":
shouldCancel = !StringUtils.stripControlCodes(item.getDisplayName()).startsWith("Off");
break;
case "Navigate the maze!":
if (item.getItem() != Item.getItemFromBlock(Blocks.stained_glass_pane)) {
shouldCancel = true;
break;
}
if (item.getItemDamage() != 0) {
shouldCancel = true;
break;
}
boolean isValid = false;
int slotIndex = slot.getSlotIndex();
if (slotIndex % 9 != 8 && slotIndex != 53) {
ItemStack itemStack = inventory.getStackInSlot(slotIndex + 1);
if (itemStack != null && itemStack.getItemDamage() == 5) isValid = true;
}
if (!isValid && slotIndex % 9 != 0 && slotIndex != 0) {
ItemStack itemStack = inventory.getStackInSlot(slotIndex - 1);
if (itemStack != null && itemStack.getItemDamage() == 5) isValid = true;
}
if (!isValid && slotIndex <= 44) {
ItemStack itemStack = inventory.getStackInSlot(slotIndex + 9);
if (itemStack != null && itemStack.getItemDamage() == 5) isValid = true;
}
if (!isValid && slotIndex >= 9) {
ItemStack itemStack = inventory.getStackInSlot(slotIndex - 9);
if (itemStack != null && itemStack.getItemDamage() == 5) isValid = true;
}
shouldCancel = !isValid;
break;
case "Click in order!":
if (slot.getSlotIndex() > 35) {
break;
}
if ((item.getItem() != Item.getItemFromBlock(Blocks.stained_glass_pane))) {
shouldCancel = true;
break;
}
if (item.getItemDamage() != 14) {
shouldCancel = true;
break;
}
int needed = ClickInOrderSolver.terminalNumberNeeded[0];
if (needed == 0) break;
shouldCancel = needed != -1 && item.stackSize != needed;
break;
}
if (!shouldCancel) {
if (inventoryName.startsWith("What starts with:")) {
char letter = inventoryName.charAt(inventoryName.indexOf("'") + 1);
shouldCancel = !(StringUtils.stripControlCodes(item.getDisplayName()).charAt(0) == letter);
} else if (inventoryName.startsWith("Select all the")) {
if (SelectAllColourSolver.terminalColorNeeded == null) return;
String itemName = StringUtils.stripControlCodes(item.getDisplayName()).toUpperCase();
shouldCancel = !(itemName.contains(SelectAllColourSolver.terminalColorNeeded) ||
(SelectAllColourSolver.terminalColorNeeded.equals("SILVER") && itemName.contains("LIGHT GRAY")) ||
(SelectAllColourSolver.terminalColorNeeded.equals("WHITE") && (itemName.equals("WOOL") || itemName.equals("BONE MEAL"))) ||
(SelectAllColourSolver.terminalColorNeeded.equals("BLACK") && itemName.equals("INK SACK")) ||
(SelectAllColourSolver.terminalColorNeeded.equals("BLUE") && itemName.equals("LAPIS LAZULI")) ||
(SelectAllColourSolver.terminalColorNeeded.equals("BROWN") && itemName.equals("COCOA BEANS")));
}
}
event.setCanceled(shouldCancel && !Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) && !Keyboard.isKeyDown(Keyboard.KEY_RCONTROL));
}
}
}
|