aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/ClientInformationPacket.h
blob: e9d73a5d67078cf44b997f6e92b86886d30ec817 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#pragma once

#include "stdafx.h"

class ClientInformationPacket : public Packet
{
#if 0
	private String language;
	private int viewDistance;
	private int chatVisibility;
	private boolean chatColors;
	private int difficulty;

	public ClientInformationPacket() {
	}

	public ClientInformationPacket(String language, int viewDistance, int chatVisibility, boolean chatColors, int difficulty, boolean showCape) {
		this.language = language;
		this.viewDistance = viewDistance;
		this.chatVisibility = chatVisibility;
		this.chatColors = chatColors;
		this.difficulty = difficulty;
        this.showCape = showCape;
	}

	@Override
		public void read(DataInputStream dis) throws IOException {
			language = readUtf(dis, 7);
			viewDistance = dis.readByte();

			int chat = dis.readByte();
			chatVisibility = chat & 0x7;
			chatColors = (chat & 0x8) == 0x8;

			difficulty = dis.readByte();
        showCape = dis.readBoolean();
	}

	@Override
		public void write(DataOutputStream dos) throws IOException {
			writeUtf(language, dos);
			dos.writeByte(viewDistance);
			dos.writeByte(chatVisibility | (chatColors ? 1 : 0) << 3);
			dos.writeByte(difficulty);
        dos.writeBoolean(showCape);
	}

	@Override
		public void handle(PacketListener listener) {
			listener.handleClientInformation(this);
	}

	@Override
		public int getEstimatedSize() {
			return 7;
	}

	public String getLanguage() {
		return language;
	}

	public int getViewDistance() {
		return viewDistance;
	}

	public int getChatVisibility() {
		return chatVisibility;
	}

	public boolean getChatColors() {
		return chatColors;
	}

	public int getDifficulty() {
		return difficulty;
	}

    public boolean getShowCape() {
        return showCape;
    }

	public void setDifficulty(int difficulty) {
		this.difficulty = difficulty;
	}

	@Override
		public String getDebugInfo() {
			return String.format("lang='%s', view=%d, chat=%d, col=%b, difficulty=%d", language, viewDistance, chatVisibility, chatColors, difficulty);
	}

	@Override
		public boolean canBeInvalidated() {
			return true;
	}

	@Override
		public boolean isInvalidatedBy(Packet packet) {
			return true;
	}
#endif
};