| 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 S01PacketJoinGame implements Packet<INetHandlerPlayClient>
|
| 12 | {
|
| 13 | private int entityId;
|
| 14 | private boolean hardcoreMode;
|
| 15 | private WorldSettings.GameType gameType;
|
| 16 | private int dimension;
|
| 17 | private EnumDifficulty difficulty;
|
| 18 | private int maxPlayers;
|
| 19 | private WorldType worldType;
|
| 20 | private boolean reducedDebugInfo;
|
| 21 |
|
| 22 | public S01PacketJoinGame()
|
| 23 | {
|
| 24 | }
|
| 25 |
|
| 26 | public S01PacketJoinGame(int entityIdIn, WorldSettings.GameType gameTypeIn, boolean hardcoreModeIn, int dimensionIn, EnumDifficulty difficultyIn, int maxPlayersIn, WorldType worldTypeIn, boolean reducedDebugInfoIn)
|
| 27 | {
|
| 28 | this.entityId = entityIdIn;
|
| 29 | this.dimension = dimensionIn;
|
| 30 | this.difficulty = difficultyIn;
|
| 31 | this.gameType = gameTypeIn;
|
| 32 | this.maxPlayers = maxPlayersIn;
|
| 33 | this.hardcoreMode = hardcoreModeIn;
|
| 34 | this.worldType = worldTypeIn;
|
| 35 | this.reducedDebugInfo = reducedDebugInfoIn;
|
| 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.entityId = buf.readInt();
|
| 44 | int i = buf.readUnsignedByte();
|
| 45 | this.hardcoreMode = (i & 8) == 8;
|
| 46 | i = i & -9;
|
| 47 | this.gameType = WorldSettings.GameType.getByID(i);
|
| 48 | this.dimension = buf.readByte();
|
| 49 | this.difficulty = EnumDifficulty.getDifficultyEnum(buf.readUnsignedByte());
|
| 50 | this.maxPlayers = buf.readUnsignedByte();
|
| 51 | this.worldType = WorldType.parseWorldType(buf.readStringFromBuffer(16));
|
| 52 |
|
| 53 | if (this.worldType == null)
|
| 54 | {
|
| 55 | this.worldType = WorldType.DEFAULT;
|
| 56 | }
|
| 57 |
|
| 58 | this.reducedDebugInfo = buf.readBoolean();
|
| 59 | }
|
| 60 |
|
| 61 | /**
|
| 62 | * Writes the raw packet data to the data stream.
|
| 63 | */
|
| 64 | public void writePacketData(PacketBuffer buf) throws IOException
|
| 65 | {
|
| 66 | buf.writeInt(this.entityId);
|
| 67 | int i = this.gameType.getID();
|
| 68 |
|
| 69 | if (this.hardcoreMode)
|
| 70 | {
|
| 71 | i |= 8;
|
| 72 | }
|
| 73 |
|
| 74 | buf.writeByte(i);
|
| 75 | buf.writeByte(this.dimension);
|
| 76 | buf.writeByte(this.difficulty.getDifficultyId());
|
| 77 | buf.writeByte(this.maxPlayers);
|
| 78 | buf.writeString(this.worldType.getWorldTypeName());
|
| 79 | buf.writeBoolean(this.reducedDebugInfo);
|
| 80 | }
|
| 81 |
|
| 82 | /**
|
| 83 | * Passes this Packet on to the NetHandler for processing.
|
| 84 | */
|
| 85 | public void processPacket(INetHandlerPlayClient handler)
|
| 86 | {
|
| 87 | handler.handleJoinGame(this);
|
| 88 | }
|
| 89 |
|
| 90 | public int getEntityId()
|
| 91 | {
|
| 92 | return this.entityId;
|
| 93 | }
|
| 94 |
|
| 95 | public boolean isHardcoreMode()
|
| 96 | {
|
| 97 | return this.hardcoreMode;
|
| 98 | }
|
| 99 |
|
| 100 | public WorldSettings.GameType getGameType()
|
| 101 | {
|
| 102 | return this.gameType;
|
| 103 | }
|
| 104 |
|
| 105 | public int getDimension()
|
| 106 | {
|
| 107 | return this.dimension;
|
| 108 | }
|
| 109 |
|
| 110 | public EnumDifficulty getDifficulty()
|
| 111 | {
|
| 112 | return this.difficulty;
|
| 113 | }
|
| 114 |
|
| 115 | public int getMaxPlayers()
|
| 116 | {
|
| 117 | return this.maxPlayers;
|
| 118 | }
|
| 119 |
|
| 120 | public WorldType getWorldType()
|
| 121 | {
|
| 122 | return this.worldType;
|
| 123 | }
|
| 124 |
|
| 125 | public boolean isReducedDebugInfo()
|
| 126 | {
|
| 127 | return this.reducedDebugInfo;
|
| 128 | }
|
| 129 | }
|
| 130 |
|