From 0ef3386ebf8cfb4a317597a23922115cefbd52b1 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 19 Dec 2018 12:47:22 -0800 Subject: [PATCH] appease codacy --- src/main/java/baritone/behavior/InventoryBehavior.java | 5 +---- src/main/java/baritone/behavior/MemoryBehavior.java | 8 +++----- src/main/java/baritone/cache/ContainerMemory.java | 3 ++- src/main/java/baritone/utils/pathing/Favoring.java | 6 +----- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/main/java/baritone/behavior/InventoryBehavior.java b/src/main/java/baritone/behavior/InventoryBehavior.java index b6d7e1bd..a49cbb7d 100644 --- a/src/main/java/baritone/behavior/InventoryBehavior.java +++ b/src/main/java/baritone/behavior/InventoryBehavior.java @@ -55,10 +55,7 @@ public class InventoryBehavior extends Behavior { } private void swapWithHotBar(int inInventory, int inHotbar) { - if (inInventory < 9) { - inInventory += 36; - } - ctx.playerController().windowClick(ctx.player().inventoryContainer.windowId, inInventory, inHotbar, ClickType.SWAP, ctx.player()); + ctx.playerController().windowClick(ctx.player().inventoryContainer.windowId, inInventory < 9 ? inInventory + 36 : inInventory, inHotbar, ClickType.SWAP, ctx.player()); } private int firstValidThrowaway() { // TODO offhand idk diff --git a/src/main/java/baritone/behavior/MemoryBehavior.java b/src/main/java/baritone/behavior/MemoryBehavior.java index 06627d7e..34b266b3 100644 --- a/src/main/java/baritone/behavior/MemoryBehavior.java +++ b/src/main/java/baritone/behavior/MemoryBehavior.java @@ -116,12 +116,10 @@ public final class MemoryBehavior extends Behavior { System.out.println("Received packet " + packet.getGuiId() + " " + packet.getEntityId() + " " + packet.getSlotCount() + " " + packet.getWindowId()); System.out.println(packet.getWindowTitle()); - if (packet.getWindowTitle() instanceof TextComponentTranslation) { + if (packet.getWindowTitle() instanceof TextComponentTranslation && ((TextComponentTranslation) packet.getWindowTitle()).getKey().equals("container.enderchest")) { // title is not customized (i.e. this isn't just a renamed shulker) - if (((TextComponentTranslation) packet.getWindowTitle()).getKey().equals("container.enderchest")) { - enderChestWindowId = packet.getWindowId(); - return; - } + enderChestWindowId = packet.getWindowId(); + return; } futureInventories.stream() .filter(i -> i.type.equals(packet.getGuiId()) && i.slots == packet.getSlotCount()) diff --git a/src/main/java/baritone/cache/ContainerMemory.java b/src/main/java/baritone/cache/ContainerMemory.java index ae54e157..f2b69e5c 100644 --- a/src/main/java/baritone/cache/ContainerMemory.java +++ b/src/main/java/baritone/cache/ContainerMemory.java @@ -123,7 +123,8 @@ public class ContainerMemory implements IContainerMemory { return out.array(); } - public static PacketBuffer writeItemStacks(List write, PacketBuffer out) { + public static PacketBuffer writeItemStacks(List write, PacketBuffer out2) { + PacketBuffer out = out2; // avoid reassigning an argument LOL out = new PacketBuffer(out.writeInt(write.size())); for (ItemStack stack : write) { out = out.writeItemStack(stack); diff --git a/src/main/java/baritone/utils/pathing/Favoring.java b/src/main/java/baritone/utils/pathing/Favoring.java index de80f442..7ffe49ff 100644 --- a/src/main/java/baritone/utils/pathing/Favoring.java +++ b/src/main/java/baritone/utils/pathing/Favoring.java @@ -23,16 +23,12 @@ import baritone.api.utils.BetterBlockPos; import baritone.api.utils.IPlayerContext; import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; -import java.util.List; - public final class Favoring { - private List avoidances; private final Long2DoubleOpenHashMap favorings; public Favoring(IPlayerContext ctx, IPath previous) { this(previous); - avoidances = Avoidance.create(ctx); - for (Avoidance avoid : avoidances) { + for (Avoidance avoid : Avoidance.create(ctx)) { avoid.applySpherical(favorings); } System.out.println("Favoring size: " + favorings.size());