diff --git a/build.gradle b/build.gradle index 52c8ec0cc..0355c6fe2 100755 --- a/build.gradle +++ b/build.gradle @@ -37,7 +37,13 @@ allprojects { } group = rootProject.maven_group - sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = targetCompatibility = JavaVersion.VERSION_21 + + java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(21)) + } + } repositories { maven { @@ -72,8 +78,8 @@ allprojects { } dependencies { - implementation "org.spongepowered:mixin:0.8.5" - implementation "org.ow2.asm:asm:9.3" + compileOnly "org.spongepowered:mixin:0.8" + compileOnly "org.ow2.asm:asm:9.7" // The following line declares the yarn mappings you may select this one as well. // mappings "net.fabricmc:yarn:1.17.1+build.32:v2" //launchImplementation('dev.babbaj:nether-pathfinder:1.3.0') diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index a58fe6089..b613c5d6b 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -40,5 +40,5 @@ dependencies { implementation group: 'com.google.code.gson', name: 'gson', version: '2.9.0' implementation group: 'commons-io', name: 'commons-io', version: '2.7' - implementation group: 'xyz.wagyourtail.unimined', name: 'xyz.wagyourtail.unimined.gradle.plugin', version: '1.1.0' + implementation group: 'xyz.wagyourtail.unimined', name: 'xyz.wagyourtail.unimined.gradle.plugin', version: '1.2.3' } \ No newline at end of file diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index c1512a6cc..52a233052 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.20.3", "1.20.4"] + "minecraft": ["1.20.5", "1.20.6"] } } diff --git a/gradle.properties b/gradle.properties index 18a9f77e0..e4909c69f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,16 +1,16 @@ org.gradle.jvmargs=-Xmx4G -available_loaders=fabric,forge,neoforge,tweaker +available_loaders=fabric,neoforge,tweaker mod_version=1.10.2 maven_group=baritone archives_base_name=baritone -minecraft_version=1.20.4 +minecraft_version=1.20.5 forge_version=49.0.3 neoforge_version=0-beta -fabric_version=0.14.22 +fabric_version=0.15.10 nether_pathfinder_version=1.4.1 diff --git a/neoforge/src/main/resources/META-INF/mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml similarity index 93% rename from neoforge/src/main/resources/META-INF/mods.toml rename to neoforge/src/main/resources/META-INF/neoforge.mods.toml index 4ad41a286..fd6d003cc 100644 --- a/neoforge/src/main/resources/META-INF/mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -1,4 +1,4 @@ -# This is an example mods.toml file. It contains the data relating to the loading mods. +# This is an example neoforge.mods.toml file. It contains the data relating to the loading mods. # There are several mandatory fields (#mandatory), and many more that are optional (#optional). # The overall format is standard TOML format, v0.5.0. # Note that there are a couple of TOML lists in this file. @@ -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.20.3, 1.20.4]" +versionRange="[1.20.5, 1.20.6]" ordering="NONE" side="BOTH" diff --git a/src/api/java/baritone/api/utils/BlockOptionalMeta.java b/src/api/java/baritone/api/utils/BlockOptionalMeta.java index ac14d0187..d4e92e7d8 100644 --- a/src/api/java/baritone/api/utils/BlockOptionalMeta.java +++ b/src/api/java/baritone/api/utils/BlockOptionalMeta.java @@ -18,26 +18,26 @@ package baritone.api.utils; import baritone.api.utils.accessor.IItemStack; +import baritone.api.utils.accessor.ILootTable; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import io.netty.util.concurrent.ThreadPerTaskExecutor; import net.minecraft.client.Minecraft; -import net.minecraft.core.BlockPos; +import net.minecraft.commands.Commands; +import net.minecraft.core.RegistryAccess; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.ReloadableServerRegistries; +import net.minecraft.server.ReloadableServerResources; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.progress.ChunkProgressListener; -import net.minecraft.server.packs.PackType; import net.minecraft.server.packs.VanillaPackResources; import net.minecraft.server.packs.repository.ServerPacksSource; -import net.minecraft.server.packs.resources.MultiPackResourceManager; -import net.minecraft.server.packs.resources.ReloadableResourceManager; -import net.minecraft.util.Unit; import net.minecraft.world.RandomSequences; import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import net.minecraft.world.level.CustomSpawner; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; @@ -48,8 +48,8 @@ import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraft.world.level.storage.ServerLevelData; import net.minecraft.world.level.storage.loot.BuiltInLootTables; import net.minecraft.world.level.storage.loot.LootContext; -import net.minecraft.world.level.storage.loot.LootDataManager; import net.minecraft.world.level.storage.loot.LootParams; +import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.phys.Vec3; @@ -60,7 +60,6 @@ import javax.annotation.Nullable; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.*; -import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -75,7 +74,6 @@ public final class BlockOptionalMeta { private final Set blockstates; private final ImmutableSet stateHashes; private final ImmutableSet stackHashes; - private static LootDataManager lootTables; private static Map> drops = new HashMap<>(); public BlockOptionalMeta(@Nonnull Block block) { @@ -218,43 +216,21 @@ public final class BlockOptionalMeta { return null; } - public static LootDataManager getManager() { - if (lootTables == null) { - MultiPackResourceManager resources = new MultiPackResourceManager(PackType.SERVER_DATA, List.of(getVanillaServerPack())); - ReloadableResourceManager resourceManager = new ReloadableResourceManager(PackType.SERVER_DATA); - lootTables = new LootDataManager(); - resourceManager.registerReloadListener(lootTables); - try { - resourceManager.createReload(new ThreadPerTaskExecutor(Thread::new), new ThreadPerTaskExecutor(Thread::new), CompletableFuture.completedFuture(Unit.INSTANCE), resources.listPacks().toList()).done().get(); - } catch (Exception exception) { - throw new RuntimeException(exception); - } - - } - return lootTables; - } - private static synchronized List drops(Block b) { return drops.computeIfAbsent(b, block -> { - ResourceLocation lootTableLocation = block.getLootTable(); - if (lootTableLocation == BuiltInLootTables.EMPTY) { + ResourceLocation lootTableLocation = block.getLootTable().location(); + if (lootTableLocation.equals(BuiltInLootTables.EMPTY.location())) { return Collections.emptyList(); } else { List items = new ArrayList<>(); try { + ServerLevel lv2 = ServerLevelStub.fastCreate(); - getManager().getLootTable(lootTableLocation).getRandomItemsRaw( - new LootContext.Builder( - new LootParams.Builder(ServerLevelStub.fastCreate()) - .withParameter(LootContextParams.ORIGIN, Vec3.atLowerCornerOf(BlockPos.ZERO)) - .withParameter(LootContextParams.TOOL, ItemStack.EMPTY) - .withOptionalParameter(LootContextParams.BLOCK_ENTITY, null) - .withParameter(LootContextParams.BLOCK_STATE, block.defaultBlockState()) - .create(LootContextParamSets.BLOCK) - ).withOptionalRandomSeed(1L) - .create(null), - stack -> items.add(stack.getItem()) - ); + LootParams.Builder lv5 = new LootParams.Builder(lv2) + .withParameter(LootContextParams.ORIGIN, Vec3.ZERO) + .withParameter(LootContextParams.BLOCK_STATE, b.defaultBlockState()) + .withParameter(LootContextParams.TOOL, new ItemStack(Items.NETHERITE_PICKAXE, 1)); + getDrops(block, lv5).stream().map(ItemStack::getItem).forEach(items::add); } catch (Exception e) { e.printStackTrace(); } @@ -263,7 +239,19 @@ public final class BlockOptionalMeta { }); } - private static class ServerLevelStub extends ServerLevel { + private static List getDrops(Block state, LootParams.Builder params) { + ResourceKey lv = state.getLootTable(); + if (lv == BuiltInLootTables.EMPTY) { + 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); + return((ILootTable) lv4).invokeGetRandomItems(new LootContext.Builder(lv2).withOptionalRandomSeed(1).create(null)); + } + } + + public static class ServerLevelStub extends ServerLevel { private static Minecraft client = Minecraft.getInstance(); private static Unsafe unsafe = getUnsafe(); @@ -285,6 +273,15 @@ public final class BlockOptionalMeta { } } + @Override + public RegistryAccess registryAccess() { + return client.level.registryAccess(); + } + + public ReloadableServerRegistries.Holder holder() { + return new ReloadableServerRegistries.Holder(registryAccess().freeze()); + } + public static Unsafe getUnsafe() { try { Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe"); diff --git a/src/api/java/baritone/api/utils/accessor/ILootTable.java b/src/api/java/baritone/api/utils/accessor/ILootTable.java new file mode 100644 index 000000000..c032fc6cd --- /dev/null +++ b/src/api/java/baritone/api/utils/accessor/ILootTable.java @@ -0,0 +1,28 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Baritone. If not, see . + */ + +package baritone.api.utils.accessor; + +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; + +public interface ILootTable { + + ObjectArrayList invokeGetRandomItems(LootContext context); + +} diff --git a/src/launch/java/baritone/launch/mixins/MixinLootContext.java b/src/launch/java/baritone/launch/mixins/MixinLootContextBuilder.java similarity index 54% rename from src/launch/java/baritone/launch/mixins/MixinLootContext.java rename to src/launch/java/baritone/launch/mixins/MixinLootContextBuilder.java index 223444e12..707a4c317 100644 --- a/src/launch/java/baritone/launch/mixins/MixinLootContext.java +++ b/src/launch/java/baritone/launch/mixins/MixinLootContextBuilder.java @@ -19,41 +19,28 @@ package baritone.launch.mixins; import baritone.api.utils.BlockOptionalMeta; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.ReloadableServerRegistries; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.storage.loot.LootContext; -import net.minecraft.world.level.storage.loot.LootDataManager; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(LootContext.Builder.class) -public class MixinLootContext { +public abstract class MixinLootContextBuilder { - @Redirect( - method = "create", - at = @At( - value = "INVOKE", - target = "net/minecraft/server/level/ServerLevel.getServer()Lnet/minecraft/server/MinecraftServer;" - ) - ) - private MinecraftServer getServer(ServerLevel world) { - if (world == null) { - return null; + @Shadow public abstract ServerLevel getLevel(); + + @Redirect(method = "create", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;reloadableRegistries()Lnet/minecraft/server/ReloadableServerRegistries$Holder;")) + private ReloadableServerRegistries.Holder create(MinecraftServer instance) { + if (instance != null) { + return instance.reloadableRegistries(); } - return world.getServer(); + if (getLevel() instanceof BlockOptionalMeta.ServerLevelStub sls) { + return sls.holder(); + } + return null; } - @Redirect( - method = "create", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/server/MinecraftServer;getLootData()Lnet/minecraft/world/level/storage/loot/LootDataManager;" - ) - ) - private LootDataManager getLootTableManager(MinecraftServer server) { - if (server == null) { - return BlockOptionalMeta.getManager(); - } - return server.getLootData(); - } } diff --git a/src/launch/java/baritone/launch/mixins/MixinLootTable.java b/src/launch/java/baritone/launch/mixins/MixinLootTable.java new file mode 100644 index 000000000..f3f2e3600 --- /dev/null +++ b/src/launch/java/baritone/launch/mixins/MixinLootTable.java @@ -0,0 +1,34 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Baritone. If not, see . + */ + +package baritone.launch.mixins; + +import baritone.api.utils.accessor.ILootTable; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.LootTable; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(LootTable.class) +public abstract class MixinLootTable implements ILootTable { + + @Invoker + public abstract ObjectArrayList invokeGetRandomItems(LootContext context); + +} diff --git a/src/launch/java/baritone/launch/mixins/MixinMinecraft.java b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java index e615a822a..de78501ef 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.TickEvent; import baritone.api.event.events.WorldEvent; import baritone.api.event.events.type.EventState; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.ReceivingLevelScreen; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.player.LocalPlayer; @@ -130,7 +131,7 @@ public class MixinMinecraft { method = "setLevel", at = @At("HEAD") ) - private void preLoadWorld(ClientLevel world, CallbackInfo ci) { + private void preLoadWorld(ClientLevel world, ReceivingLevelScreen.Reason arg2, CallbackInfo ci) { // If we're unloading the world but one doesn't exist, ignore it if (this.level == null && world == null) { return; @@ -150,7 +151,7 @@ public class MixinMinecraft { method = "setLevel", at = @At("RETURN") ) - private void postLoadWorld(ClientLevel world, CallbackInfo ci) { + private void postLoadWorld(ClientLevel world, ReceivingLevelScreen.Reason arg2, CallbackInfo ci) { // still fire event for both null, as that means we've just finished exiting a world // mc.world changing is only the primary baritone diff --git a/src/launch/java/baritone/launch/mixins/MixinWorldRenderer.java b/src/launch/java/baritone/launch/mixins/MixinWorldRenderer.java index a6cf48899..1a1ae74e2 100644 --- a/src/launch/java/baritone/launch/mixins/MixinWorldRenderer.java +++ b/src/launch/java/baritone/launch/mixins/MixinWorldRenderer.java @@ -44,9 +44,11 @@ public class MixinWorldRenderer { at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILSOFT ) - private void onStartHand(PoseStack matrixStackIn, float partialTicks, long finishTimeNano, boolean drawBlockOutline, Camera activeRenderInfoIn, GameRenderer gameRendererIn, LightTexture lightmapIn, Matrix4f projectionIn, CallbackInfo ci) { + private void onStartHand(float f, long l, boolean bl, Camera arg, GameRenderer arg2, LightTexture arg3, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci) { for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { - ibaritone.getGameEventHandler().onRenderPass(new RenderEvent(partialTicks, matrixStackIn, projectionIn)); + PoseStack poseStack = new PoseStack(); + poseStack.mulPose(matrix4f); + ibaritone.getGameEventHandler().onRenderPass(new RenderEvent(f, poseStack, matrix4f2)); } } } \ No newline at end of file diff --git a/src/launch/resources/mixins.baritone.json b/src/launch/resources/mixins.baritone.json index 35d5ae0d6..9d526addc 100644 --- a/src/launch/resources/mixins.baritone.json +++ b/src/launch/resources/mixins.baritone.json @@ -18,7 +18,8 @@ "MixinFireworkRocketEntity", "MixinItemStack", "MixinLivingEntity", - "MixinLootContext", + "MixinLootContextBuilder", + "MixinLootTable", "MixinMinecraft", "MixinNetworkManager", "MixinPalettedContainer", @@ -26,5 +27,7 @@ "MixinPlayerController", "MixinScreen", "MixinWorldRenderer" + ], + "mixins": [ ] } diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index f5c928cd4..16119bb07 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -177,15 +177,10 @@ public interface MovementHelper extends ActionCosts, Helper { if (block instanceof CauldronBlock) { return NO; } - try { // A dodgy catch-all at the end, for most blocks with default behaviour this will work, however where blocks are special this will error out, and we can handle it when we have this information - if (state.isPathfindable(null, null, PathComputationType.LAND)) { - return YES; - } else { - return NO; - } - } catch (Throwable exception) { - System.out.println("The block " + state.getBlock().getName().getString() + " requires a special case due to the exception " + exception.getMessage()); - return MAYBE; + if (state.isPathfindable(PathComputationType.LAND)) { + return YES; + } else { + return NO; } } @@ -228,10 +223,7 @@ public interface MovementHelper extends ActionCosts, Helper { return fluidState.getType() instanceof WaterFluid; } - // every block that overrides isPassable with anything more complicated than a "return true;" or "return false;" - // has already been accounted for above - // therefore it's safe to not construct a blockpos from our x, y, z ints and instead just pass null - return state.isPathfindable(bsi.access, BlockPos.ZERO, PathComputationType.LAND); // workaround for future compatibility =P + return state.isPathfindable(PathComputationType.LAND); } static Ternary fullyPassableBlockState(BlockState state) { @@ -259,16 +251,10 @@ public interface MovementHelper extends ActionCosts, Helper { } // door, fence gate, liquid, trapdoor have been accounted for, nothing else uses the world or pos parameters // at least in 1.12.2 vanilla, that is..... - try { // A dodgy catch-all at the end, for most blocks with default behaviour this will work, however where blocks are special this will error out, and we can handle it when we have this information - if (state.isPathfindable(null, null, PathComputationType.LAND)) { - return YES; - } else { - return NO; - } - } catch (Throwable exception) { - // see PR #1087 for why - System.out.println("The block " + state.getBlock().getName().getString() + " requires a special case due to the exception " + exception.getMessage()); - return MAYBE; + if (state.isPathfindable(PathComputationType.LAND)) { + return YES; + } else { + return NO; } } @@ -293,11 +279,14 @@ public interface MovementHelper extends ActionCosts, Helper { if (fullyPassable == NO) { return false; } - return fullyPassablePosition(new BlockStateInterface(ctx), pos.getX(), pos.getY(), pos.getZ(), state); // meh + return state.isPathfindable(PathComputationType.LAND); } + /** + * params retained for backwards compatibility + */ static boolean fullyPassablePosition(BlockStateInterface bsi, int x, int y, int z, BlockState state) { - return state.isPathfindable(bsi.access, bsi.isPassableBlockPos.set(x, y, z), PathComputationType.LAND); + return state.isPathfindable(PathComputationType.LAND); } static boolean isReplaceable(int x, int y, int z, BlockState state, BlockStateInterface bsi) { diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 3d0d0d4b7..301019275 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -1028,8 +1028,8 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil if (!ignoreDirection && ignoredProps.isEmpty()) { return first.equals(second); // early return if no properties are being ignored } - ImmutableMap, Comparable> map1 = first.getValues(); - ImmutableMap, Comparable> map2 = second.getValues(); + Map, Comparable> map1 = first.getValues(); + Map, Comparable> map2 = second.getValues(); for (Property prop : map1.keySet()) { if (map1.get(prop) != map2.get(prop) && !(ignoreDirection && ORIENTATION_PROPS.contains(prop)) diff --git a/src/main/java/baritone/process/ElytraProcess.java b/src/main/java/baritone/process/ElytraProcess.java index fcd6c4b34..466969071 100644 --- a/src/main/java/baritone/process/ElytraProcess.java +++ b/src/main/java/baritone/process/ElytraProcess.java @@ -360,7 +360,7 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro private boolean shouldLandForSafety() { ItemStack chest = ctx.player().getItemBySlot(EquipmentSlot.CHEST); - if (chest.getItem() != Items.ELYTRA || chest.getItem().getMaxDamage() - chest.getDamageValue() < Baritone.settings().elytraMinimumDurability.value) { + if (chest.getItem() != Items.ELYTRA || chest.getMaxDamage() - chest.getDamageValue() < Baritone.settings().elytraMinimumDurability.value) { // elytrabehavior replaces when durability <= minimumDurability, so if durability < minimumDurability then we can reasonably assume that the elytra will soon be broken without replacement return true; } diff --git a/src/main/java/baritone/process/elytra/ElytraBehavior.java b/src/main/java/baritone/process/elytra/ElytraBehavior.java index 8cdfd0e39..8ace420e9 100644 --- a/src/main/java/baritone/process/elytra/ElytraBehavior.java +++ b/src/main/java/baritone/process/elytra/ElytraBehavior.java @@ -35,6 +35,7 @@ import it.unimi.dsi.fastutil.floats.FloatArrayList; import it.unimi.dsi.fastutil.floats.FloatIterator; import net.minecraft.core.BlockPos; import net.minecraft.core.NonNullList; +import net.minecraft.core.component.DataComponents; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket; import net.minecraft.util.Mth; @@ -44,6 +45,7 @@ import net.minecraft.world.entity.projectile.FireworkRocketEntity; import net.minecraft.world.inventory.ClickType; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import net.minecraft.world.item.component.Fireworks; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.block.AirBlock; @@ -922,9 +924,8 @@ public final class ElytraBehavior implements Helper { if (itemStack.getItem() != Items.FIREWORK_ROCKET) { return false; } - // If it has NBT data, make sure it won't cause us to explode. - final CompoundTag compound = itemStack.getTagElement("Fireworks"); - return compound == null || !compound.getAllKeys().contains("Explosions"); + Fireworks fw = itemStack.get(DataComponents.FIREWORKS); + return fw != null && fw.explosions().isEmpty(); } private static boolean isBoostingFireworks(final ItemStack itemStack) { @@ -932,11 +933,9 @@ public final class ElytraBehavior implements Helper { } private static OptionalInt getFireworkBoost(final ItemStack itemStack) { - if (isFireworks(itemStack)) { - final CompoundTag compound = itemStack.getTagElement("Fireworks"); - if (compound != null && compound.getAllKeys().contains("Flight")) { - return OptionalInt.of(compound.getByte("Flight")); - } + Fireworks fw = itemStack.get(DataComponents.FIREWORKS); + if (fw != null && fw.explosions().isEmpty()) { + return OptionalInt.of(fw.flightDuration()); } return OptionalInt.empty(); } @@ -1292,7 +1291,7 @@ public final class ElytraBehavior implements Helper { NonNullList invy = ctx.player().getInventory().items; for (int i = 0; i < invy.size(); i++) { ItemStack slot = invy.get(i); - if (slot.getItem() == Items.ELYTRA && (slot.getItem().getMaxDamage() - slot.getDamageValue()) > Baritone.settings().elytraMinimumDurability.value) { + if (slot.getItem() == Items.ELYTRA && (slot.getMaxDamage() - slot.getDamageValue()) > Baritone.settings().elytraMinimumDurability.value) { return i; } } @@ -1306,7 +1305,7 @@ public final class ElytraBehavior implements Helper { ItemStack chest = ctx.player().getItemBySlot(EquipmentSlot.CHEST); if (chest.getItem() != Items.ELYTRA - || chest.getItem().getMaxDamage() - chest.getDamageValue() > Baritone.settings().elytraMinimumDurability.value) { + || chest.getMaxDamage() - chest.getDamageValue() > Baritone.settings().elytraMinimumDurability.value) { return; } diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index 095694db9..9708f40bc 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -30,9 +30,9 @@ 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; -import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunkSection; +import net.minecraft.world.level.chunk.status.ChunkStatus; /** * Wraps get for chuck caching capability diff --git a/src/main/java/baritone/utils/IRenderer.java b/src/main/java/baritone/utils/IRenderer.java index 7f6065b72..86db4c87f 100644 --- a/src/main/java/baritone/utils/IRenderer.java +++ b/src/main/java/baritone/utils/IRenderer.java @@ -115,11 +115,10 @@ public interface IRenderer { float x1, float y1, float z1, float x2, float y2, float z2, float nx, float ny, float nz) { - final Matrix4f matrix4f = stack.last().pose(); - final Matrix3f normal = stack.last().normal(); + PoseStack.Pose pose = stack.last(); - buffer.vertex(matrix4f, x1, y1, z1).color(color[0], color[1], color[2], color[3]).normal(normal, nx, ny, nz).endVertex(); - buffer.vertex(matrix4f, x2, y2, z2).color(color[0], color[1], color[2], color[3]).normal(normal, nx, ny, nz).endVertex(); + buffer.vertex(pose, x1, y1, z1).color(color[0], color[1], color[2], color[3]).normal(pose, nx, ny, nz).endVertex(); + buffer.vertex(pose, x2, y2, z2).color(color[0], color[1], color[2], color[3]).normal(pose, nx, ny, nz).endVertex(); } static void emitAABB(PoseStack stack, AABB aabb) { diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index 38b1fafdd..ef83a2db1 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -86,7 +86,7 @@ public class ToolSet { private int getMaterialCost(ItemStack itemStack) { if (itemStack.getItem() instanceof TieredItem) { TieredItem tool = (TieredItem) itemStack.getItem(); - return tool.getTier().getLevel(); + return (int) tool.getTier().getAttackDamageBonus(); } else { return -1; } @@ -184,7 +184,7 @@ public class ToolSet { float speed = item.getDestroySpeed(state); if (speed > 1) { - int effLevel = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_EFFICIENCY, item); + int effLevel = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.EFFICIENCY, item); if (effLevel > 0 && !item.isEmpty()) { speed += effLevel * effLevel + 1; }