001 package net.minecraft.src; 002 003 import java.io.DataInputStream; 004 import java.io.DataOutputStream; 005 import java.io.IOException; 006 007 public class Packet9Respawn extends Packet 008 { 009 public int respawnDimension; 010 011 /** 012 * The difficulty setting. 0 through 3 for peaceful, easy, normal, hard. The client always sends 1. 013 */ 014 public int difficulty; 015 016 /** Defaults to 128 */ 017 public int worldHeight; 018 public EnumGameType gameType; 019 public WorldType terrainType; 020 021 public Packet9Respawn() {} 022 023 public Packet9Respawn(int par1, byte par2, WorldType par3WorldType, int par4, EnumGameType par5EnumGameType) 024 { 025 this.respawnDimension = par1; 026 this.difficulty = par2; 027 this.worldHeight = par4; 028 this.gameType = par5EnumGameType; 029 this.terrainType = par3WorldType; 030 } 031 032 /** 033 * Passes this Packet on to the NetHandler for processing. 034 */ 035 public void processPacket(NetHandler par1NetHandler) 036 { 037 par1NetHandler.handleRespawn(this); 038 } 039 040 /** 041 * Abstract. Reads the raw packet data from the data stream. 042 */ 043 public void readPacketData(DataInputStream par1DataInputStream) throws IOException 044 { 045 this.respawnDimension = par1DataInputStream.readInt(); 046 this.difficulty = par1DataInputStream.readByte(); 047 this.gameType = EnumGameType.getByID(par1DataInputStream.readByte()); 048 this.worldHeight = par1DataInputStream.readShort(); 049 String var2 = readString(par1DataInputStream, 16); 050 this.terrainType = WorldType.parseWorldType(var2); 051 052 if (this.terrainType == null) 053 { 054 this.terrainType = WorldType.DEFAULT; 055 } 056 } 057 058 /** 059 * Abstract. Writes the raw packet data to the data stream. 060 */ 061 public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException 062 { 063 par1DataOutputStream.writeInt(this.respawnDimension); 064 par1DataOutputStream.writeByte(this.difficulty); 065 par1DataOutputStream.writeByte(this.gameType.getID()); 066 par1DataOutputStream.writeShort(this.worldHeight); 067 writeString(this.terrainType.getWorldTypeName(), par1DataOutputStream); 068 } 069 070 /** 071 * Abstract. Return the size of the packet (not counting the header). 072 */ 073 public int getPacketSize() 074 { 075 return 8 + (this.terrainType == null ? 0 : this.terrainType.getWorldTypeName().length()); 076 } 077 }