From 3b32c72d631fecea29264415045c67babc9748f4 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 17 Aug 2020 17:41:13 -0700 Subject: [PATCH] remove broken furry cringe --- .../baritone/launch/mixins/MixinBitArray.java | 67 ------------------- .../launch/mixins/MixinPalettedContainer.java | 47 ------------- src/launch/resources/mixins.baritone.json | 2 - .../java/baritone/cache/WorldScanner.java | 38 +++++------ .../baritone/utils/accessor/IBitArray.java | 6 -- .../utils/accessor/IPalettedContainer.java | 27 -------- 6 files changed, 19 insertions(+), 168 deletions(-) delete mode 100644 src/launch/java/baritone/launch/mixins/MixinBitArray.java delete mode 100644 src/launch/java/baritone/launch/mixins/MixinPalettedContainer.java delete mode 100644 src/main/java/baritone/utils/accessor/IBitArray.java delete mode 100644 src/main/java/baritone/utils/accessor/IPalettedContainer.java diff --git a/src/launch/java/baritone/launch/mixins/MixinBitArray.java b/src/launch/java/baritone/launch/mixins/MixinBitArray.java deleted file mode 100644 index bece3e3bf..000000000 --- a/src/launch/java/baritone/launch/mixins/MixinBitArray.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 Lesser 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Baritone. If not, see . - */ - -package baritone.launch.mixins; - -import baritone.utils.accessor.IBitArray; -import net.minecraft.util.BitArray; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; - -@Mixin(BitArray.class) -public abstract class MixinBitArray implements IBitArray { - - @Shadow - @Final - private long[] longArray; - - @Shadow - @Final - private int bitsPerEntry; - - @Shadow - @Final - private long maxEntryValue; - - @Shadow - @Final - private int arraySize; - - @Override - @Unique - public int[] toArray() { - int[] out = new int[arraySize]; - - for (int idx = 0, kl = bitsPerEntry - 1; idx < arraySize; idx++, kl += bitsPerEntry) { - final int i = idx * bitsPerEntry; - final int j = i >> 6; - final int l = i & 63; - final int k = kl >> 6; - final long jl = longArray[j] >>> l; - - if (j == k) { - out[idx] = (int) (jl & maxEntryValue); - } else { - out[idx] = (int) ((jl | longArray[k] << (64 - l)) & maxEntryValue); - } - } - - return out; - } -} diff --git a/src/launch/java/baritone/launch/mixins/MixinPalettedContainer.java b/src/launch/java/baritone/launch/mixins/MixinPalettedContainer.java deleted file mode 100644 index c9f9e35c0..000000000 --- a/src/launch/java/baritone/launch/mixins/MixinPalettedContainer.java +++ /dev/null @@ -1,47 +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 Lesser 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Baritone. If not, see . - */ - -package baritone.launch.mixins; - -import baritone.utils.accessor.IBitArray; -import baritone.utils.accessor.IPalettedContainer; -import net.minecraft.block.BlockState; -import net.minecraft.util.BitArray; -import net.minecraft.util.palette.IPalette; -import net.minecraft.util.palette.PalettedContainer; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(PalettedContainer.class) -public abstract class MixinPalettedContainer implements IPalettedContainer { - - @Shadow - protected BitArray storage; - - @Shadow - protected IPalette palette; - - @Override - public BlockState getAtPalette(int index) { - return palette.get(index); - } - - @Override - public int[] storageArray() { - return ((IBitArray) storage).toArray(); - } -} diff --git a/src/launch/resources/mixins.baritone.json b/src/launch/resources/mixins.baritone.json index 12584443f..de4f25e84 100644 --- a/src/launch/resources/mixins.baritone.json +++ b/src/launch/resources/mixins.baritone.json @@ -8,7 +8,6 @@ "maxShiftBy": 2 }, "client": [ - "MixinBitArray", "MixinChunkArray", "MixinClientChunkProvider", "MixinClientPlayerEntity", @@ -21,7 +20,6 @@ "MixinLootContext", "MixinMinecraft", "MixinNetworkManager", - "MixinPalettedContainer", "MixinPlayerController", "MixinScreen", "MixinWorldRenderer" diff --git a/src/main/java/baritone/cache/WorldScanner.java b/src/main/java/baritone/cache/WorldScanner.java index 662d600e1..402e4844b 100644 --- a/src/main/java/baritone/cache/WorldScanner.java +++ b/src/main/java/baritone/cache/WorldScanner.java @@ -22,11 +22,11 @@ import baritone.api.utils.BetterBlockPos; import baritone.api.utils.BlockOptionalMetaLookup; import baritone.api.utils.IPlayerContext; -import baritone.utils.accessor.IPalettedContainer; import net.minecraft.block.BlockState; import net.minecraft.client.multiplayer.ClientChunkProvider; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; +import net.minecraft.util.palette.PalettedContainer; import net.minecraft.world.chunk.AbstractChunkProvider; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.ChunkSection; @@ -155,27 +155,27 @@ private boolean scanChunkInto(int chunkX, int chunkZ, Chunk chunk, BlockOptional continue; } int yReal = y0 << 4; - IPalettedContainer bsc = (IPalettedContainer) section.getData(); - // storageArray uses an optimized algorithm that's faster than getAt - // creating this array and then using getAtPalette is faster than even getFast(int index) - int[] storage = bsc.storageArray(); - final int imax = 1 << 12; - for (int i = 0; i < imax; i++) { - BlockState state = bsc.getAtPalette(storage[i]); - if (state != null && filter.has(state)) { - int y = yReal | ((i >> 8) & 15); - if (result.size() >= max) { - if (Math.abs(y - playerY) < yLevelThreshold) { - foundWithinY = true; - } else { - if (foundWithinY) { - // have found within Y in this chunk, so don't need to consider outside Y - // TODO continue iteration to one more sorted Y coordinate block - return true; + PalettedContainer bsc = section.getData(); + for (int yy = 0; yy < 16; yy++) { + for (int z = 0; z < 16; z++) { + for (int x = 0; x < 16; x++) { + BlockState state = bsc.get(x, yy, z); + if (filter.has(state)) { + int y = yReal | yy; + if (result.size() >= max) { + if (Math.abs(y - playerY) < yLevelThreshold) { + foundWithinY = true; + } else { + if (foundWithinY) { + // have found within Y in this chunk, so don't need to consider outside Y + // TODO continue iteration to one more sorted Y coordinate block + return true; + } + } } + result.add(new BlockPos(chunkX | x, y, chunkZ | z)); } } - result.add(new BlockPos(chunkX | (i & 15), y, chunkZ | ((i >> 4) & 15))); } } } diff --git a/src/main/java/baritone/utils/accessor/IBitArray.java b/src/main/java/baritone/utils/accessor/IBitArray.java deleted file mode 100644 index baea5c1da..000000000 --- a/src/main/java/baritone/utils/accessor/IBitArray.java +++ /dev/null @@ -1,6 +0,0 @@ -package baritone.utils.accessor; - -public interface IBitArray { - - int[] toArray(); -} diff --git a/src/main/java/baritone/utils/accessor/IPalettedContainer.java b/src/main/java/baritone/utils/accessor/IPalettedContainer.java deleted file mode 100644 index 1d0490832..000000000 --- a/src/main/java/baritone/utils/accessor/IPalettedContainer.java +++ /dev/null @@ -1,27 +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 Lesser 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Baritone. If not, see . - */ - -package baritone.utils.accessor; - -import net.minecraft.block.BlockState; - -public interface IPalettedContainer { - - BlockState getAtPalette(int index); - - int[] storageArray(); -}