diff --git a/build.gradle b/build.gradle index fed91a19c..2050d0207 100755 --- a/build.gradle +++ b/build.gradle @@ -89,7 +89,7 @@ dependencies { mappings loom.layered() { officialMojangMappings() //technically optional, but really helpful in dev: - parchment("org.parchmentmc.data:parchment-1.17.1:BLEEDING-SNAPSHOT@zip" as String) + parchment("org.parchmentmc.data:parchment-1.17.1:2021.10.24@zip" as String) } minecraft "com.mojang:minecraft:${project.minecraft_version}" if (!compileType.equals("FORGE")) { diff --git a/src/launch/java/baritone/launch/mixins/MixinSodiumChunkProvider.java b/src/launch/java/baritone/launch/mixins/MixinSodiumChunkProvider.java deleted file mode 100644 index 029c8cdaa..000000000 --- a/src/launch/java/baritone/launch/mixins/MixinSodiumChunkProvider.java +++ /dev/null @@ -1,94 +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.IChunkArray; -import baritone.utils.accessor.IClientChunkProvider; -import baritone.utils.accessor.ISodiumChunkArray; -import org.spongepowered.asm.mixin.*; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; -import java.util.concurrent.locks.StampedLock; -import net.minecraft.client.multiplayer.ClientChunkCache; -import net.minecraft.client.multiplayer.ClientLevel; - -@Pseudo -@Mixin(targets = "me.jellysquid.mods.sodium.client.world.SodiumChunkManager", remap = false) -public class MixinSodiumChunkProvider implements IClientChunkProvider { - - @Shadow - @Final - private StampedLock lock; - - @Shadow - @Final - private ClientLevel world; - - @Shadow - private int radius; - - @Unique - private static Constructor thisConstructor = null; - - @Unique - private static Field chunkArrayField = null; - - @Override - public ClientChunkCache createThreadSafeCopy() { - // similar operation to https://github.com/jellysquid3/sodium-fabric/blob/d3528521d48a130322c910c6f0725cf365ebae6f/src/main/java/me/jellysquid/mods/sodium/client/world/SodiumChunkManager.java#L139 - long stamp = this.lock.writeLock(); - - try { - ISodiumChunkArray refArray = extractReferenceArray(); - if (thisConstructor == null) { - thisConstructor = this.getClass().getConstructor(ClientLevel.class, int.class); - } - ClientChunkCache result = (ClientChunkCache) thisConstructor.newInstance(world, radius - 3); // -3 because it adds 3 for no reason here too lmao - IChunkArray copyArr = ((IClientChunkProvider) result).extractReferenceArray(); - copyArr.copyFrom(refArray); - return result; - } catch (InstantiationException | InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { - throw new RuntimeException("Sodium chunk manager initialization for baritone failed", e); - } finally { - // put this in finally so we can't break anything. - this.lock.unlockWrite(stamp); - } - } - - @Override - public ISodiumChunkArray extractReferenceArray() { - https://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html#jls-14.15 - if (chunkArrayField == null) { - for (Field f : this.getClass().getDeclaredFields()) { - if (ISodiumChunkArray.class.isAssignableFrom(f.getType())) { - chunkArrayField = f; - break https; - } - } - throw new RuntimeException(Arrays.toString(this.getClass().getDeclaredFields())); - } - try { - return (ISodiumChunkArray) chunkArrayField.get(this); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - } -} diff --git a/src/launch/java/baritone/launch/mixins/MixinSodiumFixedLongHashTable.java b/src/launch/java/baritone/launch/mixins/MixinSodiumFixedLongHashTable.java deleted file mode 100644 index 31443e77d..000000000 --- a/src/launch/java/baritone/launch/mixins/MixinSodiumFixedLongHashTable.java +++ /dev/null @@ -1,80 +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.IChunkArray; -import baritone.utils.accessor.ISodiumChunkArray; -import it.unimi.dsi.fastutil.longs.Long2ObjectMap; -import it.unimi.dsi.fastutil.objects.ObjectIterator; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.Shadow; - -import java.util.concurrent.atomic.AtomicReferenceArray; -import net.minecraft.world.level.chunk.LevelChunk; - -@Pseudo -@Mixin(targets = "me.jellysquid.mods.sodium.client.util.collections.FixedLongHashTable", remap = false) -public abstract class MixinSodiumFixedLongHashTable implements ISodiumChunkArray { - - @Shadow - public abstract ObjectIterator> iterator(); - - @Shadow - public abstract Object put(final long k, final Object v); - - /** - * similar to https://github.com/jellysquid3/sodium-fabric/blob/d3528521d48a130322c910c6f0725cf365ebae6f/src/main/java/me/jellysquid/mods/sodium/client/world/SodiumChunkManager.java#L149 - * except that since we aren't changing the radius, the key value doesn't change. - */ - @Override - public void copyFrom(IChunkArray other) { - ObjectIterator> it = ((ISodiumChunkArray) other).callIterator(); - while (it.hasNext()) { - Long2ObjectMap.Entry entry = it.next(); - this.put(entry.getLongKey(), entry.getValue()); - } - } - - @Override - public ObjectIterator> callIterator() { - return iterator(); - } - - //these are useless here... - @Override - public AtomicReferenceArray getChunks() { - return null; - } - - @Override - public int centerX() { - return 0; - } - - @Override - public int centerZ() { - return 0; - } - - @Override - public int viewDistance() { - return 0; - } - -} diff --git a/src/launch/resources/mixins.baritone.json b/src/launch/resources/mixins.baritone.json index 12d3aad67..befa220ff 100644 --- a/src/launch/resources/mixins.baritone.json +++ b/src/launch/resources/mixins.baritone.json @@ -22,8 +22,6 @@ "MixinNetworkManager", "MixinPlayerController", "MixinScreen", - "MixinSodiumChunkProvider", - "MixinSodiumFixedLongHashTable", "MixinWorldRenderer" ] } \ No newline at end of file diff --git a/src/main/java/baritone/utils/accessor/ISodiumChunkArray.java b/src/main/java/baritone/utils/accessor/ISodiumChunkArray.java deleted file mode 100644 index 7fcb25722..000000000 --- a/src/main/java/baritone/utils/accessor/ISodiumChunkArray.java +++ /dev/null @@ -1,26 +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 it.unimi.dsi.fastutil.longs.Long2ObjectMap; -import it.unimi.dsi.fastutil.objects.ObjectIterator; - -public interface ISodiumChunkArray extends IChunkArray { - - ObjectIterator> callIterator(); -}