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

Commit

Permalink
v0.4.10
Browse files Browse the repository at this point in the history
corn cex
  • Loading branch information
Snoworange420 authored Nov 1, 2022
1 parent 707bf92 commit c599a03
Show file tree
Hide file tree
Showing 85 changed files with 7,792 additions and 0 deletions.
121 changes: 121 additions & 0 deletions src/main/java/com/snoworange/mousse/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package com.snoworange.mousse;

import com.mojang.realmsclient.gui.ChatFormatting;
import com.snoworange.mousse.command.CommandManager;
import com.snoworange.mousse.module.Module;
import com.snoworange.mousse.module.ModuleManager;
import com.snoworange.mousse.ui.ClickGui;
import com.snoworange.mousse.ui.Hud;
import com.snoworange.mousse.ui.theme.ThemeManager;
import com.snoworange.mousse.util.misc.FileUtils;
import com.snoworange.mousse.util.render.JColor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.Display;


@Mod(modid = Main.MOD_ID, name = Main.NAME, version = Main.VERSION)
public class Main {
public static ThemeManager themeManager = new ThemeManager();

public static ModuleManager moduleManager;

public static Hud hud;
public static KeyBinding ClickGUI;
public static CommandManager commandManager;
private ClickGui clickgui;
//public ClickGui clickGui;

//

public static final String MOD_ID = "mousse";
public static final String NAME = "Mousse";
public static final String VERSION = "v0.4.10";

public static Minecraft mc = Minecraft.getMinecraft();

public static final JColor MOUSSE_COLOR = new JColor(131, 141, 59);

//
@Mod.Instance
public Main instance;


@Mod.EventHandler
public void PreInit(FMLPreInitializationEvent event) {
}

public void initFilesystem() {
FileUtils.createDirectory();
FileUtils.loadAll();
}

@Mod.EventHandler
public void init(FMLPreInitializationEvent event) {

MinecraftForge.EVENT_BUS.register(instance);
MinecraftForge.EVENT_BUS.register(new Hud());

Display.setTitle(Main.NAME + " " + Main.VERSION);

moduleManager = new ModuleManager();
commandManager = new CommandManager();
hud = new Hud();
clickgui = new ClickGui();

ClickGUI = new KeyBinding("ClickGUI", Keyboard.KEY_NONE, "Mousse");
ClientRegistry.registerKeyBinding(ClickGUI);

this.initFilesystem();
}

@Mod.EventHandler
public void post(FMLPostInitializationEvent event) {

}


@SubscribeEvent
public void key(InputEvent.KeyInputEvent e) {
if(Minecraft.getMinecraft().world == null || Minecraft.getMinecraft().player == null)
return;
try {
if (Keyboard.isCreated()) {
if (Keyboard.getEventKeyState()) {
int keyCode = Keyboard.getEventKey();
if (keyCode <= 0)
return;
for (Module m : moduleManager.modules) {
if (m.getKey() == keyCode && keyCode > 0) {
m.toggle();
}
}
}
}
} catch (Exception ex) {ex.printStackTrace();}
}

public static void sendMessage(String msg) {

if (Minecraft.getMinecraft().world == null || Minecraft.getMinecraft().player == null) return;

Minecraft.getMinecraft().player.sendMessage(new TextComponentString( ChatFormatting.RESET + "[" + Main.NAME + "] " + msg));
}

@SubscribeEvent
public void displayGuiScreen(TickEvent.ClientTickEvent event) {
if (Main.ClickGUI.isPressed()) {
mc.displayGuiScreen(new ClickGui());
}
}
}
59 changes: 59 additions & 0 deletions src/main/java/com/snoworange/mousse/command/Command.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.snoworange.mousse.command;

import com.mojang.realmsclient.gui.ChatFormatting;
import net.minecraft.client.Minecraft;

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

public class Command {

public String name, description, syntax;
public List<String> aliases = new ArrayList<String>();

protected static final Minecraft mc = Minecraft.getMinecraft();

public Command(String name, String description, String syntax, String... aliases) {
this.name = name;
this.description = description;
this.syntax = syntax;
this.aliases = Arrays.asList(aliases);
}

public void onCommand(String[] args, String command) {

}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public String getSyntax() {
return syntax;
}

public void setSyntax(String syntax) {
this.syntax = syntax;
}

public List<String> getAliases() {
return aliases;
}

public void setAliases(List<String> aliases) {
this.aliases = aliases;
}
}
129 changes: 129 additions & 0 deletions src/main/java/com/snoworange/mousse/command/CommandManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
package com.snoworange.mousse.command;

import com.mojang.realmsclient.gui.ChatFormatting;
import com.snoworange.mousse.Main;
import com.snoworange.mousse.command.impl.*;
import net.minecraft.client.Minecraft;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.client.event.ClientChatEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

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

