use of net.minecraft.network.protocol.game.ClientboundCommandsPacket in project MinecraftForge by MinecraftForge.
the class VanillaConnectionNetworkFilter method filterCommandList.
/**
* Filter for SCommandListPacket. Uses {@link CommandTreeCleaner} to filter out any ArgumentTypes that are not in the "minecraft" or "brigadier" namespace.
* A vanilla client would fail to deserialize the packet and disconnect with an error message if these were sent.
*/
@Nonnull
private static ClientboundCommandsPacket filterCommandList(ClientboundCommandsPacket packet) {
RootCommandNode<SharedSuggestionProvider> root = packet.getRoot();
RootCommandNode<SharedSuggestionProvider> newRoot = CommandTreeCleaner.cleanArgumentTypes(root, argType -> {
ResourceLocation id = ArgumentTypes.getId(argType);
return id != null && (id.getNamespace().equals("minecraft") || id.getNamespace().equals("brigadier"));
});
return new ClientboundCommandsPacket(newRoot);
}
Aggregations