Skip to content

Commit

Permalink
Update to 1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrofab committed Jun 27, 2022
1 parent 3883c90 commit 01f03ed
Show file tree
Hide file tree
Showing 25 changed files with 159 additions and 115 deletions.
16 changes: 9 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@

import net.fabricmc.loom.task.RemapJarTask

import java.util.stream.Collectors

plugins {
id 'io.github.ladysnake.chenille' version "0.7.0"
id 'io.github.ladysnake.chenille' version "0.9.0"
id 'io.github.juuxel.loom-quiltflower' version "1.6.0"
}

Expand Down Expand Up @@ -88,15 +86,19 @@ repositories {

dependencies {
minecraft "com.mojang:minecraft:${minecraft_version}"
mappings "net.fabricmc:yarn:${yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${loader_version}"
mappings(loom.layered {
addLayer(quiltMappings.mappings("org.quiltmc:quilt-mappings:${minecraft_version}+build.${quilt_mappings_version}:v2"))
})
modImplementation "org.quiltmc:quilt-loader:${project.quilt_loader_version}"

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 "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
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}"
modTestImplementation("io.github.ladysnake:elmendorf:${elmendorf_version}") {
modLocalImplementation("io.github.ladysnake:elmendorf:${elmendorf_version}") {
transitive = false
}
compileOnly "com.demonwav.mcdev:annotations:1.0"
Expand Down
11 changes: 6 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ mod_name = Automatone
mod_version = 0.8.0
maven_group = io.github.ladysnake

minecraft_version=1.19-pre1
yarn_mappings=1.19-pre1+build.1
loader_version=0.14.5
fabric_version=0.52.4+1.19
minecraft_version=1.19
quilt_mappings_version=1
quilt_loader_version=0.17.1-beta.1
qsl_version = 2.0.0-beta.2
quilted_fabric_api_version = 2.0.0-alpha.2+0.55.3
cca_version = 5.0.0-beta.1
reach_version = 2.1.1
reach_version = 2.3.0
elmendorf_version = 0.6.0
4 changes: 4 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ pluginManagement {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
maven {
name = 'Quilt'
url = 'https://maven.quiltmc.org/repository/release'
}
gradlePluginPortal()
mavenLocal()
}
Expand Down
9 changes: 7 additions & 2 deletions src/api/java/baritone/api/utils/BlockOptionalMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,15 @@
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.random.AbstractRandom;

import javax.annotation.Nonnull;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.MatchResult;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down
4 changes: 2 additions & 2 deletions src/launch/java/baritone/launch/mixins/MixinEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

@Mixin(Entity.class)
public abstract class MixinEntity implements IEntityAccessor {
@Shadow public abstract World getEntityWorld();
@Shadow public abstract World getWorld();

@Override
@Invoker("getEyeHeight")
Expand All @@ -46,7 +46,7 @@ public abstract class MixinEntity implements IEntityAccessor {

@Inject(method = "setRemoved", at = @At("RETURN"))
private void shutdownPathingOnUnloading(Entity.RemovalReason reason, CallbackInfo ci) {
if (!getEntityWorld().isClient()) {
if (!getWorld().isClient()) {
IBaritone.KEY.maybeGet(this).ifPresent(b -> ((PathingBehavior) b.getPathingBehavior()).shutdown());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public abstract class MixinServerPlayerInteractionManager implements IServerPlay
}

@Inject(method = "processBlockBreakingAction", at = @At(value = "FIELD", target = "Lnet/minecraft/server/network/ServerPlayerInteractionManager;miningPos:Lnet/minecraft/util/math/BlockPos;", opcode = Opcodes.PUTFIELD))
private void setBrokeBlock(BlockPos pos, PlayerActionC2SPacket.Action action, Direction direction, int worldHeight, CallbackInfo ci) {
private void setBrokeBlock(BlockPos pos, PlayerActionC2SPacket.Action action, Direction direction, int worldHeight, int i, CallbackInfo ci) {
this.automatone$brokeBlock = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,15 @@
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.Set;

@Mixin(Entity.class)
public abstract class EntityMixin {
@SuppressWarnings("unused") // makes the field mutable for use by IEntityAccessor
@Shadow @Mutable @Final private EntityType<?> type;

@Dynamic("hasPlayerRider player check lambda")
@Inject(method = "method_31469", at = @At(value = "HEAD"), cancellable = true)
@Inject(method = "m_lsaraprt", at = @At(value = "HEAD"), cancellable = true)
private static void removeFakePlayers(Entity entity, CallbackInfoReturnable<Boolean> cir) {
if (entity instanceof AutomatoneFakePlayer) {
cir.setReturnValue(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public abstract class PlayerAdvancementTrackerMixin {
@Shadow
private ServerPlayerEntity owner;

@Inject(method = "grantCriterion", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/PlayerManager;broadcast(Lnet/minecraft/text/Text;Lnet/minecraft/network/MessageType;Ljava/util/UUID;)V"), cancellable = true)
@Inject(method = "grantCriterion", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/PlayerManager;broadcastSystemMessage(Lnet/minecraft/text/Text;Lnet/minecraft/util/registry/RegistryKey;)V"), cancellable = true)
private void cancelAdvancementProgress(Advancement advancement, String criterionName, CallbackInfoReturnable<Boolean> cir) {
if (this.owner instanceof AutomatoneFakePlayer) cir.setReturnValue(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.mojang.authlib.GameProfile;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.encryption.PlayerPublicKey;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
Expand All @@ -50,8 +51,8 @@

@Mixin(ServerPlayerEntity.class)
public abstract class ServerPlayerEntityMixin extends PlayerEntity {
public ServerPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile profile) {
super(world, pos, yaw, profile);
public ServerPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile profile, PlayerPublicKey playerPublicKey) {
super(world, pos, yaw, profile, playerPublicKey);
}

/**
Expand Down
42 changes: 0 additions & 42 deletions src/launch/resources/fabric.mod.json

This file was deleted.

60 changes: 60 additions & 0 deletions src/launch/resources/quilt.mod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"schema_version": 1,
"quilt_loader": {
"group": "io.github.ladysnake",
"id": "automatone",
"version": "${version}",
"metadata": {
"name": "Automatone",
"description": "A serverside Minecraft pathfinder bot.",
"authors": [
"leijurv",
"Brady",
"Pyrofab"
],
"icon": "assets/automatone/icon.png",
"contact": {
"sources": "https://github.com/Ladysnake/automatone",
"issues": "https://github.com/Ladysnake/automatone/issues"
},
"license": "LGPL-3.0"
},
"intermediate_mappings": "net.fabricmc:intermediary",
"entrypoints": {
"init": "baritone.Automatone",
"client_init": "baritone.AutomatoneClient",
"cardinal-components": "baritone.AutomatoneComponents"
},
"depends": [
{
"id": "cardinal-components-base",
"version": "^5.0.0-"
},
{
"id": "cardinal-components-entity",
"version": "^5.0.0-"
},
{
"id": "cardinal-components-world",
"version": "^5.0.0-"
},
{
"id": "fabric",
"version": "*"
},
{
"id": "reach-entity-attributes",
"version": "*"
}]
},
"mixin": "mixins.automatone.json",
"minecraft": {
"environment": "*"
},
"cardinal-components": [
"automatone:core",
"automatone:controller",
"automatone:selection_manager",
"automatone:world_data_provider"
]
}
12 changes: 7 additions & 5 deletions src/main/java/baritone/Automatone.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@

import baritone.command.defaults.DefaultCommands;
import baritone.command.manager.BaritoneArgumentType;
import net.fabricmc.api.ModInitializer;
import net.minecraft.command.argument.ArgumentTypes;
import net.minecraft.command.argument.serialize.ConstantArgumentSerializer;
import com.mojang.brigadier.arguments.StringArgumentType;
import net.minecraft.command.argument.SingletonArgumentInfo;
import net.minecraft.item.Item;
import net.minecraft.tag.TagKey;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.qsl.base.api.entrypoint.ModInitializer;
import org.quiltmc.qsl.command.api.ServerArgumentType;

import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
Expand Down Expand Up @@ -58,8 +60,8 @@ public static ThreadPoolExecutor getExecutor() {
}

@Override
public void onInitialize() {
public void onInitialize(ModContainer mod) {
DefaultCommands.registerAll();
ArgumentTypes.register("automatone:command", BaritoneArgumentType.class, ConstantArgumentSerializer.of(BaritoneArgumentType::baritone));
ServerArgumentType.register(id("command"), BaritoneArgumentType.class, SingletonArgumentInfo.contextFree(BaritoneArgumentType::baritone), t -> StringArgumentType.greedyString());
}
}
9 changes: 6 additions & 3 deletions src/main/java/baritone/AutomatoneClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import baritone.utils.GuiClick;
import baritone.utils.PathRenderer;
import com.mojang.authlib.GameProfile;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientEntityEvents;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
Expand All @@ -39,8 +38,11 @@
import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.registry.Registry;
import org.jetbrains.annotations.Nullable;
import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.qsl.base.api.entrypoint.client.ClientModInitializer;

import java.util.Collections;
import java.util.Objects;
Expand Down Expand Up @@ -77,7 +79,7 @@ public static void onRenderPass(WorldRenderContext context) {
}

@Override
public void onInitializeClient() {
public void onInitializeClient(ModContainer mod) {
WorldRenderEvents.BEFORE_DEBUG_RENDER.register(AutomatoneClient::onRenderPass);
ClientPlayNetworking.registerGlobalReceiver(ClickCommand.OPEN_CLICK_SCREEN, (client, handler, buf, responseSender) -> {
UUID uuid = buf.readUuid();
Expand Down Expand Up @@ -110,6 +112,7 @@ public void onInitializeClient() {
});
ClientEntityEvents.ENTITY_UNLOAD.register((entity, world) -> {
//yes, it is normal to remove an IBaritone from a Baritone set
//noinspection SuspiciousMethodCalls
renderList.remove(IBaritone.KEY.getNullable(entity));
selectionRenderList.remove(ISelectionManager.KEY.getNullable(entity));
});
Expand All @@ -122,7 +125,7 @@ private <P extends PlayerEntity & AutomatoneFakePlayer> void spawnPlayer(int id,
P other = FakeClientPlayerEntity.createClientFakePlayer(playerType, world, new GameProfile(uuid, name));
other.setId(id);
other.setPosition(x, y, z);
other.updateTrackedPosition(x, y, z);
other.method_43389().method_43494(new Vec3d(x, y, z));
other.bodyYaw = headYaw;
other.prevBodyYaw = headYaw;
other.headYaw = headYaw;
Expand Down
19 changes: 14 additions & 5 deletions src/main/java/baritone/cache/WorldScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,18 @@
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.chunk.*;

import java.util.*;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkManager;
import net.minecraft.world.chunk.ChunkSection;
import net.minecraft.world.chunk.ChunkStatus;
import net.minecraft.world.chunk.WorldChunk;
import net.minecraft.world.chunk.palette.PalettedContainer;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.IntStream;

public enum WorldScanner implements IWorldScanner {
Expand Down Expand Up @@ -164,11 +173,11 @@ private boolean scanChunkInto(int chunkX, int chunkZ, Chunk chunk, BlockOptional
continue;
}
int yReal = y0 << 4;
PalettedContainer<BlockState> bsc = section.getBlockStateContainer();
PalettedContainer<BlockState> bsc = section.getContainer();
for (int yy = 0; yy < 16; yy++) {
for (int z = 0; z < 16; z++) {
for (int x = 0; x < 16; x++) {
BlockState state = bsc.get(x, yy, z);
BlockState state = bsc.method_12321(x, yy, z);
if (filter.has(state)) {
int y = yReal | yy;
if (result.size() >= max) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/baritone/command/defaults/DefaultCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import com.mojang.brigadier.Message;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
import net.minecraft.command.argument.EntityArgumentType;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
Expand All @@ -46,6 +45,7 @@
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Pair;
import org.quiltmc.qsl.command.api.CommandRegistrationCallback;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -103,7 +103,7 @@ public static void registerAll() {
for (ICommand command : commands) {
ICommandManager.registry.register(command);
}
CommandRegistrationCallback.EVENT.register(((dispatcher, dedicated) -> register(dispatcher)));
CommandRegistrationCallback.EVENT.register(((dispatcher, ctx, dedicated) -> register(dispatcher)));
}

private static void logRanCommand(ServerCommandSource source, String command, String rest) {
Expand Down
Loading

0 comments on commit 01f03ed

Please sign in to comment.