Skip to content
This repository was archived by the owner on Mar 23, 2023. It is now read-only.

Commit c957bff

Browse files
v0.5.2
butch
1 parent a2e4674 commit c957bff

File tree

95 files changed

+8117
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+8117
-0
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
package com.snoworange.mousse;
2+
3+
import com.mojang.realmsclient.gui.ChatFormatting;
4+
import com.snoworange.mousse.command.CommandManager;
5+
import com.snoworange.mousse.module.Module;
6+
import com.snoworange.mousse.module.ModuleManager;
7+
import com.snoworange.mousse.ui.ClickGui;
8+
import com.snoworange.mousse.ui.Hud;
9+
import com.snoworange.mousse.ui.theme.ThemeManager;
10+
import com.snoworange.mousse.util.misc.FileUtils;
11+
import com.snoworange.mousse.util.render.JColor;
12+
import net.minecraft.client.Minecraft;
13+
import net.minecraft.client.settings.KeyBinding;
14+
import net.minecraft.util.text.TextComponentString;
15+
import net.minecraftforge.common.MinecraftForge;
16+
import net.minecraftforge.fml.client.registry.ClientRegistry;
17+
import net.minecraftforge.fml.common.Mod;
18+
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
19+
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
20+
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
21+
import net.minecraftforge.fml.common.gameevent.InputEvent;
22+
import net.minecraftforge.fml.common.gameevent.TickEvent;
23+
import org.lwjgl.input.Keyboard;
24+
import org.lwjgl.opengl.Display;
25+
26+
27+
@Mod(modid = Main.MOD_ID, name = Main.NAME, version = Main.VERSION)
28+
public class Main {
29+
public static ThemeManager themeManager = new ThemeManager();
30+
31+
public static ModuleManager moduleManager;
32+
33+
public static Hud hud;
34+
public static KeyBinding ClickGUI;
35+
public static CommandManager commandManager;
36+
private ClickGui clickgui;
37+
//public ClickGui clickGui;
38+
39+
//
40+
41+
public static final String MOD_ID = "mousse";
42+
public static final String NAME = "Mousse";
43+
public static final String VERSION = "v0.5.2";
44+
45+
public static Minecraft mc = Minecraft.getMinecraft();
46+
47+
public static final JColor MOUSSE_COLOR = new JColor(131, 141, 59);
48+
49+
//
50+
@Mod.Instance
51+
public Main instance;
52+
53+
54+
@Mod.EventHandler
55+
public void PreInit(FMLPreInitializationEvent event) {
56+
}
57+
58+
public void initFilesystem() {
59+
FileUtils.createDirectory();
60+
FileUtils.loadAll();
61+
}
62+
63+
@Mod.EventHandler
64+
public void init(FMLPreInitializationEvent event) {
65+
66+
MinecraftForge.EVENT_BUS.register(instance);
67+
MinecraftForge.EVENT_BUS.register(new Hud());
68+
69+
Display.setTitle(Main.NAME + " " + Main.VERSION);
70+
71+
moduleManager = new ModuleManager();
72+
commandManager = new CommandManager();
73+
hud = new Hud();
74+
clickgui = new ClickGui();
75+
76+
ClickGUI = new KeyBinding("ClickGUI", Keyboard.KEY_NONE, "Mousse");
77+
ClientRegistry.registerKeyBinding(ClickGUI);
78+
79+
this.initFilesystem();
80+
}
81+
82+
@Mod.EventHandler
83+
public void post(FMLPostInitializationEvent event) {
84+
85+
}
86+
87+
88+
@SubscribeEvent
89+
public void key(InputEvent.KeyInputEvent e) {
90+
if(Minecraft.getMinecraft().world == null || Minecraft.getMinecraft().player == null)
91+
return;
92+
try {
93+
if (Keyboard.isCreated()) {
94+
if (Keyboard.getEventKeyState()) {
95+
int keyCode = Keyboard.getEventKey();
96+
if (keyCode <= 0)
97+
return;
98+
for (Module m : moduleManager.modules) {
99+
if (m.getKey() == keyCode && keyCode > 0) {
100+
m.toggle();
101+
}
102+
}
103+
}
104+
}
105+
} catch (Exception ex) {ex.printStackTrace();}
106+
}
107+
108+
public static void sendMessage(String msg) {
109+
110+
if (Minecraft.getMinecraft().world == null || Minecraft.getMinecraft().player == null) return;
111+
112+
Minecraft.getMinecraft().player.sendMessage(new TextComponentString( ChatFormatting.RESET + "[" + Main.NAME + "] " + msg));
113+
}
114+
115+
@SubscribeEvent
116+
public void displayGuiScreen(TickEvent.ClientTickEvent event) {
117+
if (Main.ClickGUI.isPressed()) {
118+
mc.displayGuiScreen(new ClickGui());
119+
}
120+
}
121+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.snoworange.mousse.command;
2+
3+
import com.mojang.realmsclient.gui.ChatFormatting;
4+
import net.minecraft.client.Minecraft;
5+
6+
import java.util.ArrayList;
7+
import java.util.Arrays;
8+
import java.util.List;
9+
10+
public class Command {
11+
12+
public String name, description, syntax;
13+
public List<String> aliases = new ArrayList<String>();
14+
15+
protected static final Minecraft mc = Minecraft.getMinecraft();
16+
17+
public Command(String name, String description, String syntax, String... aliases) {
18+
this.name = name;
19+
this.description = description;
20+
this.syntax = syntax;
21+
this.aliases = Arrays.asList(aliases);
22+
}
23+
24+
public void onCommand(String[] args, String command) {
25+
26+
}
27+
28+
public String getName() {
29+
return name;
30+
}
31+
32+
public void setName(String name) {
33+
this.name = name;
34+
}
35+
36+
public String getDescription() {
37+
return description;
38+
}
39+
40+
public void setDescription(String description) {
41+
this.description = description;
42+
}
43+
44+
public String getSyntax() {
45+
return syntax;
46+
}
47+
48+
public void setSyntax(String syntax) {
49+
this.syntax = syntax;
50+
}
51+
52+
public List<String> getAliases() {
53+
return aliases;
54+
}
55+
56+
public void setAliases(List<String> aliases) {
57+
this.aliases = aliases;
58+
}
59+
}
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
package com.snoworange.mousse.command;
2+
3+
import com.mojang.realmsclient.gui.ChatFormatting;
4+
import com.snoworange.mousse.Main;
5+
import com.snoworange.mousse.command.impl.*;
6+
import net.minecraft.client.Minecraft;
7+
import net.minecraft.util.text.TextComponentString;
8+
import net.minecraftforge.client.event.ClientChatEvent;
9+
import net.minecraftforge.common.MinecraftForge;
10+
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
11+
12+
import java.util.ArrayList;
13+
import java.util.Arrays;
14+
import java.util.List;
15+
16+
public class CommandManager {
17+
public List<Command> commands = new ArrayList<Command>();
18+
public String prefix = "&";
19+
20+
public CommandManager() {
21+
MinecraftForge.EVENT_BUS.register(this);
22+
23+
commands.add(new Peek());
24+
commands.add(new Say());
25+
//commands.add(new Dispenser32kRedstoneDelay());
26+
//commands.add(new Dispenser32kAutoClose());
27+
commands.add(new Load());
28+
commands.add(new Save());
29+
}
30+
31+
@SubscribeEvent
32+
public void onChat(final ClientChatEvent event) {
33+
String message = event.getMessage();
34+
35+
if (!message.startsWith(prefix)) {
36+
return;
37+
}
38+
39+
event.setCanceled(true);
40+
message = message.substring(prefix.length());
41+
42+
if (message.split(" ").length > 0) {
43+
44+
boolean commandFound = false;
45+
String commandName = message.split(" ")[0];
46+
47+
if (commandName.equals("") || commandName.equals("help")) {
48+
sendCommandDescriptions();
49+
} else {
50+
for (Command c : commands) {
51+
if (c.aliases.contains(commandName) || c.name.equalsIgnoreCase(commandName)) {
52+
c.onCommand(Arrays.copyOfRange(message.split(" "), 1, message.split(" ").length), message);
53+
commandFound = true;
54+
break;
55+
}
56+
}
57+
if (!commandFound) {
58+
sendClientChatMessage(ChatFormatting.DARK_RED + "command does not exist, use " + ChatFormatting.ITALIC + prefix + "help " + ChatFormatting.RESET + "" + ChatFormatting.DARK_RED + "for help.", true);
59+
}
60+
}
61+
}
62+
}
63+
64+
/*
65+
@EventHandler
66+
public Listener<ClientChatEvent> listener = new Listener<>(event -> {
67+
68+
String message = event.getMessage();
69+
70+
if (!message.startsWith(prefix)) {
71+
return;
72+
}
73+
74+
event.setCanceled(true);
75+
message = message.substring(prefix.length());
76+
77+
if(message.split(" ").length > 0) {
78+
boolean commandFound = false;
79+
String commandName = message.split(" ")[0];
80+
if(commandName.equals("") || commandName.equals("help")) {
81+
ChatFormatting GRAY = ChatFormatting.GRAY;
82+
ChatFormatting BOLD = ChatFormatting.BOLD;
83+
ChatFormatting RESET = ChatFormatting.RESET;
84+
sendCommandDescriptions();
85+
} else {
86+
for (Command c : commands) {
87+
if (c.aliases.contains(commandName) || c.name.equalsIgnoreCase(commandName)) {
88+
c.onCommand(Arrays.copyOfRange(message.split(" "), 1, message.split(" ").length), message);
89+
commandFound = true;
90+
break;
91+
}
92+
}
93+
if (!commandFound) {
94+
sendClientChatMessage(ChatFormatting.DARK_RED + "command does not exist, use " + ChatFormatting.ITALIC + prefix + "help " + ChatFormatting.RESET + "" + ChatFormatting.DARK_RED + "for help.", true);
95+
}
96+
}
97+
}
98+
});
99+
*/
100+
private void sendCommandDescriptions() {
101+
sendClientChatMessage("\n", false);
102+
for (Command c : Main.commandManager.commands) {
103+
sendClientChatMessage(c.name + " - " + c.description + " [" + c.syntax + "]", false);
104+
}
105+
}
106+
107+
public void setCommandPrefix(String pre) {
108+
prefix = pre;
109+
110+
//if (Main.saveLoad != null) {
111+
// Main.saveLoad.save();
112+
//}
113+
}
114+
115+
public void sendClientChatMessage(String message, boolean prefix) {
116+
String messageWithPrefix = ChatFormatting.WHITE + "" + ChatFormatting.ITALIC + "[" + Main.NAME + ": " + ChatFormatting.RESET + ChatFormatting.GRAY + message;
117+
118+
if (prefix)
119+
Minecraft.getMinecraft().player.sendMessage(new TextComponentString(messageWithPrefix));
120+
else
121+
Minecraft.getMinecraft().player.sendMessage(new TextComponentString(message));
122+
}
123+
124+
public void sendCorrectionMessage(String name, String syntax) {
125+
String correction = "correct usage of " + ChatFormatting.WHITE + name + ChatFormatting.GRAY + " command -> " + ChatFormatting.WHITE + prefix + syntax + ChatFormatting.GRAY + ".";
126+
sendClientChatMessage(correction, true);
127+
}
128+
129+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.snoworange.mousse.command.impl;
2+
3+
import com.snoworange.mousse.Main;
4+
import com.snoworange.mousse.command.Command;
5+
import com.snoworange.mousse.util.misc.FileUtils;
6+
7+
public class Load extends Command {
8+
9+
public Load() {
10+
super("Load", "loads stuff", "load", "sv");
11+
}
12+
13+
@Override
14+
public void onCommand(String[] args, String command) {
15+
if (args.length >= 0) {
16+
FileUtils.loadAll();
17+
Main.sendMessage("Loaded configs!");
18+
}
19+
}
20+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.snoworange.mousse.command.impl;
2+
3+
import com.snoworange.mousse.Main;
4+
import com.snoworange.mousse.command.Command;
5+
public class Peek extends Command {
6+
public Peek() {
7+
super("Peek", "Peeks inside shulker box", "peek", "pe");
8+
}
9+
10+
@Override
11+
public void onCommand(String[] args, String command) {
12+
Main.moduleManager.getModule("ShulkerPeek").toggle();
13+
Main.sendMessage("Opened shulker box.");
14+
}
15+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.snoworange.mousse.command.impl;
2+
3+
import com.snoworange.mousse.Main;
4+
import com.snoworange.mousse.command.Command;
5+
import com.snoworange.mousse.util.misc.FileUtils;
6+
import net.minecraft.client.Minecraft;
7+
8+
public class Save extends Command {
9+
10+
public Save() {
11+
super("Save", "saves stuff", "save", "sv");
12+
}
13+
14+
@Override
15+
public void onCommand(String[] args, String command) {
16+
if (args.length >= 0) {
17+
FileUtils.saveAll();
18+
Main.sendMessage("Saved configs!");
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)