Added back the tablist dimension indicator
This commit is contained in:
@ -0,0 +1,34 @@
|
||||
package wtf.hak.survivalfabric.mixin;
|
||||
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import wtf.hak.survivalfabric.commands.SpectatorCommand;
|
||||
import wtf.hak.survivalfabric.utils.Messages;
|
||||
|
||||
@Mixin(ServerPlayerEntity.class)
|
||||
public abstract class ServerPlayerEntityMixin {
|
||||
|
||||
@Inject(method = "getPlayerListName", at = @At("HEAD"), cancellable = true)
|
||||
private void changePlayerListName(CallbackInfoReturnable<Text> cir) {
|
||||
ServerPlayerEntity p = (ServerPlayerEntity) (Object) this;
|
||||
String world = p.getServerWorld().getRegistryKey().getValue().toTranslationKey();
|
||||
String finalName;
|
||||
if(!SpectatorCommand.spectating.containsKey(p)) {
|
||||
finalName = switch (world) {
|
||||
case "minecraft.overworld" -> Messages.OVERWORLD_PREFIX;
|
||||
case "minecraft.the_nether" -> Messages.NETHER_PREFIX;
|
||||
case "minecraft.the_end" -> Messages.END_PREFIX;
|
||||
default -> Messages.UNKNOWN_PREFIX;
|
||||
};
|
||||
} else
|
||||
finalName = Messages.SPECTATOR_PREFIX;
|
||||
|
||||
finalName += "§7" + p.getName().getString();
|
||||
|
||||
cir.setReturnValue(Text.of(finalName));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user