Skip to content

Commit

Permalink
Fixed minor Issues and added LiveOverflow Bypass button
Browse files Browse the repository at this point in the history
  • Loading branch information
dkonis committed Nov 23, 2022
1 parent ce2ac1e commit 2058a96
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 73 deletions.
5 changes: 1 addition & 4 deletions src/main/java/net/wubz/wubzmod/WubzMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@

public class WubzMod implements ModInitializer {
public static final Logger LOGGER = LoggerFactory.getLogger("wubzmod");
public static String colorName = "\u00a7cWubz\u00a78Mod";

public static boolean hud = true;
public static boolean hudCoords = true;
public static boolean LiveOverflowBypass = true;


public static boolean Flying = false;
Expand Down
59 changes: 26 additions & 33 deletions src/main/java/net/wubz/wubzmod/gui/ModHud.java
Original file line number Diff line number Diff line change
@@ -1,82 +1,75 @@
/*
* Credits to FuFuClient
*/
package net.wubz.wubzmod.gui;

import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.wubz.wubzmod.WubzMod;

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

public class ModHud {
public class ModHud extends Screen {
private final MinecraftClient client = WubzMod.instance;
private final TextRenderer fontRenderer = WubzMod.instance.textRenderer;
private ClientPlayerEntity player;
private MatrixStack matrixStack;
private String Name = "WubzMod";

public ModHud() {
super(Text.translatable("Mod Hud"));

}

public void draw(MatrixStack matrixStack) {

this.player = this.client.player;

this.matrixStack = matrixStack;

RenderSystem.enableBlend();

this.drawWatermak();
this.drawInfo();

this.client.getProfiler().pop();
}

private void drawInfo() {
List<String> gameInfo = getGameInfo();

int lineHeight = this.fontRenderer.fontHeight;
int top = 28;
int left = 4;
int height = this.height + 40;
int width = this.width + 4;

for (String line : gameInfo) {
this.fontRenderer.drawWithShadow(this.matrixStack, line, left, top - (lineHeight + 4), 0x00E0E0E0);
top -= lineHeight + 3;
this.fontRenderer.drawWithShadow(this.matrixStack, line, width, height - (lineHeight), 0x00E0E0E0);
height -= lineHeight + 4;
}
}

private void drawWatermak() {
int top = 260;
int left = 4;

this.fontRenderer.drawWithShadow(this.matrixStack, WubzMod.colorName, left, top, 0x00E0E0E0);
if (this.player.getWorld().getRegistryKey().getValue().toString().equals("minecraft:overworld"))
this.Name = "\u00a7cWubz\u00a78Mod";
else if (this.player.getWorld().getRegistryKey().getValue().toString().equals("minecraft:the_nether"))
this.Name = "\u00a7aWubz\u00a78Mod";
this.fontRenderer.drawWithShadow(this.matrixStack, this.Name, this.width + 4, this.height + 4, 0x00E0E0E0);
}

private List<String> getGameInfo() {
List<String> gameInfo = new ArrayList<>();

String coordDirectionStatus = "";
String direction = this.player.getHorizontalFacing().asString();
String coordsFormat = "%.0f, %.0f, %.0f";

if (WubzMod.hudCoords) {
String coordsFormat = "%.0f, %.0f, %.0f";
if (this.player.getWorld().getRegistryKey().getValue().toString().equals("minecraft:overworld")) {
gameInfo.add("\u00a7cNether: \u00a7f" + String.format(coordsFormat, this.player.getX() / 8, this.player.getY(), this.player.getZ() / 8));
} else if (this.player.getWorld().getRegistryKey().getValue().toString().equals("minecraft:the_nether")) {
gameInfo.add("\u00a7aOverworld: \u00a7f" + String.format(coordsFormat, this.player.getX() * 8, this.player.getY(), this.player.getZ() * 8));
}
}


if (WubzMod.hudCoords) {
String coordsFormat = "%.0f, %.0f, %.0f";
coordDirectionStatus += String.format(coordsFormat, this.player.getX(), this.player.getY(), this.player.getZ());
if (this.player.getWorld().getRegistryKey().getValue().toString().equals("minecraft:overworld"))
gameInfo.add("\u00a7cNether: \u00a7f" + String.format(coordsFormat, this.player.getX() / 8, this.player.getY(), this.player.getZ() / 8));
else if (this.player.getWorld().getRegistryKey().getValue().toString().equals("minecraft:the_nether"))
gameInfo.add("\u00a7aOverworld: \u00a7f" + String.format(coordsFormat, this.player.getX() * 8, this.player.getY(), this.player.getZ() * 8));

coordDirectionStatus += " (" + direction + ")";
gameInfo.add("\u00a78Cords: \u00a7f"+coordDirectionStatus);
}
coordDirectionStatus += String.format(coordsFormat, this.player.getX(), this.player.getY(), this.player.getZ());
coordDirectionStatus += " (" + direction + ")";
gameInfo.add("\u00a78Cords: \u00a7f"+coordDirectionStatus);

return gameInfo;
}
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/net/wubz/wubzmod/gui/ModOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,28 @@ protected void init() {
this.client.setScreen(this.parent);
}));

this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 6 +25, 60, 20, Text.translatable("TP X"), (button) -> {
this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 6 + 25, 60, 20, Text.translatable("TP X"), (button) -> {
Vec3d pos = WubzMod.instance.player.getPos();
WubzMod.instance.player.setPos(pos.getX()+ 5, pos.getY(), pos.getZ());
WubzMod.instance.player.kill();
}));

