Skip to content

Commit

Permalink
Update to 1.21.2
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaCartes committed Oct 27, 2024
1 parent ec8517d commit 5156bc9
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 44 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### 3.0.25
##### Minecraft 1.21
##### Minecraft 1.21-1.21.3

1) Fix toLowerCase() using on PC with Turkish locale

Expand Down
9 changes: 5 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ modrinth {
token.set(System.getenv("MODRINTH_TOKEN"))
projectId.set("aZj58GfX")
versionNumber.set("${project.version}")
versionName = "[1.21] ${project.version}"
versionName = "[1.21.2, 1.21.3] ${project.version}"
versionType = "beta"
changelog.set("Release notes:\nhttps://github.com/NikitaCartes/EasyAuth/releases/tag/${project.version}\n\nChangelog:\nhttps://github.com/NikitaCartes/EasyAuth/tree/HEAD/CHANGELOG.md")
uploadFile = remapJar
gameVersions.addAll("1.21")
gameVersions.addAll("1.21.2", "1.21.3")
loaders = ["fabric", "quilt"]
dependencies {
required.project("P7dR8mSH") // Fabric API
Expand All @@ -130,10 +130,11 @@ curseforge {

addGameVersion("Java 21")

addGameVersion("1.21")
addGameVersion("1.21.2")
addGameVersion("1.21.3")

mainArtifact(remapJar) {
displayName = "[1.21] ${project.version}"
displayName = "[1.21.2, 1.21.3] ${project.version}"
relations {
requiredDependency("fabric-api")
embeddedLibrary 'server-translation-api'
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Mod
mod_name=EasyAuth
mod_id=easyauth
mod_version=3.0.26-SNAPSHOT
mod_version=3.0.25

# Fabric
minecraft_version=1.21
yarn_mappings=1.21+build.1
minecraft_version=1.21.2
yarn_mappings=1.21.2+build.1
loader_version=0.16.7
fabric_version=0.100.1+1.21
fabric_version=0.107.0+1.21.3

# Dependencies
server_translations_version=2.3.1+1.21-pre2
fabric_permissions_version=0.3.1
server_translations_version=2.4.0+1.21.2-rc1
fabric_permissions_version=0.3.2
floodgate_api_version=2.2.0-SNAPSHOT

argon2_version=2.11
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public static void registerCommand(CommandDispatcher<ServerCommandSource> dispat
// +1 to not spawn player in ground
BlockPosArgumentType.getLoadedBlockPos(ctx, "position").getY() + 1,
BlockPosArgumentType.getLoadedBlockPos(ctx, "position").getZ(),
RotationArgumentType.getRotation(ctx, "angle").toAbsoluteRotation(ctx.getSource()).y,
RotationArgumentType.getRotation(ctx, "angle").toAbsoluteRotation(ctx.getSource()).x
RotationArgumentType.getRotation(ctx, "angle").getRotation(ctx.getSource()).y,
RotationArgumentType.getRotation(ctx, "angle").getRotation(ctx.getSource()).x
)
)
)
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/xyz/nikitacartes/easyauth/config/LangConfigV1.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.common.io.Resources;
import net.minecraft.server.command.CommandOutput;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import org.apache.commons.text.StringSubstitutor;
Expand Down Expand Up @@ -145,6 +146,16 @@ public void send(ServerCommandSource commandOutput) {
}
}

public void send(ServerPlayerEntity commandOutput) {
if (enabled && commandOutput != null) {
if (langConfig.enableServerSideTranslation && serverSide) {
commandOutput.sendMessage(translatableWithFallback(key, fallback));
} else {
commandOutput.sendMessage(Text.literal(fallback));
}
}
}

public <T extends CommandOutput> void send(T commandOutput) {
if (enabled && commandOutput != null) {
if (langConfig.enableServerSideTranslation && serverSide) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
import net.fabricmc.fabric.api.networking.v1.ServerLoginNetworking;
import net.minecraft.block.Blocks;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.network.packet.s2c.play.BlockUpdateS2CPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.PlayerManager;
import net.minecraft.server.network.ServerLoginNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.Uuids;
import net.minecraft.util.math.BlockPos;
import xyz.nikitacartes.easyauth.storage.PlayerCacheV0;
Expand Down Expand Up @@ -222,13 +220,13 @@ public static boolean onBreakBlock(PlayerEntity player) {
}

// Using an item
public static TypedActionResult<ItemStack> onUseItem(PlayerEntity player) {
public static ActionResult onUseItem(PlayerEntity player) {
if (!((PlayerAuth) player).easyAuth$isAuthenticated() && !extendedConfig.allowItemUsing) {
((PlayerAuth) player).easyAuth$sendAuthMessage();
return TypedActionResult.fail(ItemStack.EMPTY);
return ActionResult.FAIL;
}

return TypedActionResult.pass(ItemStack.EMPTY);
return ActionResult.PASS;
}

// Dropping an item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private RegistryKey<World> onPlayerConnect(RegistryKey<World> world, ClientConne
cache = PlayerCacheV0.fromJson(player, uuid);
playerCacheMap.put(uuid, cache);
}
if (config.hidePlayerCoords && !(hasValidSession(player, connection))) {
if (config.hidePlayerCoords && !(hasValidSession(player))) {
((PlayerAuth) player).easyAuth$saveLastDimension(world);
return RegistryKey.of(RegistryKeys.WORLD, Identifier.of(config.worldSpawn.dimension));
}
Expand All @@ -78,7 +78,7 @@ private RegistryKey<World> onPlayerConnect(RegistryKey<World> world, ClientConne
@ModifyArgs(method = "onPlayerConnect(Lnet/minecraft/network/ClientConnection;Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/server/network/ConnectedClientData;)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayNetworkHandler;requestTeleport(DDDFF)V"))
private void onPlayerConnect(Args args, ClientConnection connection, ServerPlayerEntity player, ConnectedClientData clientData) {
if (config.hidePlayerCoords && !(hasValidSession(player, connection))) {
if (config.hidePlayerCoords && !(hasValidSession(player))) {
PlayerCacheV0 cache = playerCacheMap.get(((PlayerAuth) player).easyAuth$getFakeUuid());
((PlayerAuth) player).easyAuth$saveLastLocation(false);

Expand Down Expand Up @@ -117,24 +117,6 @@ private TeleportTarget replaceRespawnTarget(ServerPlayerEntity player, boolean a
return player.getRespawnTarget(alive, postDimensionTransition);
}

@Redirect(method = "onPlayerConnect(Lnet/minecraft/network/ClientConnection;Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/server/network/ConnectedClientData;)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;startRiding(Lnet/minecraft/entity/Entity;Z)Z"))
private boolean onPlayerConnectStartRiding(ServerPlayerEntity instance, Entity entity, boolean force, ClientConnection connection, ServerPlayerEntity player, ConnectedClientData clientData) {
if (config.hidePlayerCoords && !(hasValidSession(player, connection))) {
return false;
}
return instance.startRiding(entity, force);
}

@Redirect(method = "onPlayerConnect(Lnet/minecraft/network/ClientConnection;Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/server/network/ConnectedClientData;)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;hasVehicle()Z"))
private boolean onPlayerConnectStartRiding(ServerPlayerEntity instance, ClientConnection connection, ServerPlayerEntity player, ConnectedClientData clientData) {
if (config.hidePlayerCoords && !(hasValidSession(player, connection))) {
return true;
}
return instance.hasVehicle();
}

@Inject(method = "remove(Lnet/minecraft/server/network/ServerPlayerEntity;)V", at = @At("HEAD"))
private void onPlayerLeave(ServerPlayerEntity serverPlayerEntity, CallbackInfo ci) {
AuthEventHandler.onPlayerLeave(serverPlayerEntity);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package xyz.nikitacartes.easyauth.mixin;

import net.minecraft.entity.Entity;
import net.minecraft.network.packet.s2c.play.PositionFlag;
import net.minecraft.registry.RegistryKey;
import net.minecraft.scoreboard.ScoreboardCriterion;
import net.minecraft.server.MinecraftServer;
Expand All @@ -16,15 +17,18 @@
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import xyz.nikitacartes.easyauth.event.AuthEventHandler;
import xyz.nikitacartes.easyauth.storage.PlayerCacheV0;
import xyz.nikitacartes.easyauth.utils.*;

import java.util.EnumSet;
import java.util.Locale;

import static xyz.nikitacartes.easyauth.EasyAuth.*;
import static xyz.nikitacartes.easyauth.utils.AuthHelper.hasValidSession;
import static xyz.nikitacartes.easyauth.utils.EasyLogger.LogDebug;

@Mixin(ServerPlayerEntity.class)
Expand Down Expand Up @@ -82,7 +86,7 @@ public abstract class ServerPlayerEntityMixin implements PlayerAuth {
return;
}
if (cache.wasDead) {
player.kill();
player.kill(player.getServerWorld());
player.getScoreboard().forEachScore(ScoreboardCriterion.DEATH_COUNT, player, (score) -> score.setScore(score.getScore() - 1));
return;
}
Expand All @@ -92,8 +96,10 @@ public abstract class ServerPlayerEntityMixin implements PlayerAuth {
cache.lastLocation.position.getX(),
cache.lastLocation.position.getY(),
cache.lastLocation.position.getZ(),
EnumSet.noneOf(PositionFlag.class),
cache.lastLocation.yaw,
cache.lastLocation.pitch);
cache.lastLocation.pitch,
true);
LogDebug(String.format("Teleported player %s to %s", player.getName().getContent(), cache.lastLocation));

if (cache.ridingEntityUUID != null) {
Expand Down Expand Up @@ -237,4 +243,22 @@ private void dropSelectedItem(boolean dropEntireStack, CallbackInfoReturnable<Bo
cir.setReturnValue(false);
}
}

@Redirect(method = "readRootVehicle(Ljava/util/Optional;)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;startRiding(Lnet/minecraft/entity/Entity;Z)Z"))
private boolean onPlayerConnectStartRiding(ServerPlayerEntity instance, Entity entity, boolean force) {
if (config.hidePlayerCoords && !(hasValidSession(player))) {
return false;
}
return instance.startRiding(entity, force);
}

@Redirect(method = "readRootVehicle(Ljava/util/Optional;)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;hasVehicle()Z"))
private boolean onPlayerConnectStartRiding(ServerPlayerEntity instance) {
if (config.hidePlayerCoords && !(hasValidSession(player))) {
return true;
}
return instance.hasVehicle();
}
}
5 changes: 2 additions & 3 deletions src/main/java/xyz/nikitacartes/easyauth/utils/AuthHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ public enum PasswordOptions {
NOT_REGISTERED
}

public static boolean hasValidSession(ServerPlayerEntity player, ClientConnection connection) {
public static boolean hasValidSession(ServerPlayerEntity player) {
String uuid = ((PlayerAuth) player).easyAuth$getFakeUuid();
SocketAddress socketAddress = connection.getAddress();
String playerIp = socketAddress instanceof InetSocketAddress inetSocketAddress ? InetAddresses.toAddrString(inetSocketAddress.getAddress()) : "<unknown>";
String playerIp = player.getIp();
return ((PlayerAuth) player).easyAuth$canSkipAuth() ||
(playerCacheMap.containsKey(uuid) &&
playerCacheMap.get(uuid).isAuthenticated &&
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"depends": {
"fabric-api": "*",
"fabricloader": "*",
"minecraft": ">=1.20.5-"
"minecraft": ">=1.21.2-"
},
"suggests": {
"fabric-permissions-api-v0": "*"
Expand Down

0 comments on commit 5156bc9

Please sign in to comment.