diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index a66061bf3..83832127e 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -26,6 +26,6 @@ "depends": { "fabricloader": ">=0.11.0", - "minecraft": "1.17.x" + "minecraft": "1.18.x" } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 6e8b1ff4a..77cfe8cf6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,12 @@ org.gradle.jvmargs=-Xmx2048M -mod_version=1.7.2 +mod_version=1.8.3 maven_group=baritone archives_base_name=baritone -minecraft_version=1.17.1 -forge_version=1.17.1-37.0.69 -fabric_version=0.11.6 +minecraft_version=1.18.2 +forge_version=1.18.2-40.0.0 +fabric_version=0.13.1 # # un comment for forge debugging default (as opposed to fabric) # baritone.forge_build=true diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 0d4a95168..e708b1c02 100755 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradlew b/gradlew index cccdd3d51..4f906e0c8 100755 --- a/gradlew +++ b/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,7 +44,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -66,6 +82,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -109,10 +126,11 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath @@ -138,19 +156,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -159,14 +177,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index f9553162f..107acd32c 100755 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/src/api/java/baritone/api/utils/BlockOptionalMeta.java b/src/api/java/baritone/api/utils/BlockOptionalMeta.java index d7b1b8148..d18936bf7 100644 --- a/src/api/java/baritone/api/utils/BlockOptionalMeta.java +++ b/src/api/java/baritone/api/utils/BlockOptionalMeta.java @@ -29,7 +29,6 @@ import net.minecraft.server.packs.repository.Pack; import net.minecraft.server.packs.repository.PackRepository; import net.minecraft.server.packs.repository.ServerPacksSource; import net.minecraft.server.packs.resources.ReloadableResourceManager; -import net.minecraft.server.packs.resources.SimpleReloadableResourceManager; import net.minecraft.util.Unit; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -147,11 +146,11 @@ public final class BlockOptionalMeta { PackRepository rpl = new PackRepository(PackType.SERVER_DATA, new ServerPacksSource()); rpl.reload(); PackResources thePack = rpl.getAvailablePacks().iterator().next().open(); - ReloadableResourceManager resourceManager = new SimpleReloadableResourceManager(PackType.SERVER_DATA); + ReloadableResourceManager resourceManager = new ReloadableResourceManager(PackType.SERVER_DATA); manager = new LootTables(predicate); resourceManager.registerReloadListener(manager); try { - resourceManager.reload(new ThreadPerTaskExecutor(Thread::new), new ThreadPerTaskExecutor(Thread::new), Collections.singletonList(thePack), CompletableFuture.completedFuture(Unit.INSTANCE)).get(); + resourceManager.createReload(new ThreadPerTaskExecutor(Thread::new), new ThreadPerTaskExecutor(Thread::new), CompletableFuture.completedFuture(Unit.INSTANCE), Collections.singletonList(thePack)).done().get(); } catch (Exception exception) { throw new RuntimeException(exception); } diff --git a/src/launch/java/baritone/launch/mixins/MixinClientPlayNetHandler.java b/src/launch/java/baritone/launch/mixins/MixinClientPlayNetHandler.java index 94dd931fa..df3fbf09f 100644 --- a/src/launch/java/baritone/launch/mixins/MixinClientPlayNetHandler.java +++ b/src/launch/java/baritone/launch/mixins/MixinClientPlayNetHandler.java @@ -64,10 +64,10 @@ public class MixinClientPlayNetHandler { }*/ @Inject( - method = "handleLevelChunk", + method = "handleLevelChunkWithLight", at = @At("RETURN") ) - private void postHandleChunkData(ClientboundLevelChunkPacket packetIn, CallbackInfo ci) { + private void postHandleChunkData(ClientboundLevelChunkWithLightPacket packetIn, CallbackInfo ci) { for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { LocalPlayer player = ibaritone.getPlayerContext().player(); if (player != null && player.connection == (ClientPacketListener) (Object) this) { diff --git a/src/launch/java/baritone/launch/mixins/MixinMinecraft.java b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java index 82c62e2db..ae6996d0a 100644 --- a/src/launch/java/baritone/launch/mixins/MixinMinecraft.java +++ b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java @@ -63,7 +63,7 @@ public class MixinMinecraft { value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/client/Minecraft;screen:Lnet/minecraft/client/gui/screens/Screen;", - ordinal = 5, + ordinal = 4, shift = At.Shift.BY, by = -3 ) diff --git a/src/launch/resources/mixins.baritone.json b/src/launch/resources/mixins.baritone.json index c8992290f..7b32bcd00 100644 --- a/src/launch/resources/mixins.baritone.json +++ b/src/launch/resources/mixins.baritone.json @@ -2,7 +2,7 @@ "required": true, "package": "baritone.launch.mixins", "refmap": "baritone-common-refmap.json", - "compatibilityLevel": "JAVA_16", + "compatibilityLevel": "JAVA_17", "verbose": false, "injectors": { "maxShiftBy": 2 diff --git a/src/main/java/baritone/cache/CachedRegion.java b/src/main/java/baritone/cache/CachedRegion.java index e501a6bb4..9bcebcaad 100644 --- a/src/main/java/baritone/cache/CachedRegion.java +++ b/src/main/java/baritone/cache/CachedRegion.java @@ -43,7 +43,7 @@ public final class CachedRegion implements ICachedRegion { /** * Magic value to detect invalid cache files, or incompatible cache files saved in an old version of Baritone */ - private static final int CACHED_REGION_MAGIC = 456022910; + private static final int CACHED_REGION_MAGIC = 456022911; /** * All of the chunks in this region: A 32x32 array of them. @@ -166,7 +166,7 @@ public final class CachedRegion implements ICachedRegion { out.writeShort(entry.getValue().size()); for (BlockPos pos : entry.getValue()) { out.writeByte((byte) (pos.getZ() << 4 | pos.getX())); - out.writeByte((byte) (pos.getY())); + out.writeInt(pos.getY()-dimension.minY()); } } } @@ -270,8 +270,8 @@ public final class CachedRegion implements ICachedRegion { byte xz = in.readByte(); int X = xz & 0x0f; int Z = (xz >>> 4) & 0x0f; - int Y = in.readByte() & 0xff; - locs.add(new BlockPos(X, Y, Z)); + int Y = in.readInt(); + locs.add(new BlockPos(X, Y+dimension.minY(), Z)); } } } diff --git a/src/main/java/baritone/cache/ChunkPacker.java b/src/main/java/baritone/cache/ChunkPacker.java index 0f3c11749..5af928c92 100644 --- a/src/main/java/baritone/cache/ChunkPacker.java +++ b/src/main/java/baritone/cache/ChunkPacker.java @@ -82,7 +82,7 @@ public final class ChunkPacker { Block block = state.getBlock(); if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(block)) { String name = BlockUtils.blockToString(block); - specialBlocks.computeIfAbsent(name, b -> new ArrayList<>()).add(new BlockPos(x, y, z)); + specialBlocks.computeIfAbsent(name, b -> new ArrayList<>()).add(new BlockPos(x, y+chunk.getMinBuildHeight(), z)); } } } diff --git a/src/main/java/baritone/cache/WorldProvider.java b/src/main/java/baritone/cache/WorldProvider.java index 675c515f2..f4f448106 100644 --- a/src/main/java/baritone/cache/WorldProvider.java +++ b/src/main/java/baritone/cache/WorldProvider.java @@ -57,22 +57,22 @@ public class WorldProvider implements IWorldProvider, Helper { * @param world The world's Registry Data */ public final void initWorld(ResourceKey worldKey, DimensionType world) { - File directory; - File readme; + Path directory; + Path readme; IntegratedServer integratedServer = mc.getSingleplayerServer(); // If there is an integrated server running (Aka Singleplayer) then do magic to find the world save file if (mc.hasSingleplayerServer()) { - directory = DimensionType.getStorageFolder(worldKey, integratedServer.getWorldPath(LevelResource.ROOT).toFile()); + directory = DimensionType.getStorageFolder(worldKey, integratedServer.getWorldPath(LevelResource.ROOT)); // Gets the "depth" of this directory relative the the game's run directory, 2 is the location of the world - if (directory.toPath().relativize(mc.gameDirectory.toPath()).getNameCount() != 2) { + if (directory.relativize(mc.gameDirectory.toPath()).getNameCount() != 2) { // subdirectory of the main save directory for this world - directory = directory.getParentFile(); + directory = directory.getParent(); } - directory = new File(directory, "baritone"); + directory = directory.resolve("baritone"); readme = directory; } else { // Otherwise, the server must be remote... String folderName; @@ -90,12 +90,12 @@ public class WorldProvider implements IWorldProvider, Helper { if (SystemUtils.IS_OS_WINDOWS) { folderName = folderName.replace(":", "_"); } - directory = new File(Baritone.getDir(), folderName); - readme = Baritone.getDir(); + directory = Baritone.getDir().toPath().resolve(folderName); + readme = Baritone.getDir().toPath(); } // lol wtf is this baritone folder in my minecraft save? - try (FileOutputStream out = new FileOutputStream(new File(readme, "readme.txt"))) { + try (FileOutputStream out = new FileOutputStream(readme.resolve("readme.txt").toFile())) { // good thing we have a readme out.write("https://github.com/cabaletta/baritone\n".getBytes()); } catch (IOException ignored) {} @@ -114,8 +114,8 @@ public class WorldProvider implements IWorldProvider, Helper { } } - public final Path getDimDir(ResourceKey level, int height, File directory) { - return directory.toPath().resolve(level.location().getNamespace()).resolve(level.location().getPath() + "_" + height); + public final Path getDimDir(ResourceKey level, int height, Path directory) { + return directory.resolve(level.location().getNamespace()).resolve(level.location().getPath() + "_" + height); } public final void closeWorld() { diff --git a/src/main/java/baritone/cache/WorldScanner.java b/src/main/java/baritone/cache/WorldScanner.java index 8a932555a..2ce865a8d 100644 --- a/src/main/java/baritone/cache/WorldScanner.java +++ b/src/main/java/baritone/cache/WorldScanner.java @@ -147,7 +147,7 @@ public enum WorldScanner implements IWorldScanner { boolean foundWithinY = false; for (int y0 : coordinateIterationOrder) { LevelChunkSection section = chunkInternalStorageArray[y0]; - if (section == null || LevelChunkSection.isEmpty(section)) { + if (section == null || section.hasOnlyAir()) { continue; } int yReal = y0 << 4; diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index 2ebc1c0fb..4ed589e96 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -169,7 +169,7 @@ public class BlockStateInterface { // get the block at x,y,z from this chunk WITHOUT creating a single blockpos object public static BlockState getFromChunk(LevelChunk chunk, int x, int y, int z) { LevelChunkSection section = chunk.getSections()[y >> 4]; - if (LevelChunkSection.isEmpty(section)) { + if (section.hasOnlyAir()) { return AIR; } return section.getBlockState(x & 15, y & 15, z & 15);