-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9208c87
commit 7c79f68
Showing
5 changed files
with
65 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/main/java/org/blocovermelho/bvextension/mixin/BotPrefixPlayerList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.blocovermelho.bvextension.mixin; | ||
|
||
import carpet.CarpetServer; | ||
import carpet.patches.EntityPlayerMPFake; | ||
import com.mojang.authlib.GameProfile; | ||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.format.TextColor; | ||
import net.minecraft.network.encryption.PublicPlayerSession; | ||
import net.minecraft.network.packet.s2c.play.PlayerListS2CPacket; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.world.GameMode; | ||
import org.blocovermelho.bvextension.Extension; | ||
import org.blocovermelho.bvextension.Settings; | ||
import org.jetbrains.annotations.Nullable; | ||
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.UUID; | ||
|
||
@Mixin(PlayerListS2CPacket.Entry.class) | ||
public abstract class BotPrefixPlayerList { | ||
@Shadow @Final private GameProfile profile; | ||
|
||
@Mutable | ||
@Shadow | ||
@Final | ||
@Nullable | ||
private Text displayName; | ||
|
||
@Inject( | ||
method = "<init>(Ljava/util/UUID;Lcom/mojang/authlib/GameProfile;ZILnet/minecraft/world/GameMode;Lnet/minecraft/text/Text;Lnet/minecraft/network/encryption/PublicPlayerSession$Serialized;)V", | ||
at = @At(value = "RETURN") | ||
) | ||
public void bvext$botPrefix(UUID uuid, GameProfile profile, boolean listed, int ping, GameMode gameMode, Text text, PublicPlayerSession.Serialized chatSession, CallbackInfo ci) { | ||
if (!Settings.botPlayerListPrefix) { return; } | ||
var player = CarpetServer.minecraft_server.getPlayerManager().getPlayer(this.profile.getId()); | ||
if (player instanceof EntityPlayerMPFake) { | ||
var botName = Component.text("[ʙᴏᴛ]").color(TextColor.color(0x9a26ff)) | ||
.appendSpace() | ||
.append( | ||
Component.text(player.getDisplayName().getString()) | ||
.color(TextColor.color(0xf0d3e0)) | ||
); | ||
|
||
this.displayName = Extension.audiences.toNative(botName); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"carpet.rule.carefulBreak.desc": "Places the mined block in the player inventory when sneaking", | ||
"carpet.rule.botsDontSleep.desc" : "Makes carpet bots don't count towards playersSleepingPercentage" | ||
"carpet.rule.botsDontSleep.desc" : "Makes carpet bots don't count towards playersSleepingPercentage", | ||
"carpet.rule.botPlayerListPrefix.desc": "Adds a prefix to bots on the player list" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"carpet.rule.carefulBreak.desc": "Coloca o bloco minerado direto no inventário quando o jogador está agachado", | ||
"carpet.rule.botsDontSleep.desc" : "Faz com que bots do carpet não contem para a gamerule playersSleepingPercentage" | ||
"carpet.rule.botsDontSleep.desc" : "Faz com que bots do carpet não contem para a gamerule playersSleepingPercentage", | ||
"carpet.rule.botPlayerListPrefix.desc": "Adiciona um prefixo aos bots na lista de jogadores" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters