-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1ecd80a
commit 40ce286
Showing
53 changed files
with
2,425 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/main/java/io/github/itzispyder/clickcrystals/ClickCrystals.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package io.github.itzispyder.clickcrystals; | ||
|
||
import io.github.itzispyder.clickcrystals.client.ClickCrystalsSystem; | ||
import io.github.itzispyder.clickcrystals.commands.commands.ClickCrystalToggleCommand; | ||
import io.github.itzispyder.clickcrystals.data.Configuration; | ||
import io.github.itzispyder.clickcrystals.events.events.ClientTickEndEvent; | ||
import io.github.itzispyder.clickcrystals.events.events.ClientTickStartEvent; | ||
import io.github.itzispyder.clickcrystals.gui.screens.ClickCrystalMenuScreen; | ||
import io.github.itzispyder.clickcrystals.modules.Module; | ||
import io.github.itzispyder.clickcrystals.modules.modules.*; | ||
import net.fabricmc.api.ModInitializer; | ||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; | ||
import net.minecraft.client.MinecraftClient; | ||
|
||
import java.io.File; | ||
|
||
public final class ClickCrystals implements ModInitializer { | ||
|
||
public static final File configFile = new File("ClickCrystalsClient/game_config.dat"); | ||
public static final Configuration config = Configuration.load(configFile) != null ? Configuration.load(configFile) : new Configuration(configFile); | ||
public static final MinecraftClient mc = MinecraftClient.getInstance(); | ||
public static final ClickCrystalsSystem system = new ClickCrystalsSystem(); | ||
public static final ClickCrystalMenuScreen mainMenu = new ClickCrystalMenuScreen(); | ||
|
||
@SuppressWarnings("unused") | ||
public static final String modId = "clickcrystals", prefix = "[ClickCrystals] ", starter = "§7[§bClick§3Crystals§7] §r"; | ||
|
||
/** | ||
* Runs the mod initializer. | ||
*/ | ||
@Override | ||
public void onInitialize() { | ||
// Mod initialization | ||
System.out.println(prefix + "Loading ClickCrystals by ImproperIssues"); | ||
this.startTicking(); | ||
|
||
// Commands | ||
system.addCommand(new ClickCrystalToggleCommand()); | ||
|
||
// Module | ||
system.addModule(new ClickCrystal()); | ||
system.addModule(new GlowStoneSearch()); | ||
system.addModule(new TpBlade()); | ||
system.addModule(new ClickCrystalAuto()); | ||
system.addModule(new NoBreakDelay()); | ||
system.addModule(new FullBright()); | ||
system.addModule(new NoHurtCam()); | ||
system.addModule(new SlowHandSwing()); | ||
system.addModule(new SpectatorSight()); | ||
system.addModule(new NoLoadingScreen()); | ||
Module.loadConfigModules(); | ||
} | ||
|
||
/** | ||
* Start click tick events | ||
*/ | ||
public void startTicking() { | ||
ClientTickEvents.START_CLIENT_TICK.register(client -> { | ||
ClientTickStartEvent event = new ClientTickStartEvent(); | ||
system.eventBus.pass(event); | ||
}); | ||
ClientTickEvents.END_CLIENT_TICK.register(client -> { | ||
ClientTickEndEvent event = new ClientTickEndEvent(); | ||
system.eventBus.pass(event); | ||
}); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/io/github/itzispyder/clickcrystals/client/ClickCrystalsClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.github.itzispyder.clickcrystals.client; | ||
|
||
import net.fabricmc.api.ClientModInitializer; | ||
|
||
/** | ||
* ClickCrystals client initializer | ||
*/ | ||
public final class ClickCrystalsClient implements ClientModInitializer { | ||
|
||
/** | ||
* Runs the mod initializer on the client environment. | ||
*/ | ||
@Override | ||
public void onInitializeClient() { | ||
|
||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
src/main/java/io/github/itzispyder/clickcrystals/client/ClickCrystalsSystem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package io.github.itzispyder.clickcrystals.client; | ||
|
||
import io.github.itzispyder.clickcrystals.commands.Command; | ||
import io.github.itzispyder.clickcrystals.events.EventBus; | ||
import io.github.itzispyder.clickcrystals.events.Listener; | ||
import io.github.itzispyder.clickcrystals.modules.Module; | ||
|
||
import java.io.Serializable; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* ClickCrystal system | ||
*/ | ||
public class ClickCrystalsSystem implements Serializable { | ||
|
||
public final EventBus eventBus = new EventBus(); | ||
private final Map<Class<? extends Command>, Command> commands; | ||
private final Map<Class<? extends Module>, Module> modules; | ||
|
||
/** | ||
* Constructs a ClickCrystal main system | ||
*/ | ||
public ClickCrystalsSystem() { | ||
this.commands = new HashMap<>(); | ||
this.modules = new HashMap<>(); | ||
} | ||
|
||
/** | ||
* Add a command to the system | ||
* @param command client command | ||
*/ | ||
public void addCommand(Command command) { | ||
if (command == null) return; | ||
commands.remove(command.getClass()); | ||
commands.put(command.getClass(),command); | ||
command.registerThis(); | ||
} | ||
|
||
/** | ||
* Add a module to the system. | ||
* @param module toggleable module. | ||
*/ | ||
public void addModule(Module module) { | ||
if (module == null) return; | ||
modules.remove(module.getClass()); | ||
modules.put(module.getClass(),module); | ||
} | ||
|
||
/** | ||
* Subscribe a listener to the event bus | ||
* @param listener listener | ||
*/ | ||
public void addListener(Listener listener) { | ||
eventBus.subscribe(listener); | ||
} | ||
|
||
/** | ||
* Unsubscribes a listener from the event bus | ||
* @param listener listener | ||
*/ | ||
public void removeListener(Listener listener) { | ||
eventBus.unsubscribe(listener); | ||
} | ||
|
||
/** | ||
* Returns current registered modules mapped to their class | ||
* @return map | ||
*/ | ||
public HashMap<Class<? extends Module>, Module> modules() { | ||
return new HashMap<>(modules); | ||
} | ||
|
||
/** | ||
* Returns current registered commands mapped to their class | ||
* @return map | ||
*/ | ||
public HashMap<Class<? extends Command>, Command> commands() { | ||
return new HashMap<>(commands); | ||
} | ||
|
||
/** | ||
* Returns current registered event listeners mapped to their class | ||
* @return map | ||
*/ | ||
public HashMap<Class<? extends Listener>, Listener> listeners() { | ||
return eventBus.listeners(); | ||
} | ||
} |
133 changes: 133 additions & 0 deletions
133
src/main/java/io/github/itzispyder/clickcrystals/commands/Command.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
package io.github.itzispyder.clickcrystals.commands; | ||
|
||
import com.mojang.brigadier.CommandDispatcher; | ||
import com.mojang.brigadier.arguments.ArgumentType; | ||
import com.mojang.brigadier.builder.LiteralArgumentBuilder; | ||
import com.mojang.brigadier.builder.RequiredArgumentBuilder; | ||
import io.github.itzispyder.clickcrystals.ClickCrystals; | ||
import io.github.itzispyder.clickcrystals.client.ClickCrystalsSystem; | ||
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; | ||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.command.CommandRegistryAccess; | ||
|
||
import java.io.Serializable; | ||
|
||
import static io.github.itzispyder.clickcrystals.ClickCrystals.starter; | ||
|
||
/** | ||
* Represents a client command | ||
*/ | ||
public abstract class Command implements ClientCommandRegistrationCallback, Serializable { | ||
|
||
protected static final int SINGLE_SUCCESS = 1, COMMAND_PASS = 0, COMMAND_FAIL = -1; | ||
protected static final MinecraftClient mc = ClickCrystals.mc; | ||
protected static final ClickCrystalsSystem system = ClickCrystals.system; | ||
private final String name, description, usage; | ||
private final String[] aliases; | ||
|
||
/** | ||
* Constructs a command | ||
* @param name command name | ||
* @param description command description | ||
* @param usage command usage | ||
* @param aliases command aliases | ||
*/ | ||
protected Command(String name, String description, String usage, String... aliases) { | ||
this.name = name; | ||
this.description = description; | ||
this.usage = usage; | ||
this.aliases = aliases; | ||
} | ||
|
||
/** | ||
* Constructs a command without aliases | ||
* @param name command name | ||
* @param description command description | ||
* @param usage command usage | ||
*/ | ||
protected Command(String name, String description, String usage) { | ||
this(name,description,usage, new String[0]); | ||
} | ||
|
||
/** | ||
* Build arguments from inheriting classes. | ||
* @param builder builder | ||
*/ | ||
public abstract void build(LiteralArgumentBuilder<FabricClientCommandSource> builder); | ||
|
||
/** | ||
* Helper method for brigadier | ||
* @param literal literal argument builder | ||
* @return argument builder | ||
*/ | ||
public LiteralArgumentBuilder<FabricClientCommandSource> literal(String literal) { | ||
return LiteralArgumentBuilder.literal(literal); | ||
} | ||
|
||
/** | ||
* Helper method for brigadier | ||
* @param name argument name | ||
* @param argumentType argument type | ||
* @returna argument builder | ||
* @param <T> argument of ? | ||
*/ | ||
public <T> RequiredArgumentBuilder<FabricClientCommandSource,T> argument(String name, ArgumentType<T> argumentType) { | ||
return RequiredArgumentBuilder.argument(name,argumentType); | ||
} | ||
|
||
/** | ||
* Register the command along with its aliases | ||
* @param dispatcher the command dispatcher to register commands to | ||
* @param registryAccess object exposing access to the game's registries | ||
*/ | ||
@Override | ||
public void register(CommandDispatcher<FabricClientCommandSource> dispatcher, CommandRegistryAccess registryAccess) { | ||
LiteralArgumentBuilder<FabricClientCommandSource> builder = literal(name); | ||
build(builder); | ||
dispatcher.register(builder); | ||
for (String alias : aliases) { | ||
builder = literal(alias); | ||
build(builder); | ||
dispatcher.register(builder); | ||
} | ||
} | ||
|
||
/** | ||
* Register to registration callback | ||
*/ | ||
public void registerThis() { | ||
ClientCommandRegistrationCallback.EVENT.register(this); | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String[] getAliases() { | ||
return aliases; | ||
} | ||
|
||
public String getUsage() { | ||
return usage; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
/** | ||
* Command help | ||
* @return help message | ||
*/ | ||
public String getHelp() { | ||
StringBuilder builder = new StringBuilder( | ||
" \n" + starter + "§f/" + name + "\n" | ||
+ "§7" + description + "\n" | ||
+ "§fUsage: §7" + usage +"\n" | ||
+ "§fAliases:" | ||
); | ||
for (String alias : aliases) builder.append("\n§8 -§7 ").append(alias); | ||
return builder.append("\n ").toString(); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
.../java/io/github/itzispyder/clickcrystals/commands/commands/ClickCrystalToggleCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package io.github.itzispyder.clickcrystals.commands.commands; | ||
|
||
import com.mojang.brigadier.builder.LiteralArgumentBuilder; | ||
import io.github.itzispyder.clickcrystals.commands.Command; | ||
import io.github.itzispyder.clickcrystals.modules.Module; | ||
import io.github.itzispyder.clickcrystals.util.ChatUtils; | ||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; | ||
|
||
/** | ||
* /cctoggle command | ||
*/ | ||
public class ClickCrystalToggleCommand extends Command { | ||
|
||
/** | ||
* Init command | ||
*/ | ||
public ClickCrystalToggleCommand() { | ||
super("clickcrystaltoggle","§7Toggles the modules from this mod. THIS CAN ALSO BE DONE VIA GUI MENU, PRESS YOUR §l§oAPOSTROPHE §7KEY!","/cctoggle [on|off|help]","cctoggle"); | ||
} | ||
|
||
/** | ||
* Command builder | ||
* @param builder builder | ||
*/ | ||
@Override | ||
public void build(LiteralArgumentBuilder<FabricClientCommandSource> builder) { | ||
|
||
for (Module module : system.modules().values()) { | ||
builder.then(literal(module.getId()).executes(context -> { | ||
module.setEnabled(!module.isEnabled()); | ||
return SINGLE_SUCCESS; | ||
})); | ||
|
||
builder.then(literal(module.getId()).then(literal("help").executes(context -> { | ||
ChatUtils.sendMessage(module.getHelp()); | ||
return SINGLE_SUCCESS; | ||
}))); | ||
|
||
builder.then(literal(module.getId()).then(literal("on").executes(context -> { | ||
module.setEnabled(true); | ||
return SINGLE_SUCCESS; | ||
}))); | ||
|
||
builder.then(literal(module.getId()).then(literal("off").executes(context -> { | ||
module.setEnabled(false); | ||
return SINGLE_SUCCESS; | ||
}))); | ||
} | ||
|
||
builder.executes(context -> { | ||
ChatUtils.sendMessage(super.getHelp()); | ||
return SINGLE_SUCCESS; | ||
}); | ||
} | ||
} |
Oops, something went wrong.