Skip to content
This repository has been archived by the owner on Jul 14, 2024. It is now read-only.

Commit

Permalink
finished the mod
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Sep 23, 2022
1 parent 26a24af commit c850600
Show file tree
Hide file tree
Showing 16 changed files with 605 additions and 73 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
# UI-Utils-Reborn
Dupe Hunting Mod for Fabric 1.19.2

Cleaned up rewrite from https://github.com/Coderx-Gamer/ui-utils
Cleaned up rewrite from https://github.com/Coderx-Gamer/ui-utils <br>
To understand how the features works, just take a look at the original mod

More Features:
- Multi-Language Support
- Better Design and Code-base
- AntiRespawn Fix
- Removed Restore Key and added new Button
- Recoded

![](github_images/main.png)
![](github_images/fabricate.png)
Binary file added github_images/fabricate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added github_images/main.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 0 additions & 30 deletions src/main/java/de/florianmichael/uiutilsreborn/ExploitButton.java

This file was deleted.

142 changes: 129 additions & 13 deletions src/main/java/de/florianmichael/uiutilsreborn/UIUtils.java
Original file line number Diff line number Diff line change
@@ -1,56 +1,172 @@
package de.florianmichael.uiutilsreborn;

import de.florianmichael.uiutilsreborn.feature.GeneralFeatures;
import de.florianmichael.uiutilsreborn.gui.FabricateScreen;
import de.florianmichael.uiutilsreborn.util.Side;
import de.florianmichael.uiutilsreborn.widget.ExploitButtonWidget;
import de.florianmichael.uiutilsreborn.widget.ToggleableExploitButtonWidget;
import net.fabricmc.api.ClientModInitializer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.DeathScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.SleepingChatScreen;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.gui.screen.ingame.LecternScreen;
import net.minecraft.client.gui.screen.ingame.SignEditScreen;
import net.minecraft.network.Packet;
import net.minecraft.network.packet.c2s.play.ButtonClickC2SPacket;
import net.minecraft.network.packet.c2s.play.ClickSlotC2SPacket;
import net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket;
import net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.text.Text;

import java.util.*;

