Skip to content

Commit

Permalink
Port to 1.21-pre4
Browse files Browse the repository at this point in the history
Update dependencies to 1.21-pre4. Note that PlayerAbilityLib requires a
not yet accepted PR
(Ladysnake/PlayerAbilityLib#24). This was tested
using a local build of pal.

Adapt to new function signatures for mixins.
  • Loading branch information
Peter Svensson authored and petersv5 committed Jun 11, 2024
1 parent 96dd067 commit 4f4ced2
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 34 deletions.
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ org.gradle.jvmargs=-Xmx2048M

# Fabric Properties
# check these on https://fabricmc.net/develup
minecraft_version=1.20.5
yarn_mappings=1.20.5+build.1
loader_version=0.15.10
minecraft_version=1.21-pre4
yarn_mappings=1.21-pre4+build.3
loader_version=0.15.11

#Fabric api
fabric_version=0.97.5+1.20.5
fabric_version=0.100.0+1.21

# Mod Properties
mod_name = Essential Commands
Expand All @@ -20,7 +20,7 @@ archives_base_name = essential_commands

# Dependencies
permissions_api_version=0.3.1
placeholder_api_version=2.4.0-pre.1+1.20.5
placeholder_api_version=2.4.0-pre.2+1.21
pal_version=1.9.0
vanish_version=1.5.3+1.20.4

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ private ECPlaceholderRegistry() {}
public static void register() {
var namespace = EssentialCommands.MOD_ID;
Placeholders.register(
new Identifier(namespace, "nickname"),
Identifier.of(namespace, "nickname"),
(ctx, arg) -> {
if (ctx.hasPlayer()) {
return PlaceholderResult.value(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ public static void register(
essentialCommandsRootNode.addChild(CommandManager.literal("convertEssentialsXPlayerHomes")
.requires(source -> source.hasPermissionLevel(4))
.executes((source) -> {
Path mcDir = source.getSource().getServer().getRunDirectory().toPath();
Path mcDir = source.getSource().getServer().getRunDirectory();
try {
EssentialsXParser.convertPlayerDataDir(
mcDir.resolve("plugins/Essentials/userdata").toFile(),
Expand All @@ -648,7 +648,7 @@ public static void register(
essentialCommandsRootNode.addChild(CommandManager.literal("convertEssentialsXWarps")
.requires(source -> source.hasPermissionLevel(4))
.executes((source) -> {
Path mcDir = source.getSource().getServer().getRunDirectory().toPath();
Path mcDir = source.getSource().getServer().getRunDirectory();
EssentialsConvertor.warpConvert(
source.getSource().getServer(),
mcDir.resolve("plugins/Essentials/warps").toFile()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static int reloadCommand(CommandContext<ServerCommandSource> context) thr

@SuppressWarnings("ResultOfMethodCallIgnored")
public static void reload(MinecraftServer server) throws IOException {
Path mcDir = server.getRunDirectory().toPath();
Path mcDir = server.getRunDirectory();
var rulesFile = mcDir.resolve("config/essentialcommands/rules.txt").toFile();
rulesFile.getParentFile().mkdirs();
if (rulesFile.createNewFile()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,17 @@ public EssentialCommandsConfig(Path savePath, String displayName, String documen
EssentialCommands.LOGGER.info("Possible world ids: {}", String.join(",", worldIds.stream().map(Identifier::toString).toList()));

var configuredWorldIds = configuredWorldIdStrings.stream()
.map(Identifier::new)
.map(Identifier::of)
.toList();
EssentialCommands.LOGGER.info("Configured `rtp_enabled_worlds` world ids: {}", String.join(",", configuredWorldIds.stream().map(Identifier::toString).toList()));

var validConfiguredWorldIds = configuredWorldIdStrings.stream()
.map(Identifier::new)
.map(Identifier::of)
.filter(worldIds::contains)
.collect(Collectors.toSet());

var invalidConfiguredWorldIds = configuredWorldIdStrings.stream()
.map(Identifier::new)
.map(Identifier::of)
.filter(v -> !worldIds.contains(v))
.toList();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.fibermc.essentialcommands.mixin;

import java.util.Optional;

import com.fibermc.essentialcommands.ECAbilitySources;
import com.fibermc.essentialcommands.events.PlayerConnectCallback;
import com.fibermc.essentialcommands.events.PlayerLeaveCallback;
Expand All @@ -16,12 +14,13 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

import net.minecraft.entity.Entity;
import net.minecraft.network.ClientConnection;
import net.minecraft.server.PlayerManager;
import net.minecraft.server.network.ConnectedClientData;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.TeleportTarget;

@Mixin(PlayerManager.class)
public abstract class PlayerManagerMixin {
Expand Down Expand Up @@ -55,13 +54,10 @@ public void onPlayerLeave(ServerPlayerEntity player, CallbackInfo callbackInfo)
target = "Lnet/minecraft/server/network/ServerPlayerEntity;copyFrom(Lnet/minecraft/server/network/ServerPlayerEntity;Z)V"
), locals = LocalCapture.CAPTURE_FAILHARD)
public void onRespawnPlayer(
ServerPlayerEntity oldServerPlayerEntity, boolean alive, CallbackInfoReturnable<ServerPlayerEntity> cir
, BlockPos blockPos
, float f
, boolean bl
ServerPlayerEntity oldServerPlayerEntity, boolean alive, Entity.RemovalReason removalReason
, CallbackInfoReturnable<ServerPlayerEntity> cir
, TeleportTarget teleportTarget
, ServerWorld serverWorld
, Optional optional
, ServerWorld serverWorld2
, ServerPlayerEntity serverPlayerEntity
) {
PlayerDataManager.handlePlayerDataRespawnSync(oldServerPlayerEntity, serverPlayerEntity);
Expand All @@ -74,14 +70,13 @@ public void onRespawnPlayer(
target = "Lnet/minecraft/server/world/ServerWorld;getLevelProperties()Lnet/minecraft/world/WorldProperties;"
), locals = LocalCapture.CAPTURE_FAILHARD)
public void onRespawnPlayer_afterSetPosition(
ServerPlayerEntity oldServerPlayerEntity, boolean alive, CallbackInfoReturnable<ServerPlayerEntity> cir
, BlockPos blockPos
, float f
, boolean bl
ServerPlayerEntity oldServerPlayerEntity, boolean alive, Entity.RemovalReason removalReason
, CallbackInfoReturnable<ServerPlayerEntity> cir
, TeleportTarget teleportTarget
, ServerWorld serverWorld
, Optional optional
, ServerWorld serverWorld2
, ServerPlayerEntity serverPlayerEntity
, byte b
, ServerWorld serverWorld2
) {
PlayerDataManager.handleRespawnAtEcSpawn(oldServerPlayerEntity, serverPlayerEntity);
PlayerRespawnCallback.EVENT.invoker().onPlayerRespawn(oldServerPlayerEntity, serverPlayerEntity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

import net.minecraft.entity.Entity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.registry.RegistryKey;
import net.minecraft.server.PlayerManager;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Text;
import net.minecraft.world.GameMode;
import net.minecraft.world.TeleportTarget;
import net.minecraft.world.World;
import net.minecraft.world.WorldProperties;

Expand Down Expand Up @@ -60,14 +63,18 @@ public void onChangeGameMode(GameMode gameMode, CallbackInfoReturnable<Boolean>
// ((ServerPlayerEntityAccess) this).getEcPlayerData().updatePlayer(((ServerPlayerEntity) (Object) this));
}

@Inject(method = "teleport(Lnet/minecraft/server/world/ServerWorld;DDDFF)V", at = @At(
@Inject(method = "teleportTo(Lnet/minecraft/world/TeleportTarget;)Lnet/minecraft/entity/Entity;", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/PlayerManager;sendPlayerStatus(Lnet/minecraft/server/network/ServerPlayerEntity;)V"
), locals = LocalCapture.CAPTURE_FAILSOFT)
public void onTeleportBetweenWorlds(
ServerWorld targetWorld, double x, double y, double z, float yaw, float pitch,
CallbackInfo ci,
ServerWorld serverWorld, WorldProperties worldProperties)
TeleportTarget teleportTarget,
CallbackInfoReturnable<Entity> cir,
ServerWorld serverWorld,
ServerWorld serverWorld2,
RegistryKey<World> registryKey,
WorldProperties worldProperties,
PlayerManager playerManager)
{
var playerData = ((ServerPlayerEntityAccess) this).ec$getPlayerData();
playerData.updatePlayerEntity((ServerPlayerEntity) (Object) this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.WorldSaveHandler;
import net.minecraft.world.PlayerSaveHandler;

@Mixin(WorldSaveHandler.class)
@Mixin(PlayerSaveHandler.class)
public class WorldSaveHandlerMixin {

@Inject(method = "savePlayerData", at = @At("RETURN"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private static boolean hasPermissionForTextFragment(Text text, NickPerms sourceP
|| style.isObfuscated()
|| style.isStrikethrough()
|| style.isUnderlined())
|| !style.getFont().equals(new Identifier("minecraft:default"))),
|| !style.getFont().equals(Identifier.of("minecraft:default"))),
(sourcePerms.click || (style.getClickEvent() == null)),
(sourcePerms.hover || (style.getHoverEvent() == null))
);
Expand Down

0 comments on commit 4f4ced2

Please sign in to comment.