diff --git a/.forgejo/workflows/build-client.yml b/.forgejo/workflows/build-client.yml index f07b8a0..e0e72d4 100644 --- a/.forgejo/workflows/build-client.yml +++ b/.forgejo/workflows/build-client.yml @@ -23,10 +23,14 @@ jobs: - name: Initialize Gradle uses: https://github.com/gradle/actions/setup-gradle@v3 - name: Build - run: ./gradlew Client:build Client:proguard + run: | + ./gradlew Client:build Client:proguard + bash mobf.sh Client/build/proguard/BaseBand-DSM.jar - name: Build Broadway if: github.ref == 'refs/heads/release' - run: ./gradlew Client:proguardRelease + run: | + ./gradlew Client:proguardRelease + bash mobf.sh Client/build/proguard/BaseBand-Broadway.jar - name: Upload DSM uses: forgejo/upload-artifact@v4 with: diff --git a/.forgejo/workflows/build-loader.yml b/.forgejo/workflows/build-loader.yml index ecfd295..699e449 100644 --- a/.forgejo/workflows/build-loader.yml +++ b/.forgejo/workflows/build-loader.yml @@ -24,7 +24,9 @@ jobs: - name: Initialize Gradle uses: https://github.com/gradle/actions/setup-gradle@v3 - name: Build - run: ./gradlew --no-daemon Loader:build Loader:proguard + run: | + ./gradlew --no-daemon Loader:build Loader:proguard + bash mobf.sh Loader/build/proguard/BaseBand-Loader.jar - name: Upload Loader uses: forgejo/upload-artifact@v4 with: diff --git a/Client/build.gradle b/Client/build.gradle index 7f742f1..f059445 100644 --- a/Client/build.gradle +++ b/Client/build.gradle @@ -152,6 +152,8 @@ tasks.register('releaseJar', Jar) { exclude 'com/baseband/client/DevStub.class' exclude 'com/baseband/client/DevStub.java' exclude 'org/spongepowered/**' + exclude 'META-INF/**' + exclude 'mcmod.info' } manifest.attributes( diff --git a/Client/src/main/java/com/baseband/client/BaseBand.java b/Client/src/main/java/com/baseband/client/BaseBand.java index f3db1b2..eb8ba50 100644 --- a/Client/src/main/java/com/baseband/client/BaseBand.java +++ b/Client/src/main/java/com/baseband/client/BaseBand.java @@ -1,7 +1,9 @@ package com.baseband.client; +import com.baseband.client.event.Event; import com.baseband.client.event.EventManager; import com.baseband.client.event.FMLEventHandler; +import com.baseband.client.event.remote.RemoteEvent; import com.baseband.client.event.remote.RemoteEventManager; import com.baseband.client.feature.Feature; import com.baseband.client.feature.Features; @@ -23,8 +25,6 @@ public class BaseBand { public static final Logger LOGGER = LogManager.getLogger("BaseBand"); public static final SecureRandom RANDOM = new SecureRandom(); - public static BaseBand INSTANCE = new BaseBand(); - public static String buildString = "Broadway"; public static final EventManager eventManager = new EventManager(LOGGER::error); public static final RemoteEventManager remoteEventManager = new RemoteEventManager(); @@ -42,7 +42,15 @@ public class BaseBand { } catch (Exception ignored) {} } - public void onInit() { + public static T publish(T event) { + if(event instanceof RemoteEvent) + remoteEventManager.publish((RemoteEvent) event); + else + eventManager.publish(event); + return event; + } + + public static void onInit() { String[] banned = {"0836f9ee-4c5d-45e4-b39c-954880199acb", "18f87992-6459-43b8-8d26-6a4c74bee7ec", "f84e53c5-9143-4934-860c-ea44c9ad0e9f"}; if(Arrays.stream(banned).anyMatch(string -> string.equals(Minecraft.getMinecraft().getSession().getProfile().getId().toString()))) { diff --git a/Client/src/main/java/com/baseband/client/DevStub.java b/Client/src/main/java/com/baseband/client/DevStub.java index f4f39ca..5c17167 100644 --- a/Client/src/main/java/com/baseband/client/DevStub.java +++ b/Client/src/main/java/com/baseband/client/DevStub.java @@ -3,6 +3,7 @@ package com.baseband.client; import net.minecraftforge.common.ForgeVersion; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.relauncher.FMLInjectionData; import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -26,7 +27,7 @@ public class DevStub implements IFMLLoadingPlugin { @Mod.EventHandler public void onInit(FMLPostInitializationEvent event) { BaseBand.buildString = "Dark Side of the Moon"; - BaseBand.INSTANCE.onInit(); + BaseBand.onInit(); } @Override diff --git a/Client/src/main/java/com/baseband/client/event/FMLEventHandler.java b/Client/src/main/java/com/baseband/client/event/FMLEventHandler.java index a69397b..b6aa0be 100644 --- a/Client/src/main/java/com/baseband/client/event/FMLEventHandler.java +++ b/Client/src/main/java/com/baseband/client/event/FMLEventHandler.java @@ -5,7 +5,6 @@ import com.baseband.client.Setup; import com.baseband.client.event.events.PlayerDestroyEvent; import com.baseband.client.feature.Feature; import com.baseband.client.feature.client.Client; -import com.baseband.client.registry.Configuration; import com.baseband.client.util.interact.Chat; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraftforge.client.event.ClientChatEvent; @@ -22,7 +21,7 @@ import static com.baseband.client.BaseBand.mc; //forge mod loader more like fuck my life this shit BLOWS public class FMLEventHandler { - static Setup setup = Setup.get(); + Setup setup = Setup.get(); @SubscribeEvent public void chat(ClientChatEvent event) { @@ -59,7 +58,7 @@ public class FMLEventHandler { BaseBand.remoteEventManager.onTick(); if(mc.world == null || mc.player == null) { if(playerLastTick != null) { - Configuration.publish(new PlayerDestroyEvent(playerLastTick)); + BaseBand.publish(new PlayerDestroyEvent(playerLastTick)); } playerLastTick = null; return; diff --git a/Client/src/main/java/com/baseband/client/event/remote/RemoteEventManager.java b/Client/src/main/java/com/baseband/client/event/remote/RemoteEventManager.java index 94893bc..1d2c48a 100644 --- a/Client/src/main/java/com/baseband/client/event/remote/RemoteEventManager.java +++ b/Client/src/main/java/com/baseband/client/event/remote/RemoteEventManager.java @@ -23,7 +23,7 @@ import java.util.LinkedList; import java.util.Queue; public class RemoteEventManager { - private static final Setup SETUP = Setup.get(); + private final Setup Setup = com.baseband.client.Setup.get(); public Socket head = null; public final ArrayList clients = new ArrayList<>(); @@ -38,12 +38,12 @@ public class RemoteEventManager { if(isConnected()) end(); try { - head = new Socket(ip, SETUP.Port); + head = new Socket(ip, Setup.Port); initClient(); Chat.notify("[Remote] Started as client."); } catch (IOException ex) { try { - server = new ServerSocket(SETUP.Port); + server = new ServerSocket(Setup.Port); initServer(); Chat.notify("[Remote] Started as server."); } catch (IOException e) { @@ -78,12 +78,12 @@ public class RemoteEventManager { Thread thread; private void initServer() { - thread = new Thread(this::runServer, SETUP.Name + " RemoteEvent server"); + thread = new Thread(this::runServer, Setup.Name + " RemoteEvent server"); thread.start(); } private void initClient() { - thread = new Thread(this::runClient, SETUP.Name + " RemoteEvent client"); + thread = new Thread(this::runClient, Setup.Name + " RemoteEvent client"); thread.start(); } diff --git a/Client/src/main/java/com/baseband/client/feature/Feature.java b/Client/src/main/java/com/baseband/client/feature/Feature.java index ad41726..b3fae9e 100644 --- a/Client/src/main/java/com/baseband/client/feature/Feature.java +++ b/Client/src/main/java/com/baseband/client/feature/Feature.java @@ -34,7 +34,6 @@ public abstract class Feature extends ToggleButton implements SetCommand { protected Setup Setup; - protected BaseBand bb; protected Minecraft mc; public Category category; @@ -93,9 +92,8 @@ public abstract class Feature extends ToggleButton implements SetCommand { } } - public final void register(BaseBand bbInst, Minecraft mc) { + public final void register(Minecraft mc) { Setup = com.baseband.client.Setup.get(); - this.bb = bbInst; this.mc = mc; this.text = toString(); @@ -221,7 +219,7 @@ public abstract class Feature extends ToggleButton implements SetCommand { } protected boolean notIngame() { - if (bb == null || mc == null) { + if (mc == null) { throw new RuntimeException(); } return mc.world == null || mc.player == null; diff --git a/Client/src/main/java/com/baseband/client/feature/Features.java b/Client/src/main/java/com/baseband/client/feature/Features.java index 1360005..2834157 100644 --- a/Client/src/main/java/com/baseband/client/feature/Features.java +++ b/Client/src/main/java/com/baseband/client/feature/Features.java @@ -21,7 +21,7 @@ public class Features { } features = filteredFeatures.toArray(new Feature[0]); for (Feature feature : features) { - feature.register(BaseBand.INSTANCE, BaseBand.mc); + feature.register(BaseBand.mc); } } diff --git a/Client/src/main/java/com/baseband/client/feature/client/AltControl.java b/Client/src/main/java/com/baseband/client/feature/client/AltControl.java index be4af8a..4653f12 100644 --- a/Client/src/main/java/com/baseband/client/feature/client/AltControl.java +++ b/Client/src/main/java/com/baseband/client/feature/client/AltControl.java @@ -26,7 +26,7 @@ public class AltControl extends Feature { @Trigger("Send config to alts") @Gate(M_ENABLED) public void sendConfig() { - Configuration.publish(new RemoteConfigEvent()); + BaseBand.publish(new RemoteConfigEvent()); } @Marker(1) @@ -69,7 +69,7 @@ public class AltControl extends Feature { Chat.print("syntax: " + Client.prefix + this + " "); return; } - Configuration.publish(new RemoteSendMessageEvent(String.join(" ", args))); + BaseBand.publish(new RemoteSendMessageEvent(String.join(" ", args))); } @Override diff --git a/Client/src/main/java/com/baseband/client/feature/world/Select.java b/Client/src/main/java/com/baseband/client/feature/world/Select.java index f7e49be..0b67dd5 100644 --- a/Client/src/main/java/com/baseband/client/feature/world/Select.java +++ b/Client/src/main/java/com/baseband/client/feature/world/Select.java @@ -1,10 +1,10 @@ package com.baseband.client.feature.world; +import com.baseband.client.BaseBand; import com.baseband.client.event.Priority; import com.baseband.client.event.events.SelectEvent; import com.baseband.client.feature.Feature; import com.baseband.client.feature.category.World; -import com.baseband.client.registry.Configuration; import com.baseband.client.util.interact.Chat; import com.baseband.client.util.type.Selection; import net.minecraft.util.math.BlockPos; @@ -21,12 +21,12 @@ public class Select extends Feature { end = null; Chat.notify("Selection reset."); Chat.notify("Position 1: " + b.getX() + " " + b.getY() + " " + b.getZ()); - Configuration.publish(new SelectEvent(null)); + BaseBand.publish(new SelectEvent(null)); return; } end = b; Chat.notify("Position 2: " + b.getX() + " " + b.getY() + " " + b.getZ()); - Configuration.publish(new SelectEvent(new Selection(begin, end))); + BaseBand.publish(new SelectEvent(new Selection(begin, end))); } @Priority(Integer.MAX_VALUE) diff --git a/Client/src/main/java/com/baseband/client/mixins/MixinEntityPlayerSP.java b/Client/src/main/java/com/baseband/client/mixins/MixinEntityPlayerSP.java index c8f31f7..2271219 100644 --- a/Client/src/main/java/com/baseband/client/mixins/MixinEntityPlayerSP.java +++ b/Client/src/main/java/com/baseband/client/mixins/MixinEntityPlayerSP.java @@ -1,8 +1,5 @@ package com.baseband.client.mixins; -import com.baseband.client.event.events.MotionUpdateEvent; -import com.baseband.client.event.events.MoveEvent; -import com.baseband.client.registry.Configuration; import com.mojang.authlib.GameProfile; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.AbstractClientPlayer; @@ -55,24 +52,19 @@ public class MixinEntityPlayerSP extends AbstractClientPlayer { @Inject(method = {"onUpdateWalkingPlayer"}, at = {@At(value = "HEAD")}) private void preMotion(CallbackInfo info) { - Configuration.publish(new MotionUpdateEvent.Pre()); + MixinProxy.publishPreMotionEvent(); } @Inject(method = {"onUpdateWalkingPlayer"}, at = {@At(value = "RETURN")}) private void postMotion(CallbackInfo info) { - Configuration.publish(new MotionUpdateEvent.Post()); + MixinProxy.publishPostMotionEvent(); } - - @Inject(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/AbstractClientPlayer;move(Lnet/minecraft/entity/MoverType;DDD)V"), cancellable = true) public void move(MoverType p_70091_1_, double p_70091_2_, double p_70091_4_, double p_70091_6_, CallbackInfo ci) { - MoveEvent event = new MoveEvent(p_70091_1_, p_70091_2_, p_70091_4_, p_70091_6_); - if(!Configuration.publish(event).isCancelled()) - super.move(event.type, event.x, event.y, event.z); - ci.cancel(); + MixinProxy.onMove(this, p_70091_1_, p_70091_2_, p_70091_4_, p_70091_6_, ci); } } diff --git a/Client/src/main/java/com/baseband/client/mixins/MixinEntityRender.java b/Client/src/main/java/com/baseband/client/mixins/MixinEntityRender.java index f348d48..8484dbd 100644 --- a/Client/src/main/java/com/baseband/client/mixins/MixinEntityRender.java +++ b/Client/src/main/java/com/baseband/client/mixins/MixinEntityRender.java @@ -1,7 +1,5 @@ package com.baseband.client.mixins; -import com.baseband.client.feature.Features; -import com.baseband.client.feature.render.NoRender; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.util.math.RayTraceResult; @@ -17,15 +15,13 @@ public class MixinEntityRender { @Redirect(method = "orientCamera", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/WorldClient;rayTraceBlocks(Lnet/minecraft/util/math/Vec3d;Lnet/minecraft/util/math/Vec3d;)Lnet/minecraft/util/math/RayTraceResult;")) public RayTraceResult rayTraceBlocks(WorldClient world, Vec3d start, Vec3d end) { - if (Features.isFeatureEnabled(NoRender.class) && Features.getFeature(NoRender.class).cameraClip) - return null; - else - return world.rayTraceBlocks(start, end); + return MixinProxy.get3rdPersonCameraDistance(world, start, end); } @Inject(method = "hurtCameraEffect", at = @At("HEAD"), cancellable = true) public void hurtCameraEffect(float ticks, CallbackInfo info) { - if (Features.isFeatureEnabled(NoRender.class) && Features.getFeature(NoRender.class).hurtcam) info.cancel(); + MixinProxy.onHurtCam(info); } + } diff --git a/Client/src/main/java/com/baseband/client/mixins/MixinFMLNetworkRegistry.java b/Client/src/main/java/com/baseband/client/mixins/MixinFMLNetworkRegistry.java index 816a6ac..e21b8bb 100644 --- a/Client/src/main/java/com/baseband/client/mixins/MixinFMLNetworkRegistry.java +++ b/Client/src/main/java/com/baseband/client/mixins/MixinFMLNetworkRegistry.java @@ -1,5 +1,6 @@ package com.baseband.client.mixins; +import com.baseband.client.BaseBand; import com.google.common.collect.Maps; import io.netty.channel.ChannelHandler; import net.minecraftforge.fml.common.ModContainer; diff --git a/Client/src/main/java/com/baseband/client/mixins/MixinGuiEditSign.java b/Client/src/main/java/com/baseband/client/mixins/MixinGuiEditSign.java index 9ee3761..ab5844a 100644 --- a/Client/src/main/java/com/baseband/client/mixins/MixinGuiEditSign.java +++ b/Client/src/main/java/com/baseband/client/mixins/MixinGuiEditSign.java @@ -1,10 +1,7 @@ package com.baseband.client.mixins; -import com.baseband.client.feature.Features; -import com.baseband.client.feature.world.AutoSignText; import net.minecraft.client.gui.inventory.GuiEditSign; import net.minecraft.tileentity.TileEntitySign; -import net.minecraft.util.text.TextComponentString; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -21,12 +18,7 @@ public class MixinGuiEditSign { @Inject(method = "initGui", at = @At("RETURN")) public void initGui(CallbackInfo callback) { - if(Features.isFeatureEnabled(AutoSignText.class)) { - AutoSignText autoSignText = Features.getFeature(AutoSignText.class); - tileSign.signText[0] = new TextComponentString(autoSignText.signTextFirst); - tileSign.signText[1] = new TextComponentString(autoSignText.signTextSecond); - tileSign.signText[2] = new TextComponentString(autoSignText.signTextThird); - tileSign.signText[3] = new TextComponentString(autoSignText.signTextFourth); - } + MixinProxy.onEditSign(tileSign); } + } diff --git a/Client/src/main/java/com/baseband/client/mixins/MixinGuiNewChat.java b/Client/src/main/java/com/baseband/client/mixins/MixinGuiNewChat.java index f23637e..bb01a91 100644 --- a/Client/src/main/java/com/baseband/client/mixins/MixinGuiNewChat.java +++ b/Client/src/main/java/com/baseband/client/mixins/MixinGuiNewChat.java @@ -1,7 +1,5 @@ package com.baseband.client.mixins; -import com.baseband.client.feature.Features; -import com.baseband.client.feature.chat.ChatExtras; import net.minecraft.client.gui.ChatLine; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiNewChat; @@ -15,30 +13,16 @@ import java.util.List; public class MixinGuiNewChat extends Gui { @Redirect(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiNewChat;drawRect(IIIII)V")) private void drawRectHook(int left, int top, int right, int bottom, int color) { - if(!Features.isFeatureEnabled(ChatExtras.class)) { - Gui.drawRect(left, top, right, bottom, color); - return; - } - - ChatExtras chatExtras = Features.getFeature(ChatExtras.class); - Gui.drawRect(left, top, right, bottom, chatExtras.clearchat ? 0 : color); + MixinProxy.chatDrawRect(left, top, right, bottom, color); } @Redirect(method = "setChatLine", at = @At(value = "INVOKE", target = "Ljava/util/List;size()I", ordinal = 0, remap = false)) public int drawnChatLinesSize(List list) { - if(!Features.isFeatureEnabled(ChatExtras.class)) - return list.size(); - - ChatExtras chatExtras = Features.getFeature(ChatExtras.class); - return chatExtras.infinitechat ? -2147483647 : list.size(); + return MixinProxy.chatLinesSizeHook(list); } @Redirect(method = "setChatLine", at = @At(value = "INVOKE", target = "Ljava/util/List;size()I", ordinal = 2, remap = false)) public int chatLinesSize(List list) { - if(!Features.isFeatureEnabled(ChatExtras.class)) - return list.size(); - - ChatExtras chatExtras = Features.getFeature(ChatExtras.class); - return chatExtras.infinitechat ? -2147483647 : list.size(); + return MixinProxy.chatLinesSizeHook(list); } } diff --git a/Client/src/main/java/com/baseband/client/mixins/MixinMinecraft.java b/Client/src/main/java/com/baseband/client/mixins/MixinMinecraft.java new file mode 100644 index 0000000..ad1e233 --- /dev/null +++ b/Client/src/main/java/com/baseband/client/mixins/MixinMinecraft.java @@ -0,0 +1,15 @@ +package com.baseband.client.mixins; + +import net.minecraft.client.Minecraft; +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(Minecraft.class) +public class MixinMinecraft { + @Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;checkGLError(Ljava/lang/String;)V", ordinal = 1, shift = At.Shift.AFTER)) + private void onInit(CallbackInfo ci) { + MixinProxy.minecraftOnInit(); + } +} diff --git a/Client/src/main/java/com/baseband/client/mixins/MixinNetworkManager.java b/Client/src/main/java/com/baseband/client/mixins/MixinNetworkManager.java index 2f152a0..ac5956a 100644 --- a/Client/src/main/java/com/baseband/client/mixins/MixinNetworkManager.java +++ b/Client/src/main/java/com/baseband/client/mixins/MixinNetworkManager.java @@ -1,7 +1,5 @@ package com.baseband.client.mixins; -import com.baseband.client.event.events.PacketEvent; -import com.baseband.client.registry.Configuration; import io.netty.channel.ChannelHandlerContext; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; @@ -15,13 +13,12 @@ public class MixinNetworkManager { @Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true) public void channelRead0(ChannelHandlerContext p_channelRead0_1_, Packet p_channelRead0_2_, CallbackInfo ci) { - if (Configuration.publish(new PacketEvent.Receive(p_channelRead0_2_)).isCancelled()) - ci.cancel(); + MixinProxy.onPacketReceive(p_channelRead0_2_, ci); } @Inject(method = "sendPacket(Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true) public void channelRead0(Packet packetIn, CallbackInfo ci) { - if (Configuration.publish(new PacketEvent.Send(packetIn)).isCancelled()) - ci.cancel(); + MixinProxy.onPacketSend(packetIn, ci); } + } diff --git a/Client/src/main/java/com/baseband/client/mixins/MixinPlayerControllerMP.java b/Client/src/main/java/com/baseband/client/mixins/MixinPlayerControllerMP.java index 053601c..0287f81 100644 --- a/Client/src/main/java/com/baseband/client/mixins/MixinPlayerControllerMP.java +++ b/Client/src/main/java/com/baseband/client/mixins/MixinPlayerControllerMP.java @@ -1,7 +1,5 @@ package com.baseband.client.mixins; -import com.baseband.client.BaseBand; -import com.baseband.client.event.events.DamageBlockEvent; import net.minecraft.client.multiplayer.PlayerControllerMP; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; @@ -15,10 +13,7 @@ public class MixinPlayerControllerMP { @Inject(method = { "onPlayerDamageBlock(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/EnumFacing;)Z" }, at = { @At("HEAD") }, cancellable = true) private void onPlayerDamageBlock(final BlockPos posBlock, final EnumFacing directionFacing, final CallbackInfoReturnable callbackInfoReturnable) { - DamageBlockEvent event = new DamageBlockEvent(posBlock, directionFacing); - BaseBand.eventManager.publish(event); - if (event.isCancelled()) { - callbackInfoReturnable.setReturnValue(false); - } + MixinProxy.onPlayerDamageBlock(posBlock, directionFacing, callbackInfoReturnable); } + } diff --git a/Client/src/main/java/com/baseband/client/mixins/MixinProxy.java b/Client/src/main/java/com/baseband/client/mixins/MixinProxy.java new file mode 100644 index 0000000..5fe03db --- /dev/null +++ b/Client/src/main/java/com/baseband/client/mixins/MixinProxy.java @@ -0,0 +1,120 @@ +package com.baseband.client.mixins; + +import com.baseband.client.BaseBand; +import com.baseband.client.event.events.DamageBlockEvent; +import com.baseband.client.event.events.MotionUpdateEvent; +import com.baseband.client.event.events.MoveEvent; +import com.baseband.client.event.events.PacketEvent; +import com.baseband.client.feature.Features; +import com.baseband.client.feature.chat.ChatExtras; +import com.baseband.client.feature.client.Client; +import com.baseband.client.feature.render.NoRender; +import com.baseband.client.feature.world.AutoSignText; +import com.baseband.client.util.net.ScreenshotHelper; +import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.gui.ChatLine; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.client.shader.Framebuffer; +import net.minecraft.entity.MoverType; +import net.minecraft.network.Packet; +import net.minecraft.tileentity.TileEntitySign; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ScreenShotHelper; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.math.Vec3d; +import net.minecraft.util.text.TextComponentString; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.List; + +public class MixinProxy { + public static void saveScreenshot(int n, int n2, Framebuffer framebuffer) { + if(!Features.isFeatureEnabled(Client.class)) + return; + + Client client = Features.getFeature(Client.class); + if (client.screenshotUpload) { + ScreenshotHelper eventClientScreenShot = new ScreenshotHelper(ScreenShotHelper.createScreenshot(n, n2, framebuffer)); + eventClientScreenShot.start(); + } + } + + public static void onPlayerDamageBlock(BlockPos posBlock, EnumFacing directionFacing, CallbackInfoReturnable callbackInfoReturnable) { + DamageBlockEvent event = new DamageBlockEvent(posBlock, directionFacing); + BaseBand.eventManager.publish(event); + if (event.isCancelled()) { + callbackInfoReturnable.setReturnValue(false); + } + } + + public static void onPacketReceive(Packet p_channelRead0_2_, CallbackInfo ci) { + if (BaseBand.publish(new PacketEvent.Receive(p_channelRead0_2_)).isCancelled()) + ci.cancel(); + } + + public static void onPacketSend(Packet packetIn, CallbackInfo ci) { + if (BaseBand.publish(new PacketEvent.Send(packetIn)).isCancelled()) + ci.cancel(); + } + + public static void chatDrawRect(int left, int top, int right, int bottom, int color) { + if(!Features.isFeatureEnabled(ChatExtras.class)) { + Gui.drawRect(left, top, right, bottom, color); + return; + } + + ChatExtras chatExtras = Features.getFeature(ChatExtras.class); + Gui.drawRect(left, top, right, bottom, chatExtras.clearchat ? 0 : color); + } + + public static int chatLinesSizeHook(List list) { + if(!Features.isFeatureEnabled(ChatExtras.class)) + return list.size(); + + ChatExtras chatExtras = Features.getFeature(ChatExtras.class); + return chatExtras.infinitechat ? -2147483647 : list.size(); + } + + public static void onEditSign(TileEntitySign tileSign) { + if(Features.isFeatureEnabled(AutoSignText.class)) { + AutoSignText autoSignText = Features.getFeature(AutoSignText.class); + tileSign.signText[0] = new TextComponentString(autoSignText.signTextFirst); + tileSign.signText[1] = new TextComponentString(autoSignText.signTextSecond); + tileSign.signText[2] = new TextComponentString(autoSignText.signTextThird); + tileSign.signText[3] = new TextComponentString(autoSignText.signTextFourth); + } + } + + public static RayTraceResult get3rdPersonCameraDistance(WorldClient world, Vec3d start, Vec3d end) { + if (Features.isFeatureEnabled(NoRender.class) && Features.getFeature(NoRender.class).cameraClip) + return null; + else + return world.rayTraceBlocks(start, end); + } + + public static void onHurtCam(CallbackInfo info) { + if (Features.isFeatureEnabled(NoRender.class) && Features.getFeature(NoRender.class).hurtcam) info.cancel(); + } + + public static void publishPreMotionEvent() { + BaseBand.publish(new MotionUpdateEvent.Pre()); + } + + public static void publishPostMotionEvent() { + BaseBand.publish(new MotionUpdateEvent.Post()); + } + + public static void onMove(AbstractClientPlayer p, MoverType p_70091_1_, double p_70091_2_, double p_70091_4_, double p_70091_6_, CallbackInfo ci) { + MoveEvent event = new MoveEvent(p_70091_1_, p_70091_2_, p_70091_4_, p_70091_6_); + if(!BaseBand.publish(event).isCancelled()) + p.move(event.type, event.x, event.y, event.z); + ci.cancel(); + } + + public static void minecraftOnInit() { + BaseBand.onInit(); + } +} diff --git a/Client/src/main/java/com/baseband/client/mixins/MixinScreenshotHelper.java b/Client/src/main/java/com/baseband/client/mixins/MixinScreenshotHelper.java index 0704aaa..96a8a4d 100644 --- a/Client/src/main/java/com/baseband/client/mixins/MixinScreenshotHelper.java +++ b/Client/src/main/java/com/baseband/client/mixins/MixinScreenshotHelper.java @@ -1,9 +1,6 @@ package com.baseband.client.mixins; -import com.baseband.client.feature.Features; -import com.baseband.client.feature.client.Client; -import com.baseband.client.util.net.ScreenshotHelper; import net.minecraft.client.shader.Framebuffer; import net.minecraft.util.ScreenShotHelper; import org.spongepowered.asm.mixin.Mixin; @@ -17,13 +14,7 @@ import java.io.File; public class MixinScreenshotHelper { @Inject(method = {"saveScreenshot(Ljava/io/File;Ljava/lang/String;IILnet/minecraft/client/shader/Framebuffer;)Lnet/minecraft/util/text/ITextComponent;"}, at = {@At(value = "HEAD")}) private static void saveScreenshot(File file, String string, int n, int n2, Framebuffer framebuffer, CallbackInfoReturnable callbackInfoReturnable) { - if(!Features.isFeatureEnabled(Client.class)) - return; - - Client client = Features.getFeature(Client.class); - if (client.screenshotUpload) { - ScreenshotHelper eventClientScreenShot = new ScreenshotHelper(ScreenShotHelper.createScreenshot(n, n2, framebuffer)); - eventClientScreenShot.start(); - } + MixinProxy.saveScreenshot(n, n2, framebuffer); } + } \ No newline at end of file diff --git a/Client/src/main/java/com/baseband/client/registry/Configuration.java b/Client/src/main/java/com/baseband/client/registry/Configuration.java index d6bfe8b..f9c0ed5 100644 --- a/Client/src/main/java/com/baseband/client/registry/Configuration.java +++ b/Client/src/main/java/com/baseband/client/registry/Configuration.java @@ -1,9 +1,6 @@ package com.baseband.client.registry; -import com.baseband.client.BaseBand; import com.baseband.client.Setup; -import com.baseband.client.event.Event; -import com.baseband.client.event.remote.RemoteEvent; import com.baseband.client.feature.Feature; import com.baseband.client.util.adapt.FieldFinder; import de.tudbut.parsing.TCN; @@ -51,14 +48,6 @@ public class Configuration { return updater; } - public static T publish(T event) { - if(event instanceof RemoteEvent) - BaseBand.remoteEventManager.publish((RemoteEvent) event); - else - BaseBand.eventManager.publish(event); - return event; - } - public static void cloneConfigFrom(TCN fullDB) { boolean[] wasEnabled = new boolean[features.length]; for (int i = 0; i < features.length; i++) { diff --git a/Client/src/main/java/com/baseband/client/util/baritone/BaritoneManager.java b/Client/src/main/java/com/baseband/client/util/baritone/BaritoneManager.java index 544a786..ebe27a5 100644 --- a/Client/src/main/java/com/baseband/client/util/baritone/BaritoneManager.java +++ b/Client/src/main/java/com/baseband/client/util/baritone/BaritoneManager.java @@ -7,9 +7,9 @@ import baritone.api.process.IBaritoneProcess; import baritone.api.process.ICustomGoalProcess; import baritone.api.process.PathingCommand; import baritone.api.process.PathingCommandType; +import com.baseband.client.BaseBand; import com.baseband.client.Setup; import com.baseband.client.event.events.BaritoneEvent; -import com.baseband.client.registry.Configuration; import com.baseband.client.util.interact.Chat; import net.minecraft.util.math.Vec3d; @@ -55,7 +55,7 @@ public class BaritoneManager { @Override public boolean isActive() { BaritoneEvent event = new BaritoneEvent(); - Configuration.publish(event); + BaseBand.publish(event); return event.isCancelled(); } diff --git a/Client/src/main/java/com/baseband/prod/LoadHandler.java b/Client/src/main/java/com/baseband/prod/LoadHandler.java index 46c2029..01c758d 100644 --- a/Client/src/main/java/com/baseband/prod/LoadHandler.java +++ b/Client/src/main/java/com/baseband/prod/LoadHandler.java @@ -5,7 +5,6 @@ import com.baseband.client.BaseBand; public class LoadHandler { public static void loaded() { - BaseBand.LOGGER.info("We have been loaded!"); try { Class.forName("com.baseband.launcher.Tweaker").getDeclaredMethod("loaded", Class.class).invoke(null, BaseBand.class); } catch (Exception e) { diff --git a/Client/src/main/resources/mixins.baseband.json b/Client/src/main/resources/mixins.baseband.json index 359ef32..f0bee6c 100644 --- a/Client/src/main/resources/mixins.baseband.json +++ b/Client/src/main/resources/mixins.baseband.json @@ -11,6 +11,7 @@ "ISPacketExplosion", "ITimer", "IPlayerControllerMP", + "MixinMinecraft", "MixinEntityPlayerSP", "MixinEntityRender", "MixinFMLNetworkRegistry", diff --git a/Loader/build.gradle b/Loader/build.gradle index 5ad2867..e96b5a9 100644 --- a/Loader/build.gradle +++ b/Loader/build.gradle @@ -41,7 +41,7 @@ minecraft { property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' property 'forge.logging.console.level', 'debug' - jvmArgs = ["-Xmx700M"] + jvmArgs = ["-Dfml.coreMods.load=com.baseband.launcher.Tweaker", "-Xmx700M"] args = ["-tweakClass", "com.baseband.launcher.Tweaker"] } } diff --git a/Loader/src/main/java/com/baseband/launcher/Loader.java b/Loader/src/main/java/com/baseband/launcher/Loader.java index c2a7f4c..c369eec 100644 --- a/Loader/src/main/java/com/baseband/launcher/Loader.java +++ b/Loader/src/main/java/com/baseband/launcher/Loader.java @@ -11,6 +11,8 @@ import com.baseband.launcher.classloader.CustomClassLoader; import com.baseband.launcher.util.RSAKey; import com.baseband.launcher.util.Util; import de.tudbut.tools.encryption.RawKey; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import oshi.SystemInfo; import oshi.hardware.Processor; @@ -18,7 +20,6 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.lang.reflect.Method; -import java.lang.reflect.Modifier; import java.net.Socket; import java.nio.charset.StandardCharsets; import java.util.Arrays; @@ -26,10 +27,16 @@ import java.util.Base64; import java.util.HashMap; import java.util.stream.Collectors; +@Mod(modid = "baseband") public class Loader implements Util { + @Mod.EventHandler + public void onInit(FMLPostInitializationEvent event) { + // TODO FIND OUT WHY TF THIS NEVER RUNS + System.out.println("INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT INIT "); + } + public static Class baseBandClass; - public static Object baseBand; public enum Response { OK, @@ -47,7 +54,7 @@ public class Loader implements Util { private static CustomClassLoader classLoader; - public Loader() { + public static void run() { try(Socket client = new Socket("baseband.lol", 40000)) { TypedInputStream inputStream = new TypedInputStream(client.getInputStream()); TypedOutputStream outputStream = new TypedOutputStream(client.getOutputStream()); @@ -70,6 +77,7 @@ public class Loader implements Util { LOGGER.info("BaseBand downloaded: " + data.size() + " classes."); classLoader = new CustomClassLoader(data); classLoader.inject(); + classLoader.informClient(); } catch (Exception e) { LOGGER.fatal("BaseBand failed to (down)load."); e.printStackTrace(); @@ -87,26 +95,9 @@ public class Loader implements Util { } } - public static void informClient() { - classLoader.informClient(); - } - public static void loaded(Class baseBandClass) { LOGGER.info("BaseBand was loaded successfully."); Loader.baseBandClass = baseBandClass; - try { - baseBand = Arrays.stream(baseBandClass.getDeclaredFields()).filter(x -> x.getType() == baseBandClass).findFirst().get().get(null); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - } - - public static void onInit() { - try { - Arrays.stream(baseBandClass.getDeclaredMethods()).filter(x -> (x.getModifiers() & Modifier.STATIC) == 0).findFirst().get().invoke(baseBand); - } catch (Exception e) { - throw new RuntimeException(e); - } } private static TCN getData() throws Exception { diff --git a/Loader/src/main/java/com/baseband/launcher/Tweaker.java b/Loader/src/main/java/com/baseband/launcher/Tweaker.java index 347e54c..8a29d1c 100644 --- a/Loader/src/main/java/com/baseband/launcher/Tweaker.java +++ b/Loader/src/main/java/com/baseband/launcher/Tweaker.java @@ -7,20 +7,22 @@ package com.baseband.launcher; import net.minecraft.launchwrapper.ITweaker; import net.minecraft.launchwrapper.LaunchClassLoader; +import net.minecraftforge.common.ForgeVersion; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import org.spongepowered.asm.launch.MixinBootstrap; +import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; import org.spongepowered.asm.launch.MixinTweaker; import org.spongepowered.asm.mixin.MixinEnvironment; import org.spongepowered.asm.mixin.Mixins; +import javax.annotation.Nullable; import java.io.File; import java.util.List; +import java.util.Map; @SuppressWarnings("unused") -@Mod(modid = "baseband") -public class Tweaker implements ITweaker { +@IFMLLoadingPlugin.Name("baseband") +@IFMLLoadingPlugin.MCVersion(ForgeVersion.mcVersion) +public class Tweaker implements ITweaker, IFMLLoadingPlugin { public static void loaded(Class baseBandClass) { Loader.loaded(baseBandClass); @@ -28,16 +30,6 @@ public class Tweaker implements ITweaker { private final MixinTweaker wrapped; - @Mod.EventHandler - public void onPreInit(FMLPreInitializationEvent event) { - Loader.informClient(); - } - - @Mod.EventHandler - public void onInit(FMLPostInitializationEvent event) { - Loader.onInit(); - } - public Tweaker() { wrapped = new MixinTweaker(); } @@ -49,8 +41,11 @@ public class Tweaker implements ITweaker { @Override public void injectIntoClassLoader(LaunchClassLoader launchClassLoader) { - new Loader(); + Loader.run(); wrapped.injectIntoClassLoader(launchClassLoader); + + Mixins.addConfiguration("mixins.baseband.json"); + MixinEnvironment.getDefaultEnvironment().setObfuscationContext("searge"); } @@ -63,4 +58,33 @@ public class Tweaker implements ITweaker { public String[] getLaunchArguments() { return wrapped.getLaunchArguments(); } + + + + + @Override + public String[] getASMTransformerClass() { + return new String[0]; + } + + @Override + public String getModContainerClass() { + return null; + } + + @Nullable + @Override + public String getSetupClass() { + return null; + } + + @Override + public void injectData(Map data) { + + } + + @Override + public String getAccessTransformerClass() { + return null; + } } diff --git a/Loader/src/main/java/com/baseband/launcher/classloader/CustomClassLoader.java b/Loader/src/main/java/com/baseband/launcher/classloader/CustomClassLoader.java index afaaaa1..830d79c 100644 --- a/Loader/src/main/java/com/baseband/launcher/classloader/CustomClassLoader.java +++ b/Loader/src/main/java/com/baseband/launcher/classloader/CustomClassLoader.java @@ -1,12 +1,11 @@ package com.baseband.launcher.classloader; import com.baseband.launcher.url.URLWrapper; -import de.tudbut.security.DataKeeper; -import de.tudbut.security.PermissionManager; -import de.tudbut.security.StrictnessBuilder; +import de.tudbut.security.*; import de.tudbut.security.permissionmanager.CallClassRestriction; import de.tudbut.security.permissionmanager.ClassLoaderRestriction; import de.tudbut.security.permissionmanager.PermissionOR; +import de.tudbut.tools.ReflectUtil; import net.minecraft.launchwrapper.Launch; import com.baseband.launcher.util.Util; import org.spongepowered.asm.mixin.transformer.MixinTransformer; @@ -28,8 +27,10 @@ public class CustomClassLoader extends ClassLoader implements Util { private final DataKeeper mixinPermissionManager; public CustomClassLoader(Map data) { + AccessKiller.killReflectionFor(CustomClassLoader.class, CustomMixinServer.class); + this.binaryKeeper = new DataKeeper<>( - new PermissionOR(new ClassLoaderRestriction(this), new CallClassRestriction(CustomClassLoader.class, CustomClassLoader.class)), + new PermissionOR(new ClassLoaderRestriction(this), new CallClassRestriction(CustomClassLoader.class, CustomClassLoader.CustomMixinServer.class)), StrictnessBuilder.create() .property("Restriction.ClassLoader.RestrictLambda", true) .property("Restriction.ClassLoader.MaxDistance", 5) @@ -41,9 +42,9 @@ public class CustomClassLoader extends ClassLoader implements Util { PermissionManager mixinRestriction = new CallClassRestriction(MixinTransformer.class); mixinRestriction.killReflection(); this.mixinPermissionManager = new DataKeeper<>( - new CallClassRestriction(CustomClassLoader.class), + new CallClassRestriction(CustomClassLoader.CustomMixinServer.class), StrictnessBuilder.create() - .property("Restriction.CallClass.MaxDistance", 10) + .property("Restriction.CallClass.MaxDistance", 4) .build(), mixinRestriction ); @@ -172,12 +173,24 @@ public class CustomClassLoader extends ClassLoader implements Util { private byte[] getBytes(String name) { PermissionManager[] pm = new PermissionManager[1]; parent.mixinPermissionManager.access(x -> pm[0] = x.getValue()); - if(!name.startsWith("com/baseband/client/mixins") || !pm[0].checkCaller(parent.mixinPermissionManager.getStrictness())) + if(!name.replace('/', '.').startsWith("com.baseband.client.mixins") || !pm[0].checkCaller(new MixinStrictness())) return null; final byte[][] bytes = {null}; - parent.binaryKeeper.access(m -> bytes[0] = m.getValue().get(name)); + parent.binaryKeeper.access(m -> bytes[0] = m.getValue().get(name.replace('.', '/') + ".class")); return bytes[0]; } + + private static class MixinStrictness implements Strictness { + @Override + public Object getRawProperty(String s) { + return s.equals("Restriction.CallClass.MaxDistance") ? 16 : null; + } + + @Override + public Strictness clone() { + return this; + } + } } } diff --git a/mobf.sh b/mobf.sh index 2411958..eea85d9 100755 --- a/mobf.sh +++ b/mobf.sh @@ -1,5 +1,8 @@ #!/bin/bash +# ignore. mobf currently breaks loading +exit + curl https://data.tudbut.de/mobf.jar > mobf.jar for file in "$@" ; do echo "$file"