this.addDrawableChild(new ButtonWidget(this.width / 2 - 30, this.height / 6 +25, 60, 20, Text.translatable("TP Y"), (button) -> {
this.addDrawableChild(new ButtonWidget(this.width / 2 - 30, this.height / 6 + 25, 60, 20, Text.translatable("TP Y"), (button) -> {
Vec3d pos = WubzMod.instance.player.getPos();
WubzMod.instance.player.setPos(pos.getX(), pos.getY() + 5, pos.getZ() + 5);
}));

this.addDrawableChild(new ButtonWidget(this.width / 2 + 40, this.height / 6 +25, 60, 20, Text.translatable("TP Z"), (button) -> {
this.addDrawableChild(new ButtonWidget(this.width / 2 + 40, this.height / 6 + 25, 60, 20, Text.translatable("TP Z"), (button) -> {
Vec3d pos = WubzMod.instance.player.getPos();
WubzMod.instance.player.setPos(pos.getX(), pos.getY(), pos.getZ() + 5);
}));

this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 6 +50, 200, 20, ModText(WubzMod.Flying, "Flying hack is:"), (button) -> {
this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 6 + 50, 200, 20, ModText(WubzMod.Flying, "Flying hack:"), (button) -> {
WubzMod.Flying = !WubzMod.Flying;
button.setMessage(ModText(WubzMod.Flying, "Flying hack is:"));
button.setMessage(ModText(WubzMod.Flying, "Flying hack:"));
}));

this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 6 +75, 200, 20, ModText(WubzMod.XRay, "XRay hack is:"), (button) -> {
this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 6 + 75, 200, 20, ModText(WubzMod.XRay, "XRay hack:"), (button) -> {
assert client != null;
if(client.worldRenderer.isTerrainRenderComplete()) {
WubzMod.XRay = !WubzMod.XRay;
Expand All @@ -69,14 +69,14 @@ protected void init() {
WubzMod.instance.player.removeStatusEffect(StatusEffect.byRawId(16));
}
client.worldRenderer.reload();
button.setMessage(ModText(WubzMod.XRay, "XRay hack is:"));
button.setMessage(ModText(WubzMod.XRay, "XRay hack:"));
}
}));

this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 6 +100, 200, 20, ModText(WubzMod.GigaChad, "GigaChad hack is:"), (button) -> {
this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 6 + 100, 200, 20, ModText(WubzMod.GigaChad, "GigaChad hack:"), (button) -> {
WubzMod.GigaChad = !WubzMod.GigaChad;
GigaChad.GigaChad();
button.setMessage(ModText(WubzMod.GigaChad, "GigaChad hack is:"));
button.setMessage(ModText(WubzMod.GigaChad, "GigaChad hack:"));
}));

}
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/net/wubz/wubzmod/mixin/GameInfoMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,15 @@

@Mixin(value = InGameHud.class)
public class GameInfoMixin {

private ModHud hudInfo;


@Inject(method = "<init>(Lnet/minecraft/client/MinecraftClient;Lnet/minecraft/client/render/item/ItemRenderer;)V", at = @At(value = "RETURN"))
private void onInit(MinecraftClient client, ItemRenderer render, CallbackInfo ci) {
this.hudInfo = new ModHud();
}

@Inject(method = "render", at = @At("HEAD"))
private void onDraw(MatrixStack matrixStack, float esp, CallbackInfo ci) {
if (WubzMod.hud) {
this.hudInfo.draw(matrixStack);
}
this.hudInfo.draw(matrixStack);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
public abstract class GameMenuScreenMixin extends Screen {
protected GameMenuScreenMixin(Text menu) { super(menu); }


@Inject(at = @At("HEAD"), method = "initWidgets")
private void onInitWigets(CallbackInfo ci){
this.addDrawableChild(new ButtonWidget(10, 10, 90, 20, Text.translatable("Wubz's Tools"), (button) ->{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@

import net.minecraft.network.listener.ClientPlayPacketListener;
import net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket;
import net.wubz.wubzmod.WubzMod;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;

@Mixin(GameStateChangeS2CPacket.class)
public class GameStateChangeS2CPacketMixin {
/**
* @author
* Wubz (dkonis)
* @reason
* Bypassing LiveOverflow's demo by not applying
* the GameStateChange Packet
*/
@Overwrite
public void apply(ClientPlayPacketListener clientPlayPacketListener) {
/**
* Bypassing LiveOverflow's demo by not applying
* the GameStateChange Packet
*/
GameStateChangeS2CPacket packet = (GameStateChangeS2CPacket) (Object) this;
if(!WubzMod.LiveOverflowBypass){
clientPlayPacketListener.onGameStateChange(packet);
}
}

}
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
/*
* This solution was provided by LynJuice
*/
package net.wubz.wubzmod.mixin;

import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import net.wubz.wubzmod.WubzMod;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArgs;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;

@Mixin(PlayerMoveC2SPacket.PositionAndOnGround.class)
public class PlayerC2SPacketPositionAndOnGroundMixin {
private static double roundCoordinate(double n) {
n = Math.round(n * 100) / 100d;
return Math.nextAfter(n, n + Math.signum(n));
}
@ModifyArgs(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/c2s/play/PlayerMoveC2SPacket;<init>(DDDFFZZZ)V"))
private static void init(Args args) {
args.set(0, roundCoordinate(args.get(0))); // Round x
args.set(2, roundCoordinate(args.get(2))); // Round z
}
private static double roundCoordinate(double n) {
n = Math.round(n * 100) / 100d; // Round to 1/100th
return Math.nextAfter(n, n + Math.signum(n)); // Fix floating point errors
if(WubzMod.LiveOverflowBypass) {
args.set(0, roundCoordinate(args.get(0)));
args.set(2, roundCoordinate(args.get(2)));
}
}
}
18 changes: 12 additions & 6 deletions src/main/java/net/wubz/wubzmod/mixin/PlayerMoveC2SPacketMixin.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/*
* This solution was provided by LynJuice
*/
package net.wubz.wubzmod.mixin;

import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import net.wubz.wubzmod.WubzMod;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArgs;
Expand All @@ -9,13 +13,15 @@

@Mixin(PlayerMoveC2SPacket.Full.class)
public abstract class PlayerMoveC2SPacketMixin {
private static double roundCoordinate(double n) {
n = Math.round(n * 100) / 100d;
return Math.nextAfter(n, n + Math.signum(n));
}
@ModifyArgs(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/c2s/play/PlayerMoveC2SPacket;<init>(DDDFFZZZ)V"))
private static void init(Args args) {
args.set(0, roundCoordinate(args.get(0))); // Round x
args.set(2, roundCoordinate(args.get(2))); // Round z
}
private static double roundCoordinate(double n) {
n = Math.round(n * 100) / 100d; // Round to 1/100th
return Math.nextAfter(n, n + Math.signum(n)); // Fix floating point errors
if(WubzMod.LiveOverflowBypass) {
args.set(0, roundCoordinate(args.get(0)));
args.set(2, roundCoordinate(args.get(2)));
}
}
}
35 changes: 35 additions & 0 deletions src/main/java/net/wubz/wubzmod/mixin/TitleScreenMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package net.wubz.wubzmod.mixin;

import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.gui.screen.world.SelectWorldScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.wubz.wubzmod.WubzMod;
import net.wubz.wubzmod.gui.ModOptions;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(TitleScreen.class)
public abstract class TitleScreenMixin extends Screen {

protected TitleScreenMixin(Text title) { super(title); }

MutableText ModText(boolean modEnabled,String modName) {
if(modEnabled)
return Text.translatable(modName + " \u00a7aEnabled");
else
return Text.translatable(modName + " \u00a7cDisabled");
}

@Inject(at = @At("HEAD"), method = "initWidgetsNormal(II)V")
private void onInitWigets(int y, int spacingY, CallbackInfo ci){
this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, y + spacingY * 5 - 10, 200, 20, ModText(WubzMod.LiveOverflowBypass, "LiveOverflow Bypass:"), (button) -> {
WubzMod.LiveOverflowBypass = !WubzMod.LiveOverflowBypass;
button.setMessage(ModText(WubzMod.LiveOverflowBypass, "LiveOverflow Bypass:"));
}));
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
package net.wubz.wubzmod.mixin;

import net.minecraft.network.listener.ClientPlayPacketListener;
import net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket;
import net.minecraft.network.packet.s2c.play.WorldBorderInitializeS2CPacket;
import net.wubz.wubzmod.WubzMod;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;

@Mixin(WorldBorderInitializeS2CPacket.class)
public class WorldBorderInitializeS2CPacketMixin {
/**
* @author
* Wubz (dkonis)
* @reason
* Bypassing LiveOverflow's border by not applying
* the WorldBorderInitialize Packet
*/
@Overwrite
public void apply(ClientPlayPacketListener clientPlayPacketListener) {
/**
* Bypassing LiveOverflow's border by not applying
* the WorldBorderInitialize Packet
*/
WorldBorderInitializeS2CPacket packet = (WorldBorderInitializeS2CPacket) (Object) this;
if(!WubzMod.LiveOverflowBypass){
clientPlayPacketListener.onWorldBorderInitialize(packet);
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/wubzmod.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"mixins": [
],
"client": [
"TitleScreenMixin",
"GameMenuScreenMixin",
"GameInfoMixin",
"MinecraftClientMixin",
Expand Down

0 comments on commit 2058a96

Please sign in to comment.