diff --git a/build.gradle b/build.gradle index e61d2eb8..19695db2 100755 --- a/build.gradle +++ b/build.gradle @@ -19,9 +19,8 @@ import net.fabricmc.loom.task.RemapJarTask plugins { - id 'org.quiltmc.loom' version '1.+' - id 'io.github.ladysnake.chenille' version "0.9.0" - id 'io.github.juuxel.loom-quiltflower' version "1.6.0" + id 'org.quiltmc.loom' version '1.4.+' + id 'io.github.ladysnake.chenille' version "0.11.3" } group project.maven_group @@ -82,6 +81,11 @@ repositories { jamieswhiteshirt() } + maven { + name = 'Quilt Snapshots' + url = 'https://maven.quiltmc.org/repository/snapshot' + } + mavenLocal() } @@ -93,10 +97,18 @@ dependencies { modImplementation "org.quiltmc:qsl:${qsl_version}+${minecraft_version}" modImplementation "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${quilted_fabric_api_version}-${minecraft_version}" implementation 'com.google.code.findbugs:jsr305:3.0.2' - modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-base:${cca_version}" - modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${cca_version}" - modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-world:${cca_version}" - modImplementation "com.jamieswhiteshirt:reach-entity-attributes:${reach_version}" + modImplementation("dev.onyxstudios.cardinal-components-api:cardinal-components-base:${cca_version}") { + transitive = false + } + modImplementation("dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${cca_version}") { + transitive = false + } + modImplementation("dev.onyxstudios.cardinal-components-api:cardinal-components-world:${cca_version}") { + transitive = false + } + modImplementation("com.jamieswhiteshirt:reach-entity-attributes:${reach_version}") { + transitive = false + } modLocalImplementation("io.github.ladysnake:elmendorf:${elmendorf_version}") { transitive = false } diff --git a/changelog.md b/changelog.md index 2b8a359d..c38aa624 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,10 @@ +------------------------------------------------------ +Version 0.11.0 +------------------------------------------------------ +Updated to 1.20.1 + +- Merged fix from 0.9.1 + ------------------------------------------------------ Version 0.10.0 ------------------------------------------------------ diff --git a/gradle.properties b/gradle.properties index 882e153d..263335ec 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,14 +20,14 @@ org.gradle.jvmargs = -Xmx3G mod_name = Automatone -mod_version = 0.10.0 +mod_version = 0.11.0 maven_group = io.github.ladysnake -minecraft_version = 1.19.3 -quilt_mappings = 20 -quilt_loader_version=0.18.1-beta.60 -qsl_version = 4.0.0-beta.9 -quilted_fabric_api_version = 5.0.0-beta.1+0.73.0 -cca_version = 5.0.1 -reach_version = 2.3.1 -elmendorf_version = 0.9.0 +minecraft_version = 1.20.1 +quilt_mappings = 7 +quilt_loader_version=0.21.1 +qsl_version = 6.0.3 +quilted_fabric_api_version = 7.0.4+0.84.0 +cca_version = 5.2.1 +reach_version = 2.4.0 +elmendorf_version = 0.11.0 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 41dfb879..e411586a 100755 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/api/java/baritone/api/command/ICommand.java b/src/api/java/baritone/api/command/ICommand.java index 2299bb62..d3c4d7bb 100644 --- a/src/api/java/baritone/api/command/ICommand.java +++ b/src/api/java/baritone/api/command/ICommand.java @@ -78,13 +78,15 @@ default boolean hiddenFromHelp() { * @param components The components to send */ default void logDirect(ServerCommandSource source, Text... components) { - MutableText component = Text.literal(""); - // If we are not logging as a Toast - // Append the prefix to the base component line - component.append(BaritoneAPI.getPrefix()); - component.append(Text.literal(" ")); - Arrays.asList(components).forEach(component::append); - source.sendFeedback(component, false); + source.sendFeedback(() -> { + MutableText component = Text.literal(""); + // If we are not logging as a Toast + // Append the prefix to the base component line + component.append(BaritoneAPI.getPrefix()); + component.append(Text.literal(" ")); + for (Text t : components) component.append(t); + return component; + }, false); } /** diff --git a/src/api/java/baritone/api/command/helpers/Paginator.java b/src/api/java/baritone/api/command/helpers/Paginator.java index 59c15e94..f204ef66 100644 --- a/src/api/java/baritone/api/command/helpers/Paginator.java +++ b/src/api/java/baritone/api/command/helpers/Paginator.java @@ -65,9 +65,10 @@ public void display(Function transform, String commandPrefix) { int offset = (page - 1) * pageSize; for (int i = offset; i < offset + pageSize; i++) { if (i < entries.size()) { - source.sendFeedback(transform.apply(entries.get(i)), false); + E entry = entries.get(i); + source.sendFeedback(() -> transform.apply(entry), false); } else { - source.sendFeedback(Text.literal("--").formatted(Formatting.DARK_GRAY), false); + source.sendFeedback(() -> Text.literal("--").formatted(Formatting.DARK_GRAY), false); } } boolean hasPrevPage = commandPrefix != null && validPage(page - 1); @@ -100,13 +101,15 @@ public void display(Function transform, String commandPrefix) { } else { nextPageComponent.setStyle(nextPageComponent.getStyle().withFormatting(Formatting.DARK_GRAY)); } - MutableText pagerComponent = Text.literal(""); - pagerComponent.setStyle(pagerComponent.getStyle().withFormatting(Formatting.GRAY)); - pagerComponent.append(prevPageComponent); - pagerComponent.append(" | "); - pagerComponent.append(nextPageComponent); - pagerComponent.append(String.format(" %d/%d", page, getMaxPage())); - source.sendFeedback(pagerComponent, false); + source.sendFeedback(() -> { + MutableText pagerComponent = Text.literal(""); + pagerComponent.setStyle(pagerComponent.getStyle().withFormatting(Formatting.GRAY)); + pagerComponent.append(prevPageComponent); + pagerComponent.append(" | "); + pagerComponent.append(nextPageComponent); + pagerComponent.append(String.format(" %d/%d", page, getMaxPage())); + return pagerComponent; + }, false); } public static void paginate(IArgConsumer consumer, Paginator pagi, Runnable pre, Function transform, String commandPrefix) throws CommandException { diff --git a/src/api/java/baritone/api/event/events/PacketEvent.java b/src/api/java/baritone/api/event/events/PacketEvent.java index 75d220af..9ce16e46 100644 --- a/src/api/java/baritone/api/event/events/PacketEvent.java +++ b/src/api/java/baritone/api/event/events/PacketEvent.java @@ -19,7 +19,7 @@ import baritone.api.event.events.type.EventState; import net.minecraft.network.ClientConnection; -import net.minecraft.network.Packet; +import net.minecraft.network.packet.Packet; /** * @author Brady diff --git a/src/api/java/baritone/api/fakeplayer/FakeClientPlayerEntity.java b/src/api/java/baritone/api/fakeplayer/FakeClientPlayerEntity.java index 63e1e63d..f5ef3240 100644 --- a/src/api/java/baritone/api/fakeplayer/FakeClientPlayerEntity.java +++ b/src/api/java/baritone/api/fakeplayer/FakeClientPlayerEntity.java @@ -95,12 +95,12 @@ public void setDisplayProfile(@CheckForNull GameProfile profile) { @Override public void playSound(SoundEvent sound, float volume, float pitch) { if (!this.isSilent()) { - this.world.playSound(this.getX(), this.getY(), this.getZ(), sound, this.getSoundCategory(), volume, pitch, false); + this.getWorld().playSound(this.getX(), this.getY(), this.getZ(), sound, this.getSoundCategory(), volume, pitch, false); } } @Override public void playSound(SoundEvent event, SoundCategory category, float volume, float pitch) { - this.world.playSound(this.getX(), this.getY(), this.getZ(), event, category, volume, pitch, false); + this.getWorld().playSound(this.getX(), this.getY(), this.getZ(), event, category, volume, pitch, false); } } diff --git a/src/api/java/baritone/api/fakeplayer/FakeServerPlayerEntity.java b/src/api/java/baritone/api/fakeplayer/FakeServerPlayerEntity.java index 8635e690..d6707901 100644 --- a/src/api/java/baritone/api/fakeplayer/FakeServerPlayerEntity.java +++ b/src/api/java/baritone/api/fakeplayer/FakeServerPlayerEntity.java @@ -50,7 +50,7 @@ import net.minecraft.nbt.NbtHelper; import net.minecraft.network.ClientConnection; import net.minecraft.network.NetworkSide; -import net.minecraft.network.Packet; +import net.minecraft.network.packet.Packet; import net.minecraft.network.PacketByteBuf; import net.minecraft.network.listener.ClientPlayPacketListener; import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket; @@ -80,7 +80,7 @@ public FakeServerPlayerEntity(EntityType type, ServerWor public FakeServerPlayerEntity(EntityType type, ServerWorld world, GameProfile profile) { super(world.getServer(), world, profile); ((IEntityAccessor)this).automatone$setType(type); - this.stepHeight = 0.6f; // same step height as LivingEntity + this.setStepHeight(0.6f); // same step height as LivingEntity // Side effects go brr new ServerPlayNetworkHandler(world.getServer(), new ClientConnection(NetworkSide.S2C), this); } @@ -172,7 +172,7 @@ public void takeKnockback(double strength, double x, double z) { @Override protected void fall(double heightDifference, boolean onGround, BlockState landedState, BlockPos landedPosition) { - this.handleFall(heightDifference, onGround); + this.handleFall(0, heightDifference, 0, onGround); } @Override diff --git a/src/api/java/baritone/api/utils/BlockOptionalMeta.java b/src/api/java/baritone/api/utils/BlockOptionalMeta.java index b3133f6d..8adaee4f 100644 --- a/src/api/java/baritone/api/utils/BlockOptionalMeta.java +++ b/src/api/java/baritone/api/utils/BlockOptionalMeta.java @@ -26,6 +26,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.loot.LootTables; import net.minecraft.loot.context.LootContext; +import net.minecraft.loot.context.LootContextParameterSet; import net.minecraft.loot.context.LootContextParameters; import net.minecraft.loot.context.LootContextTypes; import net.minecraft.server.world.ServerWorld; @@ -142,14 +143,15 @@ private static synchronized List drops(ServerWorld world, Block b) { } else { List items = new ArrayList<>(); - world.getServer().getLootManager().getTable(lootTableLocation).generateLoot( - new LootContext.Builder(world) - .random(world.random) - .parameter(LootContextParameters.ORIGIN, Vec3d.of(BlockPos.ZERO)) - .parameter(LootContextParameters.TOOL, ItemStack.EMPTY) - .optionalParameter(LootContextParameters.BLOCK_ENTITY, null) - .parameter(LootContextParameters.BLOCK_STATE, block.getDefaultState()) - .build(LootContextTypes.BLOCK), + world.getServer().getLootManager().getLootTable(lootTableLocation).generateLoot( + new LootContext.Builder(new LootContextParameterSet.Builder(world) + .add(LootContextParameters.ORIGIN, Vec3d.of(BlockPos.ZERO)) + .add(LootContextParameters.TOOL, ItemStack.EMPTY) + .addOptional(LootContextParameters.BLOCK_ENTITY, null) + .add(LootContextParameters.BLOCK_STATE, block.getDefaultState()) + .build(LootContextTypes.BLOCK)) + .withRandomSeed(world.getSeed()) + .build(null), stack -> items.add(stack.getItem()) ); return items; diff --git a/src/api/java/baritone/api/utils/RayTraceUtils.java b/src/api/java/baritone/api/utils/RayTraceUtils.java index 5b69b513..0620e054 100644 --- a/src/api/java/baritone/api/utils/RayTraceUtils.java +++ b/src/api/java/baritone/api/utils/RayTraceUtils.java @@ -58,7 +58,7 @@ public static HitResult rayTraceTowards(Entity entity, Rotation rotation, double direction.y * blockReachDistance, direction.z * blockReachDistance ); - return entity.world.raycast(new RaycastContext(start, end, RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, entity)); + return entity.getWorld().raycast(new RaycastContext(start, end, RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, entity)); } public static Vec3d inferSneakingEyePosition(Entity entity) { diff --git a/src/api/java/baritone/api/utils/RotationUtils.java b/src/api/java/baritone/api/utils/RotationUtils.java index c06eb2b1..701dfd79 100644 --- a/src/api/java/baritone/api/utils/RotationUtils.java +++ b/src/api/java/baritone/api/utils/RotationUtils.java @@ -197,8 +197,8 @@ public static Optional reachable(LivingEntity entity, BlockPos pos, do return possibleRotation; } - BlockState state = entity.world.getBlockState(pos); - VoxelShape shape = state.getOutlineShape(entity.world, pos); + BlockState state = entity.getWorld().getBlockState(pos); + VoxelShape shape = state.getOutlineShape(entity.getWorld(), pos); if (shape.isEmpty()) { shape = VoxelShapes.fullCube(); } @@ -234,7 +234,7 @@ public static Optional reachableOffset(Entity entity, BlockPos pos, Ve if (((BlockHitResult) result).getBlockPos().equals(pos)) { return Optional.of(rotation); } - if (entity.world.getBlockState(pos).getBlock() instanceof AbstractFireBlock && ((BlockHitResult) result).getBlockPos().equals(pos.down())) { + if (entity.getWorld().getBlockState(pos).getBlock() instanceof AbstractFireBlock && ((BlockHitResult) result).getBlockPos().equals(pos.down())) { return Optional.of(rotation); } } @@ -251,6 +251,6 @@ public static Optional reachableOffset(Entity entity, BlockPos pos, Ve * @return The optional rotation */ public static Optional reachableCenter(Entity entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) { - return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.world, pos), blockReachDistance, wouldSneak); + return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.getWorld(), pos), blockReachDistance, wouldSneak); } } diff --git a/src/main/java/baritone/AutomatoneClient.java b/src/main/java/baritone/AutomatoneClient.java index 49660a57..b77eb98f 100644 --- a/src/main/java/baritone/AutomatoneClient.java +++ b/src/main/java/baritone/AutomatoneClient.java @@ -125,7 +125,7 @@ private

void spawnPlayer(int id, P other = FakeClientPlayerEntity.createClientFakePlayer(playerType, world, new GameProfile(uuid, name)); other.setId(id); other.setPosition(x, y, z); - other.getPacketPositionCodec().m_tnxpdgof(new Vec3d(x, y, z)); + other.getPacketPositionCodec().setPos(new Vec3d(x, y, z)); other.bodyYaw = headYaw; other.prevBodyYaw = headYaw; other.headYaw = headYaw; diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index e687acc0..23248a60 100644 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -117,7 +117,7 @@ public Baritone(LivingEntity player) { this.commandManager = new BaritoneCommandManager(this); this.execControlProcess = DefaultCommands.controlCommands.registerProcess(this); - this.clientPathingBehaviour = player.world.isClient ? new ClientPathingBehaviour(player) : null; + this.clientPathingBehaviour = player.getWorld().isClient ? new ClientPathingBehaviour(player) : null; } @Override diff --git a/src/main/java/baritone/BaritoneProvider.java b/src/main/java/baritone/BaritoneProvider.java index 1019a857..0221ac24 100644 --- a/src/main/java/baritone/BaritoneProvider.java +++ b/src/main/java/baritone/BaritoneProvider.java @@ -47,7 +47,7 @@ public BaritoneProvider() { @Override public IBaritone getBaritone(LivingEntity entity) { - if (entity.world.isClient()) throw new IllegalStateException("Lol we only support servers now"); + if (entity.getWorld().isClient()) throw new IllegalStateException("Lol we only support servers now"); return IBaritone.KEY.get(entity); } diff --git a/src/main/java/baritone/command/defaults/BuildCommand.java b/src/main/java/baritone/command/defaults/BuildCommand.java index c03760e1..770d2bd3 100644 --- a/src/main/java/baritone/command/defaults/BuildCommand.java +++ b/src/main/java/baritone/command/defaults/BuildCommand.java @@ -49,7 +49,7 @@ public void execute(ServerCommandSource source, String label, IArgConsumer args, if (FilenameUtils.getExtension(file.getAbsolutePath()).isEmpty()) { file = new File(file.getAbsolutePath() + "." + baritone.settings().schematicFallbackExtension.get()); } - BetterBlockPos origin = new BetterBlockPos(new BlockPos(source.getPosition())); + BetterBlockPos origin = new BetterBlockPos(BlockPos.fromPosition(source.getPosition())); BetterBlockPos buildOrigin; if (args.hasAny()) { args.requireMax(3); diff --git a/src/main/java/baritone/command/defaults/ComeCommand.java b/src/main/java/baritone/command/defaults/ComeCommand.java index bdf33668..d170ae46 100644 --- a/src/main/java/baritone/command/defaults/ComeCommand.java +++ b/src/main/java/baritone/command/defaults/ComeCommand.java @@ -38,7 +38,7 @@ public ComeCommand() { @Override public void execute(ServerCommandSource source, String label, IArgConsumer args, IBaritone baritone) throws CommandException { args.requireMax(0); - baritone.getCustomGoalProcess().setGoalAndPath(new GoalBlock(new BlockPos(source.getPosition()))); + baritone.getCustomGoalProcess().setGoalAndPath(new GoalBlock(BlockPos.fromPosition(source.getPosition()))); logDirect(source, "Coming"); } diff --git a/src/main/java/baritone/command/defaults/DefaultCommands.java b/src/main/java/baritone/command/defaults/DefaultCommands.java index 3b225491..12ea20fc 100644 --- a/src/main/java/baritone/command/defaults/DefaultCommands.java +++ b/src/main/java/baritone/command/defaults/DefaultCommands.java @@ -110,24 +110,26 @@ private static void logRanCommand(ServerCommandSource source, String command, St if (BaritoneAPI.getGlobalSettings().echoCommands.get()) { String msg = command + rest; String toDisplay = BaritoneAPI.getGlobalSettings().censorRanCommands.get() ? command + " ..." : msg; - MutableText component = Text.literal(String.format("> %s", toDisplay)); - component.setStyle(component.getStyle() - .withFormatting(Formatting.WHITE) - .withHoverEvent(new HoverEvent( - HoverEvent.Action.SHOW_TEXT, - Text.literal("Click to rerun command") - )) - .withClickEvent(new ClickEvent( - ClickEvent.Action.RUN_COMMAND, - FORCE_COMMAND_PREFIX + msg - ))); - source.sendFeedback(component, false); + source.sendFeedback(() -> { + MutableText component = Text.literal(String.format("> %s", toDisplay)); + component.setStyle(component.getStyle() + .withFormatting(Formatting.WHITE) + .withHoverEvent(new HoverEvent( + HoverEvent.Action.SHOW_TEXT, + Text.literal("Click to rerun command") + )) + .withClickEvent(new ClickEvent( + ClickEvent.Action.RUN_COMMAND, + FORCE_COMMAND_PREFIX + msg + ))); + return component; + }, false); } } public static boolean runCommand(ServerCommandSource source, String msg, IBaritone baritone) throws CommandException { if (msg.trim().equalsIgnoreCase("damn")) { - source.sendFeedback(Text.literal("daniel"), false); + source.sendFeedback(() -> Text.literal("daniel"), false); return false; } else if (msg.trim().equalsIgnoreCase("orderpizza")) { Automatone.LOGGER.fatal("No pizza :("); diff --git a/src/main/java/baritone/command/defaults/SelCommand.java b/src/main/java/baritone/command/defaults/SelCommand.java index 28c1e6e8..9efcdd03 100644 --- a/src/main/java/baritone/command/defaults/SelCommand.java +++ b/src/main/java/baritone/command/defaults/SelCommand.java @@ -256,6 +256,7 @@ public List getLongDesc() { public void renderSelectionBox() { Settings settings = BaritoneAPI.getGlobalSettings(); + BetterBlockPos pos1 = this.pos1; if (!settings.renderSelectionCorners.get() || pos1 == null) { return; } diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index ea14290e..0f108645 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -263,7 +263,7 @@ static boolean isReplaceable(int x, int y, int z, BlockState state, BlockStateIn if (block == Blocks.LARGE_FERN || block == Blocks.TALL_GRASS) { return true; } - return state.getMaterial().isReplaceable(); + return state.materialReplaceable(); } @Deprecated diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index a896e5b0..9d6f0444 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -296,7 +296,7 @@ public MovementState updateState(MovementState state) { if (!blockIsThere) { BlockState frState = BlockStateInterface.get(ctx, src); // TODO: Evaluate usage of getMaterial().isReplaceable() - if (!(frState.isAir() || frState.getMaterial().isReplaceable())) { + if (!(frState.isAir() || frState.materialReplaceable())) { RotationUtils.reachable(ctx.entity(), src, ctx.playerController().getBlockReachDistance()) .map(rot -> new MovementState.MovementTarget(rot, true)) .ifPresent(state::setTarget); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index d9df4620..857465e8 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -248,7 +248,7 @@ public static void cost(CalculationContext context, int x, int y, int z, int des // now that we've checked all possible directions to side place, we actually need to backplace // none of the vanilla impls do a blocking or thread unsafe call, so passing the world directly should be fine // also none of the full cubes actually use the pos, so we should be fine not creating a real BlockPos for this - if (!srcOn.getMaterial().isReplaceable() && !srcOn.isFullCube(context.world, BlockPos.ORIGIN)) { + if (!srcOn.materialReplaceable() && !srcOn.isFullCube(context.world, BlockPos.ORIGIN)) { // If srcOn is currently replaceable, we will have a proper block when we stand on it return; // can't sneak and backplace against eg. soul sand or half slabs (regardless of whether it's top half or bottom half) =/ } @@ -294,7 +294,7 @@ public MovementState updateState(MovementState state) { return state; } - if (!state.getTarget().getRotation().isPresent()) { + if (state.getTarget().getRotation().isEmpty()) { // this can happen rarely when the server lags and doesn't send the falling sand entity until you've already walked through the block and are now mining the next one return state; } @@ -413,13 +413,13 @@ public MovementState updateState(MovementState state) { state.setInput(Input.SNEAK, true); } switch (p) { - case READY_TO_PLACE: { + case READY_TO_PLACE -> { if (ctx.entity().isSneaking() || baritone.settings().assumeSafeWalk.get()) { state.setInput(Input.CLICK_RIGHT, true); } return state; } - case ATTEMPTING: { + case ATTEMPTING -> { if (dist1 > 0.83) { // might need to go forward a bit float yaw = RotationUtils.calcRotationFromVec3d(ctx.headPos(), VecUtils.getBlockPosCenter(dest), ctx.entityRotations()).getYaw(); @@ -433,8 +433,8 @@ public MovementState updateState(MovementState state) { } return state; } - default: - break; + default -> { + } } if (feet.equals(dest)) { // If we are in the block that we are trying to get to, we are sneaking over air and we need to place a block beneath us against the one we just walked off of diff --git a/src/main/java/baritone/process/FarmProcess.java b/src/main/java/baritone/process/FarmProcess.java index ac755149..659e1909 100644 --- a/src/main/java/baritone/process/FarmProcess.java +++ b/src/main/java/baritone/process/FarmProcess.java @@ -224,7 +224,7 @@ public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) { } if (state.getBlock() instanceof Fertilizable) { Fertilizable ig = (Fertilizable) state.getBlock(); - if (ig.isFertilizable(ctx.world(), pos, state, true) && ig.canGrow(ctx.world(), ctx.world().random, pos, state)) { + if (ig.isFertilizable(ctx.world(), pos, state, true) && ig.canFertilize(ctx.world(), ctx.world().random, pos, state)) { bonemealable.add(pos); } } @@ -300,7 +300,7 @@ public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) { for (ItemEntity item : ctx.world().getEntitiesByClass(ItemEntity.class, ctx.entity().getBoundingBox().expand(30), Entity::isOnGround)) { if (PICKUP_DROPPED.contains(item.getStack().getItem())) { // +0.1 because of farmland's 0.9375 dummy height lol - goalz.add(new GoalBlock(new BlockPos(item.getX(), item.getY() + 0.1, item.getZ()))); + goalz.add(new GoalBlock(BlockPos.create(item.getX(), item.getY() + 0.1, item.getZ()))); } } return new PathingCommand(new GoalComposite(goalz.toArray(new Goal[0])), PathingCommandType.SET_GOAL_AND_PATH); diff --git a/src/main/java/baritone/process/FollowProcess.java b/src/main/java/baritone/process/FollowProcess.java index 9e163788..c98ed586 100644 --- a/src/main/java/baritone/process/FollowProcess.java +++ b/src/main/java/baritone/process/FollowProcess.java @@ -60,7 +60,7 @@ private Goal towards(Entity following) { pos = following.getBlockPos(); } else { GoalXZ g = GoalXZ.fromDirection(following.getPos(), baritone.settings().followOffsetDirection.get(), baritone.settings().followOffsetDistance.get()); - pos = new BlockPos(g.getX(), following.getY(), g.getZ()); + pos = BlockPos.create(g.getX(), following.getY(), g.getZ()); } return new GoalNear(pos, baritone.settings().followRadius.get()); } diff --git a/src/main/java/baritone/render/ClientPathingBehaviour.java b/src/main/java/baritone/render/ClientPathingBehaviour.java index 5e272856..8027cace 100644 --- a/src/main/java/baritone/render/ClientPathingBehaviour.java +++ b/src/main/java/baritone/render/ClientPathingBehaviour.java @@ -39,7 +39,7 @@ public ClientPathingBehaviour(Entity entity) { public Goal getGoal() { // Reaching across sides is fun return Optional.ofNullable(MinecraftClient.getInstance().getServer()) - .map(s -> s.getWorld(this.entity.world.getRegistryKey())) + .map(s -> s.getWorld(this.entity.getWorld().getRegistryKey())) .map(w -> w.getEntity(this.entity.getUuid())) .map(IBaritone.KEY::getNullable) .map(IBaritone::getPathingBehavior) @@ -50,7 +50,7 @@ public Goal getGoal() { public Optional getInProgress() { // Reaching across sides is fun return Optional.ofNullable(MinecraftClient.getInstance().getServer()) - .map(s -> s.getWorld(this.entity.world.getRegistryKey())) + .map(s -> s.getWorld(this.entity.getWorld().getRegistryKey())) .map(w -> w.getEntity(this.entity.getUuid())) .map(IBaritone.KEY::getNullable) .map(IBaritone::getPathingBehavior) diff --git a/src/main/java/baritone/utils/GuiClick.java b/src/main/java/baritone/utils/GuiClick.java index 575279b5..52275296 100644 --- a/src/main/java/baritone/utils/GuiClick.java +++ b/src/main/java/baritone/utils/GuiClick.java @@ -21,8 +21,14 @@ import baritone.api.utils.BetterBlockPos; import com.mojang.blaze3d.glfw.Window; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.VertexConsumer; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.render.Camera; +import net.minecraft.client.render.GameRenderer; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.WorldRenderer; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; @@ -66,7 +72,7 @@ public boolean isPauseScreen() { } @Override - public void render(MatrixStack stack, int mouseX, int mouseY, float partialTicks) { + public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) { MinecraftClient mc = MinecraftClient.getInstance(); double mx = mc.mouse.getX(); double my = mc.mouse.getY(); @@ -81,7 +87,7 @@ public void render(MatrixStack stack, int mouseX, int mouseY, float partialTicks /// Vec3d viewerPos = new Vec3d(PathRenderer.posX(), PathRenderer.posY(), PathRenderer.posZ()); PlayerEntity player = Objects.requireNonNull(MinecraftClient.getInstance().player); - BlockHitResult result = player.world.raycast(new RaycastContext(near.add(viewerPos), far.add(viewerPos), RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, player)); + BlockHitResult result = player.getWorld().raycast(new RaycastContext(near.add(viewerPos), far.add(viewerPos), RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, player)); if (result != null && result.getType() == HitResult.Type.BLOCK) { currentMouseOver = result.getBlockPos(); } @@ -97,9 +103,9 @@ public boolean mouseReleased(double mouseX, double mouseY, int mouseButton) { assert client.world != null; if (mouseButton == 0) { if (clickStart != null && !clickStart.equals(currentMouseOver)) { - client.player.networkHandler.m_gkszsvqi(String.format("execute as %s run automatone sel clear", callerUuid)); - client.player.networkHandler.m_gkszsvqi(String.format("execute as %s run automatone sel 1 %d %d %d", callerUuid, clickStart.getX(), clickStart.getY(), clickStart.getZ())); - client.player.networkHandler.m_gkszsvqi(String.format("execute as %s run automatone sel 2 %d %d %d", callerUuid, currentMouseOver.getX(), currentMouseOver.getY(), currentMouseOver.getZ())); + client.player.networkHandler.sendChatCommand(String.format("execute as %s run automatone sel clear", callerUuid)); + client.player.networkHandler.sendChatCommand(String.format("execute as %s run automatone sel 1 %d %d %d", callerUuid, clickStart.getX(), clickStart.getY(), clickStart.getZ())); + client.player.networkHandler.sendChatCommand(String.format("execute as %s run automatone sel 2 %d %d %d", callerUuid, currentMouseOver.getX(), currentMouseOver.getY(), currentMouseOver.getZ())); MutableText component = Text.literal("").append(BaritoneAPI.getPrefix()).append(" Selection made! For usage: " + FORCE_COMMAND_PREFIX + "help sel"); component.setStyle(component.getStyle() .withFormatting(Formatting.WHITE) @@ -109,10 +115,10 @@ public boolean mouseReleased(double mouseX, double mouseY, int mouseButton) { ))); client.inGameHud.getChatHud().addMessage(component); } else { - client.player.networkHandler.m_gkszsvqi(String.format("execute as %s run automatone goto %d %d %d", callerUuid, currentMouseOver.getX(), currentMouseOver.getY(), currentMouseOver.getZ())); + client.player.networkHandler.sendChatCommand(String.format("execute as %s run automatone goto %d %d %d", callerUuid, currentMouseOver.getX(), currentMouseOver.getY(), currentMouseOver.getZ())); } } else if (mouseButton == 1) { - client.player.networkHandler.m_gkszsvqi(String.format("execute as %s run automatone goto %d %d %d", callerUuid, currentMouseOver.getX(), currentMouseOver.getY() + 1, currentMouseOver.getZ())); + client.player.networkHandler.sendChatCommand(String.format("execute as %s run automatone goto %d %d %d", callerUuid, currentMouseOver.getX(), currentMouseOver.getY() + 1, currentMouseOver.getZ())); } } clickStart = null; @@ -132,23 +138,23 @@ public void onRender(MatrixStack modelViewStack, Matrix4f projectionMatrix) { if (currentMouseOver != null) { Entity e = MinecraftClient.getInstance().getCameraEntity(); - // drawSingleSelectionBox WHEN? - PathRenderer.drawManySelectionBoxes(e, Collections.singletonList(currentMouseOver), Color.CYAN); + Camera c = MinecraftClient.getInstance().gameRenderer.getCamera(); + assert e != null; + VertexConsumer vertexConsumer = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers().getBuffer(RenderLayer.getLines()); + WorldRenderer.drawBox(modelViewStack, vertexConsumer, new Box(currentMouseOver).offset(-c.getPos().x, -c.getPos().y, -c.getPos().z).expand(0.002), 0, 1, 1, 1); if (clickStart != null && !clickStart.equals(currentMouseOver)) { RenderSystem.enableBlend(); RenderSystem.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); - IRenderer.glColor(Color.RED, 0.4F); RenderSystem.lineWidth(BaritoneAPI.getGlobalSettings().pathRenderLineWidthPixels.get()); - RenderSystem.disableTexture(); + RenderSystem.setShader(GameRenderer::getPositionColorShader); RenderSystem.depthMask(false); RenderSystem.disableDepthTest(); BetterBlockPos a = new BetterBlockPos(currentMouseOver); BetterBlockPos b = new BetterBlockPos(clickStart); - IRenderer.drawAABB(new Box(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z), Math.max(a.x, b.x) + 1, Math.max(a.y, b.y) + 1, Math.max(a.z, b.z) + 1)); + WorldRenderer.drawBox(modelViewStack, vertexConsumer, new Box(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z), Math.max(a.x, b.x) + 1, Math.max(a.y, b.y) + 1, Math.max(a.z, b.z) + 1).offset(-c.getPos().x, -c.getPos().y, -c.getPos().z), 1, 0, 0, 0.4f); RenderSystem.enableDepthTest(); RenderSystem.depthMask(true); - RenderSystem.enableTexture(); RenderSystem.disableBlend(); } } diff --git a/src/main/java/baritone/utils/IRenderer.java b/src/main/java/baritone/utils/IRenderer.java index ac4a061f..042f6621 100644 --- a/src/main/java/baritone/utils/IRenderer.java +++ b/src/main/java/baritone/utils/IRenderer.java @@ -22,10 +22,13 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.BufferBuilder; import com.mojang.blaze3d.vertex.Tessellator; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexFormat; import com.mojang.blaze3d.vertex.VertexFormats; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.GameRenderer; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.WorldRenderer; import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.util.math.Box; import net.minecraft.util.math.Vec3d; @@ -51,10 +54,10 @@ static void glColor(Color color, float alpha) { static void startLines(Color color, float alpha, float lineWidth, boolean ignoreDepth) { RenderSystem.enableBlend(); + RenderSystem.setShader(GameRenderer::getPositionColorShader); RenderSystem.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); glColor(color, alpha); RenderSystem.lineWidth(lineWidth); - RenderSystem.disableTexture(); RenderSystem.depthMask(false); if (ignoreDepth) { @@ -72,7 +75,6 @@ static void endLines(boolean ignoredDepth) { } RenderSystem.depthMask(true); - RenderSystem.enableTexture(); RenderSystem.disableBlend(); } @@ -80,6 +82,8 @@ static void drawAABB(Box aabb) { Vec3d cameraPos = renderManager.camera.getPos(); Box toDraw = aabb.offset(-cameraPos.x, -cameraPos.y, -cameraPos.z); + VertexConsumer vertexConsumer3 = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers().getBuffer(RenderLayer.getLines()); + WorldRenderer.drawBox(vertexConsumer3, toDraw.minX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.maxZ, State.red, State.green, State.blue, State.alpha); RenderSystem.setShader(GameRenderer::getPositionColorShader); buffer.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR); // bottom diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index 0550c048..d050daf9 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -83,7 +83,7 @@ public static void render(WorldRenderContext event, ClientPathingBehaviour behav Goal goal = behavior.getGoal(); MinecraftClient mc = MinecraftClient.getInstance(); - DimensionType thisPlayerDimension = behavior.entity.world.getDimension(); + DimensionType thisPlayerDimension = behavior.entity.getWorld().getDimension(); World world = Objects.requireNonNull(MinecraftClient.getInstance().world); DimensionType currentRenderViewDimension = world.getDimension(); @@ -94,7 +94,7 @@ public static void render(WorldRenderContext event, ClientPathingBehaviour behav Entity renderView = mc.getCameraEntity(); - if (renderView.world != world) { + if (renderView.getWorld() != world) { Automatone.LOGGER.error("I have no idea what's going on"); Automatone.LOGGER.error("The primary baritone is in a different world than the render view entity"); Automatone.LOGGER.error("Not rendering the path"); @@ -207,8 +207,8 @@ public static void drawManySelectionBoxes(Entity player, Collection po IRenderer.startLines(color, settings.pathRenderLineWidthPixels.get(), settings.renderSelectionBoxesIgnoreDepth.get()); positions.forEach(pos -> { - BlockState state = player.world.getBlockState(pos); - VoxelShape shape = state.getOutlineShape(player.world, pos); + BlockState state = player.getWorld().getBlockState(pos); + VoxelShape shape = state.getOutlineShape(player.getWorld(), pos); Box toDraw = shape.isEmpty() ? VoxelShapes.fullCube().getBoundingBox() : shape.getBoundingBox(); toDraw = toDraw.offset(pos); IRenderer.drawAABB(toDraw, .002D); @@ -263,9 +263,9 @@ public static void drawDankLitGoalBox(MatrixStack stack, Entity player, Goal goa TEXTURE_BEACON_BEAM, partialTicks, 1.0F, - player.world.getTime(), + player.getWorld().getTime(), 0, - player.world.getHeight(), + player.getWorld().getHeight(), color.getColorComponents(null), // Arguments filled by the private method lol @@ -291,7 +291,7 @@ public static void drawDankLitGoalBox(MatrixStack stack, Entity player, Goal goa y1 = 0; y2 = 0; minY = 0 - renderPosY; - maxY = player.world.getHeight() - renderPosY; + maxY = player.getWorld().getHeight() - renderPosY; } else if (goal instanceof GoalComposite) { for (Goal g : ((GoalComposite) goal).goals()) { drawDankLitGoalBox(stack, player, g, partialTicks, color); diff --git a/src/main/java/baritone/utils/player/EntityContext.java b/src/main/java/baritone/utils/player/EntityContext.java index bdc3eadc..f830bc20 100644 --- a/src/main/java/baritone/utils/player/EntityContext.java +++ b/src/main/java/baritone/utils/player/EntityContext.java @@ -72,7 +72,7 @@ public IPlayerController playerController() { @Override public ServerWorld world() { - World world = this.entity.world; + World world = this.entity.getWorld(); if (world.isClient) throw new IllegalStateException(); return (ServerWorld) world; } diff --git a/src/main/java/baritone/utils/player/ServerPlayerController.java b/src/main/java/baritone/utils/player/ServerPlayerController.java index 3b1c91ec..1338de91 100644 --- a/src/main/java/baritone/utils/player/ServerPlayerController.java +++ b/src/main/java/baritone/utils/player/ServerPlayerController.java @@ -80,22 +80,22 @@ public GameMode getGameType() { @Override public ActionResult processRightClickBlock(PlayerEntity player, World world, Hand hand, BlockHitResult result) { - return this.player.interactionManager.interactBlock(this.player, this.player.world, this.player.getStackInHand(hand), hand, result); + return this.player.interactionManager.interactBlock(this.player, this.player.getWorld(), this.player.getStackInHand(hand), hand, result); } @Override public ActionResult processRightClick(PlayerEntity player, World world, Hand hand) { - return this.player.interactionManager.interactItem(this.player, this.player.world, this.player.getStackInHand(hand), hand); + return this.player.interactionManager.interactItem(this.player, this.player.getWorld(), this.player.getStackInHand(hand), hand); } @Override public boolean clickBlock(BlockPos loc, Direction face) { - BlockState state = this.player.world.getBlockState(loc); + BlockState state = this.player.getWorld().getBlockState(loc); if (state.isAir()) return false; this.player.interactionManager.processBlockBreakingAction(loc, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, face, this.player.getWorld().getTopY(), sequence++); // Success = starting the mining process or insta-mining - return ((IServerPlayerInteractionManager) this.player.interactionManager).isMining() || this.player.world.isAir(loc); + return ((IServerPlayerInteractionManager) this.player.interactionManager).isMining() || this.player.getWorld().isAir(loc); } @Override diff --git a/src/testmod/java/io/github/ladysnake/otomaton/Otomaton.java b/src/testmod/java/io/github/ladysnake/otomaton/Otomaton.java index a8c7c9b8..59e2948d 100644 --- a/src/testmod/java/io/github/ladysnake/otomaton/Otomaton.java +++ b/src/testmod/java/io/github/ladysnake/otomaton/Otomaton.java @@ -42,7 +42,7 @@ public static Identifier id(String path) { public static final EntityType FAKE_PLAYER = FabricEntityTypeBuilder.createLiving() .spawnGroup(SpawnGroup.MISC) .entityFactory(FakePlayers.entityFactory(FakeServerPlayerEntity::new)) - .defaultAttributes(PlayerEntity::createPlayerAttributes) + .defaultAttributes(PlayerEntity::createAttributes) .dimensions(EntityDimensions.changing(EntityType.PLAYER.getWidth(), EntityType.PLAYER.getHeight())) .trackRangeBlocks(64) .trackedUpdateRate(1) diff --git a/src/testmod/java/io/github/ladysnake/otomaton/OtomatonTestSuite.java b/src/testmod/java/io/github/ladysnake/otomaton/OtomatonTestSuite.java index 5e7d7ccc..b124d31f 100644 --- a/src/testmod/java/io/github/ladysnake/otomaton/OtomatonTestSuite.java +++ b/src/testmod/java/io/github/ladysnake/otomaton/OtomatonTestSuite.java @@ -22,7 +22,6 @@ import io.github.ladysnake.elmendorf.GameTestUtil; import io.github.ladysnake.elmendorf.impl.MockClientConnection; import io.github.ladysnake.otomaton.mixin.ServerWorldAccessor; -import net.fabricmc.fabric.api.gametest.v1.FabricGameTest; import net.minecraft.advancement.criterion.Criteria; import net.minecraft.block.Blocks; import net.minecraft.entity.Entity; @@ -44,10 +43,11 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; +import org.quiltmc.qsl.testing.api.game.QuiltGameTest; import java.util.List; -public class OtomatonTestSuite implements FabricGameTest { +public class OtomatonTestSuite implements QuiltGameTest { @BeforeBatch(batchId = "sleepingBatch") public void beforeSleepingTests(ServerWorld world) { world.setTimeOfDay(20000); @@ -65,18 +65,18 @@ public void shellsDoNotPreventSleeping(TestContext ctx) { BlockPos bedPos = new BlockPos(1, 0, 2); fakePlayer.interactionManager.interactBlock( fakePlayer, - fakePlayer.world, + fakePlayer.getWorld(), bed, Hand.MAIN_HAND, new BlockHitResult(new Vec3d(0.5, 0.5, 0.5), Direction.UP, ctx.getAbsolutePos(bedPos), false) ); ctx.expectBlock(Blocks.RED_BED, bedPos); player.interactionManager.interactBlock( - player, player.world, ItemStack.EMPTY, Hand.OFF_HAND, + player, player.getWorld(), ItemStack.EMPTY, Hand.OFF_HAND, new BlockHitResult(new Vec3d(0.5, 0.5, 0.5), Direction.UP, ctx.getAbsolutePos(bedPos), false) ); List players = List.of(fakePlayer, player); - SleepManager sleepManager = ((ServerWorldAccessor) player.world).requiem$getSleepManager(); + SleepManager sleepManager = ((ServerWorldAccessor) player.getWorld()).requiem$getSleepManager(); sleepManager.update(players); GameTestUtil.assertTrue("player should be sleeping", player.isSleeping()); GameTestUtil.assertTrue("all players should be sleeping", sleepManager.canResetTime(100, players)); diff --git a/src/testmod/resources/fabric.mod.json b/src/testmod/resources/fabric.mod.json index 963cf7ba..eb246c8d 100644 --- a/src/testmod/resources/fabric.mod.json +++ b/src/testmod/resources/fabric.mod.json @@ -22,7 +22,7 @@ "client_init": [ "io.github.ladysnake.otomaton.OtomatonClient" ], - "fabric-gametest": [ + "quilt:game_test": [ "io.github.ladysnake.otomaton.OtomatonTestSuite" ] },