| 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.util.IChatComponent;
|
| 8 |
|
| 9 | public class S45PacketTitle implements Packet<INetHandlerPlayClient>
|
| 10 | {
|
| 11 | private S45PacketTitle.Type type;
|
| 12 | private IChatComponent message;
|
| 13 | private int fadeInTime;
|
| 14 | private int displayTime;
|
| 15 | private int fadeOutTime;
|
| 16 |
|
| 17 | public S45PacketTitle()
|
| 18 | {
|
| 19 | }
|
| 20 |
|
| 21 | public S45PacketTitle(S45PacketTitle.Type type, IChatComponent message)
|
| 22 | {
|
| 23 | this(type, message, -1, -1, -1);
|
| 24 | }
|
| 25 |
|
| 26 | public S45PacketTitle(int fadeInTime, int displayTime, int fadeOutTime)
|
| 27 | {
|
| 28 | this(S45PacketTitle.Type.TIMES, (IChatComponent)null, fadeInTime, displayTime, fadeOutTime);
|
| 29 | }
|
| 30 |
|
| 31 | public S45PacketTitle(S45PacketTitle.Type type, IChatComponent message, int fadeInTime, int displayTime, int fadeOutTime)
|
| 32 | {
|
| 33 | this.type = type;
|
| 34 | this.message = message;
|
| 35 | this.fadeInTime = fadeInTime;
|
| 36 | this.displayTime = displayTime;
|
| 37 | this.fadeOutTime = fadeOutTime;
|
| 38 | }
|
| 39 |
|
| 40 | /**
|
| 41 | * Reads the raw packet data from the data stream.
|
| 42 | */
|
| 43 | public void readPacketData(PacketBuffer buf) throws IOException
|
| 44 | {
|
| 45 | this.type = (S45PacketTitle.Type)buf.readEnumValue(S45PacketTitle.Type.class);
|
| 46 |
|
| 47 | if (this.type == S45PacketTitle.Type.TITLE || this.type == S45PacketTitle.Type.SUBTITLE)
|
| 48 | {
|
| 49 | this.message = buf.readChatComponent();
|
| 50 | }
|
| 51 |
|
| 52 | if (this.type == S45PacketTitle.Type.TIMES)
|
| 53 | {
|
| 54 | this.fadeInTime = buf.readInt();
|
| 55 | this.displayTime = buf.readInt();
|
| 56 | this.fadeOutTime = buf.readInt();
|
| 57 | }
|
| 58 | }
|
| 59 |
|
| 60 | /**
|
| 61 | * Writes the raw packet data to the data stream.
|
| 62 | */
|
| 63 | public void writePacketData(PacketBuffer buf) throws IOException
|
| 64 | {
|
| 65 | buf.writeEnumValue(this.type);
|
| 66 |
|
| 67 | if (this.type == S45PacketTitle.Type.TITLE || this.type == S45PacketTitle.Type.SUBTITLE)
|
| 68 | {
|
| 69 | buf.writeChatComponent(this.message);
|
| 70 | }
|
| 71 |
|
| 72 | if (this.type == S45PacketTitle.Type.TIMES)
|
| 73 | {
|
| 74 | buf.writeInt(this.fadeInTime);
|
| 75 | buf.writeInt(this.displayTime);
|
| 76 | buf.writeInt(this.fadeOutTime);
|
| 77 | }
|
| 78 | }
|
| 79 |
|
| 80 | /**
|
| 81 | * Passes this Packet on to the NetHandler for processing.
|
| 82 | */
|
| 83 | public void processPacket(INetHandlerPlayClient handler)
|
| 84 | {
|
| 85 | handler.handleTitle(this);
|
| 86 | }
|
| 87 |
|
| 88 | public S45PacketTitle.Type getType()
|
| 89 | {
|
| 90 | return this.type;
|
| 91 | }
|
| 92 |
|
| 93 | public IChatComponent getMessage()
|
| 94 | {
|
| 95 | return this.message;
|
| 96 | }
|
| 97 |
|
| 98 | public int getFadeInTime()
|
| 99 | {
|
| 100 | return this.fadeInTime;
|
| 101 | }
|
| 102 |
|
| 103 | public int getDisplayTime()
|
| 104 | {
|
| 105 | return this.displayTime;
|
| 106 | }
|
| 107 |
|
| 108 | public int getFadeOutTime()
|
| 109 | {
|
| 110 | return this.fadeOutTime;
|
| 111 | }
|
| 112 |
|
| 113 | public static enum Type
|
| 114 | {
|
| 115 | TITLE,
|
| 116 | SUBTITLE,
|
| 117 | TIMES,
|
| 118 | CLEAR,
|
| 119 | RESET;
|
| 120 |
|
| 121 | public static S45PacketTitle.Type byName(String name)
|
| 122 | {
|
| 123 | for (S45PacketTitle.Type s45packettitle$type : values())
|
| 124 | {
|
| 125 | if (s45packettitle$type.name().equalsIgnoreCase(name))
|
| 126 | {
|
| 127 | return s45packettitle$type;
|
| 128 | }
|
| 129 | }
|
| 130 |
|
| 131 | return TITLE;
|
| 132 | }
|
| 133 |
|
| 134 | public static String[] getNames()
|
| 135 | {
|
| 136 | String[] astring = new String[values().length];
|
| 137 | int i = 0;
|
| 138 |
|
| 139 | for (S45PacketTitle.Type s45packettitle$type : values())
|
| 140 | {
|
| 141 | astring[i++] = s45packettitle$type.name().toLowerCase();
|
| 142 | }
|
| 143 |
|
| 144 | return astring;
|
| 145 | }
|
| 146 | }
|
| 147 | }
|
| 148 |
|