S3CPacketUpdateScore .java

net.minecraft.network.play.server.S3CPacketUpdateScore (class): members: getObjectiveName, getScoreAction, getScoreValue, objective, getPlayerName, Action.

net.minecraft.network.play.serverclass109 linesserver2.7 KB

Implements

API Surface (7)

void readPacketData(PacketBuffer buf)
void writePacketData(PacketBuffer buf)
void processPacket(INetHandlerPlayClient handler)
String getPlayerName()
String getObjectiveName()
int getScoreValue()
S3CPacketUpdateScore.Action getScoreAction()

Fields & Constants (4)

name
objective
value
action

Full Source

S3CPacketUpdateScore.java109 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.network.play.server;
2
3
import java.io.IOException;
4
import net.minecraft.network.Packet;
5
import net.minecraft.network.PacketBuffer;
6
import net.minecraft.network.play.INetHandlerPlayClient;
7
import net.minecraft.scoreboard.Score;
8
import net.minecraft.scoreboard.ScoreObjective;
9
10
public class S3CPacketUpdateScore implements Packet<INetHandlerPlayClient>
11
{
12
    private String name = "";
13
    private String objective = "";
14
    private int value;
15
    private S3CPacketUpdateScore.Action action;
16
17
    public S3CPacketUpdateScore()
18
    {
19
    }
20
21
    public S3CPacketUpdateScore(Score scoreIn)
22
    {
23
        this.name = scoreIn.getPlayerName();
24
        this.objective = scoreIn.getObjective().getName();
25
        this.value = scoreIn.getScorePoints();
26
        this.action = S3CPacketUpdateScore.Action.CHANGE;
27
    }
28
29
    public S3CPacketUpdateScore(String nameIn)
30
    {
31
        this.name = nameIn;
32
        this.objective = "";
33
        this.value = 0;
34
        this.action = S3CPacketUpdateScore.Action.REMOVE;
35
    }
36
37
    public S3CPacketUpdateScore(String nameIn, ScoreObjective objectiveIn)
38
    {
39
        this.name = nameIn;
40
        this.objective = objectiveIn.getName();
41
        this.value = 0;
42
        this.action = S3CPacketUpdateScore.Action.REMOVE;
43
    }
44
45
    /**
46
     * Reads the raw packet data from the data stream.
47
     */
48
    public void readPacketData(PacketBuffer buf) throws IOException
49
    {
50
        this.name = buf.readStringFromBuffer(40);
51
        this.action = (S3CPacketUpdateScore.Action)buf.readEnumValue(S3CPacketUpdateScore.Action.class);
52
        this.objective = buf.readStringFromBuffer(16);
53
54
        if (this.action != S3CPacketUpdateScore.Action.REMOVE)
55
        {
56
            this.value = buf.readVarIntFromBuffer();
57
        }
58
    }
59
60
    /**
61
     * Writes the raw packet data to the data stream.
62
     */
63
    public void writePacketData(PacketBuffer buf) throws IOException
64
    {
65
        buf.writeString(this.name);
66
        buf.writeEnumValue(this.action);
67
        buf.writeString(this.objective);
68
69
        if (this.action != S3CPacketUpdateScore.Action.REMOVE)
70
        {
71
            buf.writeVarIntToBuffer(this.value);
72
        }
73
    }
74
75
    /**
76
     * Passes this Packet on to the NetHandler for processing.
77
     */
78
    public void processPacket(INetHandlerPlayClient handler)
79
    {
80
        handler.handleUpdateScore(this);
81
    }
82
83
    public String getPlayerName()
84
    {
85
        return this.name;
86
    }
87
88
    public String getObjectiveName()
89
    {
90
        return this.objective;
91
    }
92
93
    public int getScoreValue()
94
    {
95
        return this.value;
96
    }
97
98
    public S3CPacketUpdateScore.Action getScoreAction()
99
    {
100
        return this.action;
101
    }
102
103
    public static enum Action
104
    {
105
        CHANGE,
106
        REMOVE;
107
    }
108
}
109

Deobfuscated MCP 1.8.9 source of S3CPacketUpdateScore from Marcelektro/MavenMCP-1.8.9 (net/minecraft/network/play/server/S3CPacketUpdateScore.java), stored verbatim.