52 lines
		
	
	
	
		
			1.4 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
	
		
			1.4 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| package net.minecraft.network.protocol.game;
 | |
| 
 | |
| import net.minecraft.network.FriendlyByteBuf;
 | |
| import net.minecraft.network.codec.StreamCodec;
 | |
| import net.minecraft.network.protocol.Packet;
 | |
| import net.minecraft.network.protocol.PacketType;
 | |
| 
 | |
| public class ServerboundCommandSuggestionPacket implements Packet<ServerGamePacketListener> {
 | |
| 	public static final StreamCodec<FriendlyByteBuf, ServerboundCommandSuggestionPacket> STREAM_CODEC = Packet.codec(
 | |
| 		ServerboundCommandSuggestionPacket::write, ServerboundCommandSuggestionPacket::new
 | |
| 	);
 | |
| 	private final int id;
 | |
| 	private final String command;
 | |
| 
 | |
| 	public ServerboundCommandSuggestionPacket(int id, String command) {
 | |
| 		this.id = id;
 | |
| 		this.command = command;
 | |
| 	}
 | |
| 
 | |
| 	private ServerboundCommandSuggestionPacket(FriendlyByteBuf buffer) {
 | |
| 		this.id = buffer.readVarInt();
 | |
| 		this.command = buffer.readUtf(32500);
 | |
| 	}
 | |
| 
 | |
| 	/**
 | |
| 	 * Writes the raw packet data to the data stream.
 | |
| 	 */
 | |
| 	private void write(FriendlyByteBuf buffer) {
 | |
| 		buffer.writeVarInt(this.id);
 | |
| 		buffer.writeUtf(this.command, 32500);
 | |
| 	}
 | |
| 
 | |
| 	@Override
 | |
| 	public PacketType<ServerboundCommandSuggestionPacket> type() {
 | |
| 		return GamePacketTypes.SERVERBOUND_COMMAND_SUGGESTION;
 | |
| 	}
 | |
| 
 | |
| 	/**
 | |
| 	 * Passes this Packet on to the NetHandler for processing.
 | |
| 	 */
 | |
| 	public void handle(ServerGamePacketListener handler) {
 | |
| 		handler.handleCustomCommandSuggestions(this);
 | |
| 	}
 | |
| 
 | |
| 	public int getId() {
 | |
| 		return this.id;
 | |
| 	}
 | |
| 
 | |
| 	public String getCommand() {
 | |
| 		return this.command;
 | |
| 	}
 | |
| }
 |