Skip to content

Commit

Permalink
Update to 1.21.2-pre3
Browse files Browse the repository at this point in the history
  • Loading branch information
misode committed Oct 12, 2024
1 parent 1fdf05e commit acdfe71
Show file tree
Hide file tree
Showing 18 changed files with 50 additions and 115 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'fabric-loom' version '1.8-SNAPSHOT'
id 'maven-publish'
}

Expand Down
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.21.1
loader_version=0.16.5
minecraft_version=1.21.2-pre3
loader_version=0.16.7

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

# Dependencies
fabric_version=0.105.0+1.21.1
fabric_version=0.105.4+1.21.2
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public TestFunction toTestFunction(int permissionLevel) {
private Consumer<GameTestHelper> createTestBody(int permissionLevel) {
return (helper) -> {
CommandSourceStack source = helper.getLevel().getServer().createCommandSourceStack()
.withPosition(helper.absoluteVec(Vec3.ZERO).add(0, 1, 0))
.withPosition(helper.absoluteVec(Vec3.ZERO))
.withPermission(permissionLevel)
.withSuppressedOutput();
((PackTestSourceStack) source).packtest$setHelper(helper);
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/io/github/misode/packtest/PackTestLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import net.minecraft.server.packs.resources.PreparableReloadListener;
import net.minecraft.server.packs.resources.Resource;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.util.profiling.ProfilerFiller;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -50,7 +49,7 @@ public void setDispatcher(CommandDispatcher<CommandSourceStack> dispatcher) {
}

@Override
public @NotNull CompletableFuture<Void> reload(PreparableReloadListener.PreparationBarrier barrier, ResourceManager resources, ProfilerFiller profiler1, ProfilerFiller profiler2, Executor executor1, Executor executor2) {
public @NotNull CompletableFuture<Void> reload(PreparableReloadListener.PreparationBarrier barrier, ResourceManager resources, Executor executor1, Executor executor2) {
CompletableFuture<Map<ResourceLocation, CompletableFuture<PackTestFunction>>> prep = CompletableFuture.supplyAsync(
() -> LISTER.listMatchingResources(resources), executor1
).thenComposeAsync(map -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ private static int useBlock(CommandContext<CommandSourceStack> ctx, Direction hi
BlockHitResult blockHit = new BlockHitResult(pos, hitDirection, BlockPos.containing(pos), false);
InteractionResult result = dummy.gameMode.useItemOn(dummy, dummy.serverLevel(), handItem, hand, blockHit);
if (result.consumesAction()) {
if (result.shouldSwing()) dummy.swing(hand);
dummy.swing(hand);
return 1;
}
}
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/io/github/misode/packtest/dummy/Dummy.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import net.minecraft.network.DisconnectionDetails;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.PacketFlow;
import net.minecraft.network.protocol.game.ClientboundEntityPositionSyncPacket;
import net.minecraft.network.protocol.game.ClientboundRotateHeadPacket;
import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket;
import net.minecraft.network.protocol.game.ServerboundClientCommandPacket;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.MinecraftServer;
Expand All @@ -29,6 +29,7 @@
import org.jetbrains.annotations.NotNull;

import java.util.Objects;
import java.util.Set;

/**
* Heavily inspired by <a href="https://github.com/gnembon/fabric-carpet/blob/master/src/main/java/carpet/patches/EntityPlayerMPFake.java">Carpet</a>
Expand Down Expand Up @@ -68,12 +69,12 @@ public static Dummy create(String username, MinecraftServer server, ResourceKey<
new DummyClientConnection(PacketFlow.SERVERBOUND),
dummy,
new CommonListenerCookie(profile, 0, dummy.clientInformation(), false));
dummy.teleportTo(level, originalSpawn.x, originalSpawn.y, originalSpawn.z, 0, 0);
dummy.teleportTo(level, originalSpawn.x, originalSpawn.y, originalSpawn.z, Set.of(), 0, 0, true);
dummy.setHealth(20);
dummy.unsetRemoved();
dummy.gameMode.changeGameModeForPlayer(GameType.SURVIVAL);
server.getPlayerList().broadcastAll(new ClientboundRotateHeadPacket(dummy, (byte) (dummy.yHeadRot * 256 / 360)), dimensionId);
server.getPlayerList().broadcastAll(new ClientboundTeleportEntityPacket(dummy), dimensionId);
server.getPlayerList().broadcastAll(ClientboundEntityPositionSyncPacket.of(dummy), dimensionId);
dummy.entityData.set(DATA_PLAYER_MODE_CUSTOMISATION, (byte) 0x7f);
return dummy;
}
Expand All @@ -96,6 +97,7 @@ public void respawn() {
server.getPlayerList().respawn(this, false, Entity.RemovalReason.KILLED);
}

@SuppressWarnings("resource")
@Override
public void tick() {
if (Objects.requireNonNull(this.getServer()).getTickCount() % 10 == 0) {
Expand All @@ -108,11 +110,12 @@ public void tick() {
} catch (NullPointerException ignored) {}
}

@SuppressWarnings("resource")
@Override
public void die(DamageSource cause) {
super.die(cause);
if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN)) {
this.server.tell(new TickTask(this.server.getTickCount(),
this.server.schedule(new TickTask(this.server.getTickCount(),
() -> this.connection.handleClientCommand(new ServerboundClientCommandPacket(ServerboundClientCommandPacket.Action.PERFORM_RESPAWN))
));
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import java.util.Map;
import java.util.Optional;
import java.util.Set;

/**
* Fixes starting position of dummies when they load in.
Expand Down Expand Up @@ -55,7 +56,7 @@ private void skipSaveDummy(ServerPlayer player, CallbackInfo ci) {
}

@WrapOperation(method = "getPlayerAdvancements", at = @At(value = "INVOKE", target = "Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;"))
private Object getPlayerAdvancements(Map<Object, Object> map, Object key, Operation<Object> original, @Local(ordinal = 0) ServerPlayer player) {
private Object getPlayerAdvancements(Map<Object, Object> map, Object key, Operation<Object> original, @Local(ordinal = 0, argsOnly = true) ServerPlayer player) {
if (player instanceof Dummy) {
return null;
} else {
Expand All @@ -64,7 +65,7 @@ private Object getPlayerAdvancements(Map<Object, Object> map, Object key, Operat
}

@WrapOperation(method = "respawn", at = @At(value = "NEW", target = "(Lnet/minecraft/server/MinecraftServer;Lnet/minecraft/server/level/ServerLevel;Lcom/mojang/authlib/GameProfile;Lnet/minecraft/server/level/ClientInformation;)Lnet/minecraft/server/level/ServerPlayer;"))
private ServerPlayer createDummy(MinecraftServer server, ServerLevel level, GameProfile profile, ClientInformation cli, Operation<ServerPlayer> original, @Local(ordinal = 0) ServerPlayer player) {
private ServerPlayer createDummy(MinecraftServer server, ServerLevel level, GameProfile profile, ClientInformation cli, Operation<ServerPlayer> original, @Local(ordinal = 0, argsOnly = true) ServerPlayer player) {
if (player instanceof Dummy dummy) {
return new Dummy(server, level, profile, cli, dummy.originalSpawn);
} else {
Expand All @@ -77,7 +78,7 @@ private void teleportDummy(ServerPlayer serverPlayer, boolean bl, Entity.Removal
if (player instanceof Dummy dummy) {
Vec3 pos = dummy.originalSpawn;
dummy.moveTo(pos.x, pos.y, pos.z, 0, 0);
dummy.teleportTo(dummy.serverLevel(), pos.x, pos.y, pos.z, 0, 0);
dummy.teleportTo(dummy.serverLevel(), pos.x, pos.y, pos.z, Set.of(), 0, 0, true);
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import io.github.misode.packtest.PackTestLibrary;
import net.minecraft.commands.Commands;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.LayeredRegistryAccess;
import net.minecraft.core.Registry;
import net.minecraft.server.RegistryLayer;
import net.minecraft.server.ReloadableServerResources;
import net.minecraft.server.packs.resources.PreparableReloadListener;
import net.minecraft.world.flag.FeatureFlagSet;
Expand All @@ -28,7 +31,7 @@ public class ReloadableServerResourcesMixin {
private Commands commands;

@Inject(method = "<init>", at = @At("RETURN"))
private void init(RegistryAccess.Frozen frozen, FeatureFlagSet featureFlagSet, Commands.CommandSelection commandSelection, int permissionLevel, CallbackInfo ci) {
private void init(LayeredRegistryAccess<RegistryLayer> layeredRegistryAccess, HolderLookup.Provider provider, FeatureFlagSet featureFlagSet, Commands.CommandSelection commandSelection, List<Registry.PendingTags<?>> list, int permissionLevel, CallbackInfo ci) {
PackTestLibrary.INSTANCE.setPermissionLevel(permissionLevel);
PackTestLibrary.INSTANCE.setDispatcher(commands.getDispatcher());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public class ReportGameListenerMixin {

@ModifyArg(method = "visualizeFailedTest", at = @At(value = "INVOKE", target = "Lnet/minecraft/gametest/framework/ReportGameListener;say(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/ChatFormatting;Ljava/lang/String;)V"), index = 2)
private static String visualizeFailedTest(String message, @Local(ordinal = 0) Throwable error) {
private static String visualizeFailedTest(String message, @Local(ordinal = 0, argsOnly = true) Throwable error) {
if (error instanceof LineNumberException e) {
return message.replaceFirst(" failed!", " failed on line " + e.getLineNumber() + "!");
} else {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import com.mojang.serialization.DataResult;
import io.github.misode.packtest.LoadDiagnostics;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener;
Expand All @@ -11,17 +13,26 @@
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;

/**
* Catches loot table, predicate, item modifier, advancement, and recipe errors.
* Improves error message.
*/
@Mixin(SimpleJsonResourceReloadListener.class)
public class SimpleJsonResourceReloadListenerMixin {
@Shadow
@Final
private static Logger LOGGER;

@WrapOperation(method = "method_63567", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;[Ljava/lang/Object;)V", remap = false))
private static void resourceParseError(Logger logger, String message, Object[] args, Operation<Void> original) {
String resourcePath = ((ResourceLocation)args[1]).getPath();
String type = resourcePath.substring(0, resourcePath.indexOf('/')).replace("_", " ").replace("/", " ");
LoadDiagnostics.error(LOGGER, type, ((ResourceLocation)args[0]).toString(), ((DataResult.Error<?>)args[2]).message());
}

@WrapOperation(method = "scanDirectory", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;[Ljava/lang/Object;)V", remap = false))
private static void catchTagReferenceError(Logger logger, String message, Object[] args, Operation<Void> original) {
String path = ((ResourceLocation)args[1]).getPath();
String type = path.substring(0, path.indexOf("/")).replaceAll("_", " ").replaceFirst("s$", "");
String error = ((Exception)args[2]).getMessage().replaceFirst("^[A-Za-z0-9.]+Exception: ", "");
LoadDiagnostics.error(LOGGER, type, ((ResourceLocation)args[0]).toString(), error);
private static void resourceException(Logger logger, String message, Object[] args, Operation<Void> original, @Local(ordinal = 0, argsOnly = true) String directory) {
String type = directory.replace("_", " ").replace("/", " ");
LoadDiagnostics.error(LOGGER, type, ((ResourceLocation)args[0]).toString(), (args[2]).toString());
}
}
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"accessWidener": "packtest.accesswidener",
"depends": {
"fabricloader": ">=0.15.10",
"minecraft": ">=1.21.1",
"minecraft": ">=1.21.2-beta.3",
"java": ">=21",
"fabric-api": "*"
}
Expand Down
3 changes: 0 additions & 3 deletions src/main/resources/packtest.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@
"GameTestServerMixin",
"ItemPredicateArgumentMixin",
"LogTestReporterMixin",
"LootDataTypeMixin",
"MinecraftServerMixin",
"PlayerListMixin",
"RecipeManagerMixin",
"ReloadableServerResourcesMixin",
"ReportGameListenerMixin",
"ServerAdvancementsManagerMixin",
"ServerFunctionLibraryMixin",
"ServerPlayerMixin",
"SimpleJsonResourceReloadListenerMixin",
Expand Down

0 comments on commit acdfe71

Please sign in to comment.