Skip to content
Draft

1.21.11 #4925

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ allprojects {
}

repositories {
maven {
url = "https://files.minecraftforge.net/maven/"
}
maven {
name = 'spongepowered-repo'
url = 'https://repo.spongepowered.org/repository/maven-public/'
Expand Down
2 changes: 1 addition & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
],
"depends": {
"fabricloader": ">=0.14.22",
"minecraft": ["1.21.9", "1.21.10"]
"minecraft": ["1.21.11"]
},
"custom": {
"modmenu": {
Expand Down
2 changes: 1 addition & 1 deletion forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.9, 1.21.10]"
versionRange="[1.21.11]"
ordering="NONE"
side="BOTH"
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
org.gradle.jvmargs=-Xmx4G

available_loaders=fabric,neoforge,forge,tweaker
available_loaders=fabric,forge,tweaker

mod_version=1.16.0
mod_version=1.17.0
maven_group=baritone
archives_base_name=baritone

java_version=21

minecraft_version=1.21.10
minecraft_version=1.21.11

forge_version=60.0.0
forge_version=61.0.0

neoforge_version=1-beta
neoforge_version=0-beta

fabric_version=0.17.2
fabric_version=0.18.1

nether_pathfinder_version=1.4.1

// These dependencies are used for common and tweaker
// while mod loaders usually ship their own version
mixin_version=0.8.5
mixin_version=0.8.7
asm_version=9.7
2 changes: 1 addition & 1 deletion neoforge/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.9, 1.21.10]"
versionRange="[1.21.11]"
ordering="NONE"
side="BOTH"

Expand Down
4 changes: 2 additions & 2 deletions src/api/java/baritone/api/command/datatypes/BlockById.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;
import net.minecraft.world.level.block.Block;

import java.util.stream.Stream;
Expand All @@ -30,7 +30,7 @@ public enum BlockById implements IDatatypeFor<Block> {

@Override
public Block get(IDatatypeContext ctx) throws CommandException {
ResourceLocation id = ResourceLocation.parse(ctx.getConsumer().getString());
Identifier id = Identifier.parse(ctx.getConsumer().getString());
Block block;
if ((block = BuiltInRegistries.BLOCK.getOptional(id).orElse(null)) == null) {
throw new IllegalArgumentException("no block found by that id");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;
import net.minecraft.world.entity.EntityType;

import java.util.stream.Stream;
Expand All @@ -30,7 +30,7 @@ public enum EntityClassById implements IDatatypeFor<EntityType> {

@Override
public EntityType get(IDatatypeContext ctx) throws CommandException {
ResourceLocation id = ResourceLocation.parse(ctx.getConsumer().getString());
Identifier id = Identifier.parse(ctx.getConsumer().getString());
EntityType entity;
if ((entity = BuiltInRegistries.ENTITY_TYPE.getOptional(id).orElse(null)) == null) {
throw new IllegalArgumentException("no entity found by that id");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import baritone.api.command.helpers.TabCompleteHelper;
import baritone.api.utils.BlockOptionalMeta;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.properties.Property;

Expand Down Expand Up @@ -77,7 +77,7 @@ public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException
properties = parts[1];
}

Block block = BuiltInRegistries.BLOCK.getOptional(ResourceLocation.parse(blockId)).orElse(null);
Block block = BuiltInRegistries.BLOCK.getOptional(Identifier.parse(blockId)).orElse(null);
if (block == null) {
// This block doesn't exist so there's no properties to complete.
return Stream.empty();
Expand Down
6 changes: 3 additions & 3 deletions src/api/java/baritone/api/command/datatypes/ItemById.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;
import net.minecraft.world.item.Item;

import java.util.stream.Stream;
Expand All @@ -30,7 +30,7 @@ public enum ItemById implements IDatatypeFor<Item> {

@Override
public Item get(IDatatypeContext ctx) throws CommandException {
ResourceLocation id = ResourceLocation.parse(ctx.getConsumer().getString());
Identifier id = Identifier.parse(ctx.getConsumer().getString());
Item item;
if ((item = BuiltInRegistries.ITEM.getOptional(id).orElse(null)) == null) {
throw new IllegalArgumentException("No item found by that id");
Expand All @@ -44,7 +44,7 @@ public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException
.append(
BuiltInRegistries.BLOCK.keySet()
.stream()
.map(ResourceLocation::toString)
.map(Identifier::toString)
)
.filterPrefixNamespaced(ctx.getConsumer().getString())
.sortAlphabetically()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
import baritone.api.command.manager.ICommandManager;
import baritone.api.event.events.TabCompleteEvent;
import baritone.api.utils.SettingsUtil;
import net.minecraft.resources.Identifier;

import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Stream;
import net.minecraft.resources.ResourceLocation;

/**
* The {@link TabCompleteHelper} is a <b>single-use</b> object that helps you handle tab completion. It includes helper
Expand Down Expand Up @@ -206,13 +207,13 @@ public TabCompleteHelper filterPrefix(String prefix) {
/**
* Filter out any element that doesn't start with {@code prefix} and return this object for chaining
* <p>
* Assumes every element in this {@link TabCompleteHelper} is a {@link ResourceLocation}
* Assumes every element in this {@link TabCompleteHelper} is a {@link Identifier}
*
* @param prefix The prefix to filter for
* @return This {@link TabCompleteHelper}
*/
public TabCompleteHelper filterPrefixNamespaced(String prefix) {
ResourceLocation loc = ResourceLocation.tryParse(prefix);
Identifier loc = Identifier.tryParse(prefix);
if (loc == null) {
stream = Stream.empty();
return this;
Expand Down
3 changes: 2 additions & 1 deletion src/api/java/baritone/api/utils/BlockOptionalMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.concurrent.ForkJoinPool;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -324,7 +325,7 @@ public static CompletableFuture<RegistryAccess> load() {
layeredRegistryAccess,
pendingTags,
closeableResourceManager,
Minecraft.getInstance()
ForkJoinPool.commonPool()
).thenApply(r -> r.layers().compositeAccess());
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/api/java/baritone/api/utils/BlockUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@

package baritone.api.utils;

import java.util.HashMap;
import java.util.Map;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;
import net.minecraft.world.level.block.Block;

import java.util.HashMap;
import java.util.Map;

public class BlockUtils {

private static transient Map<String, Block> resourceCache = new HashMap<>();

public static String blockToString(Block block) {
ResourceLocation loc = BuiltInRegistries.BLOCK.getKey(block);
Identifier loc = BuiltInRegistries.BLOCK.getKey(block);
String name = loc.getPath(); // normally, only write the part after the minecraft:
if (!loc.getNamespace().equals("minecraft")) {
// Baritone is running on top of forge with mods installed, perhaps?
Expand Down Expand Up @@ -57,7 +57,7 @@ public static Block stringToBlockNullable(String name) {
if (resourceCache.containsKey(name)) {
return null; // cached as null
}
block = BuiltInRegistries.BLOCK.getOptional(ResourceLocation.tryParse(name.contains(":") ? name : "minecraft:" + name)).orElse(null);
block = BuiltInRegistries.BLOCK.getOptional(Identifier.tryParse(name.contains(":") ? name : "minecraft:" + name)).orElse(null);
Map<String, Block> copy = new HashMap<>(resourceCache); // read only copy is safe, wont throw concurrentmodification
copy.put(name, block);
resourceCache = copy;
Expand Down
6 changes: 2 additions & 4 deletions src/api/java/baritone/api/utils/SettingsUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@
import baritone.api.BaritoneAPI;
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;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Mirror;
Expand Down Expand Up @@ -247,7 +245,7 @@ private enum Parser implements ISettingParser {
),
ITEM(
Item.class,
str -> BuiltInRegistries.ITEM.get(ResourceLocation.parse(str.trim())).map(Holder.Reference::value).orElse(null),
str -> BuiltInRegistries.ITEM.get(Identifier.parse(str.trim())).map(Holder.Reference::value).orElse(null),
item -> BuiltInRegistries.ITEM.getKey(item).toString()
),
LIST() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ public class MixinEntityRenderManager implements IEntityRenderManager {

@Override
public double renderPosX() {
return ((EntityRenderDispatcher) (Object) this).camera.getPosition().x;
return ((EntityRenderDispatcher) (Object) this).camera.position().x;
}

@Override
public double renderPosY() {
return ((EntityRenderDispatcher) (Object) this).camera.getPosition().y;
return ((EntityRenderDispatcher) (Object) this).camera.position().y;
}

@Override
public double renderPosZ() {
return ((EntityRenderDispatcher) (Object) this).camera.getPosition().z;
return ((EntityRenderDispatcher) (Object) this).camera.position().z;
}
}
38 changes: 38 additions & 0 deletions src/launch/java/baritone/launch/mixins/MixinRenderType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/

package baritone.launch.mixins;

import baritone.utils.accessor.IRenderType;
import net.minecraft.client.renderer.rendertype.RenderSetup;
import net.minecraft.client.renderer.rendertype.RenderType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

@Mixin(RenderType.class)
public abstract class MixinRenderType implements IRenderType {

@Shadow
static RenderType create(final String string, final RenderSetup renderSetup) {
return null;
}

@Override
public RenderType createRenderType(final String name, final RenderSetup renderSetup) {
return create(name, renderSetup);
}
}
4 changes: 2 additions & 2 deletions src/launch/java/baritone/launch/mixins/MixinScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
public abstract class MixinScreen implements IGuiScreen {

//TODO: switch to enum extention with mixin 9.0 or whenever Mumfrey gets around to it
@Inject(method = "handleClickEvent", at = @At(value = "HEAD"), cancellable = true)
public void handleCustomClickEvent(final Minecraft minecraft, final ClickEvent clickEvent, final CallbackInfo ci) {
@Inject(method = "defaultHandleGameClickEvent", at = @At(value = "HEAD"), cancellable = true)
private static void handleCustomClickEvent(final ClickEvent clickEvent, final Minecraft minecraft, final Screen screen, final CallbackInfo ci) {
if (clickEvent == null) {
return;
}
Expand Down
1 change: 1 addition & 0 deletions src/launch/resources/mixins.baritone.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"MixinPalettedContainer$Data",
"MixinPlayerController",
"MixinRenderPipelines",
"MixinRenderType",
"MixinScreen",
"MixinWorldRenderer"
],
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/baritone/cache/CachedChunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import com.google.common.collect.ImmutableSet;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
Expand Down Expand Up @@ -192,7 +194,7 @@ private final void setSpecial() {
}
}

public final BlockState getBlock(int x, int y, int z, DimensionType dimension) {
public final BlockState getBlock(int x, int y, int z, DimensionType dimension, ResourceKey<Level> dimensionId) {
int index = getPositionIndex(x, y, z);
PathingBlockType type = getType(index);
int internalPos = z << 4 | x;
Expand All @@ -218,14 +220,15 @@ public final BlockState getBlock(int x, int y, int z, DimensionType dimension) {
// nether roof is always unbreakable
return Blocks.BEDROCK.defaultBlockState();
}
if (y < -59 && dimension.natural()) {

if ((dimensionId == Level.OVERWORLD || dimensionId == Level.NETHER) && y < dimension.minY() + 5) {
// solid blocks below 5 are commonly bedrock
// however, returning bedrock always would be a little yikes
// discourage paths that include breaking blocks below 5 a little more heavily just so that it takes paths breaking what's known to be stone (at 5 or above) instead of what could maybe be bedrock (below 5)
return Blocks.OBSIDIAN.defaultBlockState();
}
}
return ChunkPacker.pathingTypeToBlock(type, dimension);
return ChunkPacker.pathingTypeToBlock(type, dimension, dimensionId);
}

private PathingBlockType getType(int index) {
Expand Down
Loading