mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-04 21:01:02 -05:00
Add SetDifficultyPacket
This commit is contained in:
parent
1d3c3f20f5
commit
84625ecf27
2 changed files with 27 additions and 2 deletions
|
@ -10,6 +10,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.client.ClientKeepAlivePac
|
|||
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientPluginMessagePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientRequestPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientResourcePackStatusPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientSetDifficultyPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientSettingsPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientTabCompletePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerAbilitiesPacket;
|
||||
|
@ -459,7 +460,7 @@ public class MinecraftProtocol extends PacketProtocol {
|
|||
|
||||
this.registerOutgoing(0x00, ClientTeleportConfirmPacket.class);
|
||||
this.registerOutgoing(0x01, ClientBlockNBTRequestPacket.class);
|
||||
// 0x02 Set Difficulty
|
||||
this.registerOutgoing(0x02, ClientSetDifficultyPacket.class);
|
||||
this.registerOutgoing(0x03, ClientChatPacket.class);
|
||||
this.registerOutgoing(0x04, ClientRequestPacket.class);
|
||||
this.registerOutgoing(0x05, ClientSettingsPacket.class);
|
||||
|
@ -508,7 +509,7 @@ public class MinecraftProtocol extends PacketProtocol {
|
|||
private void initServerGame(Session session) {
|
||||
this.registerIncoming(0x00, ClientTeleportConfirmPacket.class);
|
||||
this.registerIncoming(0x01, ClientBlockNBTRequestPacket.class);
|
||||
// 0x02 Set Difficulty
|
||||
this.registerIncoming(0x02, ClientSetDifficultyPacket.class);
|
||||
this.registerIncoming(0x03, ClientChatPacket.class);
|
||||
this.registerIncoming(0x04, ClientRequestPacket.class);
|
||||
this.registerIncoming(0x05, ClientSettingsPacket.class);
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package com.github.steveice10.mc.protocol.packet.ingame.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.MagicValues;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.Difficulty;
|
||||
import com.github.steveice10.mc.protocol.packet.MinecraftPacket;
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
|
||||
public class ClientSetDifficultyPacket extends MinecraftPacket {
|
||||
|
||||
private Difficulty difficulty;
|
||||
|
||||
@Override
|
||||
public void read(NetInput in) throws IOException {
|
||||
this.difficulty = MagicValues.key(Difficulty.class, in.readByte());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(NetOutput out) throws IOException {
|
||||
out.writeByte(MagicValues.key(Byte.class, this.difficulty));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue