summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/WorldData.java
blob: 5429aabe4214f296a3cbebb5bdc8b3c36e00b734 (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
package net.minecraft.server;

import java.util.List;

public class WorldData {

    private long seed;
    private int spawnX;
    private int spawnY;
    private int spawnZ;
    private long time;
    private long lastPlayed;
    private long sizeOnDisk;
    private NBTTagCompound playerData;
    private int dimension;
    public String name; // CraftBukkit - private -> public
    private int version;
    private boolean isRaining;
    private int rainTicks;
    private boolean isThundering;
    private int thunderTicks;
    private int gameType;
    private boolean useMapFeatures;
    private boolean hardcore = false;

    public WorldData(NBTTagCompound nbttagcompound) {
        this.seed = nbttagcompound.getLong("RandomSeed");
        this.gameType = nbttagcompound.getInt("GameType");
        if (nbttagcompound.hasKey("MapFeatures")) {
            this.useMapFeatures = nbttagcompound.getBoolean("MapFeatures");
        } else {
            this.useMapFeatures = true;
        }

        this.spawnX = nbttagcompound.getInt("SpawnX");
        this.spawnY = nbttagcompound.getInt("SpawnY");
        this.spawnZ = nbttagcompound.getInt("SpawnZ");
        this.time = nbttagcompound.getLong("Time");
        this.lastPlayed = nbttagcompound.getLong("LastPlayed");
        this.sizeOnDisk = nbttagcompound.getLong("SizeOnDisk");
        this.name = nbttagcompound.getString("LevelName");
        this.version = nbttagcompound.getInt("version");
        this.rainTicks = nbttagcompound.getInt("rainTime");
        this.isRaining = nbttagcompound.getBoolean("raining");
        this.thunderTicks = nbttagcompound.getInt("thunderTime");
        this.isThundering = nbttagcompound.getBoolean("thundering");
        this.hardcore = nbttagcompound.getBoolean("hardcore");
        if (nbttagcompound.hasKey("Player")) {
            this.playerData = nbttagcompound.getCompound("Player");
            this.dimension = this.playerData.getInt("Dimension");
        }
    }

    public WorldData(WorldSettings worldsettings, String s) {
        this.seed = worldsettings.a();
        this.gameType = worldsettings.b();
        this.useMapFeatures = worldsettings.d();
        this.name = s;
        this.hardcore = worldsettings.c();
    }

    public WorldData(WorldData worlddata) {
        this.seed = worlddata.seed;
        this.gameType = worlddata.gameType;
        this.useMapFeatures = worlddata.useMapFeatures;
        this.spawnX = worlddata.spawnX;
        this.spawnY = worlddata.spawnY;
        this.spawnZ = worlddata.spawnZ;
        this.time = worlddata.time;
        this.lastPlayed = worlddata.lastPlayed;
        this.sizeOnDisk = worlddata.sizeOnDisk;
        this.playerData = worlddata.playerData;
        this.dimension = worlddata.dimension;
        this.name = worlddata.name;
        this.version = worlddata.version;
        this.rainTicks = worlddata.rainTicks;
        this.isRaining = worlddata.isRaining;
        this.thunderTicks = worlddata.thunderTicks;
        this.isThundering = worlddata.isThundering;
        this.hardcore = worlddata.hardcore;
    }

    public NBTTagCompound a() {
        NBTTagCompound nbttagcompound = new NBTTagCompound();

        this.a(nbttagcompound, this.playerData);
        return nbttagcompound;
    }

    public NBTTagCompound a(List list) {
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        EntityHuman entityhuman = null;
        NBTTagCompound nbttagcompound1 = null;

        if (list.size() > 0) {
            entityhuman = (EntityHuman) list.get(0);
        }

        if (entityhuman != null) {
            nbttagcompound1 = new NBTTagCompound();
            entityhuman.d(nbttagcompound1);
        }

        this.a(nbttagcompound, nbttagcompound1);
        return nbttagcompound;
    }

    private void a(NBTTagCompound nbttagcompound, NBTTagCompound nbttagcompound1) {
        nbttagcompound.setLong("RandomSeed", this.seed);
        nbttagcompound.setInt("GameType", this.gameType);
        nbttagcompound.setBoolean("MapFeatures", this.useMapFeatures);
        nbttagcompound.setInt("SpawnX", this.spawnX);
        nbttagcompound.setInt("SpawnY", this.spawnY);
        nbttagcompound.setInt("SpawnZ", this.spawnZ);
        nbttagcompound.setLong("Time", this.time);
        nbttagcompound.setLong("SizeOnDisk", this.sizeOnDisk);
        nbttagcompound.setLong("LastPlayed", System.currentTimeMillis());
        nbttagcompound.setString("LevelName", this.name);
        nbttagcompound.setInt("version", this.version);
        nbttagcompound.setInt("rainTime", this.rainTicks);
        nbttagcompound.setBoolean("raining", this.isRaining);
        nbttagcompound.setInt("thunderTime", this.thunderTicks);
        nbttagcompound.setBoolean("thundering", this.isThundering);
        nbttagcompound.setBoolean("hardcore", this.hardcore);
        if (nbttagcompound1 != null) {
            nbttagcompound.setCompound("Player", nbttagcompound1);
        }
    }

    public long getSeed() {
        return this.seed;
    }

    public int c() {
        return this.spawnX;
    }

    public int d() {
        return this.spawnY;
    }

    public int e() {
        return this.spawnZ;
    }

    public long f() {
        return this.time;
    }

    public long g() {
        return this.sizeOnDisk;
    }

    public int h() {
        return this.dimension;
    }

    public void a(long i) {
        this.time = i;
    }

    public void b(long i) {
        this.sizeOnDisk = i;
    }

    public void setSpawn(int i, int j, int k) {
        this.spawnX = i;
        this.spawnY = j;
        this.spawnZ = k;
    }

    public void a(String s) {
        this.name = s;
    }

    public int i() {
        return this.version;
    }

    public void a(int i) {
        this.version = i;
    }

    public boolean isThundering() {
        return this.isThundering;
    }

    public void setThundering(boolean flag) {
        this.isThundering = flag;
    }

    public int getThunderDuration() {
        return this.thunderTicks;
    }

    public void setThunderDuration(int i) {
        this.thunderTicks = i;
    }

    public boolean hasStorm() {
        return this.isRaining;
    }

    public void setStorm(boolean flag) {
        this.isRaining = flag;
    }

    public int getWeatherDuration() {
        return this.rainTicks;
    }

    public void setWeatherDuration(int i) {
        this.rainTicks = i;
    }

    public int getGameType() {
        return this.gameType;
    }

    public boolean o() {
        return this.useMapFeatures;
    }

    public void setGameType(int i) {
        this.gameType = i;
    }

    public boolean isHardcore() {
        return this.hardcore;
    }
}