From bba2458f8eb8d51fb3d3301ffb06ebbf155419ba Mon Sep 17 00:00:00 2001 From: Brady Date: Tue, 4 Sep 2018 18:48:00 -0500 Subject: [PATCH] Separate "launch" into another SourceSet --- build.gradle | 12 +- .../java/baritone/launch/BaritoneTweaker.java | 142 +++---- .../baritone/launch/BaritoneTweakerForge.java | 88 ++--- .../launch/BaritoneTweakerOptifine.java | 68 ++-- .../launch/mixins/MixinAnvilChunkLoader.java | 17 + .../baritone/launch/mixins/MixinBlockPos.java | 0 .../mixins/MixinChunkProviderServer.java | 17 + .../baritone/launch/mixins/MixinEntity.java | 0 .../launch/mixins/MixinEntityPlayerSP.java | 0 .../launch/mixins/MixinEntityRenderer.java | 0 .../launch/mixins/MixinGameSettings.java | 88 ++--- .../launch/mixins/MixinGuiContainer.java | 94 ++--- .../launch/mixins/MixinGuiScreen.java | 96 ++--- .../launch/mixins/MixinInventoryPlayer.java | 0 .../launch/mixins/MixinKeyBinding.java | 86 ++--- .../launch/mixins/MixinMinecraft.java | 352 +++++++++--------- .../mixins/MixinNetHandlerPlayClient.java | 0 .../launch/mixins/MixinNetworkManager.java | 0 .../launch/mixins/MixinWorldClient.java | 0 .../resources/mixins.baritone.json | 52 +-- 20 files changed, 578 insertions(+), 534 deletions(-) rename src/{main => launch}/java/baritone/launch/BaritoneTweaker.java (97%) mode change 100755 => 100644 rename src/{main => launch}/java/baritone/launch/BaritoneTweakerForge.java (97%) mode change 100755 => 100644 rename src/{main => launch}/java/baritone/launch/BaritoneTweakerOptifine.java (96%) mode change 100755 => 100644 rename src/{main => launch}/java/baritone/launch/mixins/MixinAnvilChunkLoader.java (65%) rename src/{main => launch}/java/baritone/launch/mixins/MixinBlockPos.java (100%) rename src/{main => launch}/java/baritone/launch/mixins/MixinChunkProviderServer.java (65%) rename src/{main => launch}/java/baritone/launch/mixins/MixinEntity.java (100%) rename src/{main => launch}/java/baritone/launch/mixins/MixinEntityPlayerSP.java (100%) rename src/{main => launch}/java/baritone/launch/mixins/MixinEntityRenderer.java (100%) rename src/{main => launch}/java/baritone/launch/mixins/MixinGameSettings.java (97%) mode change 100755 => 100644 rename src/{main => launch}/java/baritone/launch/mixins/MixinGuiContainer.java (96%) mode change 100755 => 100644 rename src/{main => launch}/java/baritone/launch/mixins/MixinGuiScreen.java (96%) mode change 100755 => 100644 rename src/{main => launch}/java/baritone/launch/mixins/MixinInventoryPlayer.java (100%) rename src/{main => launch}/java/baritone/launch/mixins/MixinKeyBinding.java (97%) mode change 100755 => 100644 rename src/{main => launch}/java/baritone/launch/mixins/MixinMinecraft.java (97%) mode change 100755 => 100644 rename src/{main => launch}/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java (100%) rename src/{main => launch}/java/baritone/launch/mixins/MixinNetworkManager.java (100%) rename src/{main => launch}/java/baritone/launch/mixins/MixinWorldClient.java (100%) rename src/{main => launch}/resources/mixins.baritone.json (95%) mode change 100755 => 100644 diff --git a/build.gradle b/build.gradle index a3717498..86c29def 100755 --- a/build.gradle +++ b/build.gradle @@ -46,6 +46,12 @@ compileJava { sourceCompatibility = targetCompatibility = '1.8' } +sourceSets { + launch { + compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output + } +} + minecraft { version = '1.12.2' mappings = 'snapshot_20180731' @@ -64,7 +70,7 @@ repositories { } dependencies { - runtime implementation('org.spongepowered:mixin:0.7.11-SNAPSHOT') { + runtime launchCompile('org.spongepowered:mixin:0.7.11-SNAPSHOT') { // Mixin includes a lot of dependencies that are too up-to-date exclude module: 'launchwrapper' exclude module: 'guava' @@ -79,3 +85,7 @@ mixin { defaultObfuscationEnv notch add sourceSets.main, 'mixins.baritone.refmap.json' } + +jar { + from sourceSets.launch.output +} diff --git a/src/main/java/baritone/launch/BaritoneTweaker.java b/src/launch/java/baritone/launch/BaritoneTweaker.java old mode 100755 new mode 100644 similarity index 97% rename from src/main/java/baritone/launch/BaritoneTweaker.java rename to src/launch/java/baritone/launch/BaritoneTweaker.java index 04941f79..e281ece3 --- a/src/main/java/baritone/launch/BaritoneTweaker.java +++ b/src/launch/java/baritone/launch/BaritoneTweaker.java @@ -1,71 +1,71 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Baritone is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -package baritone.launch; - -import net.minecraft.launchwrapper.ITweaker; -import net.minecraft.launchwrapper.LaunchClassLoader; -import org.spongepowered.asm.launch.MixinBootstrap; -import org.spongepowered.asm.mixin.MixinEnvironment; -import org.spongepowered.asm.mixin.Mixins; -import org.spongepowered.tools.obfuscation.mcp.ObfuscationServiceMCP; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/** - * @author Brady - * @since 7/31/2018 9:59 PM - */ -public class BaritoneTweaker implements ITweaker { - - List args; - - @Override - public void acceptOptions(List args, File gameDir, File assetsDir, String profile) { - this.args = new ArrayList<>(args); - if (gameDir != null) addArg("gameDir", gameDir.getAbsolutePath()); - if (assetsDir != null) addArg("assetsDir", assetsDir.getAbsolutePath()); - if (profile != null) addArg("version", profile); - } - - @Override - public void injectIntoClassLoader(LaunchClassLoader classLoader) { - MixinBootstrap.init(); - MixinEnvironment.getDefaultEnvironment().setSide(MixinEnvironment.Side.CLIENT); - MixinEnvironment.getDefaultEnvironment().setObfuscationContext(ObfuscationServiceMCP.NOTCH); - Mixins.addConfiguration("mixins.baritone.json"); - } - - @Override - public final String getLaunchTarget() { - return "net.minecraft.client.main.Main"; - } - - @Override - public final String[] getLaunchArguments() { - return this.args.toArray(new String[0]); - } - - private void addArg(String label, String value) { - if (!args.contains("--" + label) && value != null) { - this.args.add("--" + label); - this.args.add(value); - } - } -} +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.launch; + +import net.minecraft.launchwrapper.ITweaker; +import net.minecraft.launchwrapper.LaunchClassLoader; +import org.spongepowered.asm.launch.MixinBootstrap; +import org.spongepowered.asm.mixin.MixinEnvironment; +import org.spongepowered.asm.mixin.Mixins; +import org.spongepowered.tools.obfuscation.mcp.ObfuscationServiceMCP; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Brady + * @since 7/31/2018 9:59 PM + */ +public class BaritoneTweaker implements ITweaker { + + List args; + + @Override + public void acceptOptions(List args, File gameDir, File assetsDir, String profile) { + this.args = new ArrayList<>(args); + if (gameDir != null) addArg("gameDir", gameDir.getAbsolutePath()); + if (assetsDir != null) addArg("assetsDir", assetsDir.getAbsolutePath()); + if (profile != null) addArg("version", profile); + } + + @Override + public void injectIntoClassLoader(LaunchClassLoader classLoader) { + MixinBootstrap.init(); + MixinEnvironment.getDefaultEnvironment().setSide(MixinEnvironment.Side.CLIENT); + MixinEnvironment.getDefaultEnvironment().setObfuscationContext(ObfuscationServiceMCP.NOTCH); + Mixins.addConfiguration("mixins.baritone.json"); + } + + @Override + public final String getLaunchTarget() { + return "net.minecraft.client.main.Main"; + } + + @Override + public final String[] getLaunchArguments() { + return this.args.toArray(new String[0]); + } + + private void addArg(String label, String value) { + if (!args.contains("--" + label) && value != null) { + this.args.add("--" + label); + this.args.add(value); + } + } +} diff --git a/src/main/java/baritone/launch/BaritoneTweakerForge.java b/src/launch/java/baritone/launch/BaritoneTweakerForge.java old mode 100755 new mode 100644 similarity index 97% rename from src/main/java/baritone/launch/BaritoneTweakerForge.java rename to src/launch/java/baritone/launch/BaritoneTweakerForge.java index 9a45520c..c1699058 --- a/src/main/java/baritone/launch/BaritoneTweakerForge.java +++ b/src/launch/java/baritone/launch/BaritoneTweakerForge.java @@ -1,44 +1,44 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Baritone is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -package baritone.launch; - -import net.minecraft.launchwrapper.LaunchClassLoader; -import org.spongepowered.asm.mixin.MixinEnvironment; -import org.spongepowered.tools.obfuscation.mcp.ObfuscationServiceMCP; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/** - * @author Brady - * @since 7/31/2018 10:09 PM - */ -public class BaritoneTweakerForge extends BaritoneTweaker { - - @Override - public final void acceptOptions(List args, File gameDir, File assetsDir, String profile) { - this.args = new ArrayList<>(); - } - - @Override - public final void injectIntoClassLoader(LaunchClassLoader classLoader) { - super.injectIntoClassLoader(classLoader); - MixinEnvironment.getDefaultEnvironment().setObfuscationContext(ObfuscationServiceMCP.SEARGE); - } -} +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.launch; + +import net.minecraft.launchwrapper.LaunchClassLoader; +import org.spongepowered.asm.mixin.MixinEnvironment; +import org.spongepowered.tools.obfuscation.mcp.ObfuscationServiceMCP; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Brady + * @since 7/31/2018 10:09 PM + */ +public class BaritoneTweakerForge extends BaritoneTweaker { + + @Override + public final void acceptOptions(List args, File gameDir, File assetsDir, String profile) { + this.args = new ArrayList<>(); + } + + @Override + public final void injectIntoClassLoader(LaunchClassLoader classLoader) { + super.injectIntoClassLoader(classLoader); + MixinEnvironment.getDefaultEnvironment().setObfuscationContext(ObfuscationServiceMCP.SEARGE); + } +} diff --git a/src/main/java/baritone/launch/BaritoneTweakerOptifine.java b/src/launch/java/baritone/launch/BaritoneTweakerOptifine.java old mode 100755 new mode 100644 similarity index 96% rename from src/main/java/baritone/launch/BaritoneTweakerOptifine.java rename to src/launch/java/baritone/launch/BaritoneTweakerOptifine.java index 380a0b0f..8d0872aa --- a/src/main/java/baritone/launch/BaritoneTweakerOptifine.java +++ b/src/launch/java/baritone/launch/BaritoneTweakerOptifine.java @@ -1,34 +1,34 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Baritone is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -package baritone.launch; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/** - * @author Brady - * @since 7/31/2018 10:10 PM - */ -public class BaritoneTweakerOptifine extends BaritoneTweaker { - - @Override - public final void acceptOptions(List args, File gameDir, File assetsDir, String profile) { - this.args = new ArrayList<>(); - } -} +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.launch; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Brady + * @since 7/31/2018 10:10 PM + */ +public class BaritoneTweakerOptifine extends BaritoneTweaker { + + @Override + public final void acceptOptions(List args, File gameDir, File assetsDir, String profile) { + this.args = new ArrayList<>(); + } +} diff --git a/src/main/java/baritone/launch/mixins/MixinAnvilChunkLoader.java b/src/launch/java/baritone/launch/mixins/MixinAnvilChunkLoader.java similarity index 65% rename from src/main/java/baritone/launch/mixins/MixinAnvilChunkLoader.java rename to src/launch/java/baritone/launch/mixins/MixinAnvilChunkLoader.java index 96f38b87..3133c9cd 100644 --- a/src/main/java/baritone/launch/mixins/MixinAnvilChunkLoader.java +++ b/src/launch/java/baritone/launch/mixins/MixinAnvilChunkLoader.java @@ -15,6 +15,23 @@ * along with Baritone. If not, see . */ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + package baritone.launch.mixins; import baritone.utils.accessor.IAnvilChunkLoader; diff --git a/src/main/java/baritone/launch/mixins/MixinBlockPos.java b/src/launch/java/baritone/launch/mixins/MixinBlockPos.java similarity index 100% rename from src/main/java/baritone/launch/mixins/MixinBlockPos.java rename to src/launch/java/baritone/launch/mixins/MixinBlockPos.java diff --git a/src/main/java/baritone/launch/mixins/MixinChunkProviderServer.java b/src/launch/java/baritone/launch/mixins/MixinChunkProviderServer.java similarity index 65% rename from src/main/java/baritone/launch/mixins/MixinChunkProviderServer.java rename to src/launch/java/baritone/launch/mixins/MixinChunkProviderServer.java index 9a454d01..41f90481 100644 --- a/src/main/java/baritone/launch/mixins/MixinChunkProviderServer.java +++ b/src/launch/java/baritone/launch/mixins/MixinChunkProviderServer.java @@ -15,6 +15,23 @@ * along with Baritone. If not, see . */ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + package baritone.launch.mixins; import baritone.utils.accessor.IChunkProviderServer; diff --git a/src/main/java/baritone/launch/mixins/MixinEntity.java b/src/launch/java/baritone/launch/mixins/MixinEntity.java similarity index 100% rename from src/main/java/baritone/launch/mixins/MixinEntity.java rename to src/launch/java/baritone/launch/mixins/MixinEntity.java diff --git a/src/main/java/baritone/launch/mixins/MixinEntityPlayerSP.java b/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java similarity index 100% rename from src/main/java/baritone/launch/mixins/MixinEntityPlayerSP.java rename to src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java diff --git a/src/main/java/baritone/launch/mixins/MixinEntityRenderer.java b/src/launch/java/baritone/launch/mixins/MixinEntityRenderer.java similarity index 100% rename from src/main/java/baritone/launch/mixins/MixinEntityRenderer.java rename to src/launch/java/baritone/launch/mixins/MixinEntityRenderer.java diff --git a/src/main/java/baritone/launch/mixins/MixinGameSettings.java b/src/launch/java/baritone/launch/mixins/MixinGameSettings.java old mode 100755 new mode 100644 similarity index 97% rename from src/main/java/baritone/launch/mixins/MixinGameSettings.java rename to src/launch/java/baritone/launch/mixins/MixinGameSettings.java index b68cce51..f5bae8ef --- a/src/main/java/baritone/launch/mixins/MixinGameSettings.java +++ b/src/launch/java/baritone/launch/mixins/MixinGameSettings.java @@ -1,44 +1,44 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Baritone is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -package baritone.launch.mixins; - -import baritone.Baritone; -import net.minecraft.client.settings.GameSettings; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -/** - * @author Brady - * @since 8/1/2018 12:28 AM - */ -@Mixin(GameSettings.class) -public class MixinGameSettings { - - @Redirect( - method = "isKeyDown", - at = @At( - value = "INVOKE", - target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z", - remap = false - ) - ) - private static boolean isKeyDown(int keyCode) { - return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode); - } -} +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.launch.mixins; + +import baritone.Baritone; +import net.minecraft.client.settings.GameSettings; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +/** + * @author Brady + * @since 8/1/2018 12:28 AM + */ +@Mixin(GameSettings.class) +public class MixinGameSettings { + + @Redirect( + method = "isKeyDown", + at = @At( + value = "INVOKE", + target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z", + remap = false + ) + ) + private static boolean isKeyDown(int keyCode) { + return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode); + } +} diff --git a/src/main/java/baritone/launch/mixins/MixinGuiContainer.java b/src/launch/java/baritone/launch/mixins/MixinGuiContainer.java old mode 100755 new mode 100644 similarity index 96% rename from src/main/java/baritone/launch/mixins/MixinGuiContainer.java rename to src/launch/java/baritone/launch/mixins/MixinGuiContainer.java index dd9bf715..c2c62d76 --- a/src/main/java/baritone/launch/mixins/MixinGuiContainer.java +++ b/src/launch/java/baritone/launch/mixins/MixinGuiContainer.java @@ -1,47 +1,47 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Baritone is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -package baritone.launch.mixins; - -import baritone.Baritone; -import net.minecraft.client.gui.inventory.GuiContainer; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -/** - * @author Brady - * @since 7/31/2018 10:47 PM - */ -@Mixin(GuiContainer.class) -public class MixinGuiContainer { - - @Redirect( - method = { - "mouseClicked", - "mouseReleased" - }, - at = @At( - value = "INVOKE", - target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z", - remap = false - ) - ) - private boolean isKeyDown(int keyCode) { - return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode); - } -} +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.launch.mixins; + +import baritone.Baritone; +import net.minecraft.client.gui.inventory.GuiContainer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +/** + * @author Brady + * @since 7/31/2018 10:47 PM + */ +@Mixin(GuiContainer.class) +public class MixinGuiContainer { + + @Redirect( + method = { + "mouseClicked", + "mouseReleased" + }, + at = @At( + value = "INVOKE", + target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z", + remap = false + ) + ) + private boolean isKeyDown(int keyCode) { + return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode); + } +} diff --git a/src/main/java/baritone/launch/mixins/MixinGuiScreen.java b/src/launch/java/baritone/launch/mixins/MixinGuiScreen.java old mode 100755 new mode 100644 similarity index 96% rename from src/main/java/baritone/launch/mixins/MixinGuiScreen.java rename to src/launch/java/baritone/launch/mixins/MixinGuiScreen.java index 47877058..11a3e7f4 --- a/src/main/java/baritone/launch/mixins/MixinGuiScreen.java +++ b/src/launch/java/baritone/launch/mixins/MixinGuiScreen.java @@ -1,48 +1,48 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Baritone is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -package baritone.launch.mixins; - -import baritone.Baritone; -import net.minecraft.client.gui.GuiScreen; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -/** - * @author Brady - * @since 7/31/2018 10:38 PM - */ -@Mixin(GuiScreen.class) -public class MixinGuiScreen { - - @Redirect( - method = { - "isCtrlKeyDown", - "isShiftKeyDown", - "isAltKeyDown" - }, - at = @At( - value = "INVOKE", - target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z", - remap = false - ) - ) - private static boolean isKeyDown(int keyCode) { - return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode); - } -} +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.launch.mixins; + +import baritone.Baritone; +import net.minecraft.client.gui.GuiScreen; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +/** + * @author Brady + * @since 7/31/2018 10:38 PM + */ +@Mixin(GuiScreen.class) +public class MixinGuiScreen { + + @Redirect( + method = { + "isCtrlKeyDown", + "isShiftKeyDown", + "isAltKeyDown" + }, + at = @At( + value = "INVOKE", + target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z", + remap = false + ) + ) + private static boolean isKeyDown(int keyCode) { + return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode); + } +} diff --git a/src/main/java/baritone/launch/mixins/MixinInventoryPlayer.java b/src/launch/java/baritone/launch/mixins/MixinInventoryPlayer.java similarity index 100% rename from src/main/java/baritone/launch/mixins/MixinInventoryPlayer.java rename to src/launch/java/baritone/launch/mixins/MixinInventoryPlayer.java diff --git a/src/main/java/baritone/launch/mixins/MixinKeyBinding.java b/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java old mode 100755 new mode 100644 similarity index 97% rename from src/main/java/baritone/launch/mixins/MixinKeyBinding.java rename to src/launch/java/baritone/launch/mixins/MixinKeyBinding.java index db850188..838802cd --- a/src/main/java/baritone/launch/mixins/MixinKeyBinding.java +++ b/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java @@ -1,43 +1,43 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Baritone is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -package baritone.launch.mixins; - -import baritone.Baritone; -import net.minecraft.client.settings.KeyBinding; -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.CallbackInfoReturnable; - -/** - * @author Brady - * @since 7/31/2018 11:44 PM - */ -@Mixin(KeyBinding.class) -public class MixinKeyBinding { - - @Inject( - method = "isKeyDown", - at = @At("HEAD"), - cancellable = true - ) - private void isKeyDown(CallbackInfoReturnable cir) { - if (Baritone.INSTANCE.getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this)) - cir.setReturnValue(true); - } -} +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.launch.mixins; + +import baritone.Baritone; +import net.minecraft.client.settings.KeyBinding; +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.CallbackInfoReturnable; + +/** + * @author Brady + * @since 7/31/2018 11:44 PM + */ +@Mixin(KeyBinding.class) +public class MixinKeyBinding { + + @Inject( + method = "isKeyDown", + at = @At("HEAD"), + cancellable = true + ) + private void isKeyDown(CallbackInfoReturnable cir) { + if (Baritone.INSTANCE.getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this)) + cir.setReturnValue(true); + } +} diff --git a/src/main/java/baritone/launch/mixins/MixinMinecraft.java b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java old mode 100755 new mode 100644 similarity index 97% rename from src/main/java/baritone/launch/mixins/MixinMinecraft.java rename to src/launch/java/baritone/launch/mixins/MixinMinecraft.java index 49c587ba..bc419516 --- a/src/main/java/baritone/launch/mixins/MixinMinecraft.java +++ b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java @@ -1,176 +1,176 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Baritone is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Baritone. If not, see . - */ - -package baritone.launch.mixins; - -import baritone.Baritone; -import baritone.api.event.events.BlockInteractEvent; -import baritone.api.event.events.TickEvent; -import baritone.api.event.events.WorldEvent; -import baritone.api.event.events.type.EventState; -import baritone.behavior.impl.PathingBehavior; -import baritone.utils.ExampleBaritoneControl; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.multiplayer.WorldClient; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import org.spongepowered.asm.lib.Opcodes; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -/** - * @author Brady - * @since 7/31/2018 10:51 PM - */ -@Mixin(Minecraft.class) -public class MixinMinecraft { - - @Shadow - private int leftClickCounter; - @Shadow - public EntityPlayerSP player; - @Shadow - public WorldClient world; - - @Inject( - method = "init", - at = @At("RETURN") - ) - private void init(CallbackInfo ci) { - Baritone.INSTANCE.init(); - ExampleBaritoneControl.INSTANCE.initAndRegister(); - } - - @Inject( - method = "runTick", - at = @At( - value = "FIELD", - opcode = Opcodes.GETFIELD, - target = "net/minecraft/client/Minecraft.currentScreen:Lnet/minecraft/client/gui/GuiScreen;", - ordinal = 5, - shift = At.Shift.BY, - by = -3 - ) - ) - private void runTick(CallbackInfo ci) { - Minecraft mc = (Minecraft) (Object) this; - Baritone.INSTANCE.getGameEventHandler().onTick(new TickEvent( - EventState.PRE, - (mc.player != null && mc.world != null) - ? TickEvent.Type.IN - : TickEvent.Type.OUT - )); - } - - @Redirect( - method = "runTickKeyboard", - at = @At( - value = "INVOKE", - target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z", - remap = false - ) - ) - private boolean Keyboard$isKeyDown(int keyCode) { - return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode); - } - - @Inject( - method = "processKeyBinds", - at = @At("HEAD") - ) - private void runTickKeyboard(CallbackInfo ci) { - Baritone.INSTANCE.getGameEventHandler().onProcessKeyBinds(); - } - - @Inject( - method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V", - at = @At("HEAD") - ) - private void preLoadWorld(WorldClient world, String loadingMessage, CallbackInfo ci) { - // If we're unloading the world but one doesn't exist, ignore it - if (this.world == null && world == null) { - return; - } - - Baritone.INSTANCE.getGameEventHandler().onWorldEvent( - new WorldEvent( - world, - EventState.PRE - ) - ); - } - - @Inject( - method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V", - at = @At("RETURN") - ) - private void postLoadWorld(WorldClient world, String loadingMessage, CallbackInfo ci) { - // still fire event for both null, as that means we've just finished exiting a world - - Baritone.INSTANCE.getGameEventHandler().onWorldEvent( - new WorldEvent( - world, - EventState.POST - ) - ); - } - - @Redirect( - method = "runTick", - at = @At( - value = "FIELD", - opcode = Opcodes.GETFIELD, - target = "net/minecraft/client/gui/GuiScreen.allowUserInput:Z" - ) - ) - private boolean isAllowUserInput(GuiScreen screen) { - return (PathingBehavior.INSTANCE.getCurrent() != null && player != null) || screen.allowUserInput; - } - - @Inject( - method = "clickMouse", - at = @At( - value = "INVOKE", - target = "net/minecraft/client/multiplayer/PlayerControllerMP.clickBlock(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/EnumFacing;)Z" - ), - locals = LocalCapture.CAPTURE_FAILHARD - ) - private void onBlockBreak(CallbackInfo ci, BlockPos pos) { - Baritone.INSTANCE.getGameEventHandler().onBlockInteract(new BlockInteractEvent(pos, BlockInteractEvent.Type.BREAK)); - } - - @Inject( - method = "rightClickMouse", - at = @At( - value = "INVOKE", - target = "net/minecraft/client/entity/EntityPlayerSP.swingArm(Lnet/minecraft/util/EnumHand;)V" - ), - locals = LocalCapture.CAPTURE_FAILHARD - ) - private void onBlockUse(CallbackInfo ci, EnumHand var1[], int var2, int var3, EnumHand enumhand, ItemStack itemstack, BlockPos blockpos, int i, EnumActionResult enumactionresult) { - Baritone.INSTANCE.getGameEventHandler().onBlockInteract(new BlockInteractEvent(blockpos, BlockInteractEvent.Type.USE)); - } -} +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.launch.mixins; + +import baritone.Baritone; +import baritone.api.event.events.BlockInteractEvent; +import baritone.api.event.events.TickEvent; +import baritone.api.event.events.WorldEvent; +import baritone.api.event.events.type.EventState; +import baritone.behavior.impl.PathingBehavior; +import baritone.utils.ExampleBaritoneControl; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.BlockPos; +import org.spongepowered.asm.lib.Opcodes; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +/** + * @author Brady + * @since 7/31/2018 10:51 PM + */ +@Mixin(Minecraft.class) +public class MixinMinecraft { + + @Shadow + private int leftClickCounter; + @Shadow + public EntityPlayerSP player; + @Shadow + public WorldClient world; + + @Inject( + method = "init", + at = @At("RETURN") + ) + private void init(CallbackInfo ci) { + Baritone.INSTANCE.init(); + ExampleBaritoneControl.INSTANCE.initAndRegister(); + } + + @Inject( + method = "runTick", + at = @At( + value = "FIELD", + opcode = Opcodes.GETFIELD, + target = "net/minecraft/client/Minecraft.currentScreen:Lnet/minecraft/client/gui/GuiScreen;", + ordinal = 5, + shift = At.Shift.BY, + by = -3 + ) + ) + private void runTick(CallbackInfo ci) { + Minecraft mc = (Minecraft) (Object) this; + Baritone.INSTANCE.getGameEventHandler().onTick(new TickEvent( + EventState.PRE, + (mc.player != null && mc.world != null) + ? TickEvent.Type.IN + : TickEvent.Type.OUT + )); + } + + @Redirect( + method = "runTickKeyboard", + at = @At( + value = "INVOKE", + target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z", + remap = false + ) + ) + private boolean Keyboard$isKeyDown(int keyCode) { + return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode); + } + + @Inject( + method = "processKeyBinds", + at = @At("HEAD") + ) + private void runTickKeyboard(CallbackInfo ci) { + Baritone.INSTANCE.getGameEventHandler().onProcessKeyBinds(); + } + + @Inject( + method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V", + at = @At("HEAD") + ) + private void preLoadWorld(WorldClient world, String loadingMessage, CallbackInfo ci) { + // If we're unloading the world but one doesn't exist, ignore it + if (this.world == null && world == null) { + return; + } + + Baritone.INSTANCE.getGameEventHandler().onWorldEvent( + new WorldEvent( + world, + EventState.PRE + ) + ); + } + + @Inject( + method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V", + at = @At("RETURN") + ) + private void postLoadWorld(WorldClient world, String loadingMessage, CallbackInfo ci) { + // still fire event for both null, as that means we've just finished exiting a world + + Baritone.INSTANCE.getGameEventHandler().onWorldEvent( + new WorldEvent( + world, + EventState.POST + ) + ); + } + + @Redirect( + method = "runTick", + at = @At( + value = "FIELD", + opcode = Opcodes.GETFIELD, + target = "net/minecraft/client/gui/GuiScreen.allowUserInput:Z" + ) + ) + private boolean isAllowUserInput(GuiScreen screen) { + return (PathingBehavior.INSTANCE.getCurrent() != null && player != null) || screen.allowUserInput; + } + + @Inject( + method = "clickMouse", + at = @At( + value = "INVOKE", + target = "net/minecraft/client/multiplayer/PlayerControllerMP.clickBlock(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/EnumFacing;)Z" + ), + locals = LocalCapture.CAPTURE_FAILHARD + ) + private void onBlockBreak(CallbackInfo ci, BlockPos pos) { + Baritone.INSTANCE.getGameEventHandler().onBlockInteract(new BlockInteractEvent(pos, BlockInteractEvent.Type.BREAK)); + } + + @Inject( + method = "rightClickMouse", + at = @At( + value = "INVOKE", + target = "net/minecraft/client/entity/EntityPlayerSP.swingArm(Lnet/minecraft/util/EnumHand;)V" + ), + locals = LocalCapture.CAPTURE_FAILHARD + ) + private void onBlockUse(CallbackInfo ci, EnumHand var1[], int var2, int var3, EnumHand enumhand, ItemStack itemstack, BlockPos blockpos, int i, EnumActionResult enumactionresult) { + Baritone.INSTANCE.getGameEventHandler().onBlockInteract(new BlockInteractEvent(blockpos, BlockInteractEvent.Type.USE)); + } +} diff --git a/src/main/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java b/src/launch/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java similarity index 100% rename from src/main/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java rename to src/launch/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java diff --git a/src/main/java/baritone/launch/mixins/MixinNetworkManager.java b/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java similarity index 100% rename from src/main/java/baritone/launch/mixins/MixinNetworkManager.java rename to src/launch/java/baritone/launch/mixins/MixinNetworkManager.java diff --git a/src/main/java/baritone/launch/mixins/MixinWorldClient.java b/src/launch/java/baritone/launch/mixins/MixinWorldClient.java similarity index 100% rename from src/main/java/baritone/launch/mixins/MixinWorldClient.java rename to src/launch/java/baritone/launch/mixins/MixinWorldClient.java diff --git a/src/main/resources/mixins.baritone.json b/src/launch/resources/mixins.baritone.json old mode 100755 new mode 100644 similarity index 95% rename from src/main/resources/mixins.baritone.json rename to src/launch/resources/mixins.baritone.json index 989c9355..7f9bda48 --- a/src/main/resources/mixins.baritone.json +++ b/src/launch/resources/mixins.baritone.json @@ -1,27 +1,27 @@ -{ - "required": true, - "package": "baritone.launch.mixins", - "refmap": "mixins.baritone.refmap.json", - "compatibilityLevel": "JAVA_8", - "verbose": false, - "injectors": { - "maxShiftBy": 2 - }, - "client": [ - "MixinAnvilChunkLoader", - "MixinBlockPos", - "MixinChunkProviderServer", - "MixinEntity", - "MixinEntityPlayerSP", - "MixinEntityRenderer", - "MixinGameSettings", - "MixinGuiContainer", - "MixinGuiScreen", - "MixinInventoryPlayer", - "MixinKeyBinding", - "MixinMinecraft", - "MixinNetHandlerPlayClient", - "MixinNetworkManager", - "MixinWorldClient" - ] +{ + "required": true, + "package": "baritone.launch.mixins", + "refmap": "mixins.baritone.refmap.json", + "compatibilityLevel": "JAVA_8", + "verbose": false, + "injectors": { + "maxShiftBy": 2 + }, + "client": [ + "MixinAnvilChunkLoader", + "MixinBlockPos", + "MixinChunkProviderServer", + "MixinEntity", + "MixinEntityPlayerSP", + "MixinEntityRenderer", + "MixinGameSettings", + "MixinGuiContainer", + "MixinGuiScreen", + "MixinInventoryPlayer", + "MixinKeyBinding", + "MixinMinecraft", + "MixinNetHandlerPlayClient", + "MixinNetworkManager", + "MixinWorldClient" + ] } \ No newline at end of file