From 7d863ebfed5fe04a28b81a2ce02320392e693710 Mon Sep 17 00:00:00 2001 From: Brady Date: Sat, 25 Aug 2018 23:03:25 -0500 Subject: [PATCH] Intercept toStringHelper to fix BlockPos obfuscated name, fixes #95 --- .../baritone/launch/mixins/MixinVec3i.java | 49 +++++++++++++++++++ src/main/resources/mixins.baritone.json | 1 + 2 files changed, 50 insertions(+) create mode 100644 src/main/java/baritone/launch/mixins/MixinVec3i.java diff --git a/src/main/java/baritone/launch/mixins/MixinVec3i.java b/src/main/java/baritone/launch/mixins/MixinVec3i.java new file mode 100644 index 00000000..84823015 --- /dev/null +++ b/src/main/java/baritone/launch/mixins/MixinVec3i.java @@ -0,0 +1,49 @@ +/* + * 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 com.google.common.base.MoreObjects; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3i; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +/** + * @author Brady + * @since 8/25/2018 + */ +@Mixin(Vec3i.class) +public class MixinVec3i { + + @Redirect( + method = "toString", + at = @At( + value = "INVOKE", + target = "com/google/common/base/MoreObjects.toStringHelper(Ljava/lang/Object;)Lcom/google/common/base/MoreObjects$ToStringHelper;" + ) + ) + private MoreObjects.ToStringHelper toStringHelper(Object object) { + + if (object.getClass().equals(BlockPos.class)) { + return MoreObjects.toStringHelper("BlockPos"); + } + + return MoreObjects.toStringHelper(object); + } +} diff --git a/src/main/resources/mixins.baritone.json b/src/main/resources/mixins.baritone.json index 523662db..2735cdd6 100755 --- a/src/main/resources/mixins.baritone.json +++ b/src/main/resources/mixins.baritone.json @@ -19,6 +19,7 @@ "MixinMinecraft", "MixinNetHandlerPlayClient", "MixinNetworkManager", + "MixinVec3i", "MixinWorldClient", "accessor.IAnvilChunkLoader",