Skip to content

Commit

Permalink
Port to 1.21-pre2
Browse files Browse the repository at this point in the history
  • Loading branch information
misode committed Jun 4, 2024
1 parent 988d3ee commit 36a7138
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 14 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.5
loader_version=0.15.10
minecraft_version=1.21-pre2
loader_version=0.15.11

# Mod Properties
mod_version=1.7.0
mod_version=1.8.0-beta1
maven_group=io.github.misode
archives_base_name=packtest

# Dependencies
fabric_version=0.97.5+1.20.5
fabric_version=0.99.4+1.21
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public record CommandStep(String line, int lineNumber, CommandDispatcher<Command
@Override
public void register(GameTestSequence sequence, CommandSourceStack source) {
try {
ResourceLocation id = new ResourceLocation("packtest", "internal");
ResourceLocation id = ResourceLocation.fromNamespaceAndPath("packtest", "internal");
CommandFunction<CommandSourceStack> function = CommandFunction.fromLines(id, this.dispatcher, source, List.of(this.line));
InstantiatedFunction<CommandSourceStack> instantiated = function.instantiate(null, this.dispatcher);
Runnable runCommands = () -> {
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/io/github/misode/packtest/dummy/Dummy.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.mojang.authlib.GameProfile;
import net.minecraft.core.BlockPos;
import net.minecraft.core.UUIDUtil;
import net.minecraft.network.DisconnectionDetails;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.PacketFlow;
import net.minecraft.network.protocol.game.ClientboundRotateHeadPacket;
Expand All @@ -18,6 +19,7 @@
import net.minecraft.server.players.GameProfileCache;
import net.minecraft.util.RandomSource;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameRules;
Expand Down Expand Up @@ -87,11 +89,11 @@ public String getUsername() {

public void leave(Component reason) {
server.getPlayerList().remove(this);
this.connection.onDisconnect(reason);
this.connection.onDisconnect(new DisconnectionDetails(reason));
}

public void respawn() {
server.getPlayerList().respawn(this, false);
server.getPlayerList().respawn(this, false, Entity.RemovalReason.KILLED);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ private static <A extends ArgumentType<?>, T extends ArgumentTypeInfo.Template<A
@Inject(method = "bootstrap", at = @At("RETURN"))
private static <A extends ArgumentType<?>, T extends ArgumentTypeInfo.Template<A>> void bootstrap(Registry<ArgumentTypeInfo<?, ?>> registry, CallbackInfoReturnable<ArgumentTypeInfo<A, T>> cir) {
if (!SharedConstants.IS_RUNNING_IN_IDE) {
if (!registry.containsKey(new ResourceLocation("test_argument"))) {
if (!registry.containsKey(ResourceLocation.withDefaultNamespace("test_argument"))) {
register(registry, "test_argument", TestFunctionArgument.class, SingletonArgumentInfo.contextFree(TestFunctionArgument::testFunctionArgument));
}
if (!registry.containsKey(new ResourceLocation("test_class"))) {
if (!registry.containsKey(ResourceLocation.withDefaultNamespace("test_class"))) {
register(registry, "test_class", TestClassNameArgument.class, SingletonArgumentInfo.contextFree(TestClassNameArgument::testClassName));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.players.PlayerList;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.storage.PlayerDataStorage;
import net.minecraft.world.phys.Vec3;
Expand Down Expand Up @@ -72,7 +73,7 @@ private ServerPlayer createDummy(MinecraftServer server, ServerLevel level, Game
}

@Inject(method = "respawn", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerPlayer;restoreFrom(Lnet/minecraft/server/level/ServerPlayer;Z)V"))
private void teleportDummy(ServerPlayer serverPlayer, boolean bl, CallbackInfoReturnable<ServerPlayer> cir, @Local(ordinal = 1) ServerPlayer player) {
private void teleportDummy(ServerPlayer serverPlayer, boolean bl, Entity.RemovalReason removalReason, CallbackInfoReturnable<ServerPlayer> cir, @Local(ordinal = 1) ServerPlayer player) {
if (player instanceof Dummy dummy) {
Vec3 pos = dummy.originalSpawn;
dummy.moveTo(pos.x, pos.y, pos.z, 0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private void init(RegistryAccess.Frozen frozen, FeatureFlagSet featureFlagSet, C
}

@ModifyReturnValue(method = "listeners", at = @At("RETURN"))
private static List<PreparableReloadListener> listeners(List<PreparableReloadListener> list) {
private List<PreparableReloadListener> listeners(List<PreparableReloadListener> list) {
List<PreparableReloadListener> result = new ArrayList<>(list);
result.add(PackTestLibrary.INSTANCE);
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class TagLoaderMixin {
private static Logger LOGGER;

@WrapOperation(method = "load", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;[Ljava/lang/Object;)V", remap = false))
private static void catchTagError(Logger logger, String message, Object[] args, Operation<Void> original) {
private void catchTagError(Logger logger, String message, Object[] args, Operation<Void> original) {
String error = ((Exception)args[3]).getMessage().replaceFirst("^[A-Za-z0-9.]+Exception: ", "");
String type = ((ResourceLocation)args[1]).getPath().replaceFirst("tags/", "").replaceFirst("s?/.*", "");
LoadDiagnostics.error(LOGGER, type + " tag", ((ResourceLocation)args[0]).toString(), error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class EulaMixin {
@Shadow @Final private boolean agreed;

@WrapOperation(method = "readFile", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V", remap = false))
private static void readFile(Logger logger, String message, Object path, Operation<Void> original) {
private void readFile(Logger logger, String message, Object path, Operation<Void> original) {
if (!PackTest.isAutoEnabled()) {
original.call(logger, message, path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
@Mixin(Main.class)
public class MainMixin {
@Inject(method = "main", cancellable = true, at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/server/packs/repository/ServerPacksSource;createPackRepository(Lnet/minecraft/world/level/storage/LevelStorageSource$LevelStorageAccess;)Lnet/minecraft/server/packs/repository/PackRepository;"))
@Inject(method = "main", cancellable = true, at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/server/packs/repository/ServerPacksSource;createPackRepository(Lnet/minecraft/world/level/storage/LevelStorageSource$LevelStorageAccess;)Lnet/minecraft/server/packs/repository/PackRepository;", shift = At.Shift.AFTER))
private static void mainStartServer(String[] args, CallbackInfo ci, @Local LevelStorageSource.LevelStorageAccess storage, @Local PackRepository packRepository) {
if (PackTest.isAutoEnabled()) {
PackTest.runHeadlessServer(storage, packRepository);
Expand Down

0 comments on commit 36a7138

Please sign in to comment.