From 55cb180755aa3bb83fae63a56c208a8728cef942 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Sat, 26 Oct 2024 12:34:31 -0700 Subject: [PATCH 1/3] 1.21.3 --- fabric/src/main/resources/fabric.mod.json | 2 +- forge/src/main/resources/META-INF/mods.toml | 2 +- gradle.properties | 8 +-- neoforge/build.gradle | 2 +- .../resources/META-INF/neoforge.mods.toml | 2 +- src/api/java/baritone/api/Settings.java | 7 --- .../baritone/api/utils/BetterBlockPos.java | 4 +- .../baritone/api/utils/BlockOptionalMeta.java | 49 +++++---------- .../java/baritone/api/utils/SettingsUtil.java | 5 +- .../baritone/api/utils/gui/BaritoneToast.java | 60 ++----------------- .../launch/mixins/MixinLivingEntity.java | 9 +-- .../launch/mixins/MixinWorldRenderer.java | 3 +- src/main/java/baritone/cache/ChunkPacker.java | 2 +- .../baritone/cache/FasterWorldScanner.java | 4 +- .../movement/movements/MovementFall.java | 2 +- .../java/baritone/process/FarmProcess.java | 2 +- .../BlockStateInterfaceAccessWrapper.java | 2 +- src/main/java/baritone/utils/IRenderer.java | 9 ++- .../java/baritone/utils/PathRenderer.java | 6 +- .../baritone/utils/PlayerMovementInput.java | 25 +++++--- src/main/java/baritone/utils/ToolSet.java | 12 ++-- .../format/defaults/LitematicaSchematic.java | 12 +++- .../format/defaults/MCEditSchematic.java | 10 +++- .../format/defaults/SpongeSchematic.java | 7 ++- 24 files changed, 100 insertions(+), 146 deletions(-) diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index d4bf5e0b8..4984750cc 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -25,6 +25,6 @@ "depends": { "fabricloader": ">=0.14.22", - "minecraft": ["1.21","1.21.1"] + "minecraft": ["1.21.2","1.21.3"] } } diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index d6d02e254..0f543441f 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -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, 1.21.1]" +versionRange="[1.21.2, 1.21.3]" ordering="NONE" side="BOTH" diff --git a/gradle.properties b/gradle.properties index aa200b0ca..0407ff60c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,13 +8,13 @@ archives_base_name=baritone java_version=21 -minecraft_version=1.21 +minecraft_version=1.21.3 -forge_version=51.0.16 +forge_version=53.0.0 -neoforge_version=20-beta +neoforge_version=3-beta -fabric_version=0.15.11 +fabric_version=0.16.7 nether_pathfinder_version=1.4.1 diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 9f521ca11..6661c71fb 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -26,7 +26,7 @@ archivesBaseName = archivesBaseName + "-neoforge" unimined.minecraft { - neoForged { + neoForge { loader project.neoforge_version mixinConfig ["mixins.baritone.json"] } diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml index 10c828508..e670a2bea 100644 --- a/neoforge/src/main/resources/META-INF/neoforge.mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -35,6 +35,6 @@ 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,1.21.1]" +versionRange="[1.21.2,1.21.3]" ordering="NONE" side="BOTH" diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index d9cb501ef..38a93cf1e 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -656,13 +656,6 @@ public final class Settings { */ public final Setting logAsToast = new Setting<>(false); - /** - * The time of how long the message in the pop-up will display - *

- * If below 1000L (1sec), it's better to disable this - */ - public final Setting toastTimer = new Setting<>(5000L); - /** * Print all the debug messages to chat */ diff --git a/src/api/java/baritone/api/utils/BetterBlockPos.java b/src/api/java/baritone/api/utils/BetterBlockPos.java index 5add76555..4225985a0 100644 --- a/src/api/java/baritone/api/utils/BetterBlockPos.java +++ b/src/api/java/baritone/api/utils/BetterBlockPos.java @@ -157,7 +157,7 @@ public BetterBlockPos below(int amt) { @Override public BetterBlockPos relative(Direction dir) { - Vec3i vec = dir.getNormal(); + Vec3i vec = dir.getUnitVec3i(); return new BetterBlockPos(x + vec.getX(), y + vec.getY(), z + vec.getZ()); } @@ -166,7 +166,7 @@ public BetterBlockPos relative(Direction dir, int dist) { if (dist == 0) { return this; } - Vec3i vec = dir.getNormal(); + Vec3i vec = dir.getUnitVec3i(); return new BetterBlockPos(x + vec.getX() * dist, y + vec.getY() * dist, z + vec.getZ() * dist); } diff --git a/src/api/java/baritone/api/utils/BlockOptionalMeta.java b/src/api/java/baritone/api/utils/BlockOptionalMeta.java index bca2875c3..1d5af8359 100644 --- a/src/api/java/baritone/api/utils/BlockOptionalMeta.java +++ b/src/api/java/baritone/api/utils/BlockOptionalMeta.java @@ -25,6 +25,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.commands.Commands; import net.minecraft.core.LayeredRegistryAccess; +import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; import net.minecraft.resources.RegistryDataLoader; import net.minecraft.resources.ResourceKey; @@ -42,6 +43,7 @@ import net.minecraft.server.packs.resources.CloseableResourceManager; import net.minecraft.server.packs.resources.MultiPackResourceManager; import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.tags.TagLoader; import net.minecraft.world.RandomSequences; import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.item.Item; @@ -229,8 +231,8 @@ private static VanillaPackResources getVanillaServerPack() { private static synchronized List drops(Block b) { return drops.computeIfAbsent(b, block -> { - ResourceLocation lootTableLocation = block.getLootTable().location(); - if (lootTableLocation.equals(BuiltInLootTables.EMPTY.location())) { + Optional> optionalLootTableKey = block.getLootTable(); + if (optionalLootTableKey.isEmpty()) { return Collections.emptyList(); } else { List items = new ArrayList<>(); @@ -251,13 +253,13 @@ private static synchronized List drops(Block b) { } private static List getDrops(Block state, LootParams.Builder params) { - ResourceKey lv = state.getLootTable(); - if (lv == BuiltInLootTables.EMPTY) { + Optional> lv = state.getLootTable(); + if (lv.isEmpty()) { return Collections.emptyList(); } else { LootParams lv2 = params.withParameter(LootContextParams.BLOCK_STATE, state.defaultBlockState()).create(LootContextParamSets.BLOCK); ServerLevelStub lv3 = (ServerLevelStub) lv2.getLevel(); - LootTable lv4 = lv3.holder().getLootTable(lv); + LootTable lv4 = lv3.holder().getLootTable(lv.get()); return((ILootTable) lv4).invokeGetRandomItems(new LootContext.Builder(lv2).withOptionalRandomSeed(1).create(null)); } } @@ -307,39 +309,16 @@ public static Unsafe getUnsafe() { public static CompletableFuture load() { PackRepository packRepository = Minecraft.getInstance().getResourcePackRepository(); CloseableResourceManager closeableResourceManager = new MultiPackResourceManager(PackType.SERVER_DATA, packRepository.openAllSelected()); - LayeredRegistryAccess layeredRegistryAccess = loadAndReplaceLayer( - closeableResourceManager, RegistryLayer.createRegistryAccess(), RegistryLayer.WORLDGEN, RegistryDataLoader.WORLDGEN_REGISTRIES + LayeredRegistryAccess layeredRegistryAccess = RegistryLayer.createRegistryAccess(); + List> pendingTags = TagLoader.loadTagsForExistingRegistries( + closeableResourceManager, layeredRegistryAccess.getLayer(RegistryLayer.STATIC) ); - return ReloadableServerResources.loadResources( - closeableResourceManager, + return ReloadableServerRegistries.reload( layeredRegistryAccess, - WorldDataConfiguration.DEFAULT.enabledFeatures(), - Commands.CommandSelection.INTEGRATED, - 2, - Runnable::run, + pendingTags, + closeableResourceManager, Minecraft.getInstance() - ).thenApply(reloadableServerResources -> reloadableServerResources.fullRegistries().get()); - } - - private static LayeredRegistryAccess loadAndReplaceLayer( - ResourceManager resourceManager, - LayeredRegistryAccess registryAccess, - RegistryLayer registryLayer, - List> registryData - ) { - RegistryAccess.Frozen frozen = loadLayer(resourceManager, registryAccess, registryLayer, registryData); - return registryAccess.replaceFrom(registryLayer, frozen); + ).thenApply(r -> r.layers().compositeAccess()); } - - private static RegistryAccess.Frozen loadLayer( - ResourceManager resourceManager, - LayeredRegistryAccess registryAccess, - RegistryLayer registryLayer, - List> registryData - ) { - RegistryAccess.Frozen frozen = registryAccess.getAccessForLoading(registryLayer); - return RegistryDataLoader.load(resourceManager, frozen, registryData); - } - } } diff --git a/src/api/java/baritone/api/utils/SettingsUtil.java b/src/api/java/baritone/api/utils/SettingsUtil.java index 23ffd7b03..1987404c0 100644 --- a/src/api/java/baritone/api/utils/SettingsUtil.java +++ b/src/api/java/baritone/api/utils/SettingsUtil.java @@ -21,6 +21,7 @@ import baritone.api.Settings; import net.minecraft.client.Minecraft; import net.minecraft.core.Direction; +import net.minecraft.core.Holder; import net.minecraft.core.Registry; import net.minecraft.core.Vec3i; import net.minecraft.core.registries.BuiltInRegistries; @@ -241,8 +242,8 @@ private enum Parser implements ISettingParser { BlockUtils::blockToString ), ITEM( - Item.class, - str -> BuiltInRegistries.ITEM.get(ResourceLocation.parse(str.trim())), // TODO this now returns AIR on failure instead of null, is that an issue? + Item.class, + str -> BuiltInRegistries.ITEM.get(ResourceLocation.parse(str.trim())).map(Holder.Reference::value).orElse(null), item -> BuiltInRegistries.ITEM.getKey(item).toString() ), LIST() { diff --git a/src/api/java/baritone/api/utils/gui/BaritoneToast.java b/src/api/java/baritone/api/utils/gui/BaritoneToast.java index e8a24bc6e..effa0b804 100644 --- a/src/api/java/baritone/api/utils/gui/BaritoneToast.java +++ b/src/api/java/baritone/api/utils/gui/BaritoneToast.java @@ -17,65 +17,13 @@ package baritone.api.utils.gui; -import com.mojang.blaze3d.platform.GlStateManager; -import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.gui.components.toasts.Toast; -import net.minecraft.client.gui.components.toasts.ToastComponent; +import net.minecraft.client.gui.components.toasts.SystemToast; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; - -public class BaritoneToast implements Toast { - private String title; - private String subtitle; - private long firstDrawTime; - private boolean newDisplay; - private long totalShowTime; - - public BaritoneToast(Component titleComponent, Component subtitleComponent, long totalShowTime) { - this.title = titleComponent.getString(); - this.subtitle = subtitleComponent == null ? null : subtitleComponent.getString(); - this.totalShowTime = totalShowTime; - } - - public Visibility render(GuiGraphics gui, ToastComponent toastGui, long delta) { - if (this.newDisplay) { - this.firstDrawTime = delta; - this.newDisplay = false; - } - - - //TODO: check - gui.blit(ResourceLocation.parse("textures/gui/toasts.png"), 0, 0, 0, 32, 160, 32); - - if (this.subtitle == null) { - gui.drawString(toastGui.getMinecraft().font, this.title, 18, 12, -11534256); - } else { - gui.drawString(toastGui.getMinecraft().font, this.title, 18, 7, -11534256); - gui.drawString(toastGui.getMinecraft().font, this.subtitle, 18, 18, -16777216); - } - - return delta - this.firstDrawTime < totalShowTime ? Visibility.SHOW : Visibility.HIDE; - } - - public void setDisplayedText(Component titleComponent, Component subtitleComponent) { - this.title = titleComponent.getString(); - this.subtitle = subtitleComponent == null ? null : subtitleComponent.getString(); - this.newDisplay = true; - } - - public static void addOrUpdate(ToastComponent toast, Component title, Component subtitle, long totalShowTime) { - BaritoneToast baritonetoast = toast.getToast(BaritoneToast.class, new Object()); - - if (baritonetoast == null) { - toast.addToast(new BaritoneToast(title, subtitle, totalShowTime)); - } else { - baritonetoast.setDisplayedText(title, subtitle); - } - } +public class BaritoneToast { + private static final SystemToast.SystemToastId BARITONE_TOAST_ID = new SystemToast.SystemToastId(5000L); public static void addOrUpdate(Component title, Component subtitle) { - addOrUpdate(Minecraft.getInstance().getToasts(), title, subtitle, baritone.api.BaritoneAPI.getSettings().toastTimer.value); + SystemToast.addOrUpdate(Minecraft.getInstance().getToastManager(), BARITONE_TOAST_ID, title, subtitle); } } diff --git a/src/launch/java/baritone/launch/mixins/MixinLivingEntity.java b/src/launch/java/baritone/launch/mixins/MixinLivingEntity.java index ada92f6c2..6a4ee0e31 100644 --- a/src/launch/java/baritone/launch/mixins/MixinLivingEntity.java +++ b/src/launch/java/baritone/launch/mixins/MixinLivingEntity.java @@ -32,6 +32,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import java.util.Optional; @@ -81,13 +82,13 @@ private float overrideYaw(LivingEntity self) { } @Inject( - method = "travel", + method = "updateFallFlyingMovement", at = @At( value = "INVOKE", target = "net/minecraft/world/entity/LivingEntity.getLookAngle()Lnet/minecraft/world/phys/Vec3;" ) ) - private void onPreElytraMove(Vec3 direction, CallbackInfo ci) { + private void onPreElytraMove(Vec3 direction, final CallbackInfoReturnable cir) { this.getBaritone().ifPresent(baritone -> { this.elytraRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.MOTION_UPDATE, this.getYRot(), this.getXRot()); baritone.getGameEventHandler().onPlayerRotationMove(this.elytraRotationEvent); @@ -97,14 +98,14 @@ private void onPreElytraMove(Vec3 direction, CallbackInfo ci) { } @Inject( - method = "travel", + method = "travelFallFlying", at = @At( value = "INVOKE", target = "net/minecraft/world/entity/LivingEntity.move(Lnet/minecraft/world/entity/MoverType;Lnet/minecraft/world/phys/Vec3;)V", shift = At.Shift.AFTER ) ) - private void onPostElytraMove(Vec3 direction, CallbackInfo ci) { + private void onPostElytraMove(final CallbackInfo ci) { if (this.elytraRotationEvent != null) { this.setYRot(this.elytraRotationEvent.getOriginal().getYaw()); this.setXRot(this.elytraRotationEvent.getOriginal().getPitch()); diff --git a/src/launch/java/baritone/launch/mixins/MixinWorldRenderer.java b/src/launch/java/baritone/launch/mixins/MixinWorldRenderer.java index fd4dd1b96..d802fe501 100644 --- a/src/launch/java/baritone/launch/mixins/MixinWorldRenderer.java +++ b/src/launch/java/baritone/launch/mixins/MixinWorldRenderer.java @@ -20,6 +20,7 @@ import baritone.api.BaritoneAPI; import baritone.api.IBaritone; import baritone.api.event.events.RenderEvent; +import com.mojang.blaze3d.resource.GraphicsResourceAllocator; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Camera; import net.minecraft.client.DeltaTracker; @@ -44,7 +45,7 @@ public class MixinWorldRenderer { method = "renderLevel", at = @At("RETURN") ) - private void onStartHand(final DeltaTracker deltaTracker, final boolean bl, final Camera camera, final GameRenderer gameRenderer, final LightTexture lightTexture, final Matrix4f matrix4f, final Matrix4f matrix4f2, final CallbackInfo ci) { + private void onStartHand(final GraphicsResourceAllocator graphicsResourceAllocator, final DeltaTracker deltaTracker, final boolean bl, final Camera camera, final GameRenderer gameRenderer, final LightTexture lightTexture, final Matrix4f matrix4f, final Matrix4f matrix4f2, final CallbackInfo ci) { for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { PoseStack poseStack = new PoseStack(); poseStack.mulPose(matrix4f); diff --git a/src/main/java/baritone/cache/ChunkPacker.java b/src/main/java/baritone/cache/ChunkPacker.java index 5d619543d..5c8580187 100644 --- a/src/main/java/baritone/cache/ChunkPacker.java +++ b/src/main/java/baritone/cache/ChunkPacker.java @@ -84,7 +84,7 @@ public static CachedChunk pack(LevelChunk chunk) { 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+chunk.getMinBuildHeight(), z)); + specialBlocks.computeIfAbsent(name, b -> new ArrayList<>()).add(new BlockPos(x, y+chunk.getMinY(), z)); } } } diff --git a/src/main/java/baritone/cache/FasterWorldScanner.java b/src/main/java/baritone/cache/FasterWorldScanner.java index e364fd7b4..4d6e4fc2c 100644 --- a/src/main/java/baritone/cache/FasterWorldScanner.java +++ b/src/main/java/baritone/cache/FasterWorldScanner.java @@ -156,7 +156,7 @@ private Stream scanChunkInternal(IPlayerContext ctx, BlockOptionalMeta long chunkX = (long) pos.x << 4; long chunkZ = (long) pos.z << 4; - int playerSectionY = (ctx.playerFeet().y - ctx.world().getMinBuildHeight()) >> 4; + int playerSectionY = (ctx.playerFeet().y - ctx.world().getMinY()) >> 4; return collectChunkSections(lookup, chunkProvider.getChunk(pos.x, pos.z, false), chunkX, chunkZ, playerSectionY).stream(); } @@ -165,7 +165,7 @@ private Stream scanChunkInternal(IPlayerContext ctx, BlockOptionalMeta private List collectChunkSections(BlockOptionalMetaLookup lookup, LevelChunk chunk, long chunkX, long chunkZ, int playerSection) { // iterate over sections relative to player List blocks = new ArrayList<>(); - int chunkY = chunk.getMinBuildHeight(); + int chunkY = chunk.getMinY(); LevelChunkSection[] sections = chunk.getSections(); int l = sections.length; int i = playerSection - 1; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index 913b410aa..dee5a0972 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -140,7 +140,7 @@ public MovementState updateState(MovementState state) { } state.setInput(Input.MOVE_FORWARD, true); } - Vec3i avoid = Optional.ofNullable(avoid()).map(Direction::getNormal).orElse(null); + Vec3i avoid = Optional.ofNullable(avoid()).map(Direction::getUnitVec3i).orElse(null); if (avoid == null) { avoid = src.subtract(dest); } else { diff --git a/src/main/java/baritone/process/FarmProcess.java b/src/main/java/baritone/process/FarmProcess.java index b38ba767f..f4e79bcbd 100644 --- a/src/main/java/baritone/process/FarmProcess.java +++ b/src/main/java/baritone/process/FarmProcess.java @@ -310,7 +310,7 @@ public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) { if (!(ctx.world().getBlockState(pos.relative(dir)).getBlock() instanceof AirBlock)) { continue; } - Vec3 faceCenter = Vec3.atCenterOf(pos).add(Vec3.atLowerCornerOf(dir.getNormal()).scale(0.5)); + Vec3 faceCenter = Vec3.atCenterOf(pos).add(Vec3.atLowerCornerOf(dir.getUnitVec3i()).scale(0.5)); Optional rot = RotationUtils.reachableOffset(ctx, pos, faceCenter, blockReachDistance, false); if (rot.isPresent() && isSafeToCancel && baritone.getInventoryBehavior().throwaway(true, this::isCocoa)) { HitResult result = RayTraceUtils.rayTraceTowards(ctx.player(), rot.get(), blockReachDistance); diff --git a/src/main/java/baritone/utils/BlockStateInterfaceAccessWrapper.java b/src/main/java/baritone/utils/BlockStateInterfaceAccessWrapper.java index 19b04b454..2cadd3295 100644 --- a/src/main/java/baritone/utils/BlockStateInterfaceAccessWrapper.java +++ b/src/main/java/baritone/utils/BlockStateInterfaceAccessWrapper.java @@ -60,7 +60,7 @@ public int getHeight() { } @Override - public int getMinBuildHeight() { + public int getMinY() { return 0; } diff --git a/src/main/java/baritone/utils/IRenderer.java b/src/main/java/baritone/utils/IRenderer.java index 2989a8377..ce06fc075 100644 --- a/src/main/java/baritone/utils/IRenderer.java +++ b/src/main/java/baritone/utils/IRenderer.java @@ -24,7 +24,10 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.*; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.CoreShaders; import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.ShaderProgram; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; @@ -50,7 +53,7 @@ static void glColor(Color color, float alpha) { static BufferBuilder startLines(Color color, float alpha, float lineWidth, boolean ignoreDepth) { RenderSystem.enableBlend(); - RenderSystem.setShader(GameRenderer::getPositionColorShader); + RenderSystem.setShader(CoreShaders.POSITION_COLOR); RenderSystem.blendFuncSeparate( GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, @@ -65,7 +68,7 @@ static BufferBuilder startLines(Color color, float alpha, float lineWidth, boole if (ignoreDepth) { RenderSystem.disableDepthTest(); } - RenderSystem.setShader(GameRenderer::getRendertypeLinesShader); + RenderSystem.setShader(CoreShaders.RENDERTYPE_LINES); return tessellator.begin(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR_NORMAL); } @@ -78,7 +81,7 @@ static void endLines(BufferBuilder bufferBuilder, boolean ignoredDepth) { if (meshData != null) { BufferUploader.drawWithShader(meshData); } - + if (ignoredDepth) { RenderSystem.enableDepthTest(); } diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index f8a60130b..d747c719c 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -262,12 +262,12 @@ private static void drawGoal(@Nullable BufferBuilder bufferBuilder, PoseStack st drawDankLitGoalBox(bufferBuilder, stack, color, minX, maxX, minZ, maxZ, minY, maxY, y1, y2, setupRender); } else if (goal instanceof GoalXZ) { GoalXZ goalPos = (GoalXZ) goal; - minY = ctx.world().getMinBuildHeight(); - maxY = ctx.world().getMaxBuildHeight(); + minY = ctx.world().getMinY(); + maxY = ctx.world().getMaxY(); if (settings.renderGoalXZBeacon.value) { //TODO: check - textureManager.bindForSetup(TEXTURE_BEACON_BEAM); + textureManager.getTexture(TEXTURE_BEACON_BEAM).bind(); if (settings.renderGoalIgnoreDepth.value) { RenderSystem.disableDepthTest(); } diff --git a/src/main/java/baritone/utils/PlayerMovementInput.java b/src/main/java/baritone/utils/PlayerMovementInput.java index f8c9bbe21..5a065379f 100644 --- a/src/main/java/baritone/utils/PlayerMovementInput.java +++ b/src/main/java/baritone/utils/PlayerMovementInput.java @@ -18,8 +18,9 @@ package baritone.utils; import baritone.api.utils.input.Input; +import net.minecraft.client.player.ClientInput; -public class PlayerMovementInput extends net.minecraft.client.player.Input { +public class PlayerMovementInput extends ClientInput { private final InputOverrideHandler handler; @@ -31,28 +32,36 @@ public class PlayerMovementInput extends net.minecraft.client.player.Input { public void tick(boolean p_225607_1_, float f) { this.leftImpulse = 0.0F; this.forwardImpulse = 0.0F; + boolean jumping = handler.isInputForcedDown(Input.JUMP); // oppa gangnam style - this.jumping = handler.isInputForcedDown(Input.JUMP); // oppa gangnam style - - if (this.up = handler.isInputForcedDown(Input.MOVE_FORWARD)) { + boolean up = handler.isInputForcedDown(Input.MOVE_FORWARD); + if (up) { this.forwardImpulse++; } - if (this.down = handler.isInputForcedDown(Input.MOVE_BACK)) { + boolean down = handler.isInputForcedDown(Input.MOVE_BACK); + if (down) { this.forwardImpulse--; } - if (this.left = handler.isInputForcedDown(Input.MOVE_LEFT)) { + boolean left = handler.isInputForcedDown(Input.MOVE_LEFT); + if (left) { this.leftImpulse++; } - if (this.right = handler.isInputForcedDown(Input.MOVE_RIGHT)) { + boolean right = handler.isInputForcedDown(Input.MOVE_RIGHT); + if (right) { this.leftImpulse--; } - if (this.shiftKeyDown = handler.isInputForcedDown(Input.SNEAK)) { + boolean sneaking = handler.isInputForcedDown(Input.SNEAK); + if (sneaking) { this.leftImpulse *= 0.3D; this.forwardImpulse *= 0.3D; } + + boolean sprinting = handler.isInputForcedDown(Input.SPRINT); + + this.keyPresses = new net.minecraft.world.entity.player.Input(up, down, left, right, jumping, sneaking, sprinting); } } diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index 464fa40f4..4d286bbfb 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -20,11 +20,12 @@ import baritone.Baritone; import net.minecraft.client.player.LocalPlayer; import net.minecraft.core.Holder; +import net.minecraft.core.component.DataComponents; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.SwordItem; -import net.minecraft.world.item.TieredItem; +import net.minecraft.world.item.component.Tool; import net.minecraft.world.item.enchantment.*; import net.minecraft.world.item.enchantment.effects.EnchantmentAttributeEffect; import net.minecraft.world.level.block.Block; @@ -87,12 +88,9 @@ public double getStrVsBlock(BlockState state) { * @return values from 0 up */ private int getMaterialCost(ItemStack itemStack) { - if (itemStack.getItem() instanceof TieredItem) { - TieredItem tool = (TieredItem) itemStack.getItem(); - return (int) tool.getTier().getAttackDamageBonus(); - } else { - return -1; - } + Tool toolComponent = itemStack.get(DataComponents.TOOL); + if (toolComponent == null) return -1; + return toolComponent.damagePerBlock(); // todo: i have no idea what "material cost" means anymore } public boolean hasSilkTouch(ItemStack stack) { diff --git a/src/main/java/baritone/utils/schematic/format/defaults/LitematicaSchematic.java b/src/main/java/baritone/utils/schematic/format/defaults/LitematicaSchematic.java index d43cce65d..4e582656f 100644 --- a/src/main/java/baritone/utils/schematic/format/defaults/LitematicaSchematic.java +++ b/src/main/java/baritone/utils/schematic/format/defaults/LitematicaSchematic.java @@ -20,12 +20,14 @@ import baritone.api.schematic.CompositeSchematic; import baritone.api.schematic.IStaticSchematic; import baritone.utils.schematic.StaticSchematic; +import net.minecraft.core.Holder; import net.minecraft.core.Vec3i; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.Property; import org.apache.commons.lang3.Validate; @@ -81,8 +83,14 @@ private static BlockState[] getBlockList(ListTag blockStatePalette) { BlockState[] blockList = new BlockState[blockStatePalette.size()]; for (int i = 0; i < blockStatePalette.size(); i++) { - Block block = BuiltInRegistries.BLOCK.get(ResourceLocation.parse((((CompoundTag) blockStatePalette.get(i)).getString("Name")))); - CompoundTag properties = ((CompoundTag) blockStatePalette.get(i)).getCompound("Properties"); + CompoundTag tag = (CompoundTag) blockStatePalette.get(i); + ResourceLocation blockKey = ResourceLocation.tryParse(tag.getString("Name")); + Block block = blockKey == null + ? Blocks.AIR + : BuiltInRegistries.BLOCK.get(blockKey) + .map(Holder.Reference::value) + .orElse(Blocks.AIR); + CompoundTag properties = tag.getCompound("Properties"); blockList[i] = getBlockState(block, properties); } diff --git a/src/main/java/baritone/utils/schematic/format/defaults/MCEditSchematic.java b/src/main/java/baritone/utils/schematic/format/defaults/MCEditSchematic.java index 3018021a5..f7373672d 100644 --- a/src/main/java/baritone/utils/schematic/format/defaults/MCEditSchematic.java +++ b/src/main/java/baritone/utils/schematic/format/defaults/MCEditSchematic.java @@ -18,12 +18,14 @@ package baritone.utils.schematic.format.defaults; import baritone.utils.schematic.StaticSchematic; +import net.minecraft.core.Holder; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.datafix.fixes.ItemIdFix; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; /** @@ -63,7 +65,13 @@ public MCEditSchematic(CompoundTag schematic) { // additional is 0 through 15 inclusive since it's & 0xF above blockID |= additional[blockInd] << 8; } - Block block = BuiltInRegistries.BLOCK.get(ResourceLocation.tryParse(ItemIdFix.getItem(blockID))); + ResourceLocation blockKey = ResourceLocation.tryParse(ItemIdFix.getItem(blockID)); + Block block = blockKey == null + ? Blocks.AIR + : BuiltInRegistries.BLOCK.get(blockKey) + .map(Holder.Reference::value) + .orElse(Blocks.AIR); + // int meta = metadata[blockInd] & 0xFF; // this.states[x][z][y] = block.getStateFromMeta(meta); this.states[x][z][y] = block.defaultBlockState(); diff --git a/src/main/java/baritone/utils/schematic/format/defaults/SpongeSchematic.java b/src/main/java/baritone/utils/schematic/format/defaults/SpongeSchematic.java index 9e6178c0d..068e0203c 100644 --- a/src/main/java/baritone/utils/schematic/format/defaults/SpongeSchematic.java +++ b/src/main/java/baritone/utils/schematic/format/defaults/SpongeSchematic.java @@ -25,11 +25,14 @@ import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; + +import net.minecraft.core.Holder; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.Property; @@ -107,7 +110,9 @@ private SerializedBlockState(ResourceLocation resourceLocation, Map { From 7e8c8501a73af1b4387e1dd19e3549972533aee6 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Wed, 30 Oct 2024 17:49:03 -0700 Subject: [PATCH 2/3] restore tool getMaterialCost intended functionality --- src/main/java/baritone/utils/ToolSet.java | 39 +++++++++++++++++------ 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index 4d286bbfb..a6bcb36c0 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -20,13 +20,17 @@ import baritone.Baritone; import net.minecraft.client.player.LocalPlayer; import net.minecraft.core.Holder; -import net.minecraft.core.component.DataComponents; +import net.minecraft.tags.ItemTags; +import net.minecraft.tags.TagKey; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.SwordItem; -import net.minecraft.world.item.component.Tool; -import net.minecraft.world.item.enchantment.*; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.EnchantmentEffectComponents; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.item.enchantment.ItemEnchantments; import net.minecraft.world.item.enchantment.effects.EnchantmentAttributeEffect; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; @@ -56,6 +60,20 @@ public class ToolSet { private final LocalPlayer player; + /** + * Used for evaluating the material cost of a tool. + * see {@link #getMaterialCost(ItemStack)} + * Prefer tools with lower material cost (lower index in this list). + */ + private static final List> materialTagsPriorityList = List.of( + ItemTags.WOODEN_TOOL_MATERIALS, + ItemTags.STONE_TOOL_MATERIALS, + ItemTags.IRON_TOOL_MATERIALS, + ItemTags.GOLD_TOOL_MATERIALS, + ItemTags.DIAMOND_TOOL_MATERIALS, + ItemTags.NETHERITE_TOOL_MATERIALS + ); + public ToolSet(LocalPlayer player) { breakStrengthCache = new HashMap<>(); this.player = player; @@ -80,17 +98,18 @@ public double getStrVsBlock(BlockState state) { } /** - * Evaluate the material cost of a possible tool. The priority matches the - * harvest level order; there is a chance for multiple at the same with modded tools - * but in that case we don't really care. - * + * Evaluate the material cost of a possible tool. + * If all else is equal, we want to prefer the tool with the lowest material cost. + * i.e. we want to prefer a wooden pickaxe over a stone pickaxe, if all else is equal. * @param itemStack a possibly empty ItemStack * @return values from 0 up */ private int getMaterialCost(ItemStack itemStack) { - Tool toolComponent = itemStack.get(DataComponents.TOOL); - if (toolComponent == null) return -1; - return toolComponent.damagePerBlock(); // todo: i have no idea what "material cost" means anymore + for (int i = 0; i < materialTagsPriorityList.size(); i++) { + final TagKey tag = materialTagsPriorityList.get(i); + if (itemStack.is(tag)) return i; + } + return -1; } public boolean hasSilkTouch(ItemStack stack) { From fd4fbf5df5990cb05c43e811bdfacc38fe9f77c3 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Wed, 30 Oct 2024 20:44:51 -0700 Subject: [PATCH 3/3] update forge and resolve rebase conflicts --- gradle.properties | 6 +++--- .../java/fi/dy/masa/litematica/world/WorldSchematic.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index 0407ff60c..b447af9ed 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G available_loaders=fabric,forge,neoforge,tweaker -mod_version=1.11.0 +mod_version=1.12.0 maven_group=baritone archives_base_name=baritone @@ -10,9 +10,9 @@ java_version=21 minecraft_version=1.21.3 -forge_version=53.0.0 +forge_version=53.0.7 -neoforge_version=3-beta +neoforge_version=6-beta fabric_version=0.16.7 diff --git a/src/schematica_api/java/fi/dy/masa/litematica/world/WorldSchematic.java b/src/schematica_api/java/fi/dy/masa/litematica/world/WorldSchematic.java index 58f28b3a6..9f7bb9c48 100644 --- a/src/schematica_api/java/fi/dy/masa/litematica/world/WorldSchematic.java +++ b/src/schematica_api/java/fi/dy/masa/litematica/world/WorldSchematic.java @@ -21,7 +21,7 @@ public abstract class WorldSchematic extends Level { private WorldSchematic() { - super(null, null, null, null, null, false, false, 0, 0); + super(null, null, null, null, false, false, 0, 0); throw new LinkageError(); } }