| 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.world.EnumDifficulty;
|
| 8 | import net.minecraft.world.WorldSettings;
|
| 9 | import net.minecraft.world.WorldType;
|
| 10 |
|
| 11 | public class S07PacketRespawn implements Packet<INetHandlerPlayClient>
|
| 12 | {
|
| 13 | private int dimensionID;
|
| 14 | private EnumDifficulty difficulty;
|
| 15 | private WorldSettings.GameType gameType;
|
| 16 | private WorldType worldType;
|
| 17 |
|
| 18 | public S07PacketRespawn()
|
| 19 | {
|
| 20 | }
|
| 21 |
|
| 22 | public S07PacketRespawn(int dimensionIDIn, EnumDifficulty difficultyIn, WorldType worldTypeIn, WorldSettings.GameType gameTypeIn)
|
| 23 | {
|
| 24 | this.dimensionID = dimensionIDIn;
|
| 25 | this.difficulty = difficultyIn;
|
| 26 | this.gameType = gameTypeIn;
|
| 27 | this.worldType = worldTypeIn;
|
| 28 | }
|
| 29 |
|
| 30 | /**
|
| 31 | * Passes this Packet on to the NetHandler for processing.
|
| 32 | */
|
| 33 | public void processPacket(INetHandlerPlayClient handler)
|
| 34 | {
|
| 35 | handler.handleRespawn(this);
|
| 36 | }
|
| 37 |
|
| 38 | /**
|
| 39 | * Reads the raw packet data from the data stream.
|
| 40 | */
|
| 41 | public void readPacketData(PacketBuffer buf) throws IOException
|
| 42 | {
|
| 43 | this.dimensionID = buf.readInt();
|
| 44 | this.difficulty = EnumDifficulty.getDifficultyEnum(buf.readUnsignedByte());
|
| 45 | this.gameType = WorldSettings.GameType.getByID(buf.readUnsignedByte());
|
| 46 | this.worldType = WorldType.parseWorldType(buf.readStringFromBuffer(16));
|
| 47 |
|
| 48 | if (this.worldType == null)
|
| 49 | {
|
| 50 | this.worldType = WorldType.DEFAULT;
|
| 51 | }
|
| 52 | }
|
| 53 |
|
| 54 | /**
|
| 55 | * Writes the raw packet data to the data stream.
|
| 56 | */
|
| 57 | public void writePacketData(PacketBuffer buf) throws IOException
|
| 58 | {
|
| 59 | buf.writeInt(this.dimensionID);
|
| 60 | buf.writeByte(this.difficulty.getDifficultyId());
|
| 61 | buf.writeByte(this.gameType.getID());
|
| 62 | buf.writeString(this.worldType.getWorldTypeName());
|
| 63 | }
|
| 64 |
|
| 65 | public int getDimensionID()
|
| 66 | {
|
| 67 | return this.dimensionID;
|
| 68 | }
|
| 69 |
|
| 70 | public EnumDifficulty getDifficulty()
|
| 71 | {
|
| 72 | return this.difficulty;
|
| 73 | }
|
| 74 |
|
| 75 | public WorldSettings.GameType getGameType()
|
| 76 | {
|
| 77 | return this.gameType;
|
| 78 | }
|
| 79 |
|
| 80 | public WorldType getWorldType()
|
| 81 | {
|
| 82 | return this.worldType;
|
| 83 | }
|
| 84 | }
|
| 85 |
|