public class UIUtils implements ClientModInitializer {

public static final int BOUND = 5;
public static final int BUTTON_DIFF = 20 + 4;

private final static Map<Class<? extends Screen>, List<ExploitButton>> exploitTracker = new HashMap<>();
private final static List<ExploitButton> EMPTY_LIST = new ArrayList<>();
private final static Map<Class<? extends Screen>, List<ExploitButtonWidget>> exploitTracker = new HashMap<>();
private static final List<Packet<?>> delayedUIPackets = new ArrayList<>();

private static boolean cancelSignPackets;

private static boolean shouldSendUIPackets = true;
private static boolean shouldDelayUIPackets = true;

private static Screen storedScreen = null;
private static ScreenHandler storedScreenHandler = null;

@Override
public void onInitializeClient() {
final MinecraftClient mc = MinecraftClient.getInstance();

hookFeature(SleepingChatScreen.class, new ExploitButton("Client wake up", (parent) -> {
// Some Random GUIs
hookFeature(SleepingChatScreen.class, new ExploitButtonWidget("client-wake-up", Side.LEFT, (b) -> {
assert mc.player != null;

mc.player.wakeUp();
mc.setScreen(null);
}));
hookFeature(SignEditScreen.class, new ExploitButtonWidget("client-side-close", Side.LEFT, (b) -> {
mc.setScreen(null);

UIUtils.cancelSignPackets = true;
}));
hookFeature(DeathScreen.class, new ExploitButtonWidget("force-respawn", Side.LEFT, b -> {
assert mc.player != null;

mc.player.requestRespawn();
mc.setScreen(null);
}));

// Handled Screen Hooks
final List<ExploitButtonWidget> exploits = new ArrayList<>();

exploits.add(new ExploitButtonWidget("client-side-close", Side.LEFT, button -> mc.setScreen(null)));
exploits.add(new ExploitButtonWidget("server-side-close", Side.LEFT, button -> {
assert mc.player != null;

Objects.requireNonNull(mc.getNetworkHandler()).sendPacket(new CloseHandledScreenC2SPacket(mc.player.currentScreenHandler.syncId));
}));
exploits.add(new ToggleableExploitButtonWidget("send-packets", Side.LEFT, button -> shouldSendUIPackets = !shouldSendUIPackets));
exploits.add(new ToggleableExploitButtonWidget("delay-packets", Side.LEFT, button -> {
if (!shouldDelayUIPackets && !delayedUIPackets.isEmpty()) {
for (Packet<?> packet : delayedUIPackets)
Objects.requireNonNull(mc.getNetworkHandler()).sendPacket(packet);

delayedUIPackets.clear();
}
}));
exploits.add(new ExploitButtonWidget("disconnect", Side.LEFT, button -> {
if (!delayedUIPackets.isEmpty()) {
shouldDelayUIPackets = false;

for (Packet<?> packet : delayedUIPackets)
Objects.requireNonNull(mc.getNetworkHandler()).sendPacket(packet);

mc.getNetworkHandler().getConnection().disconnect(Text.literal("Connection closed (UI Utils Reborn)"));
delayedUIPackets.clear();
}
}));

hookFeature(SignEditScreen.class, new ExploitButton("Close without packet", (parent) -> mc.setScreen(null)));
GeneralFeatures.hook(this);
// Save and Load GUI
final ExploitButtonWidget load = new ExploitButtonWidget("load", Side.LEFT, button -> {
if (storedScreen != null && storedScreenHandler != null) {
mc.setScreen(storedScreen);
mc.player.currentScreenHandler = storedScreenHandler;
}
button.active = false;
});
load.active = false;
exploits.add(new ExploitButtonWidget("save", Side.LEFT, button -> {
storedScreen = mc.currentScreen;

assert mc.player != null;
storedScreenHandler = mc.player.currentScreenHandler;
load.active = true;
}));
exploits.add(load);

// Information Copy Buttons
exploits.add(new ExploitButtonWidget("sid", Side.RIGHT, b -> {
assert mc.player != null;

mc.keyboard.setClipboard(mc.player.currentScreenHandler.syncId + "");
}));
exploits.add(new ExploitButtonWidget("rev", Side.RIGHT, b -> {
assert mc.player != null;

mc.keyboard.setClipboard(mc.player.currentScreenHandler.getRevision() + "");
}));

// Packet Fabrication
exploits.add(new ExploitButtonWidget("fabricate", Side.RIGHT, b -> mc.setScreen(new FabricateScreen(mc.currentScreen))));

for (Class<? extends Screen> aClass : Arrays.asList(
HandledScreen.class,
LecternScreen.class
))
hookFeature(aClass, exploits);
}

public static boolean shouldCancel(final Packet<?> packet) {
if (cancelSignPackets && packet instanceof UpdateSignC2SPacket) {
cancelSignPackets = false;
return true;
}

if (shouldSendUIPackets && (packet instanceof ClickSlotC2SPacket || packet instanceof ButtonClickC2SPacket))
return true;

if (shouldDelayUIPackets && (packet instanceof ClickSlotC2SPacket || packet instanceof ButtonClickC2SPacket)) {
delayedUIPackets.add(packet);
return true;
}

return false;
}

public static List<ExploitButton> fromScreen(final Screen original) {
for (Map.Entry<Class<? extends Screen>, List<ExploitButton>> entry : exploitTracker.entrySet()) {
public static List<ExploitButtonWidget> fromScreen(final Screen original) {
final List<ExploitButtonWidget> buttons = new ArrayList<>();

for (Map.Entry<Class<? extends Screen>, List<ExploitButtonWidget>> entry : exploitTracker.entrySet())
if (entry.getKey().isAssignableFrom(original.getClass()))
return entry.getValue();
}
buttons.addAll(entry.getValue());

return EMPTY_LIST;
return buttons;
}

public void hookFeature(final Class<? extends Screen> screenClass, final ExploitButton exploitButton) {
public void hookFeature(final Class<? extends Screen> screenClass, final ExploitButtonWidget exploitButton) {
hookFeature(screenClass, Collections.singletonList(exploitButton));
}

public void hookFeature(final Class<? extends Screen> screenClass, final List<ExploitButton> buttons) {
public void hookFeature(final Class<? extends Screen> screenClass, final List<ExploitButtonWidget> buttons) {
if (exploitTracker.containsKey(screenClass)) {
exploitTracker.get(screenClass).addAll(buttons);
return;
}
exploitTracker.put(screenClass, buttons);
}
}

This file was deleted.

Loading

0 comments on commit c850600

Please sign in to comment.