1
0
Fork 0
mirror of https://github.com/Miasmusa/Shadow.git synced 2025-04-15 05:34:25 -04:00
This commit is contained in:
0x3C50 2022-04-20 01:27:39 +02:00
parent dae8a9731f
commit f4268fb97a
22 changed files with 183 additions and 85 deletions

View file

@ -36,7 +36,17 @@ dependencies {
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
Set<String> apiModules = [
"fabric-api-base",
"fabric-item-groups-v0",
"fabric-resource-loader-v0"
]
// Add each module as a dependency
apiModules.forEach {
impl(fabricApi.module(it, project.fabric_api_version))
}
// modImplementation ("net.fabricmc.fabric-api:fabric-resource-loader:0.1.0")
compileOnly 'org.projectlombok:lombok:1.18.22'

View file

@ -2,7 +2,7 @@ org.gradle.jvmargs = -Xmx1G
#Fabric properties
minecraft_version = 1.18.2
yarn_mappings = 1.18.2+build.2
yarn_mappings = 1.18.2+build.3
loader_version = 0.13.3
#Mod properties

View file

@ -14,6 +14,7 @@ import net.shadow.client.feature.command.CommandRegistry;
import net.shadow.client.feature.gui.FastTickable;
import net.shadow.client.feature.gui.notifications.NotificationRenderer;
import net.shadow.client.feature.gui.screen.HomeScreen;
import net.shadow.client.feature.itemMenu.ItemGroupRegistry;
import net.shadow.client.feature.module.Module;
import net.shadow.client.feature.module.ModuleRegistry;
import net.shadow.client.helper.Rotations;
@ -46,16 +47,7 @@ public class ShadowMain implements ModInitializer {
public static final Logger LOGGER = LogManager.getLogger();
public static final MinecraftClient client = MinecraftClient.getInstance();
public static final File BASE = new File(MinecraftClient.getInstance().runDirectory, "shadow");
public static long lastScreenChange = System.currentTimeMillis();
public static ShadowMain INSTANCE;
public static Thread MODULE_FTTICKER;
public static Thread FAST_TICKER;
private static final String REPORT_WEBHOOK_URL = "https://discord.com/api/webhooks/965552777453502474/z6HSQvGos82UzCh7g5N6921GMf4aUChrnKnajcqM5XV2RVXZ6eBPtysaJLxYEAmqt211";
public static void log(Level level, String message) {
LOGGER.log(level, "[" + MOD_NAME + "] " + message);
}
private static final boolean isDevMode = Util.make(() -> {
try {
File execF = new File(HomeScreen.class.getProtectionDomain().getCodeSource().getLocation().toURI());
@ -65,6 +57,14 @@ public class ShadowMain implements ModInitializer {
return true;
}
});
public static long lastScreenChange = System.currentTimeMillis();
public static ShadowMain INSTANCE;
public static Thread MODULE_FTTICKER;
public static Thread FAST_TICKER;
public static void log(Level level, String message) {
LOGGER.log(level, "[" + MOD_NAME + "] " + message);
}
public static boolean isDev() {
return isDevMode;
@ -78,7 +78,7 @@ public class ShadowMain implements ModInitializer {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss dd/MM/yyyy");
String fmt = sdf.format(System.currentTimeMillis());
try {
Utils.sendDiscordFile(REPORT_WEBHOOK_URL,String.format("Crash report submitted by **%s** (**%s**) at `%s` (h\\\\:m\\\\:s d/m/y) <@&965396880286707732>", client.getSession().getUsername(), client.getSession().getUuid(),fmt),"crash.txt",reportData.getBytes(StandardCharsets.UTF_8));
Utils.sendDiscordFile(REPORT_WEBHOOK_URL, String.format("Crash report submitted by **%s** (**%s**) at `%s` (h\\\\:m\\\\:s d/m/y) <@&965396880286707732>", client.getSession().getUsername(), client.getSession().getUuid(), fmt), "crash.txt", reportData.getBytes(StandardCharsets.UTF_8));
} catch (Exception e) {
e.printStackTrace();
}
@ -102,6 +102,8 @@ public class ShadowMain implements ModInitializer {
ConfigManager.loadState();
ItemGroupRegistry.init();
log(Level.INFO, "Done initializing");
}

View file

@ -54,7 +54,7 @@ public abstract class Command extends Utils.Logging {
public ExamplesEntry getExampleArguments() {
return null;
}
public record ExamplesEntry(String... examples) {}
protected void validateArgumentsLength(String[] args, int requiredLength, String message) throws CommandException {
if (args.length < requiredLength)
throw new CommandException("Invalid number of arguments: " + requiredLength + " arguments required", message);
@ -63,4 +63,7 @@ public abstract class Command extends Utils.Logging {
public PossibleArgument getSuggestionsWithType(int index, String[] args) {
return new PossibleArgument(null);
}
public record ExamplesEntry(String... examples) {
}
}

View file

@ -31,11 +31,6 @@ public class ForEach extends Command {
String partial;
boolean recieving;
@Override
public ExamplesEntry getExampleArguments() {
return new ExamplesEntry("player 1000 /msg %s you stink", "tab 10 /kick %s Server wipe", "tab 0 /ban %s MOLED LLLLL");
}
public ForEach() {
super("ForEach", "Do something for each player", "forEach", "for", "fe");
Events.registerEventHandler(EventType.PACKET_RECEIVE, event -> {
@ -55,6 +50,11 @@ public class ForEach extends Command {
});
}
@Override
public ExamplesEntry getExampleArguments() {
return new ExamplesEntry("player 1000 /msg %s you stink", "tab 10 /kick %s Server wipe", "tab 0 /ban %s MOLED LLLLL");
}
@Override
public PossibleArgument getSuggestionsWithType(int index, String[] args) {
return StaticArgumentServer.serveFromStatic(index, new PossibleArgument(ArgumentType.STRING, "player", "tab"), new PossibleArgument(ArgumentType.NUMBER, "(delay)"), new PossibleArgument(ArgumentType.NUMBER, "(message)"));

View file

@ -23,10 +23,12 @@ public class ForceOP extends Command {
public ForceOP() {
super("ForceOP", "Edit command blocks on paper 1.14 - 1.17", "forceop", "editcmd");
}
@Override
public ExamplesEntry getExampleArguments() {
return new ExamplesEntry("say hello", "tp @e 0 0 0");
}
@Override
public void onExecute(String[] args) throws CommandException {
validateArgumentsLength(args, 1, "Provide command");

View file

@ -39,7 +39,7 @@ public class Help extends Command {
}
@Override
public void onExecute(String[] args) throws CommandException{
public void onExecute(String[] args) throws CommandException {
if (args.length == 0) {
message("All commands and their description");
for (Command command : CommandRegistry.getCommands()) {
@ -49,11 +49,11 @@ public class Help extends Command {
} else {
String s = args[0];
Command c = CommandRegistry.getByAlias(s);
if (c == null) error("Command \""+s+"\" was not found");
if (c == null) error("Command \"" + s + "\" was not found");
else {
message("Command "+c.getName());
message("Command " + c.getName());
message0(c.getDescription(), Color.GRAY);
message0("Aliases: "+String.join(", ",c.getAliases()), Color.GRAY);
message0("Aliases: " + String.join(", ", c.getAliases()), Color.GRAY);
message("");
ExamplesEntry e = c.getExampleArguments();
if (e == null) {
@ -62,8 +62,8 @@ public class Help extends Command {
message("Examples:");
String prefix = ModuleRegistry.getByClass(ClientSettings.class).getPrefix().getValue();
for (String example : e.examples()) {
String mEx = prefix+c.getAliases()[0]+" "+example;
message(" - "+mEx);
String mEx = prefix + c.getAliases()[0] + " " + example;
message(" - " + mEx);
}
}
}

View file

@ -154,7 +154,7 @@ public class ServerCrash extends Command {
}
case "lag2" -> {
for(int i = 0; i < 255; i++){
for (int i = 0; i < 255; i++) {
client.player.networkHandler.sendPacket(new RequestCommandCompletionsC2SPacket(0, "/"));
}
Notification.create(2000, "Server Crash", Notification.Type.SUCCESS, "Sent Quick Lag Crash");

View file

@ -67,7 +67,7 @@ public class AddonManagerScreen extends ClientScreen implements FastTickable {
@Override
protected void init() {
reInitViewers();
RoundButton openFolder = new RoundButton(RoundButton.STANDARD,5,5,100,20,"Open folder", () -> {
RoundButton openFolder = new RoundButton(RoundButton.STANDARD, 5, 5, 100, 20, "Open folder", () -> {
Util.getOperatingSystem().open(AddonManager.ADDON_DIRECTORY);
});
this.addDrawableChild(openFolder);

View file

@ -1,37 +0,0 @@
/*
* Copyright (c) Shadow client, 0x150, Saturn5VFive 2022. All rights reserved.
*/
package net.shadow.client.feature.itemMenu;
import lombok.Getter;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import net.shadow.client.helper.util.Utils;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
public class ItemGroup {
@Getter
String translationKey;
@Getter
ItemStack icon;
@Getter
List<ItemStack> items = new CopyOnWriteArrayList<>();
public ItemGroup(String translationkey, ItemStack icon) {
this.translationKey = translationkey;
this.icon = icon;
FabricItemGroupBuilder.create(new Identifier("shadow", translationkey)).icon(() -> icon).appendItems((itemStacks, itemGroup) -> {
itemStacks.addAll(this.getItems());
}).build();
}
public void addItem(ItemStack stack) {
items.add(stack);
}
public void addItem(Item type, String nbt) {
addItem(Utils.generateItemStackWithMeta(nbt, type));
}
}

View file

@ -0,0 +1,31 @@
/*
* Copyright (c) Shadow client, 0x150, Saturn5VFive 2022. All rights reserved.
*/
package net.shadow.client.feature.itemMenu;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
public class ItemGroupRegistry {
public static ShadItemGroup EXPLOITS = new ShadItemGroup("Exploits", new ItemStack(Items.ARMOR_STAND));
public static ShadItemGroup GRIEF = new ShadItemGroup("Grief", new ItemStack(Items.TNT));
public static ShadItemGroup CRASH = new ShadItemGroup("Crash", new ItemStack(Items.FIRE_CHARGE));
public static void addItem(ShadItemGroup group, ItemStack stack) {
group.addItem(stack);
}
public static void addItem(ShadItemGroup group, Item item, String nbt) {
group.addItem(item, nbt);
}
public static void init() {
initExploits();
}
static void initExploits() {
addItem(ItemGroupRegistry.CRASH, Items.ARMOR_STAND, "{EntityTag:{CustomName:\"\\\"Amogi\\\"\", CustomNameVisible: true}}");
}
}

View file

@ -0,0 +1,58 @@
/*
* Copyright (c) Shadow client, 0x150, Saturn5VFive 2022. All rights reserved.
*/
package net.shadow.client.feature.itemMenu;
import lombok.Getter;
import net.fabricmc.fabric.impl.item.group.ItemGroupExtensions;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.util.collection.DefaultedList;
import net.shadow.client.helper.util.Utils;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
public class ShadItemGroup {
@Getter
String nameS;
@Getter
ItemStack icon;
Text name;
@Getter
List<ItemStack> items = new CopyOnWriteArrayList<>();
public ShadItemGroup(String name, ItemStack icon) {
this.nameS = name;
this.name = Text.of(name);
this.icon = icon;
((ItemGroupExtensions) ItemGroup.BUILDING_BLOCKS).fabric_expandArray();
new ItemGroup(ItemGroup.GROUPS.length - 1, "shadow." + name) {
@Override
public ItemStack createIcon() {
return icon;
}
@Override
public void appendStacks(DefaultedList<ItemStack> stacks) {
stacks.addAll(ShadItemGroup.this.getItems());
}
@Override
public Text getDisplayName() {
return ShadItemGroup.this.name;
}
};
}
public void addItem(ItemStack stack) {
items.add(stack);
}
public void addItem(Item type, String nbt) {
addItem(Utils.generateItemStackWithMeta(nbt, type));
}
}

View file

@ -175,6 +175,7 @@ public class ModuleRegistry {
}
reloadInProgress.set(false);
}
public static void init() {
try {
initInner();
@ -183,10 +184,12 @@ public class ModuleRegistry {
System.exit(1);
}
}
private static void registerModule(Module module) {
ShadowMain.log(Level.INFO, "Initialized "+module.getName());
ShadowMain.log(Level.INFO, "Initialized " + module.getName());
vanillaModules.add(module);
}
private static void initInner() {
if (initialized.get()) return;
initialized.set(true);

View file

@ -11,18 +11,19 @@ import net.shadow.client.feature.module.ModuleType;
public class MoreChatHistory extends Module {
DoubleSetting size = this.config.create(new DoubleSetting.Builder(300)
.name("Size")
.description("How big the new chat history should be allowed to get (vanilla is 100)")
.min(10)
.max(1000)
.precision(0)
.get());
.name("Size")
.description("How big the new chat history should be allowed to get (vanilla is 100)")
.min(10)
.max(1000)
.precision(0)
.get());
public MoreChatHistory() {
super("MoreChatHistory", "Allows you to change the size of the chat history", ModuleType.MISC);
}
public int getHistSize() {
return (int) (size.getValue()+0);
return (int) (size.getValue() + 0);
}
@Override

View file

@ -134,7 +134,7 @@ public class Boom extends Module {
@Override
public String getContext() {
return null;
return ((int) (this.power.getValue() + 0)) + "!".repeat((int) Math.floor(this.power.getValue() / 20d));
}
@Override
@ -151,4 +151,3 @@ public class Boom extends Module {
FireballGhast, FireballInstant
}
}

View file

@ -72,7 +72,7 @@ public class Utils {
"----" + e + "\n" +
"Content-Disposition: form-data; name=\"payload_json\"\n" +
"\n" +
"{\"content\":\""+msgContent+"\",\"tts\":false}\n" +
"{\"content\":\"" + msgContent + "\",\"tts\":false}\n" +
"----" + e + "--\n").getBytes(StandardCharsets.UTF_8);
byte[] finalBody = new byte[body1.length + file.length + body2.length];
System.arraycopy(body1, 0, finalBody, 0, body1.length);

View file

@ -16,9 +16,10 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant;
@Debug(export = true)
@Mixin(ChatHud.class)
public abstract class ChatHudMixin {
@Shadow public abstract int getWidth();
@Shadow
public abstract int getWidth();
@ModifyConstant(method="addMessage(Lnet/minecraft/text/Text;IIZ)V",constant = @Constant(intValue = 100))
@ModifyConstant(method = "addMessage(Lnet/minecraft/text/Text;IIZ)V", constant = @Constant(intValue = 100))
int a(int constant) {
MoreChatHistory hist = ModuleRegistry.getByClass(MoreChatHistory.class);
if (hist.isEnabled()) return hist.getHistSize();

View file

@ -8,7 +8,6 @@ import io.netty.channel.ChannelHandlerContext;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.Packet;
import net.minecraft.network.listener.PacketListener;
import net.minecraft.network.packet.c2s.play.ClickSlotC2SPacket;
import net.shadow.client.feature.module.ModuleRegistry;
import net.shadow.client.feature.module.impl.misc.AntiPacketKick;
import net.shadow.client.helper.event.EventType;

View file

@ -4,9 +4,25 @@
package net.shadow.client.mixin;
import net.shadow.client.feature.itemMenu.ItemGroup;
import net.minecraft.item.ItemGroup;
import net.shadow.client.mixinUtil.ItemGroupDuck;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(ItemGroup.class)
public class ItemGroupMixin {
public class ItemGroupMixin implements ItemGroupDuck {
@Shadow
@Final
@Mutable
public static ItemGroup[] GROUPS;
@Override
public void expandArray() {
ItemGroup[] tempGroups = GROUPS;
GROUPS = new ItemGroup[GROUPS.length + 1];
System.arraycopy(tempGroups, 0, GROUPS, 0, tempGroups.length);
}
}

View file

@ -31,6 +31,12 @@ public class MinecraftClientMixin {
@Shadow
private int itemUseCooldown;
@Inject(method = "printCrashReport", at = @At("HEAD"))
private static void addCrashReport(CrashReport report, CallbackInfo ci) {
ShadowMain.sendCrashReport(report.asString());
ShadowMain.log(Level.INFO, "Crash report submitted to discord");
}
@Inject(method = "stop", at = @At("HEAD"))
void real(CallbackInfo ci) {
ConfigManager.saveState();
@ -55,10 +61,4 @@ public class MinecraftClientMixin {
return this.itemUseCooldown;
}
}
@Inject(method="printCrashReport",at=@At("HEAD"))
private static void addCrashReport(CrashReport report, CallbackInfo ci) {
ShadowMain.sendCrashReport(report.asString());
ShadowMain.log(Level.INFO, "Crash report submitted to discord");
}
}

View file

@ -0,0 +1,9 @@
/*
* Copyright (c) Shadow client, 0x150, Saturn5VFive 2022. All rights reserved.
*/
package net.shadow.client.mixinUtil;
public interface ItemGroupDuck {
void expandArray();
}

View file

@ -40,6 +40,7 @@
"IPlayerMoveC2SPacketAccessor",
"IRenderTickCounterAccessor",
"ISliderWidgetAccessor",
"ItemGroupMixin",
"ItemStackMixin",
"KeyboardMixin",
"LivingEntityMixin",