From db01331560a1c995919a9bb0721bcaed43bbdf34 Mon Sep 17 00:00:00 2001 From: Brady Date: Wed, 8 Aug 2018 03:37:29 -0500 Subject: [PATCH] Remove arbitrary old Minebot hooks --- src/main/java/baritone/bot/Baritone.java | 18 ----- .../java/baritone/bot/GameActionHandler.java | 34 ---------- .../java/baritone/bot/HookStateManager.java | 42 ------------ src/main/java/baritone/bot/Memory.java | 41 ------------ .../launch/mixins/MixinGuiOverlayDebug.java | 67 ------------------- .../launch/mixins/MixinMinecraft.java | 21 ------ src/main/resources/mixins.baritone.json | 1 - 7 files changed, 224 deletions(-) delete mode 100755 src/main/java/baritone/bot/GameActionHandler.java delete mode 100755 src/main/java/baritone/bot/HookStateManager.java delete mode 100755 src/main/java/baritone/bot/Memory.java delete mode 100755 src/main/java/baritone/launch/mixins/MixinGuiOverlayDebug.java diff --git a/src/main/java/baritone/bot/Baritone.java b/src/main/java/baritone/bot/Baritone.java index 26aac506..96fd857f 100755 --- a/src/main/java/baritone/bot/Baritone.java +++ b/src/main/java/baritone/bot/Baritone.java @@ -41,9 +41,6 @@ public enum Baritone { */ private boolean initialized; - private Memory memory; - private HookStateManager hookStateManager; - private GameActionHandler actionHandler; private GameEventHandler gameEventHandler; private InputOverrideHandler inputOverrideHandler; private List behaviors; @@ -54,9 +51,6 @@ public enum Baritone { private boolean active; public void init() { - this.memory = new Memory(); - this.hookStateManager = new HookStateManager(); - this.actionHandler = new GameActionHandler(); this.gameEventHandler = new GameEventHandler(); this.inputOverrideHandler = new InputOverrideHandler(); this.behaviors = new ArrayList<>(); @@ -72,18 +66,6 @@ public enum Baritone { return this.initialized; } - public final Memory getMemory() { - return this.memory; - } - - public final HookStateManager getHookStateManager() { - return this.hookStateManager; - } - - public final GameActionHandler getActionHandler() { - return this.actionHandler; - } - public final GameEventHandler getGameEventHandler() { return this.gameEventHandler; } diff --git a/src/main/java/baritone/bot/GameActionHandler.java b/src/main/java/baritone/bot/GameActionHandler.java deleted file mode 100755 index b1b77091..00000000 --- a/src/main/java/baritone/bot/GameActionHandler.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.bot; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; - -/** - * @author Brady - * @since 7/31/2018 10:56 PM - */ -public final class GameActionHandler { - - GameActionHandler() { - } - - public final void onPlacedBlock(ItemStack stack, BlockPos pos) { - } -} diff --git a/src/main/java/baritone/bot/HookStateManager.java b/src/main/java/baritone/bot/HookStateManager.java deleted file mode 100755 index 99080b2c..00000000 --- a/src/main/java/baritone/bot/HookStateManager.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.bot; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Brady - * @since 7/31/2018 10:29 PM - */ -public final class HookStateManager { - - HookStateManager() {} - - public final boolean shouldCancelDebugRenderRight() { - return false; - } - - public final boolean shouldOverrideDebugInfoLeft() { - return false; - } - - public final List getDebugInfoLeft() { - return new ArrayList<>(); - } -} diff --git a/src/main/java/baritone/bot/Memory.java b/src/main/java/baritone/bot/Memory.java deleted file mode 100755 index 2ffb0b77..00000000 --- a/src/main/java/baritone/bot/Memory.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.bot; - -import net.minecraft.util.math.BlockPos; - -/** - * @author Brady - * @since 7/31/2018 10:50 PM - */ -public final class Memory { - - public final void scanBlock(BlockPos pos) { - checkActive(() -> { - // We might want to always run this method even if Baritone - // isn't active, this is just an example of the implementation - // of checkActive(Runnable). - }); - } - - private void checkActive(Runnable runnable) { - if (Baritone.INSTANCE.isActive()) { - runnable.run(); - } - } -} diff --git a/src/main/java/baritone/launch/mixins/MixinGuiOverlayDebug.java b/src/main/java/baritone/launch/mixins/MixinGuiOverlayDebug.java deleted file mode 100755 index 10f8c56a..00000000 --- a/src/main/java/baritone/launch/mixins/MixinGuiOverlayDebug.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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.bot.HookStateManager; -import baritone.bot.Baritone; -import net.minecraft.client.gui.GuiOverlayDebug; -import net.minecraft.client.gui.ScaledResolution; -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.CallbackInfoReturnable; - -import java.util.List; - -/** - * @author Brady - * @since 7/31/2018 10:28 PM - */ -@Mixin(GuiOverlayDebug.class) -public abstract class MixinGuiOverlayDebug { - - @Shadow protected abstract void renderDebugInfoRight(ScaledResolution scaledResolution); - - @Redirect( - method = "renderDebugInfo", - at = @At( - value = "INVOKE", - target = "net/minecraft/client/gui/GuiOverlayDebug.renderDebugInfoRight(Lnet/minecraft/client/gui/ScaledResolution;)V" - ) - ) - private void onRenderDebugInfoRight(GuiOverlayDebug gui, ScaledResolution scaledResolution) { - if (!Baritone.INSTANCE.getHookStateManager().shouldCancelDebugRenderRight()) { - this.renderDebugInfoRight(scaledResolution); - } - } - - @Inject( - method = "call", - at = @At("HEAD"), - cancellable = true - ) - private void call(CallbackInfoReturnable> cir) { - HookStateManager hooks = Baritone.INSTANCE.getHookStateManager(); - - if (hooks.shouldOverrideDebugInfoLeft()) { - cir.setReturnValue(hooks.getDebugInfoLeft()); - } - } -} diff --git a/src/main/java/baritone/launch/mixins/MixinMinecraft.java b/src/main/java/baritone/launch/mixins/MixinMinecraft.java index 8964ac41..a466d0f0 100755 --- a/src/main/java/baritone/launch/mixins/MixinMinecraft.java +++ b/src/main/java/baritone/launch/mixins/MixinMinecraft.java @@ -23,9 +23,6 @@ import baritone.bot.event.events.WorldEvent; import baritone.bot.event.events.type.EventState; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.WorldClient; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.math.BlockPos; import org.spongepowered.asm.lib.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -33,7 +30,6 @@ 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 @@ -110,23 +106,6 @@ public class MixinMinecraft { this.leftClickCounter = value; } - @Inject( - method = "rightClickMouse", - at = @At( - value = "INVOKE_ASSIGN", - target = "net/minecraft/client/entity/EntityPlayerSP.swingArm(Lnet/minecraft/util/EnumHand;)V" - ), - locals = LocalCapture.CAPTURE_FAILHARD - ) - private void postSwingArm(CallbackInfo ci, ItemStack stack, BlockPos pos, int stackCount, EnumActionResult result) { - Minecraft mc = (Minecraft) (Object) this; - Baritone bot = Baritone.INSTANCE; - - bot.getMemory().scanBlock(pos); - bot.getMemory().scanBlock(pos.offset(mc.objectMouseOver.sideHit)); - bot.getActionHandler().onPlacedBlock(stack, pos); - } - @Inject( method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V", at = @At("HEAD") diff --git a/src/main/resources/mixins.baritone.json b/src/main/resources/mixins.baritone.json index 5ffe4f65..21196347 100755 --- a/src/main/resources/mixins.baritone.json +++ b/src/main/resources/mixins.baritone.json @@ -9,7 +9,6 @@ "MixinEntityRenderer", "MixinGameSettings", "MixinGuiContainer", - "MixinGuiOverlayDebug", "MixinGuiScreen", "MixinKeyBinding", "MixinMain",