diff --git a/.github/workflows/gradle_build.yml b/.github/workflows/gradle_build.yml index 0097ba67bc..8f79f25f69 100644 --- a/.github/workflows/gradle_build.yml +++ b/.github/workflows/gradle_build.yml @@ -17,11 +17,11 @@ jobs: with: fetch-depth: 0 - - name: Set up JDK 21 + - name: Set up JDK 25 uses: actions/setup-java@v5 with: - java-version: '21' - distribution: 'temurin' + java-version: '25' + distribution: 'zulu' cache: gradle - name: Grant execute permission for gradlew diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 43a75246ec..3637091872 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -12,11 +12,11 @@ jobs: steps: - uses: actions/checkout@v6 - - name: Set up JDK 21 + - name: Set up JDK 25 uses: actions/setup-java@v5 with: - java-version: '21' - distribution: 'temurin' + java-version: '25' + distribution: 'zulu' - name: Grant execute permission for gradlew run: chmod +x gradlew diff --git a/build.gradle b/build.gradle index e9809fb582..cbf845e625 100755 --- a/build.gradle +++ b/build.gradle @@ -94,9 +94,7 @@ allprojects { version rootProject.minecraft_version mappings { - intermediary() mojmap() - parchment(rootProject.minecraft_version, "2025.12.20") } } diff --git a/fabric/build.gradle b/fabric/build.gradle index ad4e096a9a..876f0bad08 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -80,7 +80,7 @@ components.java { } task proguard(type: ProguardTask) { - proguardVersion "7.4.2" + proguardVersion "7.9.1" compType "fabric" } diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 63c52e11b9..76da7a3245 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -24,8 +24,8 @@ "mixins.baritone.json" ], "depends": { - "fabricloader": ">=0.14.22", - "minecraft": ["1.21.11"] + "fabricloader": ">=0.19.3", + "minecraft": ["26.2"] }, "custom": { "modmenu": { diff --git a/forge/build.gradle b/forge/build.gradle index 462c24b487..6f8ca38f80 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -97,7 +97,7 @@ components.java { } task proguard(type: ProguardTask) { - proguardVersion "7.4.2" + proguardVersion "7.9.1" compType "forge" } diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 1792bd3dc1..5328e7bbf4 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -6,7 +6,7 @@ # The name of the mod loader type to load - for regular FML @Mod mods it should be javafml modLoader="javafml" #mandatory # A version range to match for said mod loader - for regular FML @Mod it will be the forge version -loaderVersion="[48,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. +loaderVersion="[62,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. license="https://raw.githubusercontent.com/cabaletta/baritone/1.16.2/LICENSE" # A URL to refer people to when problems occur with this mod issueTrackerURL="https://github.com/cabaletta/baritone/issues" #optional @@ -35,6 +35,6 @@ A Minecraft pathfinder bot. modId="minecraft" mandatory=true # This version range declares a minimum of the current minecraft version up to but not including the next major version -versionRange="[1.21.11]" +versionRange="[26.2]" ordering="NONE" side="BOTH" diff --git a/gradle.properties b/gradle.properties index ee9f728f76..6ab8aa48d5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,19 +2,19 @@ org.gradle.jvmargs=-Xmx4G available_loaders=fabric,forge,neoforge,tweaker -mod_version=1.17.0 +mod_version=1.18.0 maven_group=baritone archives_base_name=baritone -java_version=21 +java_version=25 -minecraft_version=1.21.11 +minecraft_version=26.2 -forge_version=61.1.5 +forge_version=65.0.3 -neoforge_version=42 +neoforge_version=11-beta -fabric_version=0.18.5 +fabric_version=0.19.3 nether_pathfinder_version=1.6 diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 6661c71fbd..d3f6ee2630 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -105,7 +105,7 @@ components.java { } task proguard(type: ProguardTask) { - proguardVersion "7.4.2" + proguardVersion "7.9.1" compType "neoforge" } diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml index ddb9dee529..4eec7768ea 100644 --- a/neoforge/src/main/resources/META-INF/neoforge.mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -35,7 +35,7 @@ A Minecraft pathfinder bot. modId="minecraft" type="required" # This version range declares a minimum of the current minecraft version up to but not including the next major version -versionRange="[1.21.11]" +versionRange="[26.2]" ordering="NONE" side="BOTH" diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index b611cadbec..91e81d86c3 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -22,8 +22,8 @@ import baritone.api.utils.SettingsUtil; import baritone.api.utils.TypeUtils; import baritone.api.utils.gui.BaritoneToast; -import net.minecraft.client.GuiMessageTag; import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.chat.GuiMessageTag; import net.minecraft.core.Vec3i; import net.minecraft.network.chat.Component; import net.minecraft.world.item.Item; @@ -1281,7 +1281,7 @@ public final class Settings { public final Setting> logger = new Setting<>((msg) -> { try { final GuiMessageTag tag = useMessageTag.value ? Helper.MESSAGE_TAG : null; - Minecraft.getInstance().gui.getChat().addMessage(msg, null, tag); + Minecraft.getInstance().gui.hud.getChat().addPlayerMessage(msg, null, tag); } catch (Throwable t) { LOGGER.warn("Failed to log message to chat: " + msg.getString(), t); } diff --git a/src/api/java/baritone/api/command/manager/ICommandManager.java b/src/api/java/baritone/api/command/manager/ICommandManager.java index 3f2d81f244..1430d2538e 100644 --- a/src/api/java/baritone/api/command/manager/ICommandManager.java +++ b/src/api/java/baritone/api/command/manager/ICommandManager.java @@ -21,7 +21,7 @@ import baritone.api.command.ICommand; import baritone.api.command.argument.ICommandArgument; import baritone.api.command.registry.Registry; -import net.minecraft.util.Tuple; +import baritone.api.utils.Pair; import java.util.List; import java.util.stream.Stream; @@ -44,9 +44,9 @@ public interface ICommandManager { boolean execute(String string); - boolean execute(Tuple> expanded); + boolean execute(Pair> expanded); - Stream tabComplete(Tuple> expanded); + Stream tabComplete(Pair> expanded); Stream tabComplete(String prefix); } diff --git a/src/api/java/baritone/api/utils/BlockOptionalMeta.java b/src/api/java/baritone/api/utils/BlockOptionalMeta.java index 2526d08a92..a9cc2caa56 100644 --- a/src/api/java/baritone/api/utils/BlockOptionalMeta.java +++ b/src/api/java/baritone/api/utils/BlockOptionalMeta.java @@ -38,7 +38,6 @@ import net.minecraft.server.packs.resources.CloseableResourceManager; import net.minecraft.server.packs.resources.MultiPackResourceManager; import net.minecraft.tags.TagLoader; -import net.minecraft.world.RandomSequences; import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -262,8 +261,8 @@ public static class ServerLevelStub extends ServerLevel { private static Unsafe unsafe = getUnsafe(); private static CompletableFuture registryAccess = load(); - public ServerLevelStub(MinecraftServer $$0, Executor $$1, LevelStorageSource.LevelStorageAccess $$2, ServerLevelData $$3, ResourceKey $$4, LevelStem $$5, boolean $$6, long $$7, List $$8, boolean $$9, @Nullable RandomSequences $$10) { - super($$0, $$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10); + public ServerLevelStub(MinecraftServer $$0, Executor $$1, LevelStorageSource.LevelStorageAccess $$2, ServerLevelData $$3, ResourceKey $$4, LevelStem $$5, boolean $$6, long $$7, List $$8, boolean $$9) { + super($$0, $$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9); } @Override @@ -321,8 +320,9 @@ public static CompletableFuture load() { RegistryDataLoader.load( closeableResourceManager, worldGenRegistryLookupList, - RegistryDataLoader.WORLDGEN_REGISTRIES - ) + RegistryDataLoader.WORLDGEN_REGISTRIES, + ForkJoinPool.commonPool() + ).join() ); return ReloadableServerRegistries.reload( layeredRegistryAccess, diff --git a/src/api/java/baritone/api/utils/Helper.java b/src/api/java/baritone/api/utils/Helper.java index 507cd85a7e..1aee893032 100755 --- a/src/api/java/baritone/api/utils/Helper.java +++ b/src/api/java/baritone/api/utils/Helper.java @@ -20,8 +20,8 @@ import baritone.api.BaritoneAPI; import baritone.api.Settings; import net.minecraft.ChatFormatting; -import net.minecraft.client.GuiMessageTag; import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.chat.GuiMessageTag; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; diff --git a/src/api/java/baritone/api/utils/IPlayerController.java b/src/api/java/baritone/api/utils/IPlayerController.java index 48142d13b7..2c098e9aee 100644 --- a/src/api/java/baritone/api/utils/IPlayerController.java +++ b/src/api/java/baritone/api/utils/IPlayerController.java @@ -24,7 +24,7 @@ import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.inventory.ClickType; +import net.minecraft.world.inventory.ContainerInput; import net.minecraft.world.level.GameType; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; @@ -43,7 +43,7 @@ public interface IPlayerController { void resetBlockRemoving(); - void windowClick(int windowId, int slotId, int mouseButton, ClickType type, Player player); + void windowClick(int windowId, int slotId, int mouseButton, ContainerInput type, Player player); GameType getGameType(); diff --git a/src/api/java/baritone/api/utils/gui/BaritoneToast.java b/src/api/java/baritone/api/utils/gui/BaritoneToast.java index effa0b8046..25e1318c99 100644 --- a/src/api/java/baritone/api/utils/gui/BaritoneToast.java +++ b/src/api/java/baritone/api/utils/gui/BaritoneToast.java @@ -24,6 +24,6 @@ public class BaritoneToast { private static final SystemToast.SystemToastId BARITONE_TOAST_ID = new SystemToast.SystemToastId(5000L); public static void addOrUpdate(Component title, Component subtitle) { - SystemToast.addOrUpdate(Minecraft.getInstance().getToastManager(), BARITONE_TOAST_ID, title, subtitle); + SystemToast.addOrUpdate(Minecraft.getInstance().gui.toastManager(), BARITONE_TOAST_ID, title, subtitle); } } diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkArray.java b/src/launch/java/baritone/launch/mixins/MixinChunkArray.java index 711ca65542..722eda84d4 100644 --- a/src/launch/java/baritone/launch/mixins/MixinChunkArray.java +++ b/src/launch/java/baritone/launch/mixins/MixinChunkArray.java @@ -84,8 +84,8 @@ public void copyFrom(IChunkArray other) { LevelChunk chunk = copyingFrom.get(k); if (chunk != null) { ChunkPos chunkpos = chunk.getPos(); - if (inRange(chunkpos.x, chunkpos.z)) { - int index = getIndex(chunkpos.x, chunkpos.z); + if (inRange(chunkpos.x(), chunkpos.z())) { + int index = getIndex(chunkpos.x(), chunkpos.z()); if (chunks.get(index) != null) { throw new IllegalStateException("Doing this would mutate the client's REAL loaded chunks?!"); } diff --git a/src/launch/java/baritone/launch/mixins/MixinClientPlayNetHandler.java b/src/launch/java/baritone/launch/mixins/MixinClientPlayNetHandler.java index d603ca632f..1985b31517 100644 --- a/src/launch/java/baritone/launch/mixins/MixinClientPlayNetHandler.java +++ b/src/launch/java/baritone/launch/mixins/MixinClientPlayNetHandler.java @@ -125,7 +125,7 @@ private void preChunkUnload(ClientboundForgetLevelChunkPacket packet, CallbackIn LocalPlayer player = ibaritone.getPlayerContext().player(); if (player != null && player.connection == (ClientPacketListener) (Object) this) { ibaritone.getGameEventHandler().onChunkEvent( - new ChunkEvent(EventState.PRE, ChunkEvent.Type.UNLOAD, packet.pos().x, packet.pos().z) + new ChunkEvent(EventState.PRE, ChunkEvent.Type.UNLOAD, packet.pos().x(), packet.pos().z()) ); } } @@ -140,7 +140,7 @@ private void postChunkUnload(ClientboundForgetLevelChunkPacket packet, CallbackI LocalPlayer player = ibaritone.getPlayerContext().player(); if (player != null && player.connection == (ClientPacketListener) (Object) this) { ibaritone.getGameEventHandler().onChunkEvent( - new ChunkEvent(EventState.POST, ChunkEvent.Type.UNLOAD, packet.pos().x, packet.pos().z) + new ChunkEvent(EventState.POST, ChunkEvent.Type.UNLOAD, packet.pos().x(), packet.pos().z()) ); } } @@ -190,7 +190,7 @@ private void postHandleMultiBlockChange(ClientboundSectionBlocksUpdatePacket pac return; } baritone.getGameEventHandler().onBlockChange(new BlockChangeEvent( - new ChunkPos(changes.get(0).first()), + ChunkPos.containing(changes.get(0).first()), changes )); } diff --git a/src/launch/java/baritone/launch/mixins/MixinFireworkRocketEntity.java b/src/launch/java/baritone/launch/mixins/MixinFireworkRocketEntity.java index b4c8e05b67..17321cca30 100644 --- a/src/launch/java/baritone/launch/mixins/MixinFireworkRocketEntity.java +++ b/src/launch/java/baritone/launch/mixins/MixinFireworkRocketEntity.java @@ -20,7 +20,7 @@ import baritone.utils.accessor.IFireworkRocketEntity; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.EntityTypes; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.projectile.FireworkRocketEntity; import net.minecraft.world.level.Level; @@ -44,7 +44,7 @@ public abstract class MixinFireworkRocketEntity extends Entity implements IFirew public abstract boolean isAttachedToEntity(); private MixinFireworkRocketEntity(Level level) { - super(EntityType.FIREWORK_ROCKET, level); + super(EntityTypes.FIREWORK_ROCKET, level); } @Override diff --git a/src/launch/java/baritone/launch/mixins/MixinItemStack.java b/src/launch/java/baritone/launch/mixins/MixinItemStack.java index fd8299d54e..e593c695e2 100644 --- a/src/launch/java/baritone/launch/mixins/MixinItemStack.java +++ b/src/launch/java/baritone/launch/mixins/MixinItemStack.java @@ -20,7 +20,6 @@ import baritone.api.utils.accessor.IItemStack; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -31,17 +30,17 @@ @Mixin(ItemStack.class) public abstract class MixinItemStack implements IItemStack { - @Shadow - @Final - private Item item; - @Unique private int baritoneHash; @Shadow public abstract int getDamageValue(); + @Shadow + public abstract Item getItem(); + private void recalculateHash() { + Item item = getItem(); baritoneHash = item == null ? -1 : item.hashCode() + getDamageValue(); } diff --git a/src/launch/java/baritone/launch/mixins/MixinMinecraft.java b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java index 7a1c16c526..37455dbd28 100644 --- a/src/launch/java/baritone/launch/mixins/MixinMinecraft.java +++ b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java @@ -24,6 +24,7 @@ import baritone.api.event.events.WorldEvent; import baritone.api.event.events.type.EventState; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.player.LocalPlayer; @@ -67,7 +68,7 @@ private void postInit(CallbackInfo ci) { at = @At( value = "FIELD", opcode = Opcodes.GETFIELD, - target = "net/minecraft/client/Minecraft.screen:Lnet/minecraft/client/gui/screens/Screen;", + target = "net/minecraft/client/Minecraft.gui:Lnet/minecraft/client/gui/Gui;", ordinal = 0, shift = At.Shift.BEFORE ), @@ -165,14 +166,14 @@ private void postLoadWorld(final ClientLevel world, final CallbackInfo ci) { @Redirect( method = "tick", at = @At( - value = "FIELD", - opcode = Opcodes.GETFIELD, - target = "Lnet/minecraft/client/Minecraft;screen:Lnet/minecraft/client/gui/screens/Screen;" + value = "INVOKE", + target = "Lnet/minecraft/client/gui/Gui;screen()Lnet/minecraft/client/gui/screens/Screen;" ), slice = @Slice( from = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/gui/components/DebugScreenOverlay;showDebugScreen()Z" + value = "FIELD", + opcode = Opcodes.PUTFIELD, + target = "net/minecraft/client/Minecraft.missTime:I" ), to = @At( value = "CONSTANT", @@ -180,12 +181,12 @@ private void postLoadWorld(final ClientLevel world, final CallbackInfo ci) { ) ) ) - private Screen passEvents(Minecraft instance) { + private Screen passEvents(Gui gui) { // allow user input is only the primary baritone if (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing() && player != null) { return null; } - return instance.screen; + return gui.screen(); } // TODO diff --git a/src/launch/java/baritone/launch/mixins/MixinWorldRenderer.java b/src/launch/java/baritone/launch/mixins/MixinWorldRenderer.java index ff8eddf3ff..51bb7e3e83 100644 --- a/src/launch/java/baritone/launch/mixins/MixinWorldRenderer.java +++ b/src/launch/java/baritone/launch/mixins/MixinWorldRenderer.java @@ -23,10 +23,10 @@ import com.mojang.blaze3d.buffers.GpuBufferSlice; import com.mojang.blaze3d.resource.GraphicsResourceAllocator; import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.Camera; import net.minecraft.client.DeltaTracker; import net.minecraft.client.renderer.LevelRenderer; -import org.joml.Matrix4f; +import net.minecraft.client.renderer.state.level.CameraRenderState; +import org.joml.Matrix4fc; import org.joml.Vector4f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -41,14 +41,14 @@ public class MixinWorldRenderer { @Inject( - method = "renderLevel", + method = "render", at = @At("RETURN") ) - private void onStartHand(final GraphicsResourceAllocator graphicsResourceAllocator, final DeltaTracker deltaTracker, final boolean bl, final Camera camera, final Matrix4f matrix4f, final Matrix4f matrix4f2, final Matrix4f matrix4f3, final GpuBufferSlice gpuBufferSlice, final Vector4f vector4f, final boolean bl2, final CallbackInfo ci) { + private void onStartHand(final GraphicsResourceAllocator allocator, final DeltaTracker deltaTracker, final boolean outline, final CameraRenderState camera, final Matrix4fc modelViewMatrix, final GpuBufferSlice fog, final Vector4f fogColor, final boolean sky, final CallbackInfo ci) { for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { PoseStack poseStack = new PoseStack(); - poseStack.mulPose(matrix4f); - ibaritone.getGameEventHandler().onRenderPass(new RenderEvent(deltaTracker.getGameTimeDeltaPartialTick(false), poseStack, matrix4f2)); + poseStack.mulPose(modelViewMatrix); + ibaritone.getGameEventHandler().onRenderPass(new RenderEvent(deltaTracker.getGameTimeDeltaPartialTick(false), poseStack, camera.projectionMatrix)); } } } diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index ad68714137..53f2bd3e0a 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -245,7 +245,7 @@ public void openClick() { new Thread(() -> { try { Thread.sleep(100); - mc.execute(() -> mc.setScreen(new GuiClick())); + mc.execute(() -> mc.gui.setScreen(new GuiClick())); } catch (Exception ignored) {} }).start(); } diff --git a/src/main/java/baritone/behavior/InventoryBehavior.java b/src/main/java/baritone/behavior/InventoryBehavior.java index 15dff73e13..5b7389ddcd 100644 --- a/src/main/java/baritone/behavior/InventoryBehavior.java +++ b/src/main/java/baritone/behavior/InventoryBehavior.java @@ -27,7 +27,7 @@ import net.minecraft.core.component.DataComponents; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.inventory.ClickType; +import net.minecraft.world.inventory.ContainerInput; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -120,7 +120,7 @@ private boolean requestSwapWithHotBar(int inInventory, int inHotbar) { logDebug("Inventory move requested but delaying until stationary"); return false; } - ctx.playerController().windowClick(ctx.player().inventoryMenu.containerId, inInventory < 9 ? inInventory + 36 : inInventory, inHotbar, ClickType.SWAP, ctx.player()); + ctx.playerController().windowClick(ctx.player().inventoryMenu.containerId, inInventory < 9 ? inInventory + 36 : inInventory, inHotbar, ContainerInput.SWAP, ctx.player()); ticksSinceLastInventoryMove = 0; lastTickRequestedMove = null; return true; diff --git a/src/main/java/baritone/cache/CachedChunk.java b/src/main/java/baritone/cache/CachedChunk.java index 86a849e5a6..c49394d76e 100644 --- a/src/main/java/baritone/cache/CachedChunk.java +++ b/src/main/java/baritone/cache/CachedChunk.java @@ -40,7 +40,8 @@ */ public final class CachedChunk { - public static final ImmutableSet BLOCKS_TO_KEEP_TRACK_OF = ImmutableSet.of( + public static final ImmutableSet BLOCKS_TO_KEEP_TRACK_OF = new ImmutableSet.Builder() + .add( Blocks.ENDER_CHEST, Blocks.FURNACE, Blocks.CHEST, @@ -50,22 +51,6 @@ public final class CachedChunk { Blocks.SPAWNER, Blocks.BARRIER, Blocks.OBSERVER, - Blocks.WHITE_SHULKER_BOX, - Blocks.ORANGE_SHULKER_BOX, - Blocks.MAGENTA_SHULKER_BOX, - Blocks.LIGHT_BLUE_SHULKER_BOX, - Blocks.YELLOW_SHULKER_BOX, - Blocks.LIME_SHULKER_BOX, - Blocks.PINK_SHULKER_BOX, - Blocks.GRAY_SHULKER_BOX, - Blocks.LIGHT_GRAY_SHULKER_BOX, - Blocks.CYAN_SHULKER_BOX, - Blocks.PURPLE_SHULKER_BOX, - Blocks.BLUE_SHULKER_BOX, - Blocks.BROWN_SHULKER_BOX, - Blocks.GREEN_SHULKER_BOX, - Blocks.RED_SHULKER_BOX, - Blocks.BLACK_SHULKER_BOX, Blocks.NETHER_PORTAL, Blocks.HOPPER, Blocks.BEACON, @@ -87,22 +72,6 @@ public final class CachedChunk { Blocks.WITHER_SKELETON_WALL_SKULL, Blocks.ENCHANTING_TABLE, Blocks.ANVIL, - Blocks.WHITE_BED, - Blocks.ORANGE_BED, - Blocks.MAGENTA_BED, - Blocks.LIGHT_BLUE_BED, - Blocks.YELLOW_BED, - Blocks.LIME_BED, - Blocks.PINK_BED, - Blocks.GRAY_BED, - Blocks.LIGHT_GRAY_BED, - Blocks.CYAN_BED, - Blocks.PURPLE_BED, - Blocks.BLUE_BED, - Blocks.BROWN_BED, - Blocks.GREEN_BED, - Blocks.RED_BED, - Blocks.BLACK_BED, Blocks.DRAGON_EGG, Blocks.JUKEBOX, Blocks.END_GATEWAY, @@ -110,7 +79,9 @@ public final class CachedChunk { Blocks.NETHER_WART, Blocks.LADDER, Blocks.VINE - ); + ).addAll(Blocks.DYED_SHULKER_BOX.asList()) + .addAll(Blocks.BED.asList()) + .build(); public final int height; diff --git a/src/main/java/baritone/cache/ChunkPacker.java b/src/main/java/baritone/cache/ChunkPacker.java index 0d3728ea05..78bca4b7a8 100644 --- a/src/main/java/baritone/cache/ChunkPacker.java +++ b/src/main/java/baritone/cache/ChunkPacker.java @@ -109,7 +109,7 @@ public static CachedChunk pack(LevelChunk chunk) { } } // @formatter:on - return new CachedChunk(chunk.getPos().x, chunk.getPos().z, height, bitSet, blocks, specialBlocks, System.currentTimeMillis()); + return new CachedChunk(chunk.getPos().x(), chunk.getPos().z(), height, bitSet, blocks, specialBlocks, System.currentTimeMillis()); } private static PathingBlockType getPathingBlockType(BlockState state, LevelChunk chunk, int x, int y, int z) { @@ -130,7 +130,7 @@ private static PathingBlockType getPathingBlockType(BlockState state, LevelChunk return PathingBlockType.AVOID; } if (x == 0 || x == 15 || z == 0 || z == 15) { - Vec3 flow = state.getFluidState().getFlow(chunk.getLevel(), new BlockPos(x + (chunk.getPos().x << 4), y, z + (chunk.getPos().z << 4))); + Vec3 flow = state.getFluidState().getFlow(chunk.getLevel(), new BlockPos(x + (chunk.getPos().x() << 4), y, z + (chunk.getPos().z() << 4))); if (flow.x != 0.0 || flow.z != 0.0) { return PathingBlockType.WATER; } diff --git a/src/main/java/baritone/cache/FasterWorldScanner.java b/src/main/java/baritone/cache/FasterWorldScanner.java index c5e6a139ad..d544caedd0 100644 --- a/src/main/java/baritone/cache/FasterWorldScanner.java +++ b/src/main/java/baritone/cache/FasterWorldScanner.java @@ -142,16 +142,16 @@ private List scanChunksInternal(IPlayerContext ctx, BlockOptionalMetaL private Stream scanChunkInternal(IPlayerContext ctx, BlockOptionalMetaLookup lookup, ChunkPos pos) { ChunkSource chunkProvider = ctx.world().getChunkSource(); // if chunk is not loaded, return empty stream - if (!chunkProvider.hasChunk(pos.x, pos.z)) { + if (!chunkProvider.hasChunk(pos.x(), pos.z())) { return Stream.empty(); } - long chunkX = (long) pos.x << 4; - long chunkZ = (long) pos.z << 4; + long chunkX = (long) pos.x() << 4; + long chunkZ = (long) pos.z() << 4; int playerSectionY = (ctx.playerFeet().y - ctx.world().getMinY()) >> 4; - return collectChunkSections(lookup, chunkProvider.getChunk(pos.x, pos.z, false), chunkX, chunkZ, playerSectionY).stream(); + return collectChunkSections(lookup, chunkProvider.getChunk(pos.x(), pos.z(), false), chunkX, chunkZ, playerSectionY).stream(); } diff --git a/src/main/java/baritone/cache/WorldProvider.java b/src/main/java/baritone/cache/WorldProvider.java index f503a07990..28b2d94f11 100644 --- a/src/main/java/baritone/cache/WorldProvider.java +++ b/src/main/java/baritone/cache/WorldProvider.java @@ -20,9 +20,9 @@ import baritone.Baritone; import baritone.api.cache.IWorldProvider; import baritone.api.utils.IPlayerContext; +import baritone.api.utils.Pair; import net.minecraft.client.multiplayer.ServerData; import net.minecraft.resources.Identifier; -import net.minecraft.util.Tuple; import net.minecraft.world.level.Level; import net.minecraft.world.level.storage.LevelResource; import org.apache.commons.lang3.SystemUtils; @@ -71,8 +71,8 @@ public final WorldData getCurrentWorld() { */ public final void initWorld(Level world) { this.getSaveDirectories(world).ifPresent(dirs -> { - final Path worldDir = dirs.getA(); - final Path readmeDir = dirs.getB(); + final Path worldDir = dirs.first(); + final Path readmeDir = dirs.second(); try { // lol wtf is this baritone folder in my minecraft save? @@ -119,7 +119,7 @@ private Path getWorldDataDirectory(Path parent, Level world) { * @return An {@link Optional} containing the world's baritone dir and readme dir, or {@link Optional#empty()} if * the world isn't valid for caching. */ - private Optional> getSaveDirectories(Level world) { + private Optional> getSaveDirectories(Level world) { Path worldDir; Path readmeDir; @@ -156,7 +156,7 @@ private Optional> getSaveDirectories(Level world) { readmeDir = baritone.getDirectory(); } - return Optional.of(new Tuple<>(worldDir, readmeDir)); + return Optional.of(new Pair<>(worldDir, readmeDir)); } /** diff --git a/src/main/java/baritone/cache/WorldScanner.java b/src/main/java/baritone/cache/WorldScanner.java index 35e46ba23d..c9431038bf 100644 --- a/src/main/java/baritone/cache/WorldScanner.java +++ b/src/main/java/baritone/cache/WorldScanner.java @@ -96,7 +96,7 @@ public List scanChunk(IPlayerContext ctx, BlockOptionalMetaLookup filt } ClientChunkCache chunkProvider = (ClientChunkCache) ctx.world().getChunkSource(); - LevelChunk chunk = chunkProvider.getChunk(pos.x, pos.z, null, false); + LevelChunk chunk = chunkProvider.getChunk(pos.x(), pos.z(), null, false); int playerY = ctx.playerFeet().getY(); if (chunk == null || chunk.isEmpty()) { @@ -104,7 +104,7 @@ public List scanChunk(IPlayerContext ctx, BlockOptionalMetaLookup filt } ArrayList res = new ArrayList<>(); - scanChunkInto(pos.x << 4, pos.z << 4, ctx.world().dimensionType().minY(), chunk, filter, res, max, yLevelThreshold, playerY, IntStream.range(0, ctx.world().dimensionType().height() / 16).toArray()); + scanChunkInto(pos.x() << 4, pos.z() << 4, ctx.world().dimensionType().minY(), chunk, filter, res, max, yLevelThreshold, playerY, IntStream.range(0, ctx.world().dimensionType().height() / 16).toArray()); return res; } diff --git a/src/main/java/baritone/command/ExampleBaritoneControl.java b/src/main/java/baritone/command/ExampleBaritoneControl.java index bb9681e97d..82f1cc57c3 100644 --- a/src/main/java/baritone/command/ExampleBaritoneControl.java +++ b/src/main/java/baritone/command/ExampleBaritoneControl.java @@ -28,6 +28,7 @@ import baritone.api.event.events.ChatEvent; import baritone.api.event.events.TabCompleteEvent; import baritone.api.utils.Helper; +import baritone.api.utils.Pair; import baritone.api.utils.SettingsUtil; import baritone.behavior.Behavior; import baritone.command.argument.ArgConsumer; @@ -38,7 +39,6 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.chat.HoverEvent; import net.minecraft.network.chat.MutableComponent; -import net.minecraft.util.Tuple; import net.minecraft.util.Util; import java.util.List; @@ -66,7 +66,7 @@ public void onSendChatMessage(ChatEvent event) { event.cancel(); String commandStr = msg.substring(forceRun ? FORCE_COMMAND_PREFIX.length() : prefix.length()); if (!runCommand(commandStr) && !commandStr.trim().isEmpty()) { - new CommandNotFoundException(CommandManager.expand(commandStr).getA()).handle(null, null); + new CommandNotFoundException(CommandManager.expand(commandStr).first()).handle(null, null); } } else if ((settings.chatControl.value || settings.chatControlAnyway.value) && runCommand(msg)) { event.cancel(); @@ -103,10 +103,10 @@ public boolean runCommand(String msg) { if (msg.isEmpty()) { return this.runCommand("help"); } - Tuple> pair = CommandManager.expand(msg); - String command = pair.getA(); - String rest = msg.substring(pair.getA().length()); - ArgConsumer argc = new ArgConsumer(this.manager, pair.getB()); + Pair> pair = CommandManager.expand(msg); + String command = pair.first(); + String rest = msg.substring(pair.first().length()); + ArgConsumer argc = new ArgConsumer(this.manager, pair.second()); if (!argc.hasAny()) { Settings.Setting setting = settings.byLowerName.get(command.toLowerCase(Locale.US)); if (setting != null) { @@ -123,7 +123,7 @@ public boolean runCommand(String msg) { if (setting.isJavaOnly()) { continue; } - if (setting.getName().equalsIgnoreCase(pair.getA())) { + if (setting.getName().equalsIgnoreCase(pair.first())) { logRanCommand(command, rest); try { this.manager.execute(String.format("set %s %s", setting.getName(), argc.getString())); @@ -134,7 +134,7 @@ public boolean runCommand(String msg) { } // If the command exists, then handle echoing the input - if (this.manager.getCommand(pair.getA()) != null) { + if (this.manager.getCommand(pair.first()) != null) { logRanCommand(command, rest); } diff --git a/src/main/java/baritone/command/defaults/RenderCommand.java b/src/main/java/baritone/command/defaults/RenderCommand.java index 37d70b42b8..a8a35948b0 100644 --- a/src/main/java/baritone/command/defaults/RenderCommand.java +++ b/src/main/java/baritone/command/defaults/RenderCommand.java @@ -38,7 +38,7 @@ public void execute(String label, IArgConsumer args) throws CommandException { args.requireMax(0); BetterBlockPos origin = ctx.playerFeet(); int renderDistance = (ctx.minecraft().options.renderDistance().get() + 1) * 16; - ctx.minecraft().levelRenderer.setBlocksDirty( + ctx.minecraft().levelExtractor.setBlocksDirty( origin.x - renderDistance, ctx.world().getMinY(), origin.z - renderDistance, diff --git a/src/main/java/baritone/command/manager/CommandManager.java b/src/main/java/baritone/command/manager/CommandManager.java index 8712165f14..813c2dfd73 100644 --- a/src/main/java/baritone/command/manager/CommandManager.java +++ b/src/main/java/baritone/command/manager/CommandManager.java @@ -27,10 +27,10 @@ import baritone.api.command.helpers.TabCompleteHelper; import baritone.api.command.manager.ICommandManager; import baritone.api.command.registry.Registry; +import baritone.api.utils.Pair; import baritone.command.argument.ArgConsumer; import baritone.command.argument.CommandArguments; import baritone.command.defaults.DefaultCommands; -import net.minecraft.util.Tuple; import java.util.List; import java.util.Locale; @@ -79,7 +79,7 @@ public boolean execute(String string) { } @Override - public boolean execute(Tuple> expanded) { + public boolean execute(Pair> expanded) { ExecutionWrapper execution = this.from(expanded); if (execution != null) { execution.execute(); @@ -88,16 +88,16 @@ public boolean execute(Tuple> expanded) { } @Override - public Stream tabComplete(Tuple> expanded) { + public Stream tabComplete(Pair> expanded) { ExecutionWrapper execution = this.from(expanded); return execution == null ? Stream.empty() : execution.tabComplete(); } @Override public Stream tabComplete(String prefix) { - Tuple> pair = expand(prefix, true); - String label = pair.getA(); - List args = pair.getB(); + Pair> pair = expand(prefix, true); + String label = pair.first(); + List args = pair.second(); if (args.isEmpty()) { return new TabCompleteHelper() .addCommands(this.baritone.getCommandManager()) @@ -108,21 +108,21 @@ public Stream tabComplete(String prefix) { } } - private ExecutionWrapper from(Tuple> expanded) { - String label = expanded.getA(); - ArgConsumer args = new ArgConsumer(this, expanded.getB()); + private ExecutionWrapper from(Pair> expanded) { + String label = expanded.first(); + ArgConsumer args = new ArgConsumer(this, expanded.second()); ICommand command = this.getCommand(label); return command == null ? null : new ExecutionWrapper(command, label, args); } - private static Tuple> expand(String string, boolean preserveEmptyLast) { + private static Pair> expand(String string, boolean preserveEmptyLast) { String label = string.split("\\s", 2)[0]; List args = CommandArguments.from(string.substring(label.length()), preserveEmptyLast); - return new Tuple<>(label, args); + return new Pair<>(label, args); } - public static Tuple> expand(String string) { + public static Pair> expand(String string) { return expand(string, false); } diff --git a/src/main/java/baritone/event/GameEventHandler.java b/src/main/java/baritone/event/GameEventHandler.java index d716ff8499..8bbdb52d67 100644 --- a/src/main/java/baritone/event/GameEventHandler.java +++ b/src/main/java/baritone/event/GameEventHandler.java @@ -120,7 +120,7 @@ public void onBlockChange(BlockChangeEvent event) { baritone.getWorldProvider().ifWorldLoaded(worldData -> { final Level world = baritone.getPlayerContext().world(); ChunkPos pos = event.getChunkPos(); - worldData.getCachedWorld().queueForPacking(world.getChunk(pos.x, pos.z)); + worldData.getCachedWorld().queueForPacking(world.getChunk(pos.x(), pos.z())); }); } } diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 1b5b597121..51a23577ba 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -221,7 +221,7 @@ static boolean canWalkThroughPosition(BlockStateInterface bsi, int x, int y, int } BlockState up = bsi.get0(x, y + 1, z); - if (!up.getFluidState().isEmpty() || up.getBlock() instanceof WaterlilyBlock) { + if (!up.getFluidState().isEmpty() || up.getBlock() instanceof LilyPadBlock) { return false; } return fluidState.getType() instanceof WaterFluid; diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 8a5359b5bd..04afddfcd7 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -34,7 +34,6 @@ import baritone.utils.BlockStateInterface; import net.minecraft.core.BlockPos; import net.minecraft.core.Vec3i; -import net.minecraft.util.Tuple; import net.minecraft.world.phys.Vec3; import java.util.*; @@ -125,10 +124,10 @@ public boolean onTick() { } } } - Tuple status = closestPathPos(path); + Pair status = closestPathPos(path); if (possiblyOffPath(status, MAX_DIST_FROM_PATH)) { ticksAway++; - System.out.println("FAR AWAY FROM PATH FOR " + ticksAway + " TICKS. Current distance: " + status.getA() + ". Threshold: " + MAX_DIST_FROM_PATH); + System.out.println("FAR AWAY FROM PATH FOR " + ticksAway + " TICKS. Current distance: " + status.first() + ". Threshold: " + MAX_DIST_FROM_PATH); if (ticksAway > MAX_TICKS_AWAY) { logDebug("Too far away from path for too long, cancelling path"); cancel(); @@ -252,7 +251,7 @@ public boolean onTick() { return canCancel; // movement is in progress, but if it reports cancellable, PathingBehavior is good to cut onto the next path } - private Tuple closestPathPos(IPath path) { + private Pair closestPathPos(IPath path) { double best = -1; BlockPos bestPos = null; for (IMovement movement : path.movements()) { @@ -264,7 +263,7 @@ private Tuple closestPathPos(IPath path) { } } } - return new Tuple<>(best, bestPos); + return new Pair<>(best, bestPos); } private boolean shouldPause() { @@ -300,8 +299,8 @@ private boolean shouldPause() { return positions.contains(ctx.playerFeet()); } - private boolean possiblyOffPath(Tuple status, double leniency) { - double distanceFromPath = status.getA(); + private boolean possiblyOffPath(Pair status, double leniency) { + double distanceFromPath = status.first(); if (distanceFromPath > leniency) { // when we're midair in the middle of a fall, we're very far from both the beginning and the end, but we aren't actually off path if (path.movements().get(pathPosition) instanceof MovementFall) { @@ -451,9 +450,9 @@ private boolean shouldSprintNextTick() { } } if (current instanceof MovementFall) { - Tuple data = overrideFall((MovementFall) current); + Pair data = overrideFall((MovementFall) current); if (data != null) { - BetterBlockPos fallDest = new BetterBlockPos(data.getB()); + BetterBlockPos fallDest = new BetterBlockPos(data.second()); if (!path.positions().contains(fallDest)) { throw new IllegalStateException(String.format( "Fall override at %s %s %s returned illegal destination %s %s %s", @@ -466,7 +465,7 @@ private boolean shouldSprintNextTick() { return true; } clearKeys(); - behavior.baritone.getLookBehavior().updateTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), data.getA(), ctx.playerRotations()), false); + behavior.baritone.getLookBehavior().updateTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), data.first(), ctx.playerRotations()), false); behavior.baritone.getInputOverrideHandler().setInputForceState(Input.MOVE_FORWARD, true); return true; } @@ -474,7 +473,7 @@ private boolean shouldSprintNextTick() { return false; } - private Tuple overrideFall(MovementFall movement) { + private Pair overrideFall(MovementFall movement) { Vec3i dir = movement.getDirection(); if (dir.getY() < -3) { return null; @@ -508,7 +507,7 @@ private Tuple overrideFall(MovementFall movement) { return null; // no valid extension exists } double len = i - pathPosition - 0.4; - return new Tuple<>( + return new Pair<>( new Vec3(flatDir.getX() * len + movement.getDest().x + 0.5, movement.getDest().y, flatDir.getZ() * len + movement.getDest().z + 0.5), movement.getDest().offset(flatDir.getX() * (i - pathPosition), 0, flatDir.getZ() * (i - pathPosition))); } diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 29a0c7d615..c1f275001e 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -46,7 +46,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Vec3i; -import net.minecraft.util.Tuple; import net.minecraft.world.InteractionHand; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.ItemStack; @@ -203,10 +202,10 @@ private ISchematic applyMapArtAndSelection(Vec3i origin, IStaticSchematic parsed @Override public void buildOpenSchematic() { if (SchematicaHelper.isSchematicaPresent()) { - Optional> schematic = SchematicaHelper.getOpenSchematic(); + Optional> schematic = SchematicaHelper.getOpenSchematic(); if (schematic.isPresent()) { - IStaticSchematic raw = schematic.get().getA(); - BlockPos origin = schematic.get().getB(); + IStaticSchematic raw = schematic.get().first(); + BlockPos origin = schematic.get().second(); ISchematic schem = applyMapArtAndSelection(origin, raw); this.build(raw.toString(), schem, origin); } else { @@ -222,10 +221,10 @@ public void buildOpenLitematic(int i) { if (LitematicaHelper.isLitematicaPresent()) { //if java.lang.NoSuchMethodError is thrown see comment in SchematicPlacementManager if (LitematicaHelper.hasLoadedSchematic(i)) { - Tuple schematic = LitematicaHelper.getSchematic(i); - Vec3i correctedOrigin = schematic.getB(); - ISchematic schematic2 = applyMapArtAndSelection(correctedOrigin, schematic.getA()); - build(schematic.getA().toString(), schematic2, correctedOrigin); + Pair schematic = LitematicaHelper.getSchematic(i); + Vec3i correctedOrigin = schematic.second(); + ISchematic schematic2 = applyMapArtAndSelection(correctedOrigin, schematic.first()); + build(schematic.first().toString(), schematic2, correctedOrigin); } else { logDirect(String.format("List of placements has no entry %s", i + 1)); } @@ -266,7 +265,7 @@ public BlockState placeAt(int x, int y, int z, BlockState current) { return state; } - private Optional> toBreakNearPlayer(BuilderCalculationContext bcc) { + private Optional> toBreakNearPlayer(BuilderCalculationContext bcc) { BetterBlockPos center = ctx.playerFeet(); BetterBlockPos pathStart = baritone.getPathingBehavior().pathStart(); for (int dx = -5; dx <= 5; dx++) { @@ -287,7 +286,7 @@ private Optional> toBreakNearPlayer(BuilderCalcu BetterBlockPos pos = new BetterBlockPos(x, y, z); Optional rot = RotationUtils.reachable(ctx, pos, ctx.playerController().getBlockReachDistance()); if (rot.isPresent()) { - return Optional.of(new Tuple<>(pos, rot.get())); + return Optional.of(new Pair<>(pos, rot.get())); } } } @@ -531,12 +530,12 @@ public int lengthZ() { trim(); } - Optional> toBreak = toBreakNearPlayer(bcc); + Optional> toBreak = toBreakNearPlayer(bcc); if (toBreak.isPresent() && isSafeToCancel && ctx.player().onGround()) { // we'd like to pause to break this block // only change look direction if it's safe (don't want to fuck up an in progress parkour for example - Rotation rot = toBreak.get().getB(); - BetterBlockPos pos = toBreak.get().getA(); + Rotation rot = toBreak.get().second(); + BetterBlockPos pos = toBreak.get().first(); baritone.getLookBehavior().updateTarget(rot, true); MovementHelper.switchToBestToolFor(ctx, bcc.get(pos)); if (ctx.player().isCrouching()) { @@ -1037,10 +1036,8 @@ private static boolean sameBlockstate(BlockState first, BlockState second) { if (!ignoreDirection && ignoredProps.isEmpty()) { return first.equals(second); // early return if no properties are being ignored } - Map, Comparable> map1 = first.getValues(); - Map, Comparable> map2 = second.getValues(); - for (Property prop : map1.keySet()) { - if (map1.get(prop) != map2.get(prop) + for (Property prop : first.getProperties()) { + if (first.getValue(prop) != second.getValue(prop) && !(ignoreDirection && ORIENTATION_PROPS.contains(prop)) && !ignoredProps.contains(prop.getName())) { return false; diff --git a/src/main/java/baritone/process/ElytraProcess.java b/src/main/java/baritone/process/ElytraProcess.java index b3420a0d56..7ee911cded 100644 --- a/src/main/java/baritone/process/ElytraProcess.java +++ b/src/main/java/baritone/process/ElytraProcess.java @@ -186,7 +186,7 @@ public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) { } if (ctx.player().isFallFlying() && this.state != State.LANDING && (this.behavior.pathManager.isComplete() || safetyLanding)) { final BetterBlockPos last = this.behavior.pathManager.path.getLast(); - if (last != null && (ctx.player().position().distanceToSqr(last.getCenter()) < (48 * 48) || safetyLanding) && (!goingToLandingSpot || (safetyLanding && this.landingSpot == null))) { + if (last != null && (last.distToCenterSqr(ctx.player().position()) < (48 * 48) || safetyLanding) && (!goingToLandingSpot || (safetyLanding && this.landingSpot == null))) { if (this.landingSearchState == null) { logDirect("Path complete, searching for safe landing spot..."); } @@ -202,7 +202,7 @@ public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) { } } - if (last != null && ctx.player().position().distanceToSqr(last.getCenter()) < 1) { + if (last != null && last.distToCenterSqr(ctx.player().position()) < 1) { if (Baritone.settings().notificationOnPathComplete.value && !reachedGoal) { logNotification("Pathing complete", false); } diff --git a/src/main/java/baritone/process/ExploreProcess.java b/src/main/java/baritone/process/ExploreProcess.java index 514a110e6a..062e07047d 100644 --- a/src/main/java/baritone/process/ExploreProcess.java +++ b/src/main/java/baritone/process/ExploreProcess.java @@ -225,13 +225,13 @@ private JsonChunkFilter(Path path, boolean invert) throws Exception { // ioexcep logDirect("Loaded " + positions.length + " positions"); inFilter = new LongOpenHashSet(); for (MyChunkPos mcp : positions) { - inFilter.add(ChunkPos.asLong(mcp.x, mcp.z)); + inFilter.add(ChunkPos.pack(mcp.x, mcp.z)); } } @Override public Status isAlreadyExplored(int chunkX, int chunkZ) { - if (inFilter.contains(ChunkPos.asLong(chunkX, chunkZ)) ^ invert) { + if (inFilter.contains(ChunkPos.pack(chunkX, chunkZ)) ^ invert) { // either it's on the list of explored chunks, or it's not on the list of unexplored chunks // either way, we have it return Status.EXPLORED; diff --git a/src/main/java/baritone/process/FarmProcess.java b/src/main/java/baritone/process/FarmProcess.java index 4669e46dfb..fbb7f66a2c 100644 --- a/src/main/java/baritone/process/FarmProcess.java +++ b/src/main/java/baritone/process/FarmProcess.java @@ -267,7 +267,7 @@ public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) { } if (state.getBlock() instanceof BonemealableBlock) { BonemealableBlock ig = (BonemealableBlock) state.getBlock(); - if (ig.isValidBonemealTarget(ctx.world(), pos, state) && ig.isBonemealSuccess(ctx.world(), ctx.world().random, pos, state)) { + if (ig.isValidBonemealTarget(ctx.world(), pos, state) && ig.isBonemealSuccess(ctx.world(), ctx.world().getRandom(), pos, state)) { bonemealable.add(pos); } } diff --git a/src/main/java/baritone/process/elytra/BuildLimitPathFinder.java b/src/main/java/baritone/process/elytra/BuildLimitPathFinder.java index 7b572738b5..01624d730f 100644 --- a/src/main/java/baritone/process/elytra/BuildLimitPathFinder.java +++ b/src/main/java/baritone/process/elytra/BuildLimitPathFinder.java @@ -20,9 +20,9 @@ import baritone.Baritone; import baritone.api.utils.BetterBlockPos; import baritone.api.utils.IPlayerContext; +import baritone.api.utils.Pair; import net.minecraft.core.BlockPos; import net.minecraft.core.Vec3i; -import net.minecraft.util.Tuple; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.levelgen.Heightmap; @@ -62,7 +62,7 @@ public BuildLimitPathFinder(IPlayerContext ctx, NetherPathfinderContext netherCt * @param maxPathSize Maximum number of nodes in the returned path * @return A tuple containing the path as a list of BetterBlockPos and a boolean indicating if the path is complete */ - public Tuple, Boolean> generateDirectPath(BetterBlockPos start, BetterBlockPos destination, int bufferDistance, int maxPathSize) { + public Pair, Boolean> generateDirectPath(BetterBlockPos start, BetterBlockPos destination, int bufferDistance, int maxPathSize) { final LinkedList path = new LinkedList<>(); final int stepDistance = 32; @@ -80,10 +80,10 @@ public Tuple, Boolean> generateDirectPath(BetterBlockPos st if(remainingDistanceSq <= bufferDistance * bufferDistance) { // We are within the buffer distance, so we can stop here - return new Tuple<>(path, true); + return new Pair<>(path, true); } else if (remainingDistance <= stepDistance) { path.add(destinationFixed); - return new Tuple<>(path, true); + return new Pair<>(path, true); } double stepRatio = stepDistance / remainingDistance; @@ -94,7 +94,7 @@ public Tuple, Boolean> generateDirectPath(BetterBlockPos st path.add(cur); } - return new Tuple<>(path, false); + return new Pair<>(path, false); } /** @@ -103,7 +103,7 @@ public Tuple, Boolean> generateDirectPath(BetterBlockPos st * @param destination * @return A tuple containing the path that transitions above build limit and a boolean indicating if a transition was found */ - public Tuple,Boolean> generateTransitionUp(BetterBlockPos start, BetterBlockPos destination) { + public Pair,Boolean> generateTransitionUp(BetterBlockPos start, BetterBlockPos destination) { final double deltaX = destination.getX() - start.getX(); final double deltaZ = destination.getZ() - start.getZ(); final double distance = Math.sqrt(deltaX * deltaX + deltaZ * deltaZ); @@ -117,7 +117,7 @@ public Tuple,Boolean> generateTransitionUp(BetterBlockPos s final ChunkPos startChunk = new ChunkPos(start.x >> 4, start.z >> 4); if(!isSkyClear(startChunk, start.y)) { - return new Tuple<>(new LinkedList<>(), false); + return new Pair<>(new LinkedList<>(), false); } LinkedList path = new LinkedList<>(); @@ -134,7 +134,7 @@ public Tuple,Boolean> generateTransitionUp(BetterBlockPos s path.add(next); } - return new Tuple<>(path, true); + return new Pair<>(path, true); } /** @@ -142,22 +142,22 @@ public Tuple,Boolean> generateTransitionUp(BetterBlockPos s * @param start * @return A tuple containing the path (single point) and a boolean indicating if a transition point was found */ - public Tuple,Boolean> generateTransitionDown(BetterBlockPos start) { + public Pair,Boolean> generateTransitionDown(BetterBlockPos start) { final int netherMaxHeight = netherCtx.getMaxHeight() + playerCtx.world().getMinY() - 1; final ChunkPos startChunk = new ChunkPos(start.x >> 4, start.z >> 4); LinkedList path = new LinkedList<>(); if(!isSkyClear(new ChunkPos(start.x >> 4, start.z >> 4), netherMaxHeight-16)) { - return new Tuple<>(new LinkedList<>(), false); + return new Pair<>(new LinkedList<>(), false); } path.add(new BetterBlockPos(startChunk.getMiddleBlockPosition(netherMaxHeight-8))); - return new Tuple<>(path, true); + return new Pair<>(path, true); } public boolean isSkyClear(ChunkPos pos, int y) { - if(!playerCtx.world().getChunkSource().hasChunk(pos.x, pos.z)) { + if(!playerCtx.world().getChunkSource().hasChunk(pos.x(), pos.z())) { return false; } @@ -188,7 +188,7 @@ public CompletableFuture pathFindAsync(BlockPos src, BlockPos d if(srcAboveSupportedHeight && dstAboveSupportedHeight) { var path = generateDirectPath(new BetterBlockPos(src), new BetterBlockPos(dst), 0, maxDirectPathSize); - return CompletableFuture.completedFuture(new UnpackedSegment(path.getA().stream(), path.getB())); + return CompletableFuture.completedFuture(new UnpackedSegment(path.first().stream(), path.second())); } if(isLongDistance) { @@ -196,23 +196,23 @@ public CompletableFuture pathFindAsync(BlockPos src, BlockPos d var directPath = generateDirectPath(new BetterBlockPos(src), new BetterBlockPos(dst), (int)maxDistance, maxDirectPathSize); return CompletableFuture.completedFuture( new UnpackedSegment( - directPath.getA().stream(), - dstAboveSupportedHeight ? directPath.getB() : false + directPath.first().stream(), + dstAboveSupportedHeight ? directPath.second() : false ) ); } else { var transition = generateTransitionUp(new BetterBlockPos(src), new BetterBlockPos(dst)); - var path = transition.getA(); - var success = transition.getB(); + var path = transition.first(); + var success = transition.second(); if(success) { var directPath = generateDirectPath(path.get(path.size()-1), new BetterBlockPos(dst), (int)maxDistance, maxDirectPathSize); - path.addAll(directPath.getA()); + path.addAll(directPath.first()); return CompletableFuture.completedFuture( new UnpackedSegment( path.stream(), - dstAboveSupportedHeight? directPath.getB() : false + dstAboveSupportedHeight? directPath.second() : false ) ); } @@ -230,13 +230,13 @@ public CompletableFuture pathFindAsync(BlockPos src, BlockPos d } else { if(srcAboveSupportedHeight) { var transition = generateTransitionDown(new BetterBlockPos(src)); - List path = transition.getA(); - boolean success = transition.getB(); + List path = transition.first(); + boolean success = transition.second(); if(!success) { BetterBlockPos newDest = distanceXZ > 32 ? new BetterBlockPos(dst) : new BetterBlockPos(dst.getX(), playerCtx.world().getMaxY(), dst.getZ()); var directPath = generateDirectPath(new BetterBlockPos(src), newDest, 0, 2); - return CompletableFuture.completedFuture(new UnpackedSegment(directPath.getA().stream(), directPath.getB())); + return CompletableFuture.completedFuture(new UnpackedSegment(directPath.first().stream(), directPath.second())); } return CompletableFuture.supplyAsync(() -> { @@ -249,13 +249,13 @@ public CompletableFuture pathFindAsync(BlockPos src, BlockPos d if(dstAboveSupportedHeight) { var transition = generateTransitionUp(new BetterBlockPos(src), new BetterBlockPos(dst)); - var path = transition.getA(); - var success = transition.getB(); + var path = transition.first(); + var success = transition.second(); if(success) { var directPath = generateDirectPath(path.get(path.size() - 1), new BetterBlockPos(dst), 0, maxDirectPathSize); - path.addAll(directPath.getA()); - return CompletableFuture.completedFuture(new UnpackedSegment(path.stream(), directPath.getB())); + path.addAll(directPath.first()); + return CompletableFuture.completedFuture(new UnpackedSegment(path.stream(), directPath.second())); } return netherCtx.pathFindAsync(src, new BetterBlockPos(dst.getX(), netherMaxHeight, dst.getZ())); diff --git a/src/main/java/baritone/process/elytra/ElytraBehavior.java b/src/main/java/baritone/process/elytra/ElytraBehavior.java index 1e825234a8..7cc23498e1 100644 --- a/src/main/java/baritone/process/elytra/ElytraBehavior.java +++ b/src/main/java/baritone/process/elytra/ElytraBehavior.java @@ -42,7 +42,7 @@ import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.projectile.FireworkRocketEntity; -import net.minecraft.world.inventory.ClickType; +import net.minecraft.world.inventory.ContainerInput; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.component.Fireworks; @@ -264,7 +264,7 @@ public void pathNextSegment(final int afterIncl) { final Throwable cause = ex.getCause(); if (cause instanceof PathCalculationException) { logDirect("Failed to compute next segment"); - if (ctx.player().distanceToSqr(pathStart.getCenter()) < 16 * 16) { + if (pathStart.distToCenterSqr(ctx.player().position()) < 16 * 16) { logVerbose("Player is near the segment start, therefore repeating this calculation is pointless. Marking as complete"); completePath = true; } @@ -326,7 +326,7 @@ private void pathfindAroundObstacles() { int rangeStartIncl = playerNear; int rangeEndExcl = playerNear; - while (rangeEndExcl < path.size() && npfContext.hasChunk(new ChunkPos(path.get(rangeEndExcl)))) { + while (rangeEndExcl < path.size() && npfContext.hasChunk(ChunkPos.containing(path.get(rangeEndExcl)))) { rangeEndExcl++; } // rangeEndExcl now represents an index either not in the path, or just outside render distance @@ -517,7 +517,7 @@ public void onTick() { } final long now = System.currentTimeMillis(); if ((now - this.timeLastCacheCull) / 1000 > Baritone.settings().elytraTimeBetweenCacheCullSecs.value) { - npfContext.queueCacheCulling(ctx.player().chunkPosition().x, ctx.player().chunkPosition().z, Baritone.settings().elytraCacheCullDistance.value); + npfContext.queueCacheCulling(ctx.player().chunkPosition().x(), ctx.player().chunkPosition().z(), Baritone.settings().elytraCacheCullDistance.value); this.timeLastCacheCull = now; } } @@ -1302,7 +1302,7 @@ private void tickInventoryTransactions() { if (invTickCountdown > 0) invTickCountdown--; } - private void queueWindowClick(int windowId, int slotId, int button, ClickType type) { + private void queueWindowClick(int windowId, int slotId, int button, ContainerInput type) { invTransactionQueue.add(() -> ctx.playerController().windowClick(windowId, slotId, button, type, ctx.player())); } @@ -1332,9 +1332,9 @@ private void trySwapElytra() { if (goodElytraSlot != -1) { final int CHEST_SLOT = 6; final int slotId = goodElytraSlot < 9 ? goodElytraSlot + 36 : goodElytraSlot; - queueWindowClick(ctx.player().inventoryMenu.containerId, slotId, 0, ClickType.PICKUP); - queueWindowClick(ctx.player().inventoryMenu.containerId, CHEST_SLOT, 0, ClickType.PICKUP); - queueWindowClick(ctx.player().inventoryMenu.containerId, slotId, 0, ClickType.PICKUP); + queueWindowClick(ctx.player().inventoryMenu.containerId, slotId, 0, ContainerInput.PICKUP); + queueWindowClick(ctx.player().inventoryMenu.containerId, CHEST_SLOT, 0, ContainerInput.PICKUP); + queueWindowClick(ctx.player().inventoryMenu.containerId, slotId, 0, ContainerInput.PICKUP); } } diff --git a/src/main/java/baritone/process/elytra/NetherPathfinderContext.java b/src/main/java/baritone/process/elytra/NetherPathfinderContext.java index 52113817f2..3ed1e19155 100644 --- a/src/main/java/baritone/process/elytra/NetherPathfinderContext.java +++ b/src/main/java/baritone/process/elytra/NetherPathfinderContext.java @@ -47,8 +47,6 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantReadWriteLock; -import static net.minecraft.world.level.chunk.LevelChunkSection.SECTION_SIZE; - /** * @author Brady */ @@ -65,6 +63,7 @@ public final class NetherPathfinderContext implements IElytraPathFinder { } } private static final BlockState AIR_BLOCK_STATE = Blocks.AIR.defaultBlockState(); + private static final int SECTION_SIZE = 16; // This lock must be held while there are active pointers to chunks in java, // but we just hold it for the entire tick so we don't have to think much about it. public final ReentrantReadWriteLock rwl = new ReentrantReadWriteLock(); @@ -99,7 +98,7 @@ public NetherPathfinderContext(long seed, Path cache, Level world) { } public boolean hasChunk(ChunkPos pos) { - return NetherPathfinder.hasChunkFromJava(this.context, pos.x, pos.z); + return NetherPathfinder.hasChunkFromJava(this.context, pos.x(), pos.z()); } public void queueCacheCulling(int chunkX, int chunkZ, int maxDistanceBlocks) { @@ -125,7 +124,7 @@ public void queueForPacking(final LevelChunk chunkIn) { try { // we might free this chunk this.boi.chunkPtr = 0L; - long ptr = NetherPathfinder.allocateAndInsertChunk(this.context, chunk.getPos().x, chunk.getPos().z); + long ptr = NetherPathfinder.allocateAndInsertChunk(this.context, chunk.getPos().x(), chunk.getPos().z()); writeChunkData(chunk, ptr); } finally { writeLock.unlock(); @@ -140,7 +139,7 @@ public void queueBlockUpdate(BlockChangeEvent event) { // not inserting or deleting from the cache hashmap but it would still be bad for this function to race with itself writeLock.lock(); try { - long ptr = NetherPathfinder.getChunk(this.context, chunkPos.x, chunkPos.z); + long ptr = NetherPathfinder.getChunk(this.context, chunkPos.x(), chunkPos.z()); if (ptr == 0) return; // this shouldn't ever happen event.getBlocks().forEach(pair -> { BlockPos pos = pair.first().below(minY); diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index 1a19415848..7a8420d8e2 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -109,7 +109,7 @@ public BlockState get0(int x, int y, int z) { // Mickey resigned // we can just skip the mc.world.getChunk lookup // which is a Long2ObjectOpenHashMap.get // see issue #113 - if (cached != null && cached.getPos().x == x >> 4 && cached.getPos().z == z >> 4) { + if (cached != null && cached.getPos().x() == x >> 4 && cached.getPos().z() == z >> 4) { return getFromChunk(cached, x, y, z); } LevelChunk chunk = provider.getChunk(x >> 4, z >> 4, ChunkStatus.FULL, false); @@ -141,7 +141,7 @@ public BlockState get0(int x, int y, int z) { // Mickey resigned public boolean isLoaded(int x, int z) { LevelChunk prevChunk = prev; - if (prevChunk != null && prevChunk.getPos().x == x >> 4 && prevChunk.getPos().z == z >> 4) { + if (prevChunk != null && prevChunk.getPos().x() == x >> 4 && prevChunk.getPos().z() == z >> 4) { return true; } prevChunk = provider.getChunk(x >> 4, z >> 4, ChunkStatus.FULL, false); diff --git a/src/main/java/baritone/utils/GuiClick.java b/src/main/java/baritone/utils/GuiClick.java index b9b0e09e45..fb8410134c 100644 --- a/src/main/java/baritone/utils/GuiClick.java +++ b/src/main/java/baritone/utils/GuiClick.java @@ -25,7 +25,7 @@ import com.mojang.blaze3d.vertex.BufferBuilder; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.ChatFormatting; -import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.GuiGraphicsExtractor; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.input.MouseButtonEvent; import net.minecraft.client.player.LocalPlayer; @@ -64,15 +64,15 @@ public boolean isPauseScreen() { } @Override - public void render(GuiGraphics stack, int mouseX, int mouseY, float partialTicks) { + public void extractRenderState(GuiGraphicsExtractor grapics, int mouseX, int mouseY, float partialTicks) { double mx = mc.mouseHandler.xpos(); double my = mc.mouseHandler.ypos(); my = mc.getWindow().getScreenHeight() - my; my *= mc.getWindow().getHeight() / (double) mc.getWindow().getScreenHeight(); mx *= mc.getWindow().getWidth() / (double) mc.getWindow().getScreenWidth(); - Vec3 near = toWorld(mx, my, 0); - Vec3 far = toWorld(mx, my, 1); // "Use 0.945 that's what stack overflow says" - leijurv + Vec3 near = toWorld(mx, my, 1); + Vec3 far = toWorld(mx, my, 0); // "Use 0.945 that's what stack overflow says" - leijurv if (near != null && far != null) { Vec3 viewerPos = new Vec3(PathRenderer.posX(), PathRenderer.posY(), PathRenderer.posZ()); @@ -85,7 +85,7 @@ public void render(GuiGraphics stack, int mouseX, int mouseY, float partialTicks } @Override - public void renderBackground(GuiGraphics stack, int mouseX, int mouseY, float partialTicks) { + public void extractBackground(GuiGraphicsExtractor grapics, int mouseX, int mouseY, float partialTicks) { // Prevent default background rendering } diff --git a/src/main/java/baritone/utils/IRenderer.java b/src/main/java/baritone/utils/IRenderer.java index a29e758ff6..4cf39bdac0 100644 --- a/src/main/java/baritone/utils/IRenderer.java +++ b/src/main/java/baritone/utils/IRenderer.java @@ -23,13 +23,17 @@ import baritone.utils.accessor.IRenderPipelines; import baritone.utils.accessor.IRenderType; import com.mojang.blaze3d.pipeline.BlendFunction; +import com.mojang.blaze3d.pipeline.ColorTargetState; +import com.mojang.blaze3d.pipeline.DepthStencilState; import com.mojang.blaze3d.pipeline.RenderPipeline; -import com.mojang.blaze3d.platform.DepthTestFunction; -import com.mojang.blaze3d.platform.DestFactor; -import com.mojang.blaze3d.platform.SourceFactor; +import com.mojang.blaze3d.platform.CompareOp; +import com.mojang.blaze3d.platform.BlendFactor; +import com.mojang.blaze3d.PrimitiveTopology; import com.mojang.blaze3d.vertex.*; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderPipelines; +import net.minecraft.client.renderer.BindGroupLayouts; +import net.minecraft.client.renderer.StagedVertexBuffer; import net.minecraft.client.renderer.blockentity.BeaconRenderer; import net.minecraft.client.renderer.rendertype.RenderSetup; import net.minecraft.client.renderer.rendertype.RenderType; @@ -45,39 +49,38 @@ public interface IRenderer { - Tesselator tessellator = Tesselator.getInstance(); + StagedVertexBuffer stagedVertexBuffer = new StagedVertexBuffer(() -> "Baritone Render", 256); IEntityRenderManager renderManager = (IEntityRenderManager) Minecraft.getInstance().getEntityRenderDispatcher(); Settings settings = BaritoneAPI.getSettings(); RenderPipeline.Snippet BARITONE_LINES_SNIPPET = RenderPipeline.builder(((IRenderPipelines) new RenderPipelines()).getLinesSnippet()) - .withBlend(new BlendFunction( - SourceFactor.SRC_ALPHA, - DestFactor.ONE_MINUS_SRC_ALPHA, - SourceFactor.ONE, - DestFactor.ZERO - )) - .withDepthWrite(false) + .withColorTargetState(new ColorTargetState(new BlendFunction( + BlendFactor.SRC_ALPHA, + BlendFactor.ONE_MINUS_SRC_ALPHA, + BlendFactor.ONE, + BlendFactor.ZERO + ))) + .withDepthStencilState(new DepthStencilState(CompareOp.LESS_THAN_OR_EQUAL, false)) .withCull(false) .buildSnippet(); RenderPipeline.Snippet BARITONE_BEACON_BEAM_SNIPPET = RenderPipeline.builder(((IRenderPipelines) new RenderPipelines()).getMatricesFogSnippet()) .withVertexShader("core/rendertype_beacon_beam") .withFragmentShader("core/rendertype_beacon_beam") - .withSampler("Sampler0") - .withVertexFormat(DefaultVertexFormat.BLOCK, VertexFormat.Mode.QUADS) + .withBindGroupLayout(BindGroupLayouts.SAMPLER0) + .withVertexBinding(0, DefaultVertexFormat.BLOCK) + .withPrimitiveTopology(PrimitiveTopology.QUADS) .buildSnippet(); RenderPipeline BEACON_BEAM_OPAQUE = ((IRenderPipelines) new RenderPipelines()).baritone$registerPipeline(RenderPipeline.builder(BARITONE_BEACON_BEAM_SNIPPET) .withLocation("pipeline/baritone_beacon_beam_opaque") - .withDepthWrite(false) - .withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST) + .withDepthStencilState(new DepthStencilState(CompareOp.ALWAYS_PASS, false)) .withCull(true) .build()); RenderPipeline BEACON_BEAM_TRANSLUCENT = ((IRenderPipelines) new RenderPipelines()).baritone$registerPipeline(RenderPipeline.builder(BARITONE_BEACON_BEAM_SNIPPET) .withLocation("pipeline/baritone_beacon_beam_translucent") - .withDepthWrite(false) - .withBlend(BlendFunction.TRANSLUCENT) - .withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST) + .withColorTargetState(new ColorTargetState(BlendFunction.TRANSLUCENT)) + .withDepthStencilState(new DepthStencilState(CompareOp.ALWAYS_PASS, false)) .withCull(true) .build()); @@ -85,18 +88,16 @@ public interface IRenderer { "renderType/baritone_lines_with_depth", RenderSetup.builder(RenderPipeline.builder(BARITONE_LINES_SNIPPET) .withLocation("pipelines/baritone_lines_with_depth") - .withDepthTestFunction(DepthTestFunction.LEQUAL_DEPTH_TEST) + .withDepthStencilState(new DepthStencilState(CompareOp.LESS_THAN_OR_EQUAL, false)) .build()) - .bufferSize(256) .createRenderSetup() ); RenderType linesNoDepthRenderType = ((IRenderType) RenderTypes.lines()).createRenderType( "renderType/baritone_lines_no_depth", RenderSetup.builder(RenderPipeline.builder(BARITONE_LINES_SNIPPET) .withLocation("pipelines/baritone_lines_no_depth") - .withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST) + .withDepthStencilState(new DepthStencilState(CompareOp.ALWAYS_PASS, false)) .build()) - .bufferSize(256) .createRenderSetup() ); @@ -110,6 +111,7 @@ public interface IRenderer { .createRenderSetup()) ); + StagedVertexBuffer.Draw[] draw = {null}; float[] color = new float[]{1.0F, 1.0F, 1.0F, 255.0F}; static void glColor(Color color, float alpha) { @@ -122,7 +124,8 @@ static void glColor(Color color, float alpha) { static BufferBuilder startLines(Color color, float alpha) { glColor(color, alpha); - return tessellator.begin(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR_NORMAL_LINE_WIDTH); + draw[0] = stagedVertexBuffer.appendDraw(DefaultVertexFormat.POSITION_COLOR_NORMAL_LINE_WIDTH, PrimitiveTopology.LINES); + return (BufferBuilder) stagedVertexBuffer.getVertexBuilder(draw[0]); } static BufferBuilder startLines(Color color) { @@ -130,25 +133,21 @@ static BufferBuilder startLines(Color color) { } static void endLines(BufferBuilder bufferBuilder, boolean ignoredDepth) { - MeshData meshData = bufferBuilder.build(); - if (meshData != null) { - if (ignoredDepth) { - linesNoDepthRenderType.draw(meshData); - } else { - linesWithDepthRenderType.draw(meshData); - } - } + endBuffer(bufferBuilder, ignoredDepth ? linesNoDepthRenderType : linesWithDepthRenderType); } static BufferBuilder startBlockQuads() { - return tessellator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK); + draw[0] = stagedVertexBuffer.appendDraw(DefaultVertexFormat.BLOCK, PrimitiveTopology.QUADS); + return (BufferBuilder) stagedVertexBuffer.getVertexBuilder(draw[0]); } static void endBuffer(BufferBuilder bufferBuilder, RenderType renderType) { - MeshData meshData = bufferBuilder.build(); - if (meshData != null) { - renderType.draw(meshData); + stagedVertexBuffer.upload(); + StagedVertexBuffer.ExecuteInfo info = stagedVertexBuffer.getExecuteInfo(draw[0]); + if (info != null) { + renderType.prepare().drawFromBuffer(info); } + stagedVertexBuffer.endFrame(); } static void emitLine(BufferBuilder bufferBuilder, PoseStack stack, double x1, double y1, double z1, double x2, double y2, double z2, float lineWidth) { diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index 95506ab5ce..6339303e05 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -74,8 +74,8 @@ public static void render(RenderEvent event, PathingBehavior behavior) { if (ctx.world() == null) { return; } - if (ctx.minecraft().screen instanceof GuiClick) { - ((GuiClick) ctx.minecraft().screen).onRender(event.getModelViewStack(), event.getProjectionMatrix()); + if (ctx.minecraft().gui.screen() instanceof GuiClick) { + ((GuiClick) ctx.minecraft().gui.screen()).onRender(event.getModelViewStack(), event.getProjectionMatrix()); } final float partialTicks = event.getPartialTicks(); diff --git a/src/main/java/baritone/utils/player/BaritonePlayerController.java b/src/main/java/baritone/utils/player/BaritonePlayerController.java index b7e729b70d..61ed357b3f 100644 --- a/src/main/java/baritone/utils/player/BaritonePlayerController.java +++ b/src/main/java/baritone/utils/player/BaritonePlayerController.java @@ -26,7 +26,7 @@ import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.inventory.ClickType; +import net.minecraft.world.inventory.ContainerInput; import net.minecraft.world.level.GameType; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; @@ -67,8 +67,8 @@ public void resetBlockRemoving() { } @Override - public void windowClick(int windowId, int slotId, int mouseButton, ClickType type, Player player) { - mc.gameMode.handleInventoryMouseClick(windowId, slotId, mouseButton, type, player); + public void windowClick(int windowId, int slotId, int mouseButton, ContainerInput type, Player player) { + mc.gameMode.handleContainerInput(windowId, slotId, mouseButton, type, player); } @Override diff --git a/src/main/java/baritone/utils/schematic/litematica/LitematicaHelper.java b/src/main/java/baritone/utils/schematic/litematica/LitematicaHelper.java index febe985d23..a4b806f15b 100644 --- a/src/main/java/baritone/utils/schematic/litematica/LitematicaHelper.java +++ b/src/main/java/baritone/utils/schematic/litematica/LitematicaHelper.java @@ -19,6 +19,7 @@ import baritone.api.schematic.CompositeSchematic; import baritone.api.schematic.IStaticSchematic; +import baritone.api.utils.Pair; import baritone.utils.schematic.StaticSchematic; import fi.dy.masa.litematica.Litematica; import fi.dy.masa.litematica.data.DataManager; @@ -28,7 +29,6 @@ import fi.dy.masa.litematica.world.WorldSchematic; import net.minecraft.core.BlockPos; import net.minecraft.core.Vec3i; -import net.minecraft.util.Tuple; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Mirror; import net.minecraft.world.level.block.Rotation; @@ -93,7 +93,7 @@ private static Vec3i transform(Vec3i in, Mirror mirror, Rotation rotation) { * @param i index of the Schematic in the schematic placement list. * @return The transformed schematic and the position of its minimum corner */ - public static Tuple getSchematic(int i) { + public static Pair getSchematic(int i) { SchematicPlacement placement = getPlacement(i); int minX = Integer.MAX_VALUE; int minY = Integer.MAX_VALUE; @@ -129,7 +129,7 @@ public static Tuple getSchematic(int i) { Vec3i pos = entry.getKey().offset(-minX, -minY, -minZ); composite.put(entry.getValue(), pos.getX(), pos.getY(), pos.getZ()); } - return new Tuple<>(composite, placement.getOrigin().offset(minX, minY, minZ)); + return new Pair<>(composite, placement.getOrigin().offset(minX, minY, minZ)); } private static class LitematicaPlacementSchematic extends CompositeSchematic implements IStaticSchematic { diff --git a/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java b/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java index 35b11c8e1d..44b493680e 100644 --- a/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java +++ b/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java @@ -18,10 +18,10 @@ package baritone.utils.schematic.schematica; import baritone.api.schematic.IStaticSchematic; +import baritone.api.utils.Pair; import com.github.lunatrius.schematica.Schematica; import com.github.lunatrius.schematica.proxy.ClientProxy; import net.minecraft.core.BlockPos; -import net.minecraft.util.Tuple; import java.util.Optional; public enum SchematicaHelper { @@ -36,9 +36,9 @@ public static boolean isSchematicaPresent() { } } - public static Optional> getOpenSchematic() { + public static Optional> getOpenSchematic() { return Optional.ofNullable(ClientProxy.schematic) - .map(world -> new Tuple<>(new SchematicAdapter(world), world.position)); + .map(world -> new Pair<>(new SchematicAdapter(world), world.position)); } } diff --git a/tweaker/build.gradle b/tweaker/build.gradle index c74bd66614..105c9d99b2 100644 --- a/tweaker/build.gradle +++ b/tweaker/build.gradle @@ -97,7 +97,7 @@ jar { } task proguard(type: ProguardTask) { - proguardVersion "7.4.2" + proguardVersion "7.9.1" } task createDist(type: CreateDistTask, dependsOn: proguard)