public class CommandManager {
public List<Command> commands = new ArrayList<Command>();
public String prefix = "&";

public CommandManager() {
MinecraftForge.EVENT_BUS.register(this);

commands.add(new Peek());
commands.add(new Say());
//commands.add(new Dispenser32kRedstoneDelay());
//commands.add(new Dispenser32kAutoClose());
commands.add(new Load());
commands.add(new Save());
}

@SubscribeEvent
public void onChat(final ClientChatEvent event) {
String message = event.getMessage();

if (!message.startsWith(prefix)) {
return;
}

event.setCanceled(true);
message = message.substring(prefix.length());

if (message.split(" ").length > 0) {

boolean commandFound = false;
String commandName = message.split(" ")[0];

if (commandName.equals("") || commandName.equals("help")) {
sendCommandDescriptions();
} else {
for (Command c : commands) {
if (c.aliases.contains(commandName) || c.name.equalsIgnoreCase(commandName)) {
c.onCommand(Arrays.copyOfRange(message.split(" "), 1, message.split(" ").length), message);
commandFound = true;
break;
}
}
if (!commandFound) {
sendClientChatMessage(ChatFormatting.DARK_RED + "command does not exist, use " + ChatFormatting.ITALIC + prefix + "help " + ChatFormatting.RESET + "" + ChatFormatting.DARK_RED + "for help.", true);
}
}
}
}

/*
@EventHandler
public Listener<ClientChatEvent> listener = new Listener<>(event -> {
String message = event.getMessage();
if (!message.startsWith(prefix)) {
return;
}
event.setCanceled(true);
message = message.substring(prefix.length());
if(message.split(" ").length > 0) {
boolean commandFound = false;
String commandName = message.split(" ")[0];
if(commandName.equals("") || commandName.equals("help")) {
ChatFormatting GRAY = ChatFormatting.GRAY;
ChatFormatting BOLD = ChatFormatting.BOLD;
ChatFormatting RESET = ChatFormatting.RESET;
sendCommandDescriptions();
} else {
for (Command c : commands) {
if (c.aliases.contains(commandName) || c.name.equalsIgnoreCase(commandName)) {
c.onCommand(Arrays.copyOfRange(message.split(" "), 1, message.split(" ").length), message);
commandFound = true;
break;
}
}
if (!commandFound) {
sendClientChatMessage(ChatFormatting.DARK_RED + "command does not exist, use " + ChatFormatting.ITALIC + prefix + "help " + ChatFormatting.RESET + "" + ChatFormatting.DARK_RED + "for help.", true);
}
}
}
});
*/
private void sendCommandDescriptions() {
sendClientChatMessage("\n", false);
for (Command c : Main.commandManager.commands) {
sendClientChatMessage(c.name + " - " + c.description + " [" + c.syntax + "]", false);
}
}

public void setCommandPrefix(String pre) {
prefix = pre;

//if (Main.saveLoad != null) {
// Main.saveLoad.save();
//}
}

public void sendClientChatMessage(String message, boolean prefix) {
String messageWithPrefix = ChatFormatting.WHITE + "" + ChatFormatting.ITALIC + "[" + Main.NAME + ": " + ChatFormatting.RESET + ChatFormatting.GRAY + message;

if (prefix)
Minecraft.getMinecraft().player.sendMessage(new TextComponentString(messageWithPrefix));
else
Minecraft.getMinecraft().player.sendMessage(new TextComponentString(message));
}

public void sendCorrectionMessage(String name, String syntax) {
String correction = "correct usage of " + ChatFormatting.WHITE + name + ChatFormatting.GRAY + " command -> " + ChatFormatting.WHITE + prefix + syntax + ChatFormatting.GRAY + ".";
sendClientChatMessage(correction, true);
}

}
20 changes: 20 additions & 0 deletions src/main/java/com/snoworange/mousse/command/impl/Load.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.snoworange.mousse.command.impl;

import com.snoworange.mousse.Main;
import com.snoworange.mousse.command.Command;
import com.snoworange.mousse.util.misc.FileUtils;

public class Load extends Command {

public Load() {
super("Load", "loads stuff", "load", "sv");
}

@Override
public void onCommand(String[] args, String command) {
if (args.length >= 0) {
FileUtils.loadAll();
Main.sendMessage("Loaded configs!");
}
}
}
15 changes: 15 additions & 0 deletions src/main/java/com/snoworange/mousse/command/impl/Peek.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.snoworange.mousse.command.impl;

import com.snoworange.mousse.Main;
import com.snoworange.mousse.command.Command;
public class Peek extends Command {
public Peek() {
super("Peek", "Peeks inside shulker box", "peek", "pe");
}

@Override
public void onCommand(String[] args, String command) {
Main.moduleManager.getModule("ShulkerPeek").toggle();
Main.sendMessage("Opened shulker box.");
}
}
21 changes: 21 additions & 0 deletions src/main/java/com/snoworange/mousse/command/impl/Save.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.snoworange.mousse.command.impl;

import com.snoworange.mousse.Main;
import com.snoworange.mousse.command.Command;
import com.snoworange.mousse.util.misc.FileUtils;
import net.minecraft.client.Minecraft;

public class Save extends Command {

public Save() {
super("Save", "saves stuff", "save", "sv");
}

@Override
public void onCommand(String[] args, String command) {
if (args.length >= 0) {
FileUtils.saveAll();
Main.sendMessage("Saved configs!");
}
}
}
Loading

0 comments on commit c599a03

Please sign in to comment.