Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Jun 10, 2024
1 parent 2baa46b commit b0900ab
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package dev.ithundxr.railwaystweaks.mixin;

import com.mojang.authlib.GameProfile;
import net.minecraft.network.Connection;
import net.minecraft.network.protocol.status.ServerStatus;
import net.minecraft.server.network.ServerStatusPacketListenerImpl;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
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.callback.CallbackInfo;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;

@Mixin(ServerStatusPacketListenerImpl.class)
public class ServerStatusPacketListenerImplMixin {
@Shadow @Mutable @Final private ServerStatus status;

@Inject(method = "<init>", at = @At("TAIL"))
private void railwaysTweaks$noSpying(ServerStatus status, Connection connection, CallbackInfo ci) {
List<String> names = List.of("Stop", "Trying", "To", "Spy");
List<GameProfile> profiles = new ArrayList<>();

for (String name : names) {
profiles.add(new GameProfile(UUID.randomUUID(), name));
}

Optional<ServerStatus.Players> players = Optional.of(new ServerStatus.Players(
1, 1, profiles
));

this.status = new ServerStatus(
status.description(),
players,
status.version(),
status.favicon(),
status.enforcesSecureChat()
);
}
}
3 changes: 2 additions & 1 deletion src/main/resources/railwaystweaks.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"package": "dev.ithundxr.railwaystweaks.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"LivingEntityMixin"
"LivingEntityMixin",
"ServerStatusPacketListenerImplMixin"
],
"client": [
"client.HttpTextureMixin",
Expand Down

0 comments on commit b0900ab

Please sign in to